* lib/mkmf.rb: Use MakeMakefile's rm_f to avoid conflict with Rake or
FileUtils. * test/ruby/test_module.rb: Hide MakeMakefile's inclusion in Object git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
434a5f93ad
commit
8b7ecdc11e
@ -1,3 +1,9 @@
|
|||||||
|
Wed Nov 30 08:57:07 2011 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
|
* lib/mkmf.rb: Use MakeMakefile's rm_f to avoid conflict with Rake or
|
||||||
|
FileUtils.
|
||||||
|
* test/ruby/test_module.rb: Hide MakeMakefile's inclusion in Object
|
||||||
|
|
||||||
Wed Nov 30 09:12:43 2011 NAKAMURA Usaku <usa@ruby-lang.org>
|
Wed Nov 30 09:12:43 2011 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* lib/rdoc/encoding.rb (RDoc::Encoding.read_file): fixup newline chars
|
* lib/rdoc/encoding.rb (RDoc::Encoding.read_file): fixup newline chars
|
||||||
|
@ -147,7 +147,7 @@ def extmake(target)
|
|||||||
remove_const(:MAKEFILE_CONFIG)
|
remove_const(:MAKEFILE_CONFIG)
|
||||||
const_set(:MAKEFILE_CONFIG, mkconfig)
|
const_set(:MAKEFILE_CONFIG, mkconfig)
|
||||||
}
|
}
|
||||||
Object.class_eval {
|
MakeMakefile.class_eval {
|
||||||
remove_const(:CONFIG)
|
remove_const(:CONFIG)
|
||||||
const_set(:CONFIG, mkconfig)
|
const_set(:CONFIG, mkconfig)
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ def extmake(target)
|
|||||||
remove_const(:MAKEFILE_CONFIG)
|
remove_const(:MAKEFILE_CONFIG)
|
||||||
const_set(:MAKEFILE_CONFIG, mkconfig0)
|
const_set(:MAKEFILE_CONFIG, mkconfig0)
|
||||||
}
|
}
|
||||||
Object.class_eval {
|
MakeMakefile.class_eval {
|
||||||
remove_const(:CONFIG)
|
remove_const(:CONFIG)
|
||||||
const_set(:CONFIG, mkconfig0)
|
const_set(:CONFIG, mkconfig0)
|
||||||
}
|
}
|
||||||
|
414
lib/mkmf.rb
414
lib/mkmf.rb
@ -6,6 +6,41 @@ require 'rbconfig'
|
|||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require 'shellwords'
|
require 'shellwords'
|
||||||
|
|
||||||
|
# :stopdoc:
|
||||||
|
class String
|
||||||
|
# Wraps a string in escaped quotes if it contains whitespace.
|
||||||
|
def quote
|
||||||
|
/\s/ =~ self ? "\"#{self}\"" : "#{self}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Generates a string used as cpp macro name.
|
||||||
|
def tr_cpp
|
||||||
|
strip.upcase.tr_s("^A-Z0-9_*", "_").tr_s("*", "P")
|
||||||
|
end
|
||||||
|
|
||||||
|
def funcall_style
|
||||||
|
/\)\z/ =~ self ? dup : "#{self}()"
|
||||||
|
end
|
||||||
|
|
||||||
|
def sans_arguments
|
||||||
|
self[/\A[^()]+/]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Array
|
||||||
|
# Wraps all strings in escaped quotes if they contain whitespace.
|
||||||
|
def quote
|
||||||
|
map {|s| s.quote}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# :startdoc:
|
||||||
|
|
||||||
|
##
|
||||||
|
# mkmf.rb is used by ruby C extensions to generate a Makefile which will
|
||||||
|
# correctly compile and link the C extension to ruby and a third-party
|
||||||
|
# library.
|
||||||
|
module MakeMakefile
|
||||||
|
|
||||||
CONFIG = RbConfig::MAKEFILE_CONFIG
|
CONFIG = RbConfig::MAKEFILE_CONFIG
|
||||||
ORIG_LIBPATH = ENV['LIB']
|
ORIG_LIBPATH = ENV['LIB']
|
||||||
|
|
||||||
@ -75,10 +110,12 @@ $dest_prefix_pattern = (File::PATH_SEPARATOR == ';' ? /\A([[:alpha:]]:)?/ : /\A/
|
|||||||
def config_string(key, config = CONFIG)
|
def config_string(key, config = CONFIG)
|
||||||
s = config[key] and !s.empty? and block_given? ? yield(s) : s
|
s = config[key] and !s.empty? and block_given? ? yield(s) : s
|
||||||
end
|
end
|
||||||
|
module_function :config_string
|
||||||
|
|
||||||
def dir_re(dir)
|
def dir_re(dir)
|
||||||
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$(?:\(target_prefix\)|\{target_prefix\}))?')
|
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$(?:\(target_prefix\)|\{target_prefix\}))?')
|
||||||
end
|
end
|
||||||
|
module_function :dir_re
|
||||||
|
|
||||||
def relative_from(path, base)
|
def relative_from(path, base)
|
||||||
dir = File.join(path, "")
|
dir = File.join(path, "")
|
||||||
@ -176,44 +213,20 @@ CPPOUTFILE = CONFIG['CPPOUTFILE']
|
|||||||
|
|
||||||
CONFTEST_C = "conftest.c".freeze
|
CONFTEST_C = "conftest.c".freeze
|
||||||
|
|
||||||
class String
|
|
||||||
# Wraps a string in escaped quotes if it contains whitespace.
|
|
||||||
def quote
|
|
||||||
/\s/ =~ self ? "\"#{self}\"" : "#{self}"
|
|
||||||
end
|
|
||||||
|
|
||||||
# Generates a string used as cpp macro name.
|
|
||||||
def tr_cpp
|
|
||||||
strip.upcase.tr_s("^A-Z0-9_*", "_").tr_s("*", "P")
|
|
||||||
end
|
|
||||||
|
|
||||||
def funcall_style
|
|
||||||
/\)\z/ =~ self ? dup : "#{self}()"
|
|
||||||
end
|
|
||||||
|
|
||||||
def sans_arguments
|
|
||||||
self[/\A[^()]+/]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
class Array
|
|
||||||
# Wraps all strings in escaped quotes if they contain whitespace.
|
|
||||||
def quote
|
|
||||||
map {|s| s.quote}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def rm_f(*files)
|
def rm_f(*files)
|
||||||
opt = (Hash === files.last ? [files.pop] : [])
|
opt = (Hash === files.last ? [files.pop] : [])
|
||||||
FileUtils.rm_f(Dir[*files.flatten], *opt)
|
FileUtils.rm_f(Dir[*files.flatten], *opt)
|
||||||
end
|
end
|
||||||
|
module_function :rm_f
|
||||||
|
|
||||||
def rm_rf(*files)
|
def rm_rf(*files)
|
||||||
opt = (Hash === files.last ? [files.pop] : [])
|
opt = (Hash === files.last ? [files.pop] : [])
|
||||||
FileUtils.rm_rf(Dir[*files.flatten], *opt)
|
FileUtils.rm_rf(Dir[*files.flatten], *opt)
|
||||||
end
|
end
|
||||||
|
module_function :rm_rf
|
||||||
|
|
||||||
# Returns time stamp of the +target+ file if it exists and is newer
|
# Returns time stamp of the +target+ file if it exists and is newer than or
|
||||||
# than or equal to all of +times+.
|
# equal to all of +times+.
|
||||||
def modified?(target, times)
|
def modified?(target, times)
|
||||||
(t = File.mtime(target)) rescue return nil
|
(t = File.mtime(target)) rescue return nil
|
||||||
Array === times or times = [times]
|
Array === times or times = [times]
|
||||||
@ -295,7 +308,7 @@ module Logging
|
|||||||
File::open(tmplog) {|t| FileUtils.copy_stream(t, log)} if File.exist?(tmplog)
|
File::open(tmplog) {|t| FileUtils.copy_stream(t, log)} if File.exist?(tmplog)
|
||||||
@log, @logfile, @orgout, @orgerr = log, *save
|
@log, @logfile, @orgout, @orgerr = log, *save
|
||||||
@postpone -= 1
|
@postpone -= 1
|
||||||
rm_f tmplog
|
MakeMakefile.rm_f tmplog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -393,7 +406,7 @@ MSG
|
|||||||
xsystem(command, *opts)
|
xsystem(command, *opts)
|
||||||
ensure
|
ensure
|
||||||
log_src(src)
|
log_src(src)
|
||||||
rm_rf 'conftest.dSYM'
|
MakeMakefile.rm_rf 'conftest.dSYM'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -455,8 +468,7 @@ def with_werror(opt, opts = nil)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# :nodoc:
|
def try_link0(src, opt="", *opts, &b) # :nodoc:
|
||||||
def try_link0(src, opt="", *opts, &b)
|
|
||||||
cmd = link_command("", opt)
|
cmd = link_command("", opt)
|
||||||
if $universal
|
if $universal
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
@ -473,10 +485,10 @@ def try_link0(src, opt="", *opts, &b)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the +src+ can be compiled as a C source and
|
# Returns whether or not the +src+ can be compiled as a C source and linked
|
||||||
# linked with its depending libraries successfully.
|
# with its depending libraries successfully. +opt+ is passed to the linker
|
||||||
# +opt+ is passed to the linker as options. Note that +$CFLAGS+ and +$LDFLAGS+
|
# as options. Note that +$CFLAGS+ and +$LDFLAGS+ are also passed to the
|
||||||
# are also passed to the linker.
|
# linker.
|
||||||
#
|
#
|
||||||
# If a block given, it is called with the source before compilation. You can
|
# If a block given, it is called with the source before compilation. You can
|
||||||
# modify the source in the block.
|
# modify the source in the block.
|
||||||
@ -486,12 +498,12 @@ end
|
|||||||
def try_link(src, opt="", *opts, &b)
|
def try_link(src, opt="", *opts, &b)
|
||||||
try_link0(src, opt, *opts, &b)
|
try_link0(src, opt, *opts, &b)
|
||||||
ensure
|
ensure
|
||||||
rm_f "conftest*", "c0x32*"
|
MakeMakefile.rm_f "conftest*", "c0x32*"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the +src+ can be compiled as a C source.
|
# Returns whether or not the +src+ can be compiled as a C source. +opt+ is
|
||||||
# +opt+ is passed to the C compiler as options. Note that +$CFLAGS+ is
|
# passed to the C compiler as options. Note that +$CFLAGS+ is also passed to
|
||||||
# also passed to the compiler.
|
# the compiler.
|
||||||
#
|
#
|
||||||
# If a block given, it is called with the source before compilation. You can
|
# If a block given, it is called with the source before compilation. You can
|
||||||
# modify the source in the block.
|
# modify the source in the block.
|
||||||
@ -501,27 +513,25 @@ end
|
|||||||
def try_compile(src, opt="", *opts, &b)
|
def try_compile(src, opt="", *opts, &b)
|
||||||
with_werror(opt, *opts) {|_opt, *_opts| try_do(src, cc_command(_opt), *_opts, &b)}
|
with_werror(opt, *opts) {|_opt, *_opts| try_do(src, cc_command(_opt), *_opts, &b)}
|
||||||
ensure
|
ensure
|
||||||
rm_f "conftest*"
|
MakeMakefile.rm_f "conftest*"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the +src+ can be preprocessed with the C preprocessor.
|
# Returns whether or not the +src+ can be preprocessed with the C
|
||||||
# +opt+ is passed to the preprocessor as options. Note that +$CFLAGS+ is
|
# preprocessor. +opt+ is passed to the preprocessor as options. Note that
|
||||||
# also passed to the preprocessor.
|
# +$CFLAGS+ is also passed to the preprocessor.
|
||||||
#
|
#
|
||||||
# If a block given, it is called with the source before preprocessing. You can
|
# If a block given, it is called with the source before preprocessing. You
|
||||||
# modify the source in the block.
|
# can modify the source in the block.
|
||||||
#
|
#
|
||||||
# [+src+] a String which contains a C source
|
# [+src+] a String which contains a C source
|
||||||
# [+opt+] a String which contains preprocessor options
|
# [+opt+] a String which contains preprocessor options
|
||||||
def try_cpp(src, opt="", *opts, &b)
|
def try_cpp(src, opt="", *opts, &b)
|
||||||
try_do(src, cpp_command(CPPOUTFILE, opt), *opts, &b)
|
try_do(src, cpp_command(CPPOUTFILE, opt), *opts, &b)
|
||||||
ensure
|
ensure
|
||||||
rm_f "conftest*"
|
MakeMakefile.rm_f "conftest*"
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
|
||||||
alias_method :try_header, (config_string('try_header') || :try_cpp)
|
alias_method :try_header, (config_string('try_header') || :try_cpp)
|
||||||
end
|
|
||||||
|
|
||||||
def cpp_include(header)
|
def cpp_include(header)
|
||||||
if header
|
if header
|
||||||
@ -616,8 +626,8 @@ end
|
|||||||
#
|
#
|
||||||
# [+func+] a String which contains a symbol name
|
# [+func+] a String which contains a symbol name
|
||||||
# [+libs+] a String which contains library names.
|
# [+libs+] a String which contains library names.
|
||||||
# [+headers+] a String or an Array of strings which contains
|
# [+headers+] a String or an Array of strings which contains names of header
|
||||||
# names of header files.
|
# files.
|
||||||
def try_func(func, libs, headers = nil, opt = "", &b)
|
def try_func(func, libs, headers = nil, opt = "", &b)
|
||||||
headers = cpp_include(headers)
|
headers = cpp_include(headers)
|
||||||
case func
|
case func
|
||||||
@ -667,8 +677,8 @@ int t(void) { const volatile void *volatile p; p = &(&#{var})[0]; return 0; }
|
|||||||
SRC
|
SRC
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the +src+ can be preprocessed with the C preprocessor and
|
# Returns whether or not the +src+ can be preprocessed with the C
|
||||||
# matches with +pat+.
|
# preprocessor and matches with +pat+.
|
||||||
#
|
#
|
||||||
# If a block given, it is called with the source before compilation. You can
|
# If a block given, it is called with the source before compilation. You can
|
||||||
# modify the source in the block.
|
# modify the source in the block.
|
||||||
@ -677,8 +687,7 @@ end
|
|||||||
# [+src+] a String which contains a C source
|
# [+src+] a String which contains a C source
|
||||||
# [+opt+] a String which contains preprocessor options
|
# [+opt+] a String which contains preprocessor options
|
||||||
#
|
#
|
||||||
# Note:
|
# NOTE: When pat is a Regexp the matching will be checked in process,
|
||||||
# When pat is a Regexp the matching will be checked in process,
|
|
||||||
# otherwise egrep(1) will be invoked to check it.
|
# otherwise egrep(1) will be invoked to check it.
|
||||||
def egrep_cpp(pat, src, opt = "", &b)
|
def egrep_cpp(pat, src, opt = "", &b)
|
||||||
src = create_tmpsrc(src, &b)
|
src = create_tmpsrc(src, &b)
|
||||||
@ -702,7 +711,7 @@ def egrep_cpp(pat, src, opt = "", &b)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
rm_f "conftest*"
|
MakeMakefile.rm_f "conftest*"
|
||||||
log_src(src)
|
log_src(src)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -718,13 +727,15 @@ def macro_defined?(macro, src, opt = "", &b)
|
|||||||
SRC
|
SRC
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not
|
# Returns whether or not:
|
||||||
# * the +src+ can be compiled as a C source,
|
# * the +src+ can be compiled as a C source,
|
||||||
# * the result object can be linked with its depending libraries successfully,
|
# * the result object can be linked with its depending libraries
|
||||||
|
# successfully,
|
||||||
# * the linked file can be invoked as an executable
|
# * the linked file can be invoked as an executable
|
||||||
# * and the executable exits successfully
|
# * and the executable exits successfully
|
||||||
# +opt+ is passed to the linker as options. Note that +$CFLAGS+ and +$LDFLAGS+
|
#
|
||||||
# are also passed to the linker.
|
# +opt+ is passed to the linker as options. Note that +$CFLAGS+ and
|
||||||
|
# +$LDFLAGS+ are also passed to the linker.
|
||||||
#
|
#
|
||||||
# If a block given, it is called with the source before compilation. You can
|
# If a block given, it is called with the source before compilation. You can
|
||||||
# modify the source in the block.
|
# modify the source in the block.
|
||||||
@ -732,8 +743,8 @@ end
|
|||||||
# [+src+] a String which contains a C source
|
# [+src+] a String which contains a C source
|
||||||
# [+opt+] a String which contains linker options
|
# [+opt+] a String which contains linker options
|
||||||
#
|
#
|
||||||
# @return true when the executable exits successfully, false when it fails, or
|
# Returns true when the executable exits successfully, false when it fails,
|
||||||
# nil when preprocessing, compilation or link fails.
|
# or nil when preprocessing, compilation or link fails.
|
||||||
def try_run(src, opt = "", &b)
|
def try_run(src, opt = "", &b)
|
||||||
if try_link0(src, opt, &b)
|
if try_link0(src, opt, &b)
|
||||||
xsystem("./conftest")
|
xsystem("./conftest")
|
||||||
@ -741,7 +752,7 @@ def try_run(src, opt = "", &b)
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
rm_f "conftest*"
|
MakeMakefile.rm_f "conftest*"
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_files(mfile, ifiles, map = nil, srcprefix = nil)
|
def install_files(mfile, ifiles, map = nil, srcprefix = nil)
|
||||||
@ -850,15 +861,15 @@ def have_macro(macro, headers = nil, opt = "", &b)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the given entry point +func+ can be found within
|
# Returns whether or not the given entry point +func+ can be found within
|
||||||
# +lib+. If +func+ is nil, the 'main()' entry point is used by default.
|
# +lib+. If +func+ is nil, the <code>main()</code> entry point is used by
|
||||||
# If found, it adds the library to list of libraries to be used when linking
|
# default. If found, it adds the library to list of libraries to be used
|
||||||
# your extension.
|
# when linking your extension.
|
||||||
#
|
#
|
||||||
# If +headers+ are provided, it will include those header files as the
|
# If +headers+ are provided, it will include those header files as the
|
||||||
# header files it looks in when searching for +func+.
|
# header files it looks in when searching for +func+.
|
||||||
#
|
#
|
||||||
# The real name of the library to be linked can be altered by
|
# The real name of the library to be linked can be altered by
|
||||||
# '--with-FOOlib' 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)
|
||||||
func = "main" if !func or func.empty?
|
func = "main" if !func or func.empty?
|
||||||
@ -878,9 +889,10 @@ def have_library(lib, func = nil, headers = nil, opt = "", &b)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the entry point +func+ can be found within the library
|
# Returns whether or not the entry point +func+ can be found within the
|
||||||
# +lib+ in one of the +paths+ specified, where +paths+ is an array of strings.
|
# library +lib+ in one of the +paths+ specified, where +paths+ is an array
|
||||||
# If +func+ is nil , then the main() function is used as the entry point.
|
# of strings. If +func+ is nil , then the <code>main()</code> function is
|
||||||
|
# used as the entry point.
|
||||||
#
|
#
|
||||||
# If +lib+ is found, then the path it was found on is added to the list of
|
# If +lib+ is found, then the path it was found on is added to the list of
|
||||||
# library paths searched and linked against.
|
# library paths searched and linked against.
|
||||||
@ -908,12 +920,12 @@ def find_library(lib, func, *paths, &b)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the function +func+ can be found in the common
|
# Returns whether or not the function +func+ can be found in the common
|
||||||
# header files, or within any +headers+ that you provide. If found, a
|
# header files, or within any +headers+ that you provide. If found, a macro
|
||||||
# macro is passed as a preprocessor constant to the compiler using the
|
# is passed as a preprocessor constant to the compiler using the function
|
||||||
# function name, in uppercase, prepended with 'HAVE_'.
|
# name, in uppercase, prepended with +HAVE_+.
|
||||||
#
|
#
|
||||||
# For example, if have_func('foo') returned true, then the HAVE_FOO
|
# For example, if <code>have_func('foo')</code> returned true, then the
|
||||||
# preprocessor macro would be passed to the compiler.
|
# +HAVE_FOO+ preprocessor macro would be passed to the compiler.
|
||||||
#
|
#
|
||||||
def have_func(func, headers = nil, opt = "", &b)
|
def have_func(func, headers = nil, opt = "", &b)
|
||||||
checking_for checking_message(func.funcall_style, headers, opt) do
|
checking_for checking_message(func.funcall_style, headers, opt) do
|
||||||
@ -927,12 +939,12 @@ def have_func(func, headers = nil, opt = "", &b)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the variable +var+ can be found in the common
|
# Returns whether or not the variable +var+ can be found in the common
|
||||||
# header files, or within any +headers+ that you provide. If found, a
|
# header files, or within any +headers+ that you provide. If found, a macro
|
||||||
# macro is passed as a preprocessor constant to the compiler using the
|
# is passed as a preprocessor constant to the compiler using the variable
|
||||||
# variable name, in uppercase, prepended with 'HAVE_'.
|
# name, in uppercase, prepended with +HAVE_+.
|
||||||
#
|
#
|
||||||
# For example, if have_var('foo') returned true, then the HAVE_FOO
|
# For example, if <code>have_var('foo')</code> returned true, then the
|
||||||
# preprocessor macro would be passed to the compiler.
|
# +HAVE_FOO+ preprocessor macro would be passed to the compiler.
|
||||||
#
|
#
|
||||||
def have_var(var, headers = nil, opt = "", &b)
|
def have_var(var, headers = nil, opt = "", &b)
|
||||||
checking_for checking_message(var, headers, opt) do
|
checking_for checking_message(var, headers, opt) do
|
||||||
@ -946,11 +958,11 @@ def have_var(var, headers = nil, opt = "", &b)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the given +header+ file can be found on your system.
|
# Returns whether or not the given +header+ file can be found on your system.
|
||||||
# If found, a macro is passed as a preprocessor constant to the compiler using
|
# If found, a macro is passed as a preprocessor constant to the compiler
|
||||||
# the header file name, in uppercase, prepended with 'HAVE_'.
|
# using the header file name, in uppercase, prepended with +HAVE_+.
|
||||||
#
|
#
|
||||||
# For example, if have_header('foo.h') returned true, then the HAVE_FOO_H
|
# For example, if <code>have_header('foo.h')</code> returned true, then the
|
||||||
# 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)
|
||||||
checking_for header do
|
checking_for header do
|
||||||
@ -964,11 +976,12 @@ def have_header(header, preheaders = nil, opt = "", &b)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the given +framework+ can be found on your system.
|
# Returns whether or not the given +framework+ can be found on your system.
|
||||||
# If found, a macro is passed as a preprocessor constant to the compiler using
|
# If found, a macro is passed as a preprocessor constant to the compiler
|
||||||
# the framework name, in uppercase, prepended with 'HAVE_FRAMEWORK_'.
|
# using the framework name, in uppercase, prepended with +HAVE_FRAMEWORK_+.
|
||||||
#
|
#
|
||||||
# For example, if have_framework('Ruby') returned true, then the HAVE_FRAMEWORK_RUBY
|
# For example, if <code>have_framework('Ruby')</code> returned true, then
|
||||||
# preprocessor macro would be passed to the compiler.
|
# the +HAVE_FRAMEWORK_RUBY+ preprocessor macro would be passed to the
|
||||||
|
# compiler.
|
||||||
#
|
#
|
||||||
def have_framework(fw, &b)
|
def have_framework(fw, &b)
|
||||||
checking_for fw do
|
checking_for fw do
|
||||||
@ -987,7 +1000,8 @@ end
|
|||||||
# provided, and returns whether or not it was found in those paths.
|
# provided, and returns whether or not it was found in those paths.
|
||||||
#
|
#
|
||||||
# If the header is found then the path it was found on is added to the list
|
# If the header is found then the path it was found on is added to the list
|
||||||
# of included directories that are sent to the compiler (via the -I switch).
|
# of included directories that are sent to the compiler (via the
|
||||||
|
# <code>-I</code> switch).
|
||||||
#
|
#
|
||||||
def find_header(header, *paths)
|
def find_header(header, *paths)
|
||||||
message = checking_message(header, paths)
|
message = checking_message(header, paths)
|
||||||
@ -1011,17 +1025,19 @@ def find_header(header, *paths)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the struct of type +type+ contains +member+. If
|
# Returns whether or not the struct of type +type+ contains +member+. If
|
||||||
# it does not, or the struct type can't be found, then false is returned. You
|
# it does not, or the struct type can't be found, then false is returned.
|
||||||
# may optionally specify additional +headers+ in which to look for the struct
|
# You may optionally specify additional +headers+ in which to look for the
|
||||||
# (in addition to the common header files).
|
# struct (in addition to the common header files).
|
||||||
#
|
#
|
||||||
# If found, a macro is passed as a preprocessor constant to the compiler using
|
# If found, a macro is passed as a preprocessor constant to the compiler
|
||||||
# the type name and the member name, in uppercase, prepended with 'HAVE_'.
|
# using the type name and the member name, in uppercase, prepended with
|
||||||
|
# +HAVE_+.
|
||||||
#
|
#
|
||||||
# For example, if have_struct_member('struct foo', 'bar') returned true, then the
|
# For example, if <code>have_struct_member('struct foo', 'bar')</code>
|
||||||
# HAVE_STRUCT_FOO_BAR preprocessor macro would be passed to the compiler.
|
# returned true, then the +HAVE_STRUCT_FOO_BAR+ preprocessor macro would be
|
||||||
|
# passed to the compiler.
|
||||||
#
|
#
|
||||||
# HAVE_ST_BAR is also defined for backward compatibility.
|
# +HAVE_ST_BAR+ is also defined for backward compatibility.
|
||||||
#
|
#
|
||||||
def have_struct_member(type, member, headers = nil, opt = "", &b)
|
def have_struct_member(type, member, headers = nil, opt = "", &b)
|
||||||
checking_for checking_message("#{type}.#{member}", headers) do
|
checking_for checking_message("#{type}.#{member}", headers) do
|
||||||
@ -1065,11 +1081,11 @@ end
|
|||||||
# You may also pass additional flags to +opt+ which are then passed along to
|
# You may also pass additional flags to +opt+ which are then passed along to
|
||||||
# the compiler.
|
# the compiler.
|
||||||
#
|
#
|
||||||
# If found, a macro is passed as a preprocessor constant to the compiler using
|
# If found, a macro is passed as a preprocessor constant to the compiler
|
||||||
# the type name, in uppercase, prepended with 'HAVE_TYPE_'.
|
# using the type name, in uppercase, prepended with +HAVE_TYPE_+.
|
||||||
#
|
#
|
||||||
# For example, if have_type('foo') returned true, then the HAVE_TYPE_FOO
|
# For example, if <code>have_type('foo')</code> returned true, then the
|
||||||
# preprocessor macro would be passed to the compiler.
|
# +HAVE_TYPE_FOO+ preprocessor macro would be passed to the compiler.
|
||||||
#
|
#
|
||||||
def have_type(type, headers = nil, opt = "", &b)
|
def have_type(type, headers = nil, opt = "", &b)
|
||||||
checking_for checking_message(type, headers, opt) do
|
checking_for checking_message(type, headers, opt) do
|
||||||
@ -1097,7 +1113,7 @@ def find_type(type, opt, *headers, &b)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the Constant +const+ is defined.
|
# Returns whether or not the constant +const+ is defined.
|
||||||
#
|
#
|
||||||
# See also +have_const+
|
# See also +have_const+
|
||||||
#
|
#
|
||||||
@ -1118,19 +1134,19 @@ end
|
|||||||
|
|
||||||
# Returns whether or not the constant +const+ is defined. You may
|
# Returns whether or not the constant +const+ is defined. You may
|
||||||
# optionally pass the +type+ of +const+ as <code>[const, type]</code>,
|
# optionally pass the +type+ of +const+ as <code>[const, type]</code>,
|
||||||
# like as:
|
# such as:
|
||||||
#
|
#
|
||||||
# have_const(%w[PTHREAD_MUTEX_INITIALIZER pthread_mutex_t], "pthread.h")
|
# have_const(%w[PTHREAD_MUTEX_INITIALIZER pthread_mutex_t], "pthread.h")
|
||||||
#
|
#
|
||||||
# You may also pass additional +headers+ to check against in addition
|
# You may also pass additional +headers+ to check against in addition to the
|
||||||
# to the common header files, and additional flags to +opt+ which are
|
# common header files, and additional flags to +opt+ which are then passed
|
||||||
# then passed along to the compiler.
|
# along to the compiler.
|
||||||
#
|
#
|
||||||
# If found, a macro is passed as a preprocessor constant to the compiler using
|
# If found, a macro is passed as a preprocessor constant to the compiler
|
||||||
# the type name, in uppercase, prepended with 'HAVE_CONST_'.
|
# using the type name, in uppercase, prepended with +HAVE_CONST_+.
|
||||||
#
|
#
|
||||||
# For example, if have_const('foo') returned true, then the HAVE_CONST_FOO
|
# For example, if <code>have_const('foo')</code> returned true, then the
|
||||||
# preprocessor macro would be passed to the compiler.
|
# +HAVE_CONST_FOO+ preprocessor macro would be passed to the compiler.
|
||||||
#
|
#
|
||||||
def have_const(const, headers = nil, opt = "", &b)
|
def have_const(const, headers = nil, opt = "", &b)
|
||||||
checking_for checking_message([*const].compact.join(' '), headers, opt) do
|
checking_for checking_message([*const].compact.join(' '), headers, opt) do
|
||||||
@ -1138,8 +1154,8 @@ def have_const(const, headers = nil, opt = "", &b)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
STRING_OR_FAILED_FORMAT = "%s"
|
|
||||||
# :stopdoc:
|
# :stopdoc:
|
||||||
|
STRING_OR_FAILED_FORMAT = "%s"
|
||||||
def STRING_OR_FAILED_FORMAT.%(x)
|
def STRING_OR_FAILED_FORMAT.%(x)
|
||||||
x ? super : "failed"
|
x ? super : "failed"
|
||||||
end
|
end
|
||||||
@ -1162,15 +1178,16 @@ end
|
|||||||
|
|
||||||
# :startdoc:
|
# :startdoc:
|
||||||
|
|
||||||
# Returns the size of the given +type+. You may optionally specify additional
|
# Returns the size of the given +type+. You may optionally specify
|
||||||
# +headers+ to search in for the +type+.
|
# additional +headers+ to search in for the +type+.
|
||||||
#
|
#
|
||||||
# If found, a macro is passed as a preprocessor constant to the compiler using
|
# If found, a macro is passed as a preprocessor constant to the compiler
|
||||||
# the type name, in uppercase, prepended with 'SIZEOF_', followed by the type
|
# using the type name, in uppercase, prepended with +SIZEOF_+, followed by
|
||||||
# name, followed by '=X' where 'X' is the actual size.
|
# the type name, followed by <code>=X</code> where "X" is the actual size.
|
||||||
#
|
#
|
||||||
# For example, if check_sizeof('mystruct') returned 12, then the
|
# For example, if <code>check_sizeof('mystruct')</code> returned 12, then
|
||||||
# SIZEOF_MYSTRUCT=12 preprocessor macro would be passed to the compiler.
|
# the <code>SIZEOF_MYSTRUCT=12</code> preprocessor macro would be passed to
|
||||||
|
# the compiler.
|
||||||
#
|
#
|
||||||
def check_sizeof(type, headers = nil, opts = "", &b)
|
def check_sizeof(type, headers = nil, opts = "", &b)
|
||||||
typedef, member, prelude = typedef_expr(type, headers)
|
typedef, member, prelude = typedef_expr(type, headers)
|
||||||
@ -1186,20 +1203,20 @@ def check_sizeof(type, headers = nil, opts = "", &b)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the signedness of the given +type+. You may optionally
|
# Returns the signedness of the given +type+. You may optionally specify
|
||||||
# specify additional +headers+ to search in for the +type+.
|
# additional +headers+ to search in for the +type+.
|
||||||
#
|
#
|
||||||
# If the +type+ is found and is a numeric type, a macro is passed as a
|
# If the +type+ is found and is a numeric type, a macro is passed as a
|
||||||
# preprocessor constant to the compiler using the +type+ name, in
|
# preprocessor constant to the compiler using the +type+ name, in uppercase,
|
||||||
# uppercase, prepended with 'SIGNEDNESS_OF_', followed by the +type+
|
# prepended with +SIGNEDNESS_OF_+, followed by the +type+ name, followed by
|
||||||
# name, followed by '=X' where 'X' is positive integer if the +type+ is
|
# <code>=X</code> where "X" is positive integer if the +type+ is unsigned
|
||||||
# unsigned, or negative integer if the +type+ is signed.
|
# and a negative integer if the +type+ is signed.
|
||||||
#
|
#
|
||||||
# For example, if size_t is defined as unsigned, then
|
# For example, if +size_t+ is defined as unsigned, then
|
||||||
# check_signedness('size_t') would returned +1 and the
|
# <code>check_signedness('size_t')</code> would return +1 and the
|
||||||
# SIGNEDNESS_OF_SIZE_T=+1 preprocessor macro would be passed to the
|
# <code>SIGNEDNESS_OF_SIZE_T=+1</code> preprocessor macro would be passed to
|
||||||
# compiler, and SIGNEDNESS_OF_INT=-1 if check_signedness('int') is
|
# the compiler. The <code>SIGNEDNESS_OF_INT=-1</code> macro would be set
|
||||||
# done.
|
# for <code>check_signedness('int')</code>
|
||||||
#
|
#
|
||||||
def check_signedness(type, headers = nil, opts = nil, &b)
|
def check_signedness(type, headers = nil, opts = nil, &b)
|
||||||
typedef, member, prelude = typedef_expr(type, headers)
|
typedef, member, prelude = typedef_expr(type, headers)
|
||||||
@ -1214,25 +1231,28 @@ end
|
|||||||
|
|
||||||
# Returns the convertible integer type of the given +type+. You may
|
# Returns the convertible integer type of the given +type+. You may
|
||||||
# optionally specify additional +headers+ to search in for the +type+.
|
# optionally specify additional +headers+ to search in for the +type+.
|
||||||
# _Convertible_ means actually same type, or typedefed from same type.
|
# _convertible_ means actually the same type, or typedef'd from the same
|
||||||
|
# type.
|
||||||
#
|
#
|
||||||
# If the +type+ is a integer type and _convertible_ type is found,
|
# If the +type+ is a integer type and the _convertible_ type is found,
|
||||||
# following macros are passed as preprocessor constants to the
|
# the following macros are passed as preprocessor constants to the compiler
|
||||||
# compiler using the +type+ name, in uppercase.
|
# using the +type+ name, in uppercase.
|
||||||
#
|
#
|
||||||
# * 'TYPEOF_', followed by the +type+ name, followed by '=X' where 'X'
|
# * +TYPEOF_+, followed by the +type+ name, followed by <code>=X</code>
|
||||||
# is the found _convertible_ type name. * 'TYP2NUM' and 'NUM2TYP,
|
# where "X" is the found _convertible_ type name.
|
||||||
# where 'TYP' is the +type+ name in uppercase with replacing '_t'
|
# * +TYP2NUM+ and +NUM2TYP+,
|
||||||
# suffix with 'T', followed by '=X' where 'X' is the macro name to
|
# where +TYP+ is the +type+ name in uppercase with replacing an +_t+
|
||||||
# convert +type+ to +Integer+ object, and vice versa.
|
# suffix with "T", followed by <code>=X</code> where "X" is the macro name
|
||||||
|
# to convert +type+ to an Integer object, and vice versa.
|
||||||
#
|
#
|
||||||
# For example, if foobar_t is defined as unsigned long, then
|
# For example, if +foobar_t+ is defined as unsigned long, then
|
||||||
# convertible_int("foobar_t") would return "unsigned long", and define
|
# <code>convertible_int("foobar_t")</code> would return "unsigned long", and
|
||||||
# macros:
|
# define these macros:
|
||||||
#
|
#
|
||||||
# #define TYPEOF_FOOBAR_T unsigned long
|
# #define TYPEOF_FOOBAR_T unsigned long
|
||||||
# #define FOOBART2NUM ULONG2NUM
|
# #define FOOBART2NUM ULONG2NUM
|
||||||
# #define NUM2FOOBART NUM2ULONG
|
# #define NUM2FOOBART NUM2ULONG
|
||||||
|
#
|
||||||
def convertible_int(type, headers = nil, opts = nil, &b)
|
def convertible_int(type, headers = nil, opts = nil, &b)
|
||||||
type, macname = *type
|
type, macname = *type
|
||||||
checking_for("convertible type of #{type}", STRING_OR_FAILED_FORMAT) do
|
checking_for("convertible type of #{type}", STRING_OR_FAILED_FORMAT) do
|
||||||
@ -1297,7 +1317,7 @@ int t(void) {return (int)(1-(conftestval#{member ? ".#{member}" : ""}));}
|
|||||||
SRC
|
SRC
|
||||||
end
|
end
|
||||||
|
|
||||||
# Used internally by the what_type? method to check if _typeof_ GCC
|
# Used internally by the what_type? method to check if the _typeof_ GCC
|
||||||
# extension is available.
|
# extension is available.
|
||||||
def have_typeof?
|
def have_typeof?
|
||||||
return $typeof if defined?($typeof)
|
return $typeof if defined?($typeof)
|
||||||
@ -1408,11 +1428,11 @@ end
|
|||||||
# :startdoc:
|
# :startdoc:
|
||||||
|
|
||||||
# Searches for the executable +bin+ on +path+. The default path is your
|
# Searches for the executable +bin+ on +path+. The default path is your
|
||||||
# PATH environment variable. If that isn't defined, it will resort to
|
# +PATH+ environment variable. If that isn't defined, it will resort to
|
||||||
# searching /usr/local/bin, /usr/ucb, /usr/bin and /bin.
|
# searching /usr/local/bin, /usr/ucb, /usr/bin and /bin.
|
||||||
#
|
#
|
||||||
# If found, it will return the full path, including the executable name,
|
# If found, it will return the full path, including the executable name, of
|
||||||
# of where it was found.
|
# where it was found.
|
||||||
#
|
#
|
||||||
# Note that this method does not actually affect the generated Makefile.
|
# Note that this method does not actually affect the generated Makefile.
|
||||||
#
|
#
|
||||||
@ -1437,11 +1457,13 @@ end
|
|||||||
|
|
||||||
# :startdoc:
|
# :startdoc:
|
||||||
|
|
||||||
# Tests for the presence of a --with-<tt>config</tt> or --without-<tt>config</tt>
|
# Tests for the presence of a <tt>--with-</tt>_config_ or
|
||||||
# option. Returns true if the with option is given, false if the without
|
# <tt>--without-</tt>_config_ option. Returns true if the with option is
|
||||||
# option is given, and the default value otherwise.
|
# given, false if the without option is given, and the default value
|
||||||
|
# otherwise.
|
||||||
#
|
#
|
||||||
# This can be useful for adding custom definitions, such as debug information.
|
# This can be useful for adding custom definitions, such as debug
|
||||||
|
# information.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
#
|
#
|
||||||
@ -1470,11 +1492,13 @@ def with_config(config, default=nil)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Tests for the presence of an --enable-<tt>config</tt> or
|
# Tests for the presence of an <tt>--enable-</tt>_config_ or
|
||||||
# --disable-<tt>config</tt> option. Returns true if the enable option is given,
|
# <tt>--disable-</tt>_config_ option. Returns true if the enable option is
|
||||||
# false if the disable option is given, and the default value otherwise.
|
# given, false if the disable option is given, and the default value
|
||||||
|
# otherwise.
|
||||||
#
|
#
|
||||||
# This can be useful for adding custom definitions, such as debug information.
|
# This can be useful for adding custom definitions, such as debug
|
||||||
|
# information.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
#
|
#
|
||||||
@ -1494,10 +1518,10 @@ def enable_config(config, default=nil)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generates a header file consisting of the various macro definitions generated
|
# Generates a header file consisting of the various macro definitions
|
||||||
# by other methods such as have_func and have_header. These are then wrapped in
|
# generated by other methods such as have_func and have_header. These are
|
||||||
# a custom #ifndef based on the +header+ file name, which defaults to
|
# then wrapped in a custom <code>#ifndef</code> based on the +header+ file
|
||||||
# 'extconf.h'.
|
# name, which defaults to "extconf.h".
|
||||||
#
|
#
|
||||||
# For example:
|
# For example:
|
||||||
#
|
#
|
||||||
@ -1542,16 +1566,17 @@ def create_header(header = "extconf.h")
|
|||||||
$extconf_h = header
|
$extconf_h = header
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets a +target+ name that the user can then use to configure various 'with'
|
# Sets a +target+ name that the user can then use to configure various
|
||||||
# options with on the command line by using that name. For example, if the
|
# "with" options with on the command line by using that name. For example,
|
||||||
# target is set to "foo", then the user could use the --with-foo-dir command
|
# if the target is set to "foo", then the user could use the
|
||||||
# line option.
|
# <code>--with-foo-dir</code> command line option.
|
||||||
#
|
#
|
||||||
# You may pass along additional 'include' or 'lib' defaults via the +idefault+
|
# You may pass along additional "include" or "lib" defaults via the
|
||||||
# and +ldefault+ parameters, respectively.
|
# +idefault+ and +ldefault+ parameters, respectively.
|
||||||
#
|
#
|
||||||
# Note that dir_config only adds to the list of places to search for libraries
|
# Note that dir_config only adds to the list of places to search for
|
||||||
# and include files. It does not link the libraries into your application.
|
# libraries and include files. It does not link the libraries into your
|
||||||
|
# application.
|
||||||
#
|
#
|
||||||
def dir_config(target, idefault=nil, ldefault=nil)
|
def dir_config(target, idefault=nil, ldefault=nil)
|
||||||
if dir = with_config(target + "-dir", (idefault unless ldefault))
|
if dir = with_config(target + "-dir", (idefault unless ldefault))
|
||||||
@ -1793,8 +1818,8 @@ all install static install-so install-rb: Makefile
|
|||||||
RULES
|
RULES
|
||||||
end
|
end
|
||||||
|
|
||||||
# Processes the data contents of the "depend" file.
|
# Processes the data contents of the "depend" file. Each line of this file
|
||||||
# Each line of this file is expected to be a file name.
|
# is expected to be a file name.
|
||||||
#
|
#
|
||||||
# Returns the output of findings, in Makefile format.
|
# Returns the output of findings, in Makefile format.
|
||||||
#
|
#
|
||||||
@ -1858,28 +1883,29 @@ end
|
|||||||
# preprocessor constants that you may have generated through other methods.
|
# preprocessor constants that you may have generated through other methods.
|
||||||
#
|
#
|
||||||
# The +target+ name should correspond the name of the global function name
|
# The +target+ name should correspond the name of the global function name
|
||||||
# defined within your C extension, minus the 'Init_'. For example, if your
|
# defined within your C extension, minus the +Init_+. For example, if your
|
||||||
# C extension is defined as 'Init_foo', then your target would simply be 'foo'.
|
# C extension is defined as +Init_foo+, then your target would simply be
|
||||||
|
# "foo".
|
||||||
#
|
#
|
||||||
# If any '/' characters are present in the target name, only the last name
|
# If any "/" characters are present in the target name, only the last name
|
||||||
# is interpreted as the target name, and the rest are considered toplevel
|
# is interpreted as the target name, and the rest are considered toplevel
|
||||||
# directory names, and the generated Makefile will be altered accordingly to
|
# directory names, and the generated Makefile will be altered accordingly to
|
||||||
# follow that directory structure.
|
# follow that directory structure.
|
||||||
#
|
#
|
||||||
# For example, if you pass 'test/foo' as a target name, your extension will
|
# For example, if you pass "test/foo" as a target name, your extension will
|
||||||
# be installed under the 'test' directory. This means that in order to
|
# be installed under the "test" directory. This means that in order to
|
||||||
# load the file within a Ruby program later, that directory structure will
|
# load the file within a Ruby program later, that directory structure will
|
||||||
# have to be followed, e.g. "require 'test/foo'".
|
# have to be followed, e.g. <code>require 'test/foo'</code>.
|
||||||
#
|
#
|
||||||
# The +srcprefix+ should be used when your source files are not in the same
|
# The +srcprefix+ should be used when your source files are not in the same
|
||||||
# directory as your build script. This will not only eliminate the need for
|
# directory as your build script. This will not only eliminate the need for
|
||||||
# you to manually copy the source files into the same directory as your build
|
# you to manually copy the source files into the same directory as your
|
||||||
# script, but it also sets the proper +target_prefix+ in the generated
|
# build script, but it also sets the proper +target_prefix+ in the generated
|
||||||
# Makefile.
|
# Makefile.
|
||||||
#
|
#
|
||||||
# Setting the +target_prefix+ will, in turn, install the generated binary in
|
# Setting the +target_prefix+ will, in turn, install the generated binary in
|
||||||
# a directory under your RbConfig::CONFIG['sitearchdir'] that mimics your local
|
# a directory under your <code>RbConfig::CONFIG['sitearchdir']</code> that
|
||||||
# filesystem when you run 'make install'.
|
# mimics your local filesystem when you run <code>make install</code>.
|
||||||
#
|
#
|
||||||
# For example, given the following file tree:
|
# For example, given the following file tree:
|
||||||
#
|
#
|
||||||
@ -1892,9 +1918,9 @@ end
|
|||||||
#
|
#
|
||||||
# create_makefile('test/foo', 'test')
|
# create_makefile('test/foo', 'test')
|
||||||
#
|
#
|
||||||
# That will set the +target_prefix+ in the generated Makefile to 'test'. That,
|
# That will set the +target_prefix+ in the generated Makefile to "test".
|
||||||
# in turn, will create the following file tree when installed via the
|
# That, in turn, will create the following file tree when installed via the
|
||||||
# 'make install' command:
|
# <code>make install</code> command:
|
||||||
#
|
#
|
||||||
# /path/to/ruby/sitearchdir/test/foo.so
|
# /path/to/ruby/sitearchdir/test/foo.so
|
||||||
#
|
#
|
||||||
@ -1903,14 +1929,14 @@ end
|
|||||||
# libraries may depend on the +target_prefix+ being set properly.
|
# libraries may depend on the +target_prefix+ being set properly.
|
||||||
#
|
#
|
||||||
# The +srcprefix+ argument can be used to override the default source
|
# The +srcprefix+ argument can be used to override the default source
|
||||||
# directory, i.e. the current directory . It is included as part of the VPATH
|
# directory, i.e. the current directory. It is included as part of the
|
||||||
# and added to the list of INCFLAGS.
|
# +VPATH+ and added to the list of +INCFLAGS+.
|
||||||
#
|
#
|
||||||
def create_makefile(target, srcprefix = nil)
|
def create_makefile(target, srcprefix = nil)
|
||||||
$target = target
|
$target = target
|
||||||
libpath = $DEFLIBPATH|$LIBPATH
|
libpath = $DEFLIBPATH|$LIBPATH
|
||||||
message "creating Makefile\n"
|
message "creating Makefile\n"
|
||||||
rm_f "conftest*"
|
MakeMakefile.rm_f "conftest*"
|
||||||
if CONFIG["DLEXT"] == $OBJEXT
|
if CONFIG["DLEXT"] == $OBJEXT
|
||||||
for lib in libs = $libs.split
|
for lib in libs = $libs.split
|
||||||
lib.sub!(/-l(.*)/, %%"lib\\1.#{$LIBEXT}"%)
|
lib.sub!(/-l(.*)/, %%"lib\\1.#{$LIBEXT}"%)
|
||||||
@ -2228,9 +2254,9 @@ def init_mkmf(config = CONFIG, rbconfig = RbConfig::CONFIG)
|
|||||||
end
|
end
|
||||||
|
|
||||||
FailedMessage = <<MESSAGE
|
FailedMessage = <<MESSAGE
|
||||||
Could not create Makefile due to some reason, probably lack of
|
Could not create Makefile due to some reason, probably lack of necessary
|
||||||
necessary libraries and/or headers. Check the mkmf.log file for more
|
libraries and/or headers. Check the mkmf.log file for more details. You may
|
||||||
details. You may need configuration options.
|
need configuration options.
|
||||||
|
|
||||||
Provided configuration options:
|
Provided configuration options:
|
||||||
MESSAGE
|
MESSAGE
|
||||||
@ -2247,8 +2273,11 @@ def mkmf_failed(path)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# :startdoc:
|
# Initializes mkmf for creating a makefile.
|
||||||
|
#
|
||||||
|
# Internal use only.
|
||||||
|
#
|
||||||
|
def make_makefile
|
||||||
init_mkmf
|
init_mkmf
|
||||||
|
|
||||||
$make = with_config("make-prog", ENV["MAKE"] || "make")
|
$make = with_config("make-prog", ENV["MAKE"] || "make")
|
||||||
@ -2276,6 +2305,9 @@ unless File.expand_path(RbConfig::CONFIG["topdir"]) == File.expand_path(curdir)
|
|||||||
end
|
end
|
||||||
$configure_args["--topdir"] ||= $curdir
|
$configure_args["--topdir"] ||= $curdir
|
||||||
$ruby = arg_config("--ruby", File.join(RbConfig::CONFIG["bindir"], CONFIG["ruby_install_name"]))
|
$ruby = arg_config("--ruby", File.join(RbConfig::CONFIG["bindir"], CONFIG["ruby_install_name"]))
|
||||||
|
end
|
||||||
|
|
||||||
|
# :startdoc:
|
||||||
|
|
||||||
split = Shellwords.method(:shellwords).to_proc
|
split = Shellwords.method(:shellwords).to_proc
|
||||||
|
|
||||||
@ -2335,7 +2367,13 @@ distclean: clean distclean-so distclean-rb-default distclean-rb
|
|||||||
|
|
||||||
realclean: distclean
|
realclean: distclean
|
||||||
"
|
"
|
||||||
|
end
|
||||||
|
|
||||||
|
include MakeMakefile
|
||||||
|
|
||||||
if not $extmk and /\A(extconf|makefile).rb\z/ =~ File.basename($0)
|
if not $extmk and /\A(extconf|makefile).rb\z/ =~ File.basename($0)
|
||||||
END {mkmf_failed($0)}
|
END {mkmf_failed($0)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
make_makefile
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class TestMkmf < Test::Unit::TestCase
|
|||||||
remove_const(:MAKEFILE_CONFIG)
|
remove_const(:MAKEFILE_CONFIG)
|
||||||
const_set(:MAKEFILE_CONFIG, mkconfig)
|
const_set(:MAKEFILE_CONFIG, mkconfig)
|
||||||
}
|
}
|
||||||
Object.class_eval {
|
MakeMakefile.class_eval {
|
||||||
remove_const(:CONFIG)
|
remove_const(:CONFIG)
|
||||||
const_set(:CONFIG, mkconfig)
|
const_set(:CONFIG, mkconfig)
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ class TestMkmf < Test::Unit::TestCase
|
|||||||
remove_const(:MAKEFILE_CONFIG)
|
remove_const(:MAKEFILE_CONFIG)
|
||||||
const_set(:MAKEFILE_CONFIG, mkconfig0)
|
const_set(:MAKEFILE_CONFIG, mkconfig0)
|
||||||
}
|
}
|
||||||
Object.class_eval {
|
MakeMakefile.class_eval {
|
||||||
remove_const(:CONFIG)
|
remove_const(:CONFIG)
|
||||||
const_set(:CONFIG, mkconfig0)
|
const_set(:CONFIG, mkconfig0)
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,10 @@ class TestModule < Test::Unit::TestCase
|
|||||||
list.reject {|c| c.to_s.start_with?("MiniTest") }
|
list.reject {|c| c.to_s.start_with?("MiniTest") }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_mkmf_mixins(list)
|
||||||
|
list.reject {|c| c.to_s.start_with?("MakeMakefile") }
|
||||||
|
end
|
||||||
|
|
||||||
module Mixin
|
module Mixin
|
||||||
MIXIN = 1
|
MIXIN = 1
|
||||||
def mixin
|
def mixin
|
||||||
@ -221,9 +225,9 @@ class TestModule < Test::Unit::TestCase
|
|||||||
assert_equal([Mixin], Mixin.ancestors)
|
assert_equal([Mixin], Mixin.ancestors)
|
||||||
|
|
||||||
assert_equal([Object, Kernel, BasicObject],
|
assert_equal([Object, Kernel, BasicObject],
|
||||||
remove_minitest_mixins(remove_rake_mixins(remove_json_mixins(remove_pp_mixins(Object.ancestors)))))
|
remove_mkmf_mixins(remove_minitest_mixins(remove_rake_mixins(remove_json_mixins(remove_pp_mixins(Object.ancestors))))))
|
||||||
assert_equal([String, Comparable, Object, Kernel, BasicObject],
|
assert_equal([String, Comparable, Object, Kernel, BasicObject],
|
||||||
remove_minitest_mixins(remove_rake_mixins(remove_json_mixins(remove_pp_mixins(String.ancestors)))))
|
remove_mkmf_mixins(remove_minitest_mixins(remove_rake_mixins(remove_json_mixins(remove_pp_mixins(String.ancestors))))))
|
||||||
end
|
end
|
||||||
|
|
||||||
CLASS_EVAL = 2
|
CLASS_EVAL = 2
|
||||||
@ -281,9 +285,9 @@ class TestModule < Test::Unit::TestCase
|
|||||||
assert_equal([], Mixin.included_modules)
|
assert_equal([], Mixin.included_modules)
|
||||||
assert_equal([Mixin], User.included_modules)
|
assert_equal([Mixin], User.included_modules)
|
||||||
assert_equal([Kernel],
|
assert_equal([Kernel],
|
||||||
remove_minitest_mixins(remove_rake_mixins(remove_json_mixins(remove_pp_mixins(Object.included_modules)))))
|
remove_mkmf_mixins(remove_minitest_mixins(remove_rake_mixins(remove_json_mixins(remove_pp_mixins(Object.included_modules))))))
|
||||||
assert_equal([Comparable, Kernel],
|
assert_equal([Comparable, Kernel],
|
||||||
remove_minitest_mixins(remove_rake_mixins(remove_json_mixins(remove_pp_mixins(String.included_modules)))))
|
remove_mkmf_mixins(remove_minitest_mixins(remove_rake_mixins(remove_json_mixins(remove_pp_mixins(String.included_modules))))))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_instance_methods
|
def test_instance_methods
|
||||||
|
Loading…
x
Reference in New Issue
Block a user