summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-05-25 23:44:08 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-05-25 23:44:08 +0000
commit65937b5eb9e35cd4b76261ac7bb3b3c3809cbe38 (patch)
tree5e2b99484f0b00685b8d05c07e88a3a56ff483e6 /lib
parent155c33c1d164987a5f872e410c506187f26869fd (diff)
* ruby.h, lib/mkmf.rb (create_header): clear command line options for
macros moved to extconf.h. * ext/extmk.rb (extract_makefile, extmk): made RUBY_EXTCONF_H and EXTSTATIC permanent. * ext/{dbm,digest/*,socket,zlib}/extconf.rb: used $defs and $INCFLAGS. * {bcc32,win32,wince}/Makefile.sub (COMPILE_C, COMPILE_CXX): added $(INCFLAGS). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/mkmf.rb56
1 files changed, 32 insertions, 24 deletions
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 412ecd6917..a0cb36fea1 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -14,6 +14,7 @@ if /mswin|bccwin|mingw|msdosdjgpp|human|os2/ !~ CONFIG['build_os']
end
SRC_EXT = %w[c m] << CXX_EXT
$static = $config_h = nil
+$default_static = $static
unless defined? $configure_args
$configure_args = {}
@@ -273,15 +274,13 @@ def link_command(ldflags, opt="", libpath=$LIBPATH)
end
def cc_command(opt="")
- Config::expand("$(CC) -c #$INCFLAGS -I$(hdrdir) " \
- "#$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} #{CONFTEST_C}",
- CONFIG.merge('hdrdir' => $hdrdir.quote))
+ Config::expand("$(CC) #$INCFLAGS #$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} -c #{CONFTEST_C}",
+ CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote))
end
def cpp_command(outfile, opt="")
- Config::expand("$(CPP) #$INCFLAGS -I$(hdrdir) " \
- "#$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}",
- CONFIG.merge('hdrdir' => $hdrdir.quote))
+ Config::expand("$(CPP) #$INCFLAGS #$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}",
+ CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote))
end
def libpathflag(libpath=$LIBPATH)
@@ -828,21 +827,24 @@ end
def create_header(header = "extconf.h")
message "creating %s\n", header
- if $defs.length > 0
- sym = header.tr("a-z./\055", "A-Z___")
+ sym = header.tr("a-z./\055", "A-Z___")
+ hdr = ["#ifndef #{sym}\n#define #{sym}\n"]
+ for line in $defs
+ case line
+ when /^-D([^=]+)(?:=(.*))?/
+ hdr << "#define #$1 #{$2 ? Shellwords.shellwords($2)[0] : 1}\n"
+ when /^-U(.*)/
+ hdr << "#undef #$1\n"
+ end
+ end
+ hdr << "#endif\n"
+ hdr = hdr.join
+ unless (IO.read(header) == hdr rescue false)
open(header, "w") do |hfile|
- hfile.print "#ifndef #{sym}\n#define #{sym}\n"
- for line in $defs
- case line
- when /^-D([^=]+)(?:=(.*))?/
- hfile.print "#define #$1 #{$2 || 1}\n"
- when /^-U(.*)/
- hfile.print "#undef #$1\n"
- end
- end
- hfile.print "#endif\n"
+ hfile.write(hdr)
end
end
+ $extconf_h = header
end
def dir_config(target, idefault=nil, ldefault=nil)
@@ -961,6 +963,7 @@ VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])}
else
sep = ""
end
+ extconf_h = $extconf_h ? "-DRUBY_EXTCONF_H=\\\"$(RUBY_EXTCONF_H)\\\" " : ""
mk << %{
CC = #{CONFIG['CC']}
LIBRUBY = #{CONFIG['LIBRUBY']}
@@ -968,8 +971,10 @@ LIBRUBY_A = #{CONFIG['LIBRUBY_A']}
LIBRUBYARG_SHARED = #$LIBRUBYARG_SHARED
LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC
+RUBY_EXTCONF_H = #{$extconf_h}
CFLAGS = #{CONFIG['CCDLFLAGS'] unless $static} #$CFLAGS #$ARCH_FLAG
-CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{$CPPFLAGS}
+INCFLAGS = -I. #$INCFLAGS
+CPPFLAGS = #{extconf_h}#{$CPPFLAGS}
CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']}
DLDFLAGS = #$LDFLAGS #$DLDFLAGS #$ARCH_FLAG
LDSHARED = #{CONFIG['LDSHARED']}
@@ -1094,6 +1099,7 @@ SRCS = #{srcs.collect(&File.method(:basename)).join(' ')}
OBJS = #{$objs}
TARGET = #{target}
DLLIB = #{dllib}
+EXTSTATIC = #{$default_static != $static && $static || ""}
STATIC_LIB = #{staticlib unless $static.nil?}
}
@@ -1264,6 +1270,7 @@ site-install-rb: install-rb
headers.each {|h| h.sub!(/.*/) {|*m| RULE_SUBST % m}}
end
headers << $config_h if $config_h
+ headers << "$(RUBY_EXTCONF_H)" if $extconf_h
mfile.print "$(OBJS): ", headers.join(' '), "\n"
end
@@ -1277,11 +1284,12 @@ def init_mkmf(config = CONFIG)
$arg_config = []
$enable_shared = config['ENABLE_SHARED'] == 'yes'
$defs = []
+ $extconf_h = nil
$CFLAGS = with_config("cflags", arg_config("CFLAGS", config["CFLAGS"])).dup
$ARCH_FLAG = with_config("arch_flag", arg_config("ARCH_FLAG", config["ARCH_FLAG"])).dup
$CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS", config["CPPFLAGS"])).dup
$LDFLAGS = (with_config("ldflags") || "").dup
- $INCFLAGS = "-I$(topdir)"
+ $INCFLAGS = "-I$(topdir) -I$(hdrdir) -I$(srcdir)"
$DLDFLAGS = with_config("dldflags", arg_config("DLDFLAGS", config["DLDFLAGS"])).dup
$LIBEXT = config['LIBEXT'].dup
$OBJEXT = config["OBJEXT"].dup
@@ -1372,10 +1380,10 @@ COMMON_LIBS = config_string('COMMON_LIBS', &split) || []
COMPILE_RULES = config_string('COMPILE_RULES', &split) || %w[.%s.%s:]
RULE_SUBST = config_string('RULE_SUBST')
-COMPILE_C = config_string('COMPILE_C') || '$(CC) $(CFLAGS) $(CPPFLAGS) -c $<'
-COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<'
+COMPILE_C = config_string('COMPILE_C') || '$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<'
+COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<'
TRY_LINK = config_string('TRY_LINK') ||
- "$(CC) #{OUTFLAG}conftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS) " \
+ "$(CC) #{OUTFLAG}conftest $(INCFLAGS) $(CPPFLAGS) " \
"$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
LINK_SO = config_string('LINK_SO') ||
if CONFIG["DLEXT"] == $OBJEXT
@@ -1394,7 +1402,7 @@ clean:
@-$(RM) $(CLEANLIBS#{sep}) $(CLEANOBJS#{sep}) $(CLEANFILES#{sep})
distclean: clean
- @-$(RM) Makefile extconf.h conftest.* mkmf.log
+ @-$(RM) Makefile #{$extconf_h} conftest.* mkmf.log
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES#{sep})
realclean: distclean