1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Configure directories for headers and libraries automatically

[EXPERIMENTAL]
This commit is contained in:
Nobuyoshi Nakada 2019-05-08 16:55:59 +09:00
parent a1bab3d1a3
commit c54d5872fb
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -1007,6 +1007,7 @@ SRC
# <code>--with-FOOlib</code> configuration option. # <code>--with-FOOlib</code> configuration option.
# #
def have_library(lib, func = nil, headers = nil, opt = "", &b) def have_library(lib, func = nil, headers = nil, opt = "", &b)
dir_config(lib)
lib = with_config(lib+'lib', lib) lib = with_config(lib+'lib', lib)
checking_for checking_message(func && func.funcall_style, LIBARG%lib, opt) do checking_for checking_message(func && func.funcall_style, LIBARG%lib, opt) do
if COMMON_LIBS.include?(lib) if COMMON_LIBS.include?(lib)
@ -1032,6 +1033,7 @@ SRC
# library paths searched and linked against. # library paths searched and linked against.
# #
def find_library(lib, func, *paths, &b) def find_library(lib, func, *paths, &b)
dir_config(lib)
lib = with_config(lib+'lib', lib) lib = with_config(lib+'lib', lib)
paths = paths.collect {|path| path.split(File::PATH_SEPARATOR)}.flatten paths = paths.collect {|path| path.split(File::PATH_SEPARATOR)}.flatten
checking_for checking_message(func && func.funcall_style, LIBARG%lib) do checking_for checking_message(func && func.funcall_style, LIBARG%lib) do
@ -1105,6 +1107,7 @@ SRC
# +HAVE_FOO_H+ preprocessor macro would be passed to the compiler. # +HAVE_FOO_H+ preprocessor macro would be passed to the compiler.
# #
def have_header(header, preheaders = nil, opt = "", &b) def have_header(header, preheaders = nil, opt = "", &b)
dir_config(header[/.*?(?=\/)|.*?(?=\.)/])
checking_for header do checking_for header do
if try_header(cpp_include(preheaders)+cpp_include(header), opt, &b) if try_header(cpp_include(preheaders)+cpp_include(header), opt, &b)
$defs.push(format("-DHAVE_%s", header.tr_cpp)) $defs.push(format("-DHAVE_%s", header.tr_cpp))
@ -1748,6 +1751,10 @@ SRC
# application. # application.
# #
def dir_config(target, idefault=nil, ldefault=nil) def dir_config(target, idefault=nil, ldefault=nil)
if conf = $config_dirs[target]
return conf
end
if dir = with_config(target + "-dir", (idefault unless ldefault)) if dir = with_config(target + "-dir", (idefault unless ldefault))
defaults = Array === dir ? dir : dir.split(File::PATH_SEPARATOR) defaults = Array === dir ? dir : dir.split(File::PATH_SEPARATOR)
idefault = ldefault = nil idefault = ldefault = nil
@ -1778,7 +1785,7 @@ SRC
end end
$LIBPATH = ldirs | $LIBPATH $LIBPATH = ldirs | $LIBPATH
[idir, ldir] $config_dirs[target] = [idir, ldir]
end end
# Returns compile/link information about an installed library in a # Returns compile/link information about an installed library in a
@ -2507,6 +2514,8 @@ site-install-rb: install-rb
$enable_shared = config['ENABLE_SHARED'] == 'yes' $enable_shared = config['ENABLE_SHARED'] == 'yes'
$defs = [] $defs = []
$extconf_h = nil $extconf_h = nil
$config_dirs = {}
if $warnflags = CONFIG['warnflags'] and CONFIG['GCC'] == 'yes' if $warnflags = CONFIG['warnflags'] and CONFIG['GCC'] == 'yes'
# turn warnings into errors only for bundled extensions. # turn warnings into errors only for bundled extensions.
config['warnflags'] = $warnflags.gsub(/(\A|\s)-Werror[-=]/, '\1-W') config['warnflags'] = $warnflags.gsub(/(\A|\s)-Werror[-=]/, '\1-W')
@ -2565,6 +2574,7 @@ site-install-rb: install-rb
$extout_prefix ||= nil $extout_prefix ||= nil
$arg_config.clear $arg_config.clear
$config_dirs.clear
dir_config("opt") dir_config("opt")
end end