2012-11-28 16:22:47 +04:00
|
|
|
# -*- coding: us-ascii -*-
|
2017-07-14 09:15:58 +03:00
|
|
|
# frozen_string_literal: true
|
2010-03-29 01:49:37 +04:00
|
|
|
require 'mkmf'
|
|
|
|
|
2022-03-29 11:45:33 +03:00
|
|
|
if $mswin or $mingw or $cygwin
|
|
|
|
$CPPFLAGS << " -DYAML_DECLARE_STATIC"
|
|
|
|
end
|
2012-11-28 08:34:41 +04:00
|
|
|
|
2022-10-07 06:45:07 +03:00
|
|
|
yaml_source = with_config("libyaml-source-dir")
|
2022-03-29 11:45:33 +03:00
|
|
|
if yaml_source
|
2022-10-07 06:46:09 +03:00
|
|
|
yaml_source = yaml_source.gsub(/\$\((\w+)\)|\$\{(\w+)\}/) {ENV[$1||$2]}
|
2022-03-31 18:45:31 +03:00
|
|
|
yaml_source = yaml_source.chomp("/")
|
2022-03-29 11:45:33 +03: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-28 08:34:41 +04:00
|
|
|
end
|
|
|
|
|
2022-03-29 11:45:33 +03:00
|
|
|
puts("Configuring libyaml source in #{yaml_source.quote}")
|
|
|
|
yaml = "libyaml"
|
|
|
|
Dir.mkdir(yaml) unless File.directory?(yaml)
|
2022-03-31 13:29:24 +03:00
|
|
|
shared = $enable_shared || !$static
|
2022-03-31 18:45:31 +03:00
|
|
|
args = [
|
|
|
|
yaml_configure,
|
|
|
|
"--enable-#{shared ? 'shared' : 'static'}",
|
2023-01-17 11:11:34 +03:00
|
|
|
"--host=#{RbConfig::CONFIG['host'].sub(/-unknown-/, '-').sub(/arm64/, 'arm')}",
|
2022-04-01 06:38:47 +03:00
|
|
|
"CC=#{RbConfig::CONFIG['CC']}",
|
2022-03-31 18:45:31 +03:00
|
|
|
*(["CFLAGS=-w"] if RbConfig::CONFIG["GCC"] == "yes"),
|
|
|
|
]
|
|
|
|
puts(args.quote.join(' '))
|
|
|
|
unless system(*args, chdir: yaml)
|
2022-03-29 11:45:33 +03: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 18:45:31 +03:00
|
|
|
puts("INCFLAGS=#$INCFLAGS")
|
2022-03-31 13:29:24 +03:00
|
|
|
libyaml = "libyaml.#$LIBEXT"
|
|
|
|
$cleanfiles << libyaml
|
2022-03-29 11:45:33 +03:00
|
|
|
$LOCAL_LIBS.prepend("$(LIBYAML) ")
|
2022-10-12 13:53:40 +03: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 14:17:46 +03:00
|
|
|
find_library('yaml', 'yaml_get_version') or abort "libyaml not found"
|
2012-11-28 08:34:41 +04:00
|
|
|
end
|
2010-03-29 01:49:37 +04:00
|
|
|
|
2019-11-29 04:16:33 +03:00
|
|
|
create_makefile 'psych' do |mk|
|
2022-03-29 11:45:33 +03:00
|
|
|
mk << "LIBYAML = #{libyaml}".strip << "\n"
|
2022-03-31 13:29:24 +03:00
|
|
|
mk << "LIBYAML_OBJDIR = libyaml/src#{shared ? '/.libs' : ''}\n"
|
|
|
|
mk << "OBJEXT = #$OBJEXT"
|
|
|
|
mk << "RANLIB = #{config_string('RANLIB') || config_string('NULLCMD')}\n"
|
2019-11-29 04:16:33 +03:00
|
|
|
end
|
2010-03-29 01:49:37 +04:00
|
|
|
|
|
|
|
# :startdoc:
|