2012-11-28 07:22:47 -05:00
|
|
|
# -*- coding: us-ascii -*-
|
2017-07-14 02:15:58 -04:00
|
|
|
# frozen_string_literal: true
|
2010-03-28 17:49:37 -04:00
|
|
|
require 'mkmf'
|
|
|
|
|
2022-03-29 04:45:33 -04:00
|
|
|
if $mswin or $mingw or $cygwin
|
|
|
|
$CPPFLAGS << " -DYAML_DECLARE_STATIC"
|
|
|
|
end
|
2012-11-27 23:34:41 -05:00
|
|
|
|
2022-10-06 23:45:07 -04:00
|
|
|
yaml_source = with_config("libyaml-source-dir")
|
2022-03-29 04:45:33 -04:00
|
|
|
if yaml_source
|
2022-10-06 23:46:09 -04:00
|
|
|
yaml_source = yaml_source.gsub(/\$\((\w+)\)|\$\{(\w+)\}/) {ENV[$1||$2]}
|
2022-03-31 11:45:31 -04:00
|
|
|
yaml_source = yaml_source.chomp("/")
|
2022-03-29 04:45:33 -04:00
|
|
|
yaml_configure = "#{File.expand_path(yaml_source)}/configure"
|
|
|
|
unless File.exist?(yaml_configure)
|
|
|
|
raise "Configure script not found in #{yaml_source.quote}"
|
2012-11-27 23:34:41 -05:00
|
|
|
end
|
|
|
|
|
2022-03-29 04:45:33 -04:00
|
|
|
puts("Configuring libyaml source in #{yaml_source.quote}")
|
|
|
|
yaml = "libyaml"
|
|
|
|
Dir.mkdir(yaml) unless File.directory?(yaml)
|
2022-03-31 06:29:24 -04:00
|
|
|
shared = $enable_shared || !$static
|
2022-03-31 11:45:31 -04:00
|
|
|
args = [
|
|
|
|
yaml_configure,
|
|
|
|
"--enable-#{shared ? 'shared' : 'static'}",
|
|
|
|
"--host=#{RbConfig::CONFIG['host'].sub(/-unknown-/, '-')}",
|
2022-03-31 23:38:47 -04:00
|
|
|
"CC=#{RbConfig::CONFIG['CC']}",
|
2022-03-31 11:45:31 -04:00
|
|
|
*(["CFLAGS=-w"] if RbConfig::CONFIG["GCC"] == "yes"),
|
|
|
|
]
|
|
|
|
puts(args.quote.join(' '))
|
|
|
|
unless system(*args, chdir: yaml)
|
2022-03-29 04:45:33 -04:00
|
|
|
raise "failed to configure libyaml"
|
|
|
|
end
|
|
|
|
inc = yaml_source.start_with?("#$srcdir/") ? "$(srcdir)#{yaml_source[$srcdir.size..-1]}" : yaml_source
|
|
|
|
$INCFLAGS << " -I#{yaml}/include -I#{inc}/include"
|
2022-03-31 11:45:31 -04:00
|
|
|
puts("INCFLAGS=#$INCFLAGS")
|
2022-03-31 06:29:24 -04:00
|
|
|
libyaml = "libyaml.#$LIBEXT"
|
|
|
|
$cleanfiles << libyaml
|
2022-03-29 04:45:33 -04:00
|
|
|
$LOCAL_LIBS.prepend("$(LIBYAML) ")
|
2022-10-12 06:53:40 -04:00
|
|
|
else # default to pre-installed libyaml
|
|
|
|
pkg_config('yaml-0.1')
|
|
|
|
dir_config('libyaml')
|
|
|
|
find_header('yaml.h') or abort "yaml.h not found"
|
2022-10-12 07:17:46 -04:00
|
|
|
find_library('yaml', 'yaml_get_version') or abort "libyaml not found"
|
2012-11-27 23:34:41 -05:00
|
|
|
end
|
2010-03-28 17:49:37 -04:00
|
|
|
|
2019-11-28 20:16:33 -05:00
|
|
|
create_makefile 'psych' do |mk|
|
2022-03-29 04:45:33 -04:00
|
|
|
mk << "LIBYAML = #{libyaml}".strip << "\n"
|
2022-03-31 06:29:24 -04:00
|
|
|
mk << "LIBYAML_OBJDIR = libyaml/src#{shared ? '/.libs' : ''}\n"
|
|
|
|
mk << "OBJEXT = #$OBJEXT"
|
|
|
|
mk << "RANLIB = #{config_string('RANLIB') || config_string('NULLCMD')}\n"
|
2019-11-28 20:16:33 -05:00
|
|
|
end
|
2010-03-28 17:49:37 -04:00
|
|
|
|
|
|
|
# :startdoc:
|