diff options
Diffstat (limited to 'ext/extmk.rb.in')
-rw-r--r-- | ext/extmk.rb.in | 76 |
1 files changed, 44 insertions, 32 deletions
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in index 78fe3070a2..e1d318d19c 100644 --- a/ext/extmk.rb.in +++ b/ext/extmk.rb.in @@ -1,5 +1,7 @@ #! /usr/local/bin/ruby +$".push 'mkmf.rb' + if ARGV[0] == 'static' $force_static = TRUE ARGV.shift @@ -21,16 +23,17 @@ $topdir = "@top_srcdir@" if $topdir !~ "^/" # get absolute path save = Dir.pwd - Dir.chdir ".." + Dir.chdir $topdir $topdir = Dir.pwd Dir.chdir save end +$dots = if "@INSTALL@" =~ /^\// then "" else "#{$topdir}/ext/" end if File.exist?("config.cache") then f = open("config.cache", "r") while f.gets case $_ - when /^lib: ([\w_]+) (yes|no)/ + when /^lib: (.+) (yes|no)/ $lib_cache[$1] = $2 when /^func: ([\w_]+) (yes|no)/ $func_cache[$1] = $2 @@ -215,6 +218,8 @@ SHELL = /bin/sh srcdir = #{$srcdir} VPATH = #{$srcdir} +hdrdir = #{$topdir} + CC = @CC@ CFLAGS = %s -I#{$topdir} %s #$CFLAGS %s @@ -233,20 +238,22 @@ libdir = @libdir@/$(RUBY_INSTALL_NAME)/@arch@ @SET_MAKE@ #### End of system configuration section. #### + " mfile.printf "LOCAL_LIBS = %s\n", $local_libs if $local_libs mfile.printf "LIBS = %s\n", $libs mfile.printf "OBJS = " if !$objs then - $objs = Dir["#{$topdir}/ext/#{target}/*.c"] - for f in $objs - f.sub!(/\.c$/, ".o") + $objs = [] + for f in Dir["#{$topdir}/ext/#{target}/*.{c,cc}"] + f = File.basename(f) + f.sub!(/\.(c|cc)$/, ".o") + $objs.push f end end mfile.printf $objs.join(" ") mfile.printf "\n" - dots = if "@INSTALL@" =~ /^\// then "" else "#{$topdir}/ext/" end mfile.printf "\ TARGET = %s.%s @@ -262,28 +269,29 @@ clean:; @rm -f *.o *.so *.sl realclean: clean ", target, - if $static then "o" else "@DLEXT@" end, dots + if $static then "o" else "@DLEXT@" end, $dots - if !$static - mfile.printf "\ + mfile.printf "\ install: +" + if !$static + mfile.printf " @test -d $(libdir) || mkdir $(libdir) $(INSTALL) $(TARGET) $(libdir)/$(TARGET) " - else - mfile.printf "\ - -install:; -" end + for rb in Dir["lib/*.rb"] + mfile.printf "\t$(INSTALL) %s @libdir@/$(RUBY_INSTALL_NAME)\n", rb + end + mfile.printf "\n" if !$static && "@DLEXT@" != "o" mfile.printf "\ $(TARGET): $(OBJS) $(LDSHARED) $(DLDFLAGS) -o $(TARGET) $(OBJS) $(LOCAL_LIBS) $(LIBS) " - elsif not File.exist?(target + ".c") + elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc") if PLATFORM == "m68k-human" mfile.printf "\ $(TARGET): $(OBJS) @@ -316,9 +324,6 @@ $(TARGET): $(OBJS) dfile.close end mfile.close - if $static - $extlist.push [$static,target] - end end def extmake(target) @@ -343,16 +348,19 @@ def extmake(target) !File.exist?("./Makefile") || older("./Makefile", "#{$topdir}/ext/@setup@") || older("./Makefile", "../extmk.rb") || - older("./Makefile", "./extconf.rb") + older("./Makefile", "#{$topdir}/ext/#{target}/extconf.rb") then $defs = [] - if File.exist?("extconf.rb") - load "extconf.rb" + if File.exist?("#{$topdir}/ext/#{target}/extconf.rb") + load "#{$topdir}/ext/#{target}/extconf.rb" else create_makefile(target); end end if File.exist?("./Makefile") + if $static + $extlist.push [$static,target] + end if $install system "make install" elsif $clean @@ -373,19 +381,22 @@ end # get static-link modules $static_ext = {} -if File.file? "#{$topdir}/ext/@setup@" - f = open("#{$topdir}/ext/@setup@") - while f.gets() - $_.chop! - sub!(/#.*$/, '') - next if /^\s*$/ - if /^option +nodynamic/ - $nodynamic = TRUE - next +for setup in ["@setup@", "#{$topdir}/ext/@setup@"] + if File.file? setup + f = open(setup) + while f.gets() + $_.chop! + sub!(/#.*$/, '') + next if /^\s*$/ + if /^option +nodynamic/ + $nodynamic = TRUE + next + end + $static_ext[$_.split[0]] = TRUE end - $static_ext[$_.split[0]] = TRUE + f.close + break end - f.close end for d in Dir["#{$topdir}/ext/*"] @@ -418,6 +429,7 @@ if $cache_mod end exit if $install or $clean +$extinit += "" if $extlist.size > 0 for s,t in $extlist f = format("%s/%s.o", s, t) |