From c4c770ecb2cfc6a7b213812cfd0b1f56bff000a4 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 25 May 2006 23:44:08 +0000 Subject: * 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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@10193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 ++++++ bcc32/Makefile.sub | 4 +- ext/dbm/extconf.rb | 2 +- ext/digest/md5/extconf.rb | 3 +- ext/digest/rmd160/extconf.rb | 3 +- ext/digest/sha1/extconf.rb | 3 +- ext/digest/sha2/extconf.rb | 3 +- ext/extmk.rb | 8 +++- ext/socket/extconf.rb | 97 ++++++++++++++++---------------------------- ext/socket/socket.c | 2 +- ext/zlib/extconf.rb | 7 +--- lib/mkmf.rb | 56 ++++++++++++++----------- ruby.h | 3 ++ win32/Makefile.sub | 4 +- wince/Makefile.sub | 4 +- 15 files changed, 106 insertions(+), 106 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3960cdac3..589fef299 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Fri May 26 08:40:03 2006 nobuyoshi nakada + + * 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). + Thu May 25 01:52:07 2006 nobuyoshi nakada * lib/mkmf.rb (pkg_config): particular config commands support. diff --git a/bcc32/Makefile.sub b/bcc32/Makefile.sub index cef02730d..030a799e9 100644 --- a/bcc32/Makefile.sub +++ b/bcc32/Makefile.sub @@ -384,8 +384,8 @@ s,@LIBPATHFLAG@, -L"%s",;t t s,@RPATHFLAG@,,;t t s,@LIBARG@,%s.lib,;t t s,@LINK_SO@,$$(LDSHARED) $$(DLDFLAGS) $$(LIBPATH) $$(OBJS), $$(@:/=\), nul, $$(LIBS) $$(LOCAL_LIBS), $$(DEFFILE), $$(RESFILE),;t t -s,@COMPILE_C@,$$(CC) $$(CFLAGS) $$(CPPFLAGS) -c $$(<:/=\),;t t -s,@COMPILE_CXX@,$$(CXX) $$(CXXFLAGS) $$(CPPFLAGS) -P -c $$(<:/=\),;t t +s,@COMPILE_C@,$$(CC) $$(INCFLAGS) $$(CFLAGS) $$(CPPFLAGS) -c $$(<:/=\),;t t +s,@COMPILE_CXX@,$$(CXX) $$(INCFLAGS) $$(CXXFLAGS) $$(CPPFLAGS) -P -c $$(<:/=\),;t t s,@COMPILE_RULES@,{$$(srcdir)}.%s{}.%s: {$$(topdir)}.%s{}.%s: {$$(hdrdir)}.%s{}.%s: .%s.%s:,;t t s,@RULE_SUBST@,{.;$$(VPATH)}%s,;t t s,@COMMON_LIBS@,m advapi32 avicap32 avifil32 cap comctl32 comdlg32 dlcapi gdi32 glu32 imagehlp imm32 inetmib1 kernel32 loadperf lsapi32 lz32 mapi32 mgmtapi mpr msacm32 msvfw32 nddeapi netapi32 ole32 oleaut32 oledlg olepro32 opengl32 pdh pkpd32 rasapi32 rasdlg rassapi rpcrt4 setupapi shell32 shfolder snmpapi sporder tapi32 url user32 vdmdbg version win32spl winmm wintrust wsock32,;t t diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb index 5a67603e6..19bfc1f6d 100644 --- a/ext/dbm/extconf.rb +++ b/ext/dbm/extconf.rb @@ -33,7 +33,7 @@ def db_check(db) if have_library(db, db_prefix("dbm_open")) || have_func(db_prefix("dbm_open")) for hdr in $dbm_conf_headers.fetch(db, ["ndbm.h"]) if have_header(hdr.dup) and have_type("DBM", hdr.dup, hsearch) - $CFLAGS += " " + hsearch + '-DDBM_HDR="<'+hdr+'>"' + $defs << hsearch << '-DDBM_HDR="<'+hdr+'>"' return true end end diff --git a/ext/digest/md5/extconf.rb b/ext/digest/md5/extconf.rb index 9acf7ba9c..981924118 100644 --- a/ext/digest/md5/extconf.rb +++ b/ext/digest/md5/extconf.rb @@ -3,7 +3,8 @@ require "mkmf" -$CFLAGS << " -DHAVE_CONFIG_H -I#{File.dirname(__FILE__)}/.." +$defs << "-DHAVE_CONFIG_H" +$INCFLAGS << " -I$(srcdir)/.." $objs = [ "md5init.#{$OBJEXT}" ] diff --git a/ext/digest/rmd160/extconf.rb b/ext/digest/rmd160/extconf.rb index 5bc968385..9358dbd09 100644 --- a/ext/digest/rmd160/extconf.rb +++ b/ext/digest/rmd160/extconf.rb @@ -3,7 +3,8 @@ require "mkmf" -$CFLAGS << " -DHAVE_CONFIG_H -I#{File.dirname(__FILE__)}/.." +$defs << "-DNDEBUG" << "-DHAVE_CONFIG_H" +$INCFLAGS << " -I$(srcdir)/.." $objs = [ "rmd160init.#{$OBJEXT}" ] diff --git a/ext/digest/sha1/extconf.rb b/ext/digest/sha1/extconf.rb index c249a415e..b93ac593a 100644 --- a/ext/digest/sha1/extconf.rb +++ b/ext/digest/sha1/extconf.rb @@ -3,7 +3,8 @@ require "mkmf" -$CFLAGS << " -DHAVE_CONFIG_H -I#{File.dirname(__FILE__)}/.." +$defs << "-DHAVE_CONFIG_H" +$INCFLAGS << " -I$(srcdir)/.." $objs = [ "sha1init.#{$OBJEXT}" ] diff --git a/ext/digest/sha2/extconf.rb b/ext/digest/sha2/extconf.rb index 17fb9f2d1..7bb143e8d 100644 --- a/ext/digest/sha2/extconf.rb +++ b/ext/digest/sha2/extconf.rb @@ -3,7 +3,8 @@ require "mkmf" -$CFLAGS << " -DHAVE_CONFIG_H -I#{File.dirname(__FILE__)}/.." +$defs << "-DHAVE_CONFIG_H" +$INCFLAGS << " -I$(srcdir)/.." $objs = [ "sha2.#{$OBJEXT}", diff --git a/ext/extmk.rb b/ext/extmk.rb index d33cbd912..c88a19803 100644 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -69,6 +69,8 @@ def extract_makefile(makefile, keep = true) return false end $target = target + $extconf_h = m[/^RUBY_EXTCONF_H[ \t]*=[ \t]*(\S+)/, 1] + $static = m[/^EXTSTATIC[ \t]*=[ \t]*(\S+)/, 1] || false /^STATIC_LIB[ \t]*=[ \t]*\S+/ =~ m or $static = nil $preload = Shellwords.shellwords(m[/^preload[ \t]*=[ \t]*(.*)/, 1] || "") $DLDFLAGS += " " + (m[/^DLDFLAGS[ \t]*=[ \t]*(.*)/, 1] || "") @@ -90,6 +92,7 @@ def extmake(target) else $static = false end + $default_static = $static unless $ignore return true if $nodynamic and not $static @@ -122,10 +125,13 @@ def extmake(target) CONFIG["srcdir"] = "$(hdrdir)/ext/#{$mdir}" CONFIG["topdir"] = $topdir begin - if (!(ok &&= extract_makefile(makefile)) || + $extconf_h = nil + ok &&= extract_makefile(makefile) + if (($extconf_h && !File.exist?($extconf_h)) || !(t = modified?(makefile, MTIMES)) || %W"#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb #{$srcdir}/depend".any? {|f| modified?(f, [t])}) then + $default_static = $static ok = false init_mkmf Logging::logfile 'mkmf.log' diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 28f38140b..5ee30a222 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -30,7 +30,7 @@ if /solaris/ =~ RUBY_PLATFORM and !try_compile("") headers << "sys/feature_tests.h" end -$ipv6 = false +ipv6 = false default_ipv6 = /cygwin/ !~ RUBY_PLATFORM if enable_config("ipv6", default_ipv6) if checking_for("ipv6") {try_link(< -EOF - $ipv6type = "inria" - $CFLAGS="-DINET6 "+$CFLAGS - elsif macro_defined?("__KAME__", < -EOF - $ipv6type = "kame" - $ipv6lib="inet6" - $ipv6libdir="/usr/local/v6/lib" - $ipv6trylibc=true - $CFLAGS="-DINET6 "+$CFLAGS - elsif File.directory? "/usr/inet6" - $ipv6type = "linux" - $ipv6lib="inet6" - $ipv6libdir="/usr/inet6/lib" - $CFLAGS="-DINET6 -I/usr/inet6/include "+$CFLAGS - elsif macro_defined?("_TOSHIBA_INET6", < -EOF - $ipv6type = "toshiba" - $ipv6lib="inet6" - $ipv6libdir="/usr/local/v6/lib" - $CFLAGS="-DINET6 "+$CFLAGS - elsif macro_defined?("__V6D__", < -EOF - $ipv6type = "v6d" - $ipv6lib="v6" - $ipv6libdir="/usr/local/v6/lib" - $CFLAGS="-DINET6 -I/usr/local/v6/include "+$CFLAGS - elsif macro_defined?("_ZETA_MINAMI_INET6", < -EOF - $ipv6type = "zeta" - $ipv6lib="inet6" - $ipv6libdir="/usr/local/v6/lib" - $CFLAGS="-DINET6 "+$CFLAGS - else - $ipv6lib=with_config("ipv6-lib", nil) - $ipv6libdir=with_config("ipv6-libdir", nil) - $CFLAGS="-DINET6 "+$CFLAGS +if ipv6 + ipv6lib = nil + class << (fmt = "unknown") + def %(s) s || self end end - - if $ipv6lib - if File.directory? $ipv6libdir and File.exist? "#{$ipv6libdir}/lib#{$ipv6lib}.a" - $LOCAL_LIBS = " -L#$ipv6libdir -l#$ipv6lib" - elsif !$ipv6trylibc - print < $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 diff --git a/ruby.h b/ruby.h index 4c1cd148d..dcb38f4a7 100644 --- a/ruby.h +++ b/ruby.h @@ -22,6 +22,9 @@ extern "C" { #endif #include "config.h" +#ifdef RUBY_EXTCONF_H +#include RUBY_EXTCONF_H +#endif #include "defines.h" #ifdef HAVE_STDLIB_H diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 3974d66cc..0e1d4fedf 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -410,8 +410,8 @@ s,@LINK_SO@,$$(LDSHARED) -Fe$$(@) $$(OBJS) $$(LIBS) $$(LOCAL_LIBS) $$(DLDFLAGS), s,@LINK_SO@,$(MANIFESTTOOL) -manifest $$(@).manifest -outputresource:$$(@);2,;t t s,@LINK_SO@,@$$(RM) $$(@:/=\).manifest,;t t !endif -s,@COMPILE_C@,$$(CC) $$(CFLAGS) $$(CPPFLAGS) -c -Tc$$(<:\=/),;t t -s,@COMPILE_CXX@,$$(CXX) $$(CXXFLAGS) $$(CPPFLAGS) -c -Tp$$(<:\=/),;t t +s,@COMPILE_C@,$$(CC) $$(INCFLAGS) $$(CFLAGS) $$(CPPFLAGS) -c -Tc$$(<:\=/),;t t +s,@COMPILE_CXX@,$$(CXX) $$(INCFLAGS) $$(CXXFLAGS) $$(CPPFLAGS) -c -Tp$$(<:\=/),;t t s,@COMPILE_RULES@,{$$(srcdir)}.%s{}.%s: {$$(topdir)}.%s{}.%s: {$$(hdrdir)}.%s{}.%s: .%s.%s:,;t t s,@RULE_SUBST@,{.;$$(srcdir);$$(topdir);$$(hdrdir)}%s,;t t s,@TRY_LINK@,$$(CC) -Feconftest $$(INCFLAGS) -I$$(hdrdir) $$(CPPFLAGS) $$(CFLAGS) $$(src) $$(LOCAL_LIBS) $$(LIBS) -link $$(LDFLAGS) $$(LIBPATH) $$(XLDFLAGS),;t t diff --git a/wince/Makefile.sub b/wince/Makefile.sub index d0254f342..2cb4aba98 100644 --- a/wince/Makefile.sub +++ b/wince/Makefile.sub @@ -401,8 +401,8 @@ s,@LIBPATHFLAG@, -libpath:"%s",;t t s,@RPATHFLAG@,,;t t s,@LIBARG@,%s.lib,;t t s,@LINK_SO@,$$(LDSHARED) -Fe$$(@) $$(OBJS) $$(LIBS) $$(LOCAL_LIBS) $$(DLDFLAGS),;t t -s,@COMPILE_C@,$$(CC) $$(CFLAGS) $$(CPPFLAGS) -c -Tc$$(<:\=/),;t t -s,@COMPILE_CXX@,$$(CXX) $$(CXXFLAGS) $$(CPPFLAGS) -c -Tp$$(<:\=/),;t t +s,@COMPILE_C@,$$(CC) $$(INCFLAGS) $$(CFLAGS) $$(CPPFLAGS) -c -Tc$$(<:\=/),;t t +s,@COMPILE_CXX@,$$(CXX) $$(INCFLAGS) $$(CXXFLAGS) $$(CPPFLAGS) -c -Tp$$(<:\=/),;t t s,@COMPILE_RULES@,{$$(srcdir)}.%s{}.%s: {$$(topdir)}.%s{}.%s: {$$(hdrdir)}.%s{}.%s: .%s.%s:,;t t s,@RULE_SUBST@,{.;$$(srcdir);$$(topdir);$$(hdrdir)}%s,;t t s,@TRY_LINK@,$$(CC) -Feconftest $$(INCFLAGS) -I$$(hdrdir) $$(CPPFLAGS) $$(CFLAGS) $$(src) $$(LOCAL_LIBS) $$(LIBS) -link $$(LDFLAGS) $$(LIBPATH) $$(XLDFLAGS),;t t -- cgit