diff options
-rw-r--r-- | bcc32/Makefile.sub | 149 | ||||
-rw-r--r-- | bcc32/configure.bat | 25 | ||||
-rw-r--r-- | bcc32/setup.mak | 109 | ||||
-rw-r--r-- | cygwin/GNUmakefile.in | 12 | ||||
-rw-r--r-- | ext/dl/extconf.rb | 39 | ||||
-rw-r--r-- | ext/extmk.rb | 545 | ||||
-rw-r--r-- | lib/mkmf.rb | 904 | ||||
-rw-r--r-- | win32/Makefile.sub | 113 | ||||
-rw-r--r-- | win32/setup.mak | 108 |
9 files changed, 877 insertions, 1127 deletions
diff --git a/bcc32/Makefile.sub b/bcc32/Makefile.sub index e13cfc5f52..d9fb077750 100644 --- a/bcc32/Makefile.sub +++ b/bcc32/Makefile.sub @@ -1,6 +1,8 @@ SHELL = $(COMSPEC) #### Start of system configuration section. #### +OS = bccwin32 +RT = $(OS) ## variables may be overridden by $(compile_dir)/Makefile !ifndef srcdir @@ -18,7 +20,7 @@ RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME:ruby=rubyw) RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME)w !endif !ifndef RUBY_SO_NAME -RUBY_SO_NAME = rubybcc +RUBY_SO_NAME = $(RT)-$(RUBY_INSTALL_NAME)17 !endif !ifndef icondirs !ifdef ICONDIRS @@ -37,16 +39,27 @@ VPATH = $(srcdir):$(srcdir)/missing !ifndef CC CC = bcc32 !endif +!ifndef CPP +CPP = cpp32 +!endif !ifndef RC RC = brcc32 !endif !ifndef YACC YACC = byacc !endif +!ifndef AR +AR = tlib +!endif + PURIFY = AUTOCONF = autoconf -!if !defined(PROCESSOR_ARCHITECTURE) || "$(PROCESSOR_ARCHITECTURE)" == "x86" +!if !defined(PROCESSOR_ARCHITECTURE) +PROCESSOR_ARCHITECTURE = x86 +!endif +MACHINE = $(PROCESSOR_ARCHITECTURE) +!if "$(PROCESSOR_ARCHITECTURE)" == "x86" !ifndef PROCESSOR_LEVEL PROCESSOR_LEVEL = 5 !endif @@ -55,7 +68,7 @@ PROCESSOR_LEVEL = 6 !endif PROCESSOR_FLAG = -$(PROCESSOR_LEVEL) CPU = i$(PROCESSOR_LEVEL)86 -ARCH = i$(PROCESSOR_LEVEL)86 +ARCH = i386 !else CPU = $(PROCESSOR_ARCHITECTURE) ARCH = $(PROCESSOR_ARCHITECTURE) @@ -66,7 +79,6 @@ DEBUGFLAGS = !ifndef OPTFLAGS OPTFLAGS = -O !endif -OS = bccwin32 !ifndef prefix prefix = /usr @@ -75,44 +87,46 @@ prefix = /usr DESTDIR = $(prefix) !endif !ifndef CFLAGS -CFLAGS = -DNT=1 $(DEBUGFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG) -w-aus -w-par -w-pro +CFLAGS = -q -DNT=1 $(DEBUGFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG) -w- !endif !ifndef CPPFLAGS CPPFLAGS = -I. -I$(srcdir) -I$(srcdir)missing -DLIBRUBY_SO=\"$(LIBRUBY_SO)\" !endif !ifndef LDFLAGS -LDFLAGS = $(CFLAGS) -!endif -!ifndef XLDFLAGS -XLDFLAGS = +LDFLAGS = -S:$(STACK) !endif !ifndef RFLAGS -RFLAGS = -r +RFLAGS = $(iconinc) !endif !ifndef EXTLIBS -EXTLIBS = # cw32.lib +EXTLIBS = !endif -LIBS = $(EXTLIBS) +LIBS = cw32.lib import32.lib ws2_32.lib $(EXTLIBS) MISSING = acosh.obj crypt.obj win32.obj !ifndef STACK STACK = 0x2000000 !endif -LDSHARED = ilink32.exe -S:$(STACK) -LINK = $(LDSHARED) -Tpe C0X32.OBJ -LINK_W = $(LDSHARED) -Tpe C0W32.OBJ -LINK_SO = $(LDSHARED) -Tpd C0D32.OBJ -LDOBJECTS = CW32.LIB IMPORT32.LIB $(MAINOBJ) +XCFLAGS = -DRUBY_EXPORT + +ARFLAGS = /a +LD = ilink32 -q -Gn +LDSHARED = $(LD) +XLDFLAGS = -Tpe c0x32.obj +WLDFLAGS = -Tpe c0w32.obj +DLDFLAGS = -Tpd c0d32.obj +LIBRUBY_LDSHARED = $(LDSHARED) +LIBRUBY_DLDFLAGS = -Gi $(DLDFLAGS) $(EXTLDFLAGS) +LDOBJECTS = $(MAINOBJ) -DLDFLAGS = SOLIBS = EXEEXT = .exe PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT) WPROGRAM=$(RUBYW_INSTALL_NAME)$(EXEEXT) RUBYDEF = $(RUBY_SO_NAME).def -MINIRUBY=miniruby$(EXEEXT) +MINIRUBY = .\miniruby$(EXEEXT) ORGLIBPATH = $(LIB) @@ -168,7 +182,7 @@ OBJS = array.obj \ all: miniruby$(EXEEXT) rbconfig.rb \ $(LIBRUBY) $(MISCLIBS) - @.\miniruby$(EXEEXT) $(srcdir)ext/extmk.rb + @.\miniruby$(EXEEXT) $(srcdir)ext/extmk.rb $(EXTSTATIC) $(MAKE) -$(MFLAGS)$(MAKEFLAGS) ruby: $(PROGRAM) rubyw: $(WPROGRAM) @@ -178,8 +192,8 @@ dll: $(LIBRUBY_SO) config: config.h config.status config.h: Makefile $(srcdir)bcc32/Makefile.sub - @echo Creating config.h - type > $@ &&| + @echo Creating $(@:.\=) + @type > $@ &&| \#define HAVE_PROTOTYPES 1 \#define HAVE_STDARG_PROTOTYPES 1 /* \#define HAVE_ATTR_NORETURN 1 */ @@ -198,7 +212,7 @@ config.h: Makefile $(srcdir)bcc32/Makefile.sub /* \#define HAVE_SYS_PARAM_H 1 */ /* \#define HAVE_SYS_WAIT_H 1 */ \#define HAVE_STRING_H 1 -/* \#define HAVE_UTIME_H 1 */ +\#define HAVE_UTIME_H 1 \#define HAVE_MEMORY_H 1 /* \#define HAVE_ST_BLKSIZE 1 */ \#define HAVE_ST_RDEV 1 @@ -262,9 +276,9 @@ config.h: Makefile $(srcdir)bcc32/Makefile.sub \#define HAVE_STRTOUL 1 | -config.status: Makefile $(srcdir)bcc32/Makefile.sub $(MINIRUBY) - @echo Creating config.status - @$(MINIRUBY) -pe "~/@CFLAGS@/||$$_.sub!(/'$(CFLAGS)'/, '$$(CFLAGS)')" > $@ &&| +config.status: Makefile $(srcdir)bcc32/Makefile.sub + @echo Creating $@ + @type > $@ &&| # Generated automatically by Makefile.sub. s,@SHELL@,$$(COMSPEC),;t t s,@CFLAGS@,$(CFLAGS),;t t @@ -272,7 +286,7 @@ s,@CPPFLAGS@,$(CPPFLAGS),;t t s,@CXXFLAGS@,$(CXXFLAGS),;t t s,@FFLAGS@,$(FFLAGS),;t t s,@LDFLAGS@,$(LDFLAGS),;t t -s,@LIBS@,,;t t +s,@LIBS@,$(LIBS),;t t s,@exec_prefix@,$${prefix},;t t s,@prefix@,,;t t s,@program_transform_name@,s,,,,;t t @@ -307,7 +321,8 @@ s,@CC@,$(CC),;t t s,@CPP@,cpp32,;t t s,@YACC@,$(YACC),;t t s,@RANLIB@,rem,;t t -s,@AR@,tlib -nologo,;t t +s,@AR@,$(AR),;t t +s,@ARFLAGS@,$(ARFLAGS),;t t s,@LN_S@,$(LN_S),;t t s,@SET_MAKE@,$(SET_MAKE),;t t s,@LIBOBJS@, acosh.obj crypt.obj win32.obj,;t t @@ -316,19 +331,22 @@ s,@DEFAULT_KCODE@,$(DEFAULT_KCODE),;t t s,@EXEEXT@,.exe,;t t s,@OBJEXT@,obj,;t t s,@XLDFLAGS@,$(XLDFLAGS),;t t -s,@DLDFLAGS@,$$(CFLAGS),;t t +s,@DLDFLAGS@,$(DLDFLAGS),;t t s,@STATIC@,$(STATIC),;t t -s,@CCDLFLAGS@,-DIMPORT,;t t -s,@LDSHARED@,ilink32 -S:$(STACK) -Tpd,;t t +s,@CCDLFLAGS@,,;t t +s,@LDSHARED@,$(LDSHARED),;t t s,@DLEXT@,so,;t t s,@DLEXT2@,dll,;t t +s,@LIBEXT@,lib,;t t s,@STRIP@,$(STRIP),;t t s,@EXTSTATIC@,$(EXTSTATIC),;t t s,@setup@,Setup,;t t s,@MINIRUBY@,$(MINIRUBY),;t t -s,@LIBRUBY_LDSHARED@,$(LIBRUBY_LDSHARED),;t t -s,@LIBRUBY_DLDFLAGS@,$(LIBRUBY_DLDFLAGS),;t t +s,@LIBRUBY_LDSHARED@,$$(LDSHARED),;t t +s,@LIBRUBY_DLDFLAGS@,-Gi $$(DLDFLAGS),;t t s,@RUBY_INSTALL_NAME@,$(RUBY_INSTALL_NAME),;t t +s,@rubyw_install_name@,$(RUBYW_INSTALL_NAME),;t t +s,@RUBYW_INSTALL_NAME@,$(RUBYW_INSTALL_NAME),;t t s,@RUBY_SO_NAME@,$(RUBY_SO_NAME),;t t s,@LIBRUBY_A@,lib$$(RUBY_INSTALL_NAME).lib,;t t s,@LIBRUBY_SO@,$$(RUBY_SO_NAME).dll,;t t @@ -340,6 +358,16 @@ s,@DLDLIBS@,$(DLDLIBS),;t t s,@ENABLE_SHARED@,yes,;t t s,@OUTFLAG@,-o,;t t s,@CPPOUTFILE@,,;t t +s,@LIBPATHFLAG@, -L%s,;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_RULES@,{$$(srcdir)}.%s{}.%s: .%s.%s:,;t t +s,@COMMON_LIBS@,m,;t t +s,@COMMON_MACROS@,WIN32_LEAN_AND_MEAN;t t +s,@COMMON_HEADERS@,winsock2.h windows.h,;t t +s,@EXPORT_PREFIX@,_,;t t s,@arch@,$(ARCH)-$(OS),;t t s,@sitearch@,$(ARCH)-$(OS),;t t s,@sitedir@,$${prefix}/lib/ruby/site_ruby,;t t @@ -349,43 +377,33 @@ s,@srcdir@,$(srcdir),;t t s,@top_srcdir@,$(srcdir),;t t | -#ext/extmk.rb: $(srcdir)ext/extmk.rb.in config.status -# @echo Creating ext/extmk.rb -# @.\miniruby$(EXEEXT) $(srcdir)ext/configsub.rb \ -# -srcdir=$(srcdir) \ -# -install_name=$(RUBY_INSTALL_NAME) \ -# -so_name=$(RUBY_SO_NAME) \ -# -output=$@ $(srcdir)ext/extmk.rb.in - -miniruby$(EXEEXT): $(OBJS) $(MAINOBJ) $(EXTOBJS) - @echo $(EXTOBJS) +miniruby$(EXEEXT): $(LIBRUBY_A) $(MAINOBJ) dmyext.obj @echo $(LIBS) - $(LINK) $(LDOBJECTS) $(EXTOBJS) $(OBJS) $(LIBS),$@ + $(LD) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) dmyext.obj,$@,nul,$(LIBRUBY_A) $(LIBS) $(PROGRAM): $(MAINOBJ) $(LIBRUBY_SO) $(RUBY_INSTALL_NAME).res - $(LINK) $(LDOBJECTS),$@,,$(LIBRUBYARG),,$(RUBY_INSTALL_NAME).res + $(LD) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ),$@,nul,$(LIBRUBYARG) $(LIBS),,$(RUBY_INSTALL_NAME).res $(WPROGRAM): $(MAINOBJ) $(WINMAINOBJ) $(LIBRUBY_SO) $(RUBYW_INSTALL_NAME).res - $(LINK_W) $(LDOBJECTS) $(WINMAINOBJ),$@,,$(LIBRUBYARG),,$(RUBYW_INSTALL_NAME).res + $(LD) $(LDFLAGS) $(WLDFLAGS) $(MAINOBJ) $(WINMAINOBJ),$@,nul,$(LIBRUBYARG) $(LIBS),,$(RUBYW_INSTALL_NAME).res -$(LIBRUBY_A): $(OBJS) dmyext.obj +$(LIBRUBY_A): $(OBJS) @-if exist $@ del $@ - tlib $@ /a @&&| -$(OBJS) dmyext.obj -| - -$(LIBRUBY): $(LIBRUBY_SO) - implib $@ $(LIBRUBY_SO) + $(AR) $(ARFLAGS)$@ $(OBJS) -$(LIBRUBY_SO): $(LIBRUBY_A) $(EXTOBJS) $(RUBYDEF) $(RUBY_SO_NAME).res - $(LINK_SO) $(LDOBJECTS) $(EXTOBJS) $(LIBS),$@,,$(LIBRUBY_A),$(RUBYDEF), $(RUBY_SO_NAME).res +# $(LIBRUBY): $(LIBRUBY_SO) +# implib $@ $(LIBRUBY_SO) +$(LIBRUBY_SO) $(LIBRUBY): $(LIBRUBY_A) dmyext.obj $(EXTOBJS) $(RUBYDEF) $(RUBY_SO_NAME).res + @echo $(EXTOBJS) + $(LIBRUBY_LDSHARED) $(LIBRUBY_DLDFLAGS) dmyext.obj,$(LIBRUBY_SO),nul,$(LIBRUBY_A) $(LIBS),$(RUBYDEF),$(RUBY_SO_NAME).res $(RUBYDEF): $(LIBRUBY_A) miniruby$(EXEEXT) - .\miniruby$(EXEEXT) $(srcdir)bcc32/mkexports.rb -output=$@ $(LIBRUBY_A) + $(MINIRUBY) $(srcdir)bcc32/mkexports.rb -output=$@ $(LIBRUBY_A) install: rbconfig.rb - .\miniruby$(EXEEXT) $(srcdir)instruby.rb $(DESTDIR) + $(MINIRUBY) $(srcdir)instruby.rb $(DESTDIR) + $(MINIRUBY) $(srcdir)ext/extmk.rb $(MAKE) -$(MFLAGS)$(MAKEFLAGS) DESTDIR=$(DESTDIR) install clean: clean-ext clean-local @@ -402,7 +420,7 @@ clean-local: @if exist *.il? del *.il? clean-ext: - @-.\miniruby$(EXEEXT) $(srcdir)ext/extmk.rb clean + @-$(MINIRUBY) $(srcdir)ext/extmk.rb $(MAKE) -$(MFLAGS)$(MAKEFLAGS) clean distclean: distclean-ext distclean-local @@ -425,7 +443,6 @@ distclean-local: clean-local @if exist *.ilk del *.ilk @if exist *.exp del *.exp @if exist $(RUBYDEF) del $(RUBYDEF) - @if exist pub.def del pub.def @if exist $(RUBY_INSTALL_NAME).rc del $(RUBY_INSTALL_NAME).rc @if exist $(RUBYW_INSTALL_NAME).rc del $(RUBYW_INSTALL_NAME).rc @if exist $(RUBY_SO_NAME).rc del $(RUBY_SO_NAME).rc @@ -437,26 +454,26 @@ distclean-local: clean-local @if exist miniruby$(EXEEXT) del miniruby$(EXEEXT) distclean-ext: - @-.\miniruby$(EXEEXT) $(srcdir)ext/extmk.rb distclean + @-$(MINIRUBY) $(srcdir)ext/extmk.rb $(MAKE) -$(MFLAGS)$(MAKEFLAGS) distclean realclean: distclean @if exist parse.c del parse.c @if exist lex.c del lex.c test: miniruby$(EXEEXT) - @.\miniruby$(EXEEXT) $(srcdir)rubytest.rb + @$(MINIRUBY) $(srcdir)rubytest.rb rbconfig.rb: miniruby$(EXEEXT) config.status - @.\miniruby$(EXEEXT) $(srcdir)mkconfig.rb -srcdir=$(srcdir) \ + @$(MINIRUBY) $(srcdir)mkconfig.rb -srcdir=$(srcdir) \ -install_name=$(RUBY_INSTALL_NAME) \ -so_name=$(RUBY_SO_NAME) rbconfig.rb $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc: rbconfig.rb - @.\miniruby$(EXEEXT) $(srcdir)win32/resource.rb \ + @$(MINIRUBY) $(srcdir)win32/resource.rb \ -ruby_name=$(RUBY_INSTALL_NAME) \ -rubyw_name=$(RUBYW_INSTALL_NAME) \ -so_name=$(RUBY_SO_NAME) \ - . $(icondirs) $(srcdir)/win32 + . $(icondirs) $(srcdir)win32 #config.status: $(srcdir)configure # $(SHELL) .config.status --recheck @@ -466,10 +483,10 @@ $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc: rbconfig.rb .path.y = $(srcdir) .c.obj: - $(CC) $(CFLAGS) -I. $(CPPFLAGS) -c $(<:/=\) + $(CC) $(CFLAGS) $(XCFLAGS) -I. $(CPPFLAGS) -c $(<:/=\) .rc.res: - $(RC) -I. -I$(<D) $(iconinc) -I$(srcdir)win32 $(RFLAGS) -fo$@ $(<:/=\) + $(RC) $(RFLAGS) -I. -I$(<D) $(iconinc) -I$(srcdir)win32 $(RFLAGS) -fo$@ $(<:/=\) .y.c: $(YACC) $(YFLAGS) $(<:\=/) diff --git a/bcc32/configure.bat b/bcc32/configure.bat index 65b53a2978..deb18d3ef4 100644 --- a/bcc32/configure.bat +++ b/bcc32/configure.bat @@ -6,6 +6,27 @@ echo> ~tmp~.mak ####
echo>> ~tmp~.mak conf = %0
echo>> ~tmp~.mak $(conf:\=/): nul
-echo>> ~tmp~.mak @del ~tmp~.mak
-echo>> ~tmp~.mak make -Dbcc32dir="$(@D)" -f$(@D)/setup.mak %1
+echo>> ~tmp~.mak @del ~tmp~.mak
+echo>> ~tmp~.mak @-$(MAKE) -l$(MAKEFLAGS) -f $(@D)setup.mak \
+:loop
+if "%1" == "" goto :end
+if "%1" == "--srcdir" goto :srcdir
+if "%1" == "srcdir" goto :srcdir
+if "%1" == "--target" goto :target
+if "%1" == "target" goto :target
+ echo>> ~tmp~.mak "%1" \
+ shift
+goto :loop
+:srcdir
+ echo>> ~tmp~.mak "srcdir=%2" \
+ shift
+ shift
+goto :loop
+:target
+ echo>> ~tmp~.mak "%2" \
+ shift
+ shift
+goto :loop
+:end
+echo>> ~tmp~.mak bcc32dir="$(@D)"
make -s -f ~tmp~.mak
diff --git a/bcc32/setup.mak b/bcc32/setup.mak index 6017ecc3cf..27cf91164a 100644 --- a/bcc32/setup.mak +++ b/bcc32/setup.mak @@ -1,50 +1,81 @@ # -*- makefile -*- -!if "$(bcc32dir)" == "bcc32/" +!if "$(srcdir)" != "" +bcc32dir = $(srcdir)bcc32/ +!elseif "$(bcc32dir)" == "bcc32/" srcdir = ./ -!elseif "$(bcc32dir)" == "../bcc32/" -srcdir = ../ +!elseif "$(bcc32dir:/bcc32/=)/bcc32/" == "$(bcc32dir)" +srcdir = $(bcc32dir:/bcc32/=/) !else srcdir = $(bcc32dir)../ !endif OS = bccwin32 +RT = $(OS) +INCLUDE = !include +APPEND = echo>>$(MAKEFILE) +!ifdef MAKEFILE +MAKE = $(MAKE) -f $(MAKEFILE) +!else +MAKEFILE = Makefile +!endif -all: ext makefile - -makefile: make_s make_e - -make_s: - @if exist makefile @del makefile - @echo ### makefile for ruby $(OS) ###> makefile - @echo srcdir = $(srcdir:\=/)>> makefile - @echo RUBY_INSTALL_NAME = ruby>> makefile - @echo RUBY_SO_NAME = $(OS)_$$(RUBY_INSTALL_NAME)17>> makefile - -make_e: - @echo !INCLUDE $$(srcdir)bcc32/makefile.sub>> makefile - @echo type `make' to make ruby for bccwin32. - -ext: - @if not exist $@\* mkdir $@ - -pl3: - @echo PROCESSOR_LEVEL = 3 >> makefile - -pl4: - @echo PROCESSOR_LEVEL = 4 >> makefile - -pl5: - @echo PROCESSOR_LEVEL = 5 >> makefile - -pl6: - @echo PROCESSOR_LEVEL = 6 >> makefile - -3: ext make_s pl3 make_e - -4: ext make_s pl4 make_e - -5: ext make_s pl5 make_e +all: Makefile +Makefile: -prologue- -generic- -epilogue- +i386-$(OS): -prologue- -i386- -epilogue- +i486-$(OS): -prologue- -i486- -epilogue- +i586-$(OS): -prologue- -i586- -epilogue- +i686-$(OS): -prologue- -i686- -epilogue- +alpha-$(OS): -prologue- -alpha- -epilogue- + +-prologue-: nul + @echo Creating $(MAKEFILE) + @type > $(MAKEFILE) &&| +\#\#\# Makefile for ruby $(OS) \#\#\# +srcdir = $(srcdir:\=/) +| + +-generic-: nul +!if defined(PROCESSOR_ARCHITECTURE) || defined(PROCESSOR_LEVEL) + @type >> $(MAKEFILE) &&| +!if defined(PROCESSOR_ARCHITECTURE) + @$(APPEND) PROCESSOR_ARCHITECTURE = $(PROCESSOR_ARCHITECTURE) +!endif +!if defined(PROCESSOR_LEVEL) + @$(APPEND) PROCESSOR_LEVEL = $(PROCESSOR_LEVEL) +!endif -6: ext make_s pl6 make_e +| +!endif +-alpha-: nul + @$(APPEND) PROCESSOR_ARCHITECTURE = alpha +-ix86-: nul + @$(APPEND) PROCESSOR_ARCHITECTURE = x86 + +-i386-: -ix86- + @$(APPEND) PROCESSOR_LEVEL = 3 +-i486-: -ix86- + @$(APPEND) PROCESSOR_LEVEL = 4 +-i586-: -ix86- + @$(APPEND) PROCESSOR_LEVEL = 5 +-i686-: -ix86- + @$(APPEND) PROCESSOR_LEVEL = 6 + +-epilogue-: nul + @type >> $(MAKEFILE) &&| + +\# OS = $(OS) +\# RT = $(RT) +\# RUBY_INSTALL_NAME = ruby +\# RUBY_SO_NAME = $$(RT)-$$(RUBY_INSTALL_NAME)17 +\# prefix = /usr +\# CFLAGS = -q $$(DEBUGFLAGS) $$(OPTFLAGS) $$(PROCESSOR_FLAG) -w- +\# CPPFLAGS = -I. -I$$(srcdir) -I$$(srcdir)missing -DLIBRUBY_SO=\"$$(LIBRUBY_SO)\" +\# STACK = 0x2000000 +\# LDFLAGS = -S:$$(STACK) +\# RFLAGS = $$(iconinc) +\# EXTLIBS = cw32.lib import32.lib user32.lib kernel32.lib +$(INCLUDE) $$(srcdir)bcc32/Makefile.sub +| + @echo type "`$(MAKE)'" to make ruby for $(OS). diff --git a/cygwin/GNUmakefile.in b/cygwin/GNUmakefile.in index b9a436544c..af79698963 100644 --- a/cygwin/GNUmakefile.in +++ b/cygwin/GNUmakefile.in @@ -27,7 +27,7 @@ $(LIBRUBY): $(LIBRUBY_SO) @WINDRES@ --include-dir . --include-dir $(<D) --include-dir $(srcdir)/win32 $< $@ $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc: rbconfig.rb - @@MINIRUBY@ $(srcdir)/win32/resource.rb \ + @$(MINIRUBY) $(srcdir)/win32/resource.rb \ -ruby_name=$(RUBY_INSTALL_NAME) -rubyw_name=$(RUBYW_INSTALL_NAME) \ -so_name=$(RUBY_SO_NAME) \ . $(icondirs) $(srcdir)/win32 @@ -40,9 +40,15 @@ $(WPROGRAM): $(RUBYW_INSTALL_NAME).res.@OBJEXT@ $(RUBYDEF): $(LIBRUBY_A) echo EXPORTS > $(RUBYDEF) - @NM@ --extern-only --defined-only $(LIBRUBY_A) | \ - @MINIRUBY@ -ne 'puts $$1 if / [CDT] _(.*)$$/' >> $(RUBYDEF) + @NM@ --extern-only --defined-only $(LIBRUBY_A) | sed -n 's/.* [CDT] _//p' >> $(RUBYDEF) + $(RUBY_EXP): $(RUBYDEF) @DLLWRAP@ --output-exp=$(RUBY_EXP) --output-lib=$(LIBRUBY) \ --def=$(RUBYDEF) $(LIBRUBY_A) $(LIBS) -o $(PROGRAM) rm $(PROGRAM) + +GNUmakefile: $(srcdir)/cygwin/GNUmakefile.in + +ifeq (@target_os@,mingw32) +$(OBJS) $(MAINOBJ): win32/win32.h +endif diff --git a/ext/dl/extconf.rb b/ext/dl/extconf.rb index 46b3c6c87d..dd9c3844e4 100644 --- a/ext/dl/extconf.rb +++ b/ext/dl/extconf.rb @@ -33,19 +33,25 @@ else end $with_dlstack = ! $with_asm -$with_type_int = try_run(<<EOF) -int main(){ return sizeof(int) == sizeof(long); } +$with_type_int = try_cpp(<<EOF) +#include "config.h" +#if SIZEOF_INT == SIZEOF_LONG +#error int not needed +#endif EOF -$with_type_float = try_run(<<EOF) -int main(){ return sizeof(float) == sizeof(double); } +$with_type_float = try_cpp(<<EOF) +#include "config.h" +#if SIZEOF_FLOAT == SIZEOF_DOUBLE +#error float not needed +#endif EOF -$with_type_voidp = try_run(<<EOF) -int main(){ - return (sizeof(void *) == sizeof(long)) - || (sizeof(void *) == sizeof(int)); -} +$with_type_voidp = try_cpp(<<EOF) +#include "config.h" +#if SIZEOF_VOIDP == SIZEOF_INT || SIZEOF_VOIDP == SIZEOF_LONG +#error void* not needed +#endif EOF $with_type_char = DLTYPE[CHAR][:sym] @@ -176,21 +182,6 @@ $INSTALLFILES = [ ["dl.h", "$(archdir)$(target_prefix)", ""], ] -if /bccwin32/ =~ RUBY_PLATFORM - srcdir = $top_srcdir + "/ext/dl/" - if !FileTest.exist?( srcdir+"dl.def.org" ) - File.copy( srcdir+"dl.def", srcdir+"dl.def.org" ) - open( srcdir+"dl.def.org" ){ |f| - open( "dl.def", "w" ) { |g| - g.print f.gets - while line = f.gets - g.print "_", line - end - } - } - end -end - create_makefile('dl') rescue SystemExit # do nothing diff --git a/ext/extmk.rb b/ext/extmk.rb index 50b2890a22..ebe562c7d4 100644 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -1,4 +1,4 @@ -#! /usr/local/bin/ruby +#! /usr/local/bin/ruby -s # -*- ruby -*- $force_static = nil @@ -9,24 +9,6 @@ $nodynamic = nil $extinit = nil $extobjs = nil -if ARGV[0] == 'static' - $force_static = true - ARGV.shift -elsif ARGV[0] == 'install' - $install = true - $destdir = ARGV[1] || '' - ARGV.shift -elsif ARGV[0] == 'clean' - $clean = "clean" - ARGV.shift -elsif ARGV[0] == 'distclean' - $clean = "distclean" - ARGV.shift -elsif ARGV[0] == 'realclean' - $clean = "realclean" - ARGV.shift -end - $extlist = [] $:.replace ["."] @@ -37,350 +19,27 @@ srcdir = Config::CONFIG["srcdir"] $:.replace [srcdir, srcdir+"/lib", "."] require 'mkmf' -require 'find' require 'ftools' require 'shellwords' $topdir = File.expand_path(".") $top_srcdir = srcdir - -# avoid warning for $VERBOSE mode -Object.class_eval do remove_method :create_makefile end - -def create_makefile(target) - $target = target - if target.include?('/') - target_prefix, target = File.split(target) - target_prefix[0,0] = '/' - else - target_prefix = "" - end - rm_f "conftest*" - if CONFIG["DLEXT"] == $OBJEXT - libs = $libs.split - for lib in libs - lib.sub!(/-l(.*)/, %%"lib\\1.#{$LIBEXT}"%) - end - $defs.push(format("-DEXTLIB='%s'", libs.join(","))) - end - - $DLDFLAGS = CONFIG["DLDFLAGS"].dup - if /linux/ =~ RUBY_PLATFORM and $configure_args['--enable-shared'] and CONFIG["GNU_LD"] == "yes" - $DLDFLAGS << " -Wl,-no-undefined" - end - - if $configure_args['--enable-shared'] or CONFIG["LIBRUBY"] != CONFIG["LIBRUBY_A"] - $libs = CONFIG["LIBRUBYARG"] + " " + $libs - $LIBPATH.unshift $topdir - end - - defflag = '' - if RUBY_PLATFORM =~ /cygwin|mingw/ and not $static - if not File.exist? target + '.def' - open(target + '.def', 'wb') do |f| - f.print "EXPORTS\n", "Init_", target, "\n" - end - end - defflag = target + ".def" - elsif RUBY_PLATFORM =~ /bccwin32/ - deffile = target + '.def' - if not File.exist? target + '.def' - open(deffile, 'wb') do |f| - f.print "EXPORTS\n", "_Init_", target, "\n" - end - end - end - - if RUBY_PLATFORM =~ /mswin32|bccwin32/ - libpath = $LIBPATH.join(';') - else - $LIBPATH.each {|d| $DLDFLAGS << " -L" << d} - if /netbsdelf/ =~ RUBY_PLATFORM - $LIBPATH.each {|d| $DLDFLAGS << " -Wl,-R" + d unless d == $topdir} - end - end - - $srcdir = File.join($top_srcdir,"ext",$mdir) - mfile = open("Makefile", "w") - mfile.binmode if /mingw/ =~ RUBY_PLATFORM - mfile.printf <<EOL, if $static then "" else CONFIG["CCDLFLAGS"] end, $defs.join(" ") -SHELL = /bin/sh - -#### Start of system configuration section. #### - -srcdir = #{$srcdir} -VPATH = #{$srcdir} - -topdir = #{$topdir} -hdrdir = #{$top_srcdir} - -CC = #{CONFIG['CC']} - -CFLAGS = %s #{CFLAGS} #$CFLAGS -CPPFLAGS = -I$(topdir) -I$(hdrdir) %s #$CPPFLAGS -#{ -if /bccwin32/ =~ RUBY_PLATFORM - "DLDFLAGS = #$LDFLAGS -L" + '"$(libdir:/=\\);$(topdir:/=\\)"' + "\n" + - "LDSHARED = #{CONFIG['LDSHARED']}\n" -else - "DLDFLAGS = #$DLDFLAGS #$LDFLAGS\n" + - "LDSHARED = #{CONFIG['LDSHARED']} #{defflag}\n" -end -} -EOL - mfile.puts "LIBPATH = #{libpath}" if libpath - - mfile.puts ".SUFFIXES: .#{CONFIG['OBJEXT']}" unless #{CONFIG['OBJEXT']} == "o" - - mfile.printf "\ - -RUBY_INSTALL_NAME = #{CONFIG['RUBY_INSTALL_NAME']} -RUBY_SO_NAME = #{CONFIG['RUBY_SO_NAME']} -ruby_version = #{Config::CONFIG["ruby_version"]} - -prefix = #{CONFIG['prefix']} -exec_prefix = #{CONFIG['exec_prefix']} -libdir = #{CONFIG['libdir']} -rubylibdir = $(libdir)/ruby/$(ruby_version) -#pkglibdir = $(libdir)/$(RUBY_INSTALL_NAME)/#{CONFIG['MAJOR']}.#{CONFIG['MINOR']} -pkglibdir = $(libdir)/ruby/#{CONFIG['MAJOR']}.#{CONFIG['MINOR']} -archdir = $(pkglibdir)/#{CONFIG['arch']} -target_prefix = #{target_prefix} -#{CONFIG['SET_MAKE']} - -#### End of system configuration section. #### - -" - mfile.printf "LOCAL_LIBS = %s %s\n", $LOCAL_LIBS, $local_flags - if /bccwin32/ =~ RUBY_PLATFORM - mfile.printf "LIBS = $(topdir:/=\\)\\%s\n", $libs - else - mfile.printf "LIBS = %s\n", $libs - end - mfile.printf "OBJS = " - if !$objs then - $objs = [] - for f in Dir["#{$top_srcdir}/ext/#{$mdir}/*.{#{SRC_EXT.join(%q{,})}}"] - f = File.basename(f) - f.sub!(/(#{SRC_EXT.join(%q{|})})$/, $OBJEXT) - $objs.push f - end - else - for i in $objs - i.sub!(/\.o\z/, ".#{$OBJEXT}") - end - end - mfile.printf $objs.join(" ") - mfile.printf "\n" - - if /bccwin32/ =~ RUBY_PLATFORM - ruby_interpreter = '$(topdir:/=\)/miniruby' + CONFIG['EXEEXT'] - else - ruby_interpreter = "$(topdir)/miniruby" + CONFIG['EXEEXT'] - if /nmake/i =~ $make - ruby_interpreter = '$(topdir:/=\)\miniruby' + CONFIG['EXEEXT'] - end - end - if defined? CROSS_COMPILING - ruby_interpreter = CONFIG['MINIRUBY'] - end - - mfile.printf <<EOS -TARGET = #{target} -DLLIB = $(TARGET).#{$static ? $LIBEXT : CONFIG['DLEXT']} - -RUBY = #{ruby_interpreter} -I$(topdir) -I$(hdrdir)/lib -RM = $(RUBY) -rftools -e "File::rm_f(*ARGV.map do|x|Dir[x]end.flatten.uniq)" -MAKEDIRS = $(RUBY) -r ftools -e 'File::makedirs(*ARGV)' -INSTALL_PROG = $(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)' -INSTALL_DATA = $(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0644, true)' - -EXEEXT = CONFIG['EXEEXT'] - -all: $(DLLIB) - -clean: - @$(RM) *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB) -#{ -if /bccwin32/ =~ RUBY_PLATFORM - " @$(RM) *.def *.ilc *.ild *.ilf *.ils *.map *.tds *.bak $(CLEANFILES)\n" + - " @if exist $(target).def.org ren $(target).def.org $(target).def" -else - " @$(RM) *.ilk *.exp *.pdb *.bak $(CLEANFILES)" -end -} - -distclean: clean - @$(RM) Makefile extconf.h conftest.* - @$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) - -realclean: distclean -EOS - - mfile.printf <<EOS - -install: - @$(MAKEDIRS) $(DESTDIR)$(libdir) $(DESTDIR)$(pkglibdir) $(DESTDIR)$(archdir)$(target_prefix) -EOS - unless $static - mfile.printf "\ - @$(INSTALL_PROG) $(DLLIB) $(DESTDIR)$(archdir)$(target_prefix)/$(DLLIB) -" - end - save_srcdir = Config::CONFIG['srcdir'] - Config::CONFIG['srcdir'] = $srcdir - install_rb(mfile, '$(DESTDIR)$(rubylibdir)$(target_prefix)', '$(srcdir)') - Config::CONFIG['srcdir'] = save_srcdir - mfile.printf "\n" - - unless /mswin32/ =~ RUBY_PLATFORM - if /bccwin32/ =~ RUBY_PLATFORM - src = '$(<:\\=/)' - else - src = '$<' - end - copt = cxxopt = '' - else - if /nmake/i =~ $make - src = '$(<:\\=/)' - else - src = '$(subst /,\\\\,$<)' - end - copt = '-Tc' - cxxopt = '-Tp' - end - unless /nmake/i =~ $make - if /bccwin32/ =~ RUBY_PLATFORM - mfile.print " -{$(srcdir)}.cc{}.#{CONFIG['OBJEXT']}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -{$(srcdir)}.cpp{}.#{CONFIG['OBJEXT']}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -{$(srcdir)}.cxx{}.#{CONFIG['OBJEXT']}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -{$(srcdir)}.c{}.#{CONFIG['OBJEXT']}: - $(CC) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src} -" - end - mfile.puts " -.cc.#{CONFIG['OBJEXT']}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.cpp.#{CONFIG['OBJEXT']}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.cxx.#{CONFIG['OBJEXT']}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.C.#{CONFIG['OBJEXT']}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.c.#{CONFIG['OBJEXT']}: - $(CC) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src} -" - else - mfile.print " -{$(srcdir)}.c{}.#{CONFIG['OBJEXT']}: - $(CC) -I. -I$(<D) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src} -.c.#{CONFIG['OBJEXT']}: - $(CC) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src} -{$(srcdir)}.cc{}.#{CONFIG['OBJEXT']}: - $(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.cc.#{CONFIG['OBJEXT']}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -{$(srcdir)}.cpp{}.#{CONFIG['OBJEXT']}: - $(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.cpp.#{CONFIG['OBJEXT']}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -{$(srcdir)}.cxx{}.#{CONFIG['OBJEXT']}: - $(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.cxx.#{CONFIG['OBJEXT']}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -" - end - - if $static - if CONFIG['AR'] =~ /^lib\b/i - mfile.printf "\ -$(DLLIB): $(OBJS) - #{CONFIG['AR']} /OUT:$(DLLIB) $(OBJS) -" - else - mfile.printf "\ -$(DLLIB): $(OBJS) - #{CONFIG['AR']} cru $(DLLIB) $(OBJS) - @-#{CONFIG['RANLIB']} $(DLLIB) 2> /dev/null || true -" - end - elsif CONFIG['DLEXT'] != $OBJEXT - mfile.print "$(DLLIB): $(OBJS)\n" - if /bccwin32/ =~ RUBY_PLATFORM - mfile.print "\t$(LDSHARED) $(DLDFLAGS) C0D32.OBJ $(OBJS), $@,, CW32.LIB IMPORT32.LIB WS2_32.LIB $(LIBS), #{deffile}\n" - else - if /mswin32/ =~ RUBY_PLATFORM - if /nmake/i =~ $make - mfile.print "\tset LIB=$(LIBPATH:/=\\);$(LIB)\n" - else - mfile.print "\tenv LIB='$(subst /,\\\\,$(LIBPATH));$(LIB)' \\\n" - end - end - mfile.print "\t$(LDSHARED) $(DLDFLAGS) #{OUTFLAG}$(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n" - end - elsif RUBY_PLATFORM == "m68k-human" - mfile.printf "\ -$(DLLIB): $(OBJS) - ar cru $(DLLIB) $(OBJS) -" - else - mfile.printf "\ -$(DLLIB): $(OBJS) - ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS) -" - end - - if File.exist?("#{$srcdir}/depend") - dfile = open("#{$srcdir}/depend", "r") - mfile.printf "###\n" - while line = dfile.gets() - line.gsub!(/\.o\b/, ".#{$OBJEXT}") - if /bccwin32/ =~ RUBY_PLATFORM - line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') - else - line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') if /nmake/i =~ $make - end - mfile.printf "%s", line.gsub(/\$\(hdrdir\)\/config.h/, '$(topdir)/config.h') - end - dfile.close - end - mfile.close -end +$hdrdir = $top_srcdir def extmake(target) + print "#{$message} #{target}\n" + $stdout.flush if $force_static or $static_ext[target] $static = target else $static = false end - unless $install or $clean + unless $ignore return if $nodynamic and not $static end - $OBJEXT = CONFIG['OBJEXT'] - $LIBEXT = "a" - $objs = nil - $libs = CONFIG['DLDLIBS'].dup - $local_flags = "" - if /mswin32/ =~ RUBY_PLATFORM - $LIBEXT = "lib" - $local_flags = "-link /INCREMENTAL:no /EXPORT:Init_$(TARGET)" - elsif /bccwin32/ =~ RUBY_PLATFORM - $LIBEXT = "lib" - end - $LOCAL_LIBS = "" # to be assigned in extconf.rb - $CFLAGS = "" - $CPPFLAGS = CONFIG['CPPFLAGS'] - $LDFLAGS = "" - $LIBPATH = [$libdir] - $INCFLAGS = "-I#{$topdir}" - - dir_config("opt") + init_mkmf begin dir = Dir.pwd @@ -388,164 +47,176 @@ def extmake(target) Dir.chdir target $target = target $mdir = target - unless $install or $clean - if $static_ext.size > 0 || - !File.exist?("./Makefile") || - older("./Makefile", $setup) || - older("./Makefile", "#{$top_srcdir}/ext/extmk.rb") || - older("./Makefile", "#{$top_srcdir}/ext/#{target}/makefile.rb") || - older("./Makefile", "#{$top_srcdir}/ext/#{target}/extconf.rb") + $srcdir = File.join($top_srcdir, "ext", $mdir) + unless $ignore + if $static || + older("./Makefile", *MTIMES + %w"#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb") then $defs = [] Logging::logfile 'mkmf.log' - if File.exist?("#{$top_srcdir}/ext/#{target}/makefile.rb") - load "#{$top_srcdir}/ext/#{target}/makefile.rb" - elsif File.exist?("#{$top_srcdir}/ext/#{target}/extconf.rb") - load "#{$top_srcdir}/ext/#{target}/extconf.rb" + Config::CONFIG["srcdir"] = $srcdir + if File.exist?("#{$srcdir}/makefile.rb") + load "#{$srcdir}/makefile.rb" + elsif File.exist?("#{$srcdir}/extconf.rb") + load "#{$srcdir}/extconf.rb" else create_makefile(target) end + Config::CONFIG["srcdir"] = $top_srcdir end end if File.exist?("./Makefile") if $static - $extlist.push [$static, $target, File.basename($target)] + $extlist.push [$static, $target, File.basename($target)] end - if $install - if /bccwin32/ =~ RUBY_PLATFORM - system "#{$make} -DDESTDIR=#{$destdir} install" - else - system "#{$make} install DESTDIR=#{$destdir}" - end - elsif $clean - system "#{$make} #{$clean}" - else - unless system "#{$make} all" - if ENV["MAKEFLAGS"] != "k" and ENV["MFLAGS"] != "-k" - exit - end - end + unless system *ARGV + $ignore or $continue or exit(1) end + else + open("./Makefile", "w") {|f| + f.print configuration($srcdir), makerules(nil) + } end if $static + $extflags ||= "" $extlibs ||= "" - $extlibs += " " + $DLDFLAGS if $DLDFLAGS - $extlibs += " " + $LDFLAGS unless $LDFLAGS == "" + $extflags += " " + $DLDFLAGS if $DLDFLAGS + $extflags += " " + $LDFLAGS unless $LDFLAGS == "" $extlibs += " " + $libs unless $libs == "" $extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == "" end + rescue SystemExit + # ignore ensure rm_f "conftest*" Dir.chdir dir end end -$make = ENV["MAKE"] -$make ||= with_config("make-prog", "make") +if ARGV[0] == "static" + ARGV.shift + $force_static = true +end + +$make = ARGV[0] if ARGV[0] +ARGV << $make if ARGV.empty? and $make +if mflags = ENV["MAKEFLAGS"] + mflags, = mflags.split(nil, 2) +else + mflags = ENV["MFLAGS"] || "" +end +$continue = mflags.include?(?k) +$dryrun = mflags.include?(?n) + +unless $message + if ARGV.size > 1 and /^[a-z]+$/ =~ ($message = ARGV[-1]) + $message = $message.sub(/^(?:dist|real)(?=(?:clean)?$)/, '\1') + case $message + when "clean" + $ignore ||= true + when "install" + $ignore ||= true + ARGV[1, 0] = ["INSTALL_PROG=install -m 0755", "INSTALL_DATA=install -m 0644"] if $dryrun + end + $message.sub!(/e?$/, "ing") + else + $message = "compiling" + end +end + +EXEEXT = CONFIG['EXEEXT'] +if defined? CROSS_COMPILING + $ruby = CONFIG['MINIRUBY'] +elsif $nmake + $ruby = '$(topdir:/=\\)\\miniruby' + EXEEXT +else + $ruby = '$(topdir)/miniruby' + EXEEXT +end +$ruby << " -I$(topdir) -I$(hdrdir)/lib" +$config_h = '$(topdir)/config.h' -File::makedirs('ext') -Dir::chdir('ext') +MTIMES = [File.mtime(__FILE__)] # get static-link modules $static_ext = {} -for setup in [CONFIG['setup'], File::join($top_srcdir, "ext", CONFIG['setup'])] +for dir in ["ext", File::join($top_srcdir, "ext")] + setup = File::join(dir, CONFIG['setup']) if File.file? setup f = open(setup) while line = f.gets() line.chomp! line.sub!(/#.*$/, '') next if /^\s*$/ =~ line - if /^option +nodynamic/ =~ line - $nodynamic = true + target, opt = line.split(nil, 3) + if target == 'option' + case opt + when 'nodynamic' + $nodynamic = true + end next end - target = line.split[0] target = target.downcase if /mswin32|bccwin32/ =~ RUBY_PLATFORM $static_ext[target] = true end + MTIMES << f.mtime $setup = setup f.close break end end +File::makedirs('ext') +Dir::chdir('ext') + ext_prefix = "#{$top_srcdir}/ext" -for d in Dir["#{ext_prefix}/**/*"] - File.directory?(d) || next - File.file?(d + "/MANIFEST") || next - +Dir.glob("#{ext_prefix}/**/MANIFEST") do |d| + d = File.dirname(d) d.slice!(0, ext_prefix.length + 1) - if $install - print "installing ", d, "\n" - elsif $clean - print "cleaning ", d, "\n" - else - print "compiling ", d, "\n" - if RUBY_PLATFORM =~ /-aix/ and older("../ruby.imp", "../miniruby") - load "#{$top_srcdir}/ext/aix_mksym.rb" - end - end - $stdout.flush extmake(d) end -if $install or $clean +if $ignore Dir.chdir ".." exit end -$extinit = "" unless $extinit - -ruby = CONFIG["RUBY_INSTALL_NAME"] + CONFIG["EXEEXT"] -miniruby = "miniruby" + CONFIG["EXEEXT"] -$extobjs = "" unless $extobjs if $extlist.size > 0 + $extinit ||= "" + $extobjs ||= "" for s,t,i in $extlist f = format("%s/%s.%s", s, i, $LIBEXT) if File.exist?(f) - $extinit += format("\ -\tInit_%s();\n\ -\trb_provide(\"%s.so\");\n\ -", i, t) - $extobjs += "ext/" - $extobjs += f - $extobjs += " " - else - false + $extinit += "\tInit_#{i}();\n\trb_provide(\"#{t}.so\");\n" + $extobjs += "ext/#{f} " end end - if older("extinit.c", $setup) || older("extinit.c", "#{$top_srcdir}/ext/extmk.rb") - f = open("extinit.c", "w") - f.printf "void Init_ext() {\n" - f.printf $extinit - f.printf "}\n" - f.close - end - if older("extinit.#{$OBJEXT}", "extinit.c") - cmd = CONFIG["CC"] + " " + CFLAGS + " -c extinit.c" - print cmd, "\n" - system cmd or exit 1 - end - - Dir.chdir ".." - - if older(ruby, $setup) or older(ruby, miniruby) - rm_f ruby + src = "void Init_ext() {\n#$extinit}\n" + if older("extinit.c", *MTIMES) || IO.read("extinit.c") != src + open("extinit.c", "w") {|f| f.print src} end $extobjs = "ext/extinit.#{$OBJEXT} " + $extobjs if RUBY_PLATFORM =~ /m68k-human|beos/ $extlibs.gsub!("-L/usr/local/lib", "") if $extlibs end - system format(%[#{$make} #{ruby} EXTOBJS='%s' EXTLIBS='%s'], $extobjs, $extlibs) -else - Dir.chdir ".." - if older(ruby, miniruby) - rm_f ruby - system("#{$make} #{ruby}") - end + conf = ['SETUP='+$setup, 'EXTOBJS='+$extobjs.strip] + conf << 'EXTLIBS='+$extlibs.strip if $extlibs + conf << 'EXTLDFLAGS='+$extflags.strip if $extflags + puts conf + ARGV.concat(conf) end +rubies = [] +%w[RUBY RUBYW].each {|r| + r = CONFIG[r+"_INSTALL_NAME"] and !r.empty? and rubies << r+EXEEXT +} + +Dir.chdir ".." +puts "making #{rubies.join(', ')}" +ARGV.concat(rubies) +host = (defined?(CROSS_COMPILING) ? CROSS_COMPILING : RUBY_PLATFORM) +/mswin|bccwin|mingw|djgpp|human|os2|macos/ =~ host or exec(*ARGV) +system(*ARGV.quote) or exit($?.exitstatus) #Local variables: # mode: ruby diff --git a/lib/mkmf.rb b/lib/mkmf.rb index f27a7faf2f..dab92c084c 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -2,7 +2,6 @@ # invoke like: ruby -r mkmf extconf.rb require 'rbconfig' -require 'find' require 'shellwords' CONFIG = Config::MAKEFILE_CONFIG @@ -50,23 +49,25 @@ $mingw = /mingw/ =~ RUBY_PLATFORM $cygwin = /cygwin/ =~ RUBY_PLATFORM $human = /human/ =~ RUBY_PLATFORM $netbsd = /netbsd/ =~ RUBY_PLATFORM +$os2 = /os2/ =~ RUBY_PLATFORM def dir_re(dir) Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$\(target_prefix\)|\{target_prefix\})?') end -commondir = dir_re('commondir') INSTALL_DIRS = [ - [commondir, "$(rubylibdir)"], - [dir_re('sitelibdir'), "$(rubylibdir)$(target_prefix)"], - [dir_re('sitearchdir'), "$(archdir)$(target_prefix)"] + [dir_re('commondir'), "$(RUBYCOMMONDIR)"], + [dir_re("sitedir"), "$(RUBYCOMMONDIR)"], + [dir_re('rubylibdir'), "$(RUBYLIBDIR)"], + [dir_re('archdir'), "$(RUBYARCHDIR)"], + [dir_re('sitelibdir'), "$(RUBYLIBDIR)"], + [dir_re('sitearchdir'), "$(RUBYARCHDIR)"] ] -SITEINSTALL_DIRS = [ - [commondir, "$(sitedir)$(target_prefix)"], - [dir_re('rubylibdir'), "$(sitelibdir)$(target_prefix)"], - [dir_re('archdir'), "$(sitearchdir)$(target_prefix)"] -] +def map_dir(dir, map = nil) + map ||= INSTALL_DIRS + map.inject(dir) {|dir, (orig, new)| dir.gsub(orig, new)} +end if not $extmk and File.exist? Config::CONFIG["archdir"] + "/ruby.h" $hdrdir = $archdir @@ -78,21 +79,24 @@ else end $topdir = $hdrdir -CFLAGS = CONFIG["CFLAGS"] -if $human - CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '') -elsif RUBY_PLATFORM =~ /-nextstep|-rhapsody|-darwin/ - CFLAGS.gsub!( /-arch\s\w*/, '' ) -end - OUTFLAG = CONFIG['OUTFLAG'] CPPOUTFILE = CONFIG['CPPOUTFILE'] -LIBPATHFLAG = $mswin ? ' -libpath:' : ' -L' CONFTEST_C = "conftest.c" $INSTALLFILES ||= nil +class String + def quote + /\s/ =~ self ? "\"#{self}\"" : self + end +end +class Array + def quote + map {|s| s.quote} + end +end + def rm_f(*files) targets = [] for file in files @@ -104,17 +108,17 @@ def rm_f(*files) end end -def older(file1, file2) - if !File.exist?(file1) then - return true - end - if !File.exist?(file2) then - return false +def older(target, *files) + mtime = proc do |f| + break f if Time === f + break f.mtime if f.respond_to?(:mtime) + File.mtime(f) rescue nil end - if File.mtime(file1) < File.mtime(file2) - return true + t = mtime[target] or return true + for f in files + return true if t < (mtime[f] or next) end - return false + false end module Logging @@ -150,8 +154,9 @@ end def xsystem command Config.expand(command) Logging::open do - puts command - system(command) + command = Shellwords.shellwords(command) + puts command.quote.join(' ') + system(*command) end end @@ -191,40 +196,35 @@ ensure log_src(src) end -def link_command(ldflags, opt="") -# ldflags = "-link " + ldflags if $mswin - "$(CC) #{OUTFLAG}conftest #$INCFLAGS -I#{$hdrdir} " \ - "#$CPPFLAGS $(CFLAGS) #$CFLAGS #{CONFTEST_C} #{opt} " \ - "#$LOCAL_LIBS $(LIBS) #{ldflags} $(LDFLAGS) #$LDFLAGS" +def link_command(ldflags, opt="", libpath=$LIBPATH) + Config::expand(TRY_LINK.dup, + 'hdrdir' => $hdrdir, + 'src' => CONFTEST_C, + 'INCFLAGS' => $INCFLAGS, + 'CPPFLAGS' => $CPPFLAGS, + 'CFLAGS' => "#$CFLAGS #{opt}", + 'LDFLAGS' => "#$LDFLAGS #{ldflags}", + 'LIBPATH' => libpathflag(libpath), + 'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs", + 'LIBS' => "#$LIBRUBYARG #$LIBS") end def cc_command(opt="") - "$(CC) -c $(CPPFLAGS) #$INCFLAGS -I#{$hdrdir} " \ - "#$CPPFLAGS $(CFLAGS) #$CFLAGS #{opt} #{CONFTEST_C}" + "$(CC) -c #$INCFLAGS -I#{$hdrdir} " \ + "#$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C}" end def cpp_command(outfile, opt="") - "$(CPP) $(CPPFLAGS) #$INCFLAGS -I#{$hdrdir} " \ - "#$CPPFLAGS $(CFLAGS) #$CFLAGS #{outfile} #{opt} #{CONFTEST_C}" + "$(CPP) #$INCFLAGS -I#{$hdrdir} " \ + "#$CPPFLAGS #$CFLAGS #{outfile} #{opt} #{CONFTEST_C}" end -def libpathflag - if $mswin - ENV['LIB'] = ($LIBPATH + [ORIG_LIBPATH]).join(';') - begin - yield "" - ensure - ENV['LIB'] = ORIG_LIBPATH - end - else - yield $LIBPATH.map{|x| %Q[#{LIBPATHFLAG}"#{x}"]}.join - end +def libpathflag(libpath=$LIBPATH) + libpath.map{|x| LIBPATHFLAG % %["#{x}"]}.join end def try_link0(src, opt="") - libpathflag do |flag| - try_do(src, link_command(flag, opt)) - end + try_do(src, link_command("", opt)) end def try_link(src, opt="") @@ -245,6 +245,30 @@ ensure rm_f "conftest*" end +def cpp_include(header) + if header + header = [header] unless header.kind_of? Array + header.map {|h| "#include <#{h}>\n"}.join + else + "" + end +end + +def try_func(func, libs, headers = nil) + headers = cpp_include(headers) + try_link(<<"SRC", libs) or try_link(<<"SRC", libs) +#{COMMON_HEADERS} +#{headers} +int main() { return 0; } +int t() { #{func}(); return 0; } +SRC +#{COMMON_HEADERS} +#{headers} +int main() { return 0; } +int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; } +SRC +end + def egrep_cpp(pat, src, opt="") src += "\n" unless /\n\z/ =~ src create_tmpsrc(src) @@ -290,41 +314,34 @@ ensure rm_f "conftest*" end -def install_files(mfile, ifiles, map = INSTALL_DIRS, srcprefix = nil) +def install_files(mfile, ifiles, map = nil, srcprefix = nil) ifiles or return srcprefix ||= '$(srcdir)' Config::expand(srcdir = srcprefix.dup) dirs = [] path = Hash.new {|h, i| h[i] = dirs.push([i])[-1]} ifiles.each do |files, dir, prefix| - dir = map.inject(dir) {|dir, (orig, new)| dir.gsub(orig, new)} if map + dir = map_dir(dir, map) prefix = %r"\A#{Regexp.quote(prefix)}/?" if prefix if( files[0,2] == "./" ) # install files which are in current working directory. - Dir.glob(files) do |f| - d = File.dirname(f) - d.sub!(prefix, "") if prefix - d = (d.empty? || d == ".") ? dir : File.join(dir,d) - path[d] << f - end + files = files[2..-1] + len = nil else # install files which are under the $(srcdir). - Dir.glob(File.join(srcdir,files)) do |f| - f[0..srcdir.size] = "" - d = File.dirname(f) - d.sub!(prefix, "") if prefix - d = (d.empty? || d == ".") ? dir : File.join(dir, d) - path[d] << (srcprefix ? File.join(srcprefix, f) : f) - end + files = File.join(srcdir, files) + len = srcdir.size end - end - - dirs.each do |dir, *files| - mfile.printf("\t@$(MAKEDIRS) %s\n", dir) - files.each do |f| - mfile.printf("\t@$(INSTALL_DATA) %s %s\n", f, dir) + Dir.glob(files) do |f| + f[0..len] = "" if len + d = File.dirname(f) + d.sub!(prefix, "") if prefix + d = (d.empty? || d == ".") ? dir : File.join(dir, d) + f = File.join(srcprefix, f) if len + path[d] << f end end + dirs end def install_rb(mfile, dest, srcdir = nil) @@ -332,11 +349,7 @@ def install_rb(mfile, dest, srcdir = nil) end def append_library(libs, lib) - if /mswin32|bccwin32/ =~ RUBY_PLATFORM - lib + ".lib " + libs - else - "-l" + lib + " " + libs - end + format(LIBARG, lib) + " " + libs end def message(*s) @@ -346,186 +359,101 @@ def message(*s) end end -def have_library(lib, func="main") - message "checking for #{func}() in -l#{lib}... " - Logging::message"have_library: checking for #{func}() in -l#{lib}\n" +def checking_for(m) + f = caller[0][/in \`(.*)\'$/, 1] and f << ": " + m = "checking for #{m}... " + message m + Logging::message "#{f}#{m}\n" + r = yield + message(r ? "yes\n" : "no\n") + r +end - if func && func != "" +def have_library(lib, func="main") + checking_for "#{func}() in -l#{lib}" do libs = append_library($libs, lib) - if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM - if lib == 'm' - message "yes\n" - return true - end - r = try_link(<<"SRC", libs) -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#include <winsock.h> -int main() { return 0; } -int t() { #{func}(); return 0; } -SRC - unless r - r = try_link(<<"SRC", libs) -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#include <winsock.h> -int main() { return 0; } -int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; } -SRC - end + if func && func != "" && COMMON_LIBS.include?(lib) + true + elsif try_func(func, libs) + $libs = libs + true else - r = try_link(<<"SRC", libs) -int main() { return 0; } -int t() { #{func}(); return 0; } -SRC - end - unless r - message "no\n" - return false + false end - else - libs = append_library($libs, lib) end - - $libs = libs - message "yes\n" - return true end def find_library(lib, func, *paths) - message "checking for #{func}() in -l#{lib}... " - Logging::message"find_library: checking for #{func}() in -l#{lib}\n" - - libpath = $LIBPATH - libs = append_library($libs, lib) - until try_link(<<"SRC", libs) -int main() { return 0; } -int t() { #{func}(); return 0; } -SRC - if paths.size == 0 - $LIBPATH = libpath - message "no\n" - return false + checking_for "#{func}() in -l#{lib}" do + libpath = $LIBPATH + libs = append_library($libs, lib) + begin + until r = try_func(func, libs) or paths.empty? + $LIBPATH = libpath | [paths.shift] + end + if r + $libs = libs + libpath = nil + end + ensure + $LIBPATH = libpath if libpath end - $LIBPATH = libpath | [paths.shift] + r end - $libs = libs - message "yes\n" - return true end def have_func(func, header=nil) - message "checking for #{func}()... " - Logging::message"have_func: checking for #{func}()\n" - - libs = $libs - src = - if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM - r = <<"SRC" -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#include <winsock.h> -SRC + checking_for "#{func}()" do + if try_func(func, $libs, header) + $defs.push(format("-DHAVE_%s", func.upcase)) + true else - "" + false end - unless header.nil? - src << <<"SRC" -#include <#{header}> -SRC - end - r = try_link(src + <<"SRC", libs) -int main() { return 0; } -int t() { #{func}(); return 0; } -SRC - unless r - r = try_link(src + <<"SRC", libs) -int main() { return 0; } -int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; } -SRC - end - unless r - message "no\n" - return false end - $defs.push(format("-DHAVE_%s", func.upcase)) - message "yes\n" - return true end def have_header(header) - message "checking for #{header}... " - Logging::message"have_header: checking for #{header}\n" - - unless try_cpp(<<"SRC") -#include <#{header}> -SRC - message "no\n" - return false + checking_for header do + if try_cpp(cpp_include(header)) + $defs.push(format("-DHAVE_%s", header.tr("a-z./\055", "A-Z___"))) + true + else + false + end end - $defs.push(format("-DHAVE_%s", header.tr("a-z./\055", "A-Z___"))) - message "yes\n" - return true end def have_struct_member(type, member, header=nil) - message "checking for #{type}.#{member}... " - Logging::message "have_struct_member: checking for #{type}.#{member}\n" - - src = - if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM - r = <<"SRC" -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#include <winsock.h> + checking_for "#{type}.#{member}" do + if try_compile(<<"SRC") +#{COMMON_HEADERS} +#{cpp_include(header)} +int main() { return 0; } +int s = (char *)&((#{type}*)0)->#{member} - (char *)0; SRC + $defs.push(format("-DHAVE_ST_%s", member.upcase)) + true else - "" + false end - unless header.nil? - header = [header] unless header.kind_of? Array - header.each {|h| - src << <<"SRC" -#include <#{h}> -SRC - } end - src << <<"SRC" -int main() { return 0; } -int s = (char *)&((#{type}*)0)->#{member} - (char *)0; -SRC - r = try_compile(src) - unless r - message "no\n" - return false +end + +def find_executable0(bin, path = nil) + path = (path || ENV['PATH']).split(File::PATH_SEPARATOR) + bin += Config::CONFIG['EXEEXT'] + file = nil + path.each do |dir| + return file if File.executable?(file = File.join(dir, bin)) end - $defs.push(format("-DHAVE_ST_%s", member.upcase)) - message "yes\n" - return true + nil end def find_executable(bin, path = nil) - message "checking for #{bin}... " - Logging::message "find_executable: checking for #{bin}\n" - - if path.nil? - path = ENV['PATH'].split(Config::CONFIG['PATH_SEPARATOR']) - else - path = path.split(Config::CONFIG['PATH_SEPARATOR']) + checking_for bin do + find_executable0(bin, path) end - - bin += Config::CONFIG['EXEEXT'] - for dir in path - file = File.join(dir, bin) - if FileTest.executable?(file) - message "yes\n" - return file - else - next - end - end - message "no\n" - return nil end def arg_config(config, default=nil) @@ -549,14 +477,21 @@ def enable_config(config, default=nil) end end -def create_header() - message "creating extconf.h\n" +def create_header(header = "extconf.h") + message "creating #{header}\n" if $defs.length > 0 - open("extconf.h", "w") do |hfile| + sym = header.tr("a-z./\055", "A-Z___") + open(header, "w") do |hfile| + hfile.print "#ifndef #{sym}\n#define #{sym}\n" for line in $defs - line =~ /^-D(.*)/ - hfile.printf "#define %s 1\n", $1 + case line + when /^-D(.*)(?:=(.*))?/ + hfile.print "#define #$1 #{$2 || 1}\n" + when /^-U(.*)/ + hfile.print "#undef #$1\n" + end end + hfile.print "#endif\n" end end end @@ -590,81 +525,9 @@ def winsep(s) s.tr('/', '\\') end -def create_makefile(target, srcprefix = nil) - save_libs = $libs.dup - save_libpath = $LIBPATH.dup - message "creating Makefile\n" - rm_f "conftest*" - if target.include?('/') - target_prefix, target = File.split(target) - target_prefix[0,0] = '/' - else - target_prefix = "" - end - if CONFIG["DLEXT"] == $OBJEXT - libs = $libs.split - for lib in libs - lib.sub!(/-l(.*)/, '"lib\1.a"') - end - $defs.push(format("-DEXTLIB='%s'", libs.join(","))) - end - $DLDFLAGS = CONFIG["DLDFLAGS"] - - $libs = CONFIG["LIBRUBYARG"] + " " + $libs + " " + CONFIG["LIBS"] - $configure_args['--enable-shared'] or $LIBPATH |= [$topdir] - $LIBPATH |= [CONFIG["libdir"]] - - srcprefix ||= '$(srcdir)' - Config::expand(srcdir = srcprefix.dup) - defflag = '' - if RUBY_PLATFORM =~ /bccwin32/ - deffile = target + '.def' - if not File.exist? deffile - open(deffile, 'wb') do |f| - f.print "EXPORTS\n", "_Init_", target, "\n" - end - end - elsif RUBY_PLATFORM =~ /cygwin|mingw/ - deffile = target + '.def' - if not File.exist? deffile - if File.exist? File.join(srcdir, deffile) - deffile = File.join srcdir, deffile - else - open(deffile, 'wb') do |f| - f.print "EXPORTS\n", "Init_", target, "\n" - end - end - end - defflag = deffile - end - - if RUBY_PLATFORM =~ /mswin32|bccwin32/ - libpath = $LIBPATH.join(';') - else - $LIBPATH.each {|d| $DLDFLAGS << " -L" << d} - if /netbsdelf/ =~ RUBY_PLATFORM - $LIBPATH.each {|d| $DLDFLAGS << " -Wl,-R" + d} - end - end - drive = File::PATH_SEPARATOR == ';' ? /\A\w:/ : /\A/ - - unless $objs then - $objs = [] - for f in Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")] - f = File.basename(f) - f.sub!(/(#{SRC_EXT.join(%q{|})})$/, $OBJEXT) - $objs.push f - end - else - for i in $objs - i.sub!(/\.o\z/, ".#{$OBJEXT}") - end - end - $objs = $objs.join(" ") - - mfile = open("Makefile", "w") - mfile.binmode if /mingw/ =~ RUBY_PLATFORM - mfile.print <<EOMF +def configuration(srcdir) + mk = [] + mk << %{ SHELL = /bin/sh #### Start of system configuration section. #### @@ -673,228 +536,323 @@ srcdir = #{srcdir} topdir = #{$topdir} hdrdir = #{$hdrdir} VPATH = $(srcdir) - -CC = #{CONFIG["CC"]} - -CFLAGS = #{CONFIG["CCDLFLAGS"]} #{CFLAGS} #{$CFLAGS} -CPPFLAGS = -I. -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{CONFIG["CPPFLAGS"]} #{$CPPFLAGS} -CXXFLAGS = $(CFLAGS) -#{ -if /bccwin32/ =~ RUBY_PLATFORM - "DLDFLAGS = #$LDFLAGS -L\"$(libdir:/=\\);$(topdir:/=\\)\"\n" + - "LDSHARED = #{CONFIG['LDSHARED']}\n" -else - "DLDFLAGS = #{$DLDFLAGS} #{$LDFLAGS}\n" + - "LDSHARED = #{CONFIG['LDSHARED']} #{defflag}\n" -end } -LIBPATH = #{libpath} - -RUBY_INSTALL_NAME = #{CONFIG["RUBY_INSTALL_NAME"]} -RUBY_SO_NAME = #{CONFIG["RUBY_SO_NAME"]} -arch = #{CONFIG["arch"]} -sitearch = #{CONFIG["sitearch"]} -ruby_version = #{Config::CONFIG["ruby_version"]} -EOMF + drive = File::PATH_SEPARATOR == ';' ? /\A\w:/ : /\A/ if destdir = CONFIG["prefix"].scan(drive)[0] and !destdir.empty? - mfile.print "\nDESTDIR = ", destdir, "\n" + mk << "\nDESTDIR = #{destdir}\n" end CONFIG.each do |key, var| next unless /prefix$/ =~ key - mfile.print key, " = ", with_destdir(var.sub(drive, '')), "\n" + mk << "#{key} = #{with_destdir(var.sub(drive, ''))}\n" end CONFIG.each do |key, var| + next if /^abs_/ =~ key next unless /^(?:src|top|(.*))dir$/ =~ key and $1 - mfile.print key, " = ", with_destdir(var.sub(drive, '')), "\n" - end - mfile.print <<EOMF -target_prefix = #{target_prefix} - -#### End of system configuration section. #### - -LOCAL_LIBS = #{$LOCAL_LIBS} #{$local_flags} -LIBS = #{$libs} -OBJS = #{$objs} - -TARGET = #{target} -DLLIB = $(TARGET).#{CONFIG["DLEXT"]} - -RUBY = #{CONFIG["ruby_install_name"]} + mk << "#{key} = #{with_destdir(var.sub(drive, ''))}\n" + end + mk << %{ +CC = #{CONFIG['CC']} + +CFLAGS = #{CONFIG['CCDLFLAGS'] unless $static} #$CFLAGS +CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{$CPPFLAGS} +CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']} +DLDFLAGS = #$LDFLAGS #{CONFIG['DLDFLAGS']} #$DLDFLAGS +LDSHARED = #{CONFIG['LDSHARED']} +AR = #{CONFIG['AR']} +EXEEXT = #{CONFIG['EXEEXT']} + +RUBY_INSTALL_NAME = #{CONFIG['RUBY_INSTALL_NAME']} +RUBY_SO_NAME = #{CONFIG['RUBY_SO_NAME']} +arch = #{CONFIG['arch']} +sitearch = #{CONFIG['sitearch']} +ruby_version = #{Config::CONFIG['ruby_version']} +RUBY = #{$ruby} RM = $(RUBY) -rftools -e "File::rm_f(*ARGV.map do|x|Dir[x]end.flatten.uniq)" MAKEDIRS = $(RUBY) -r ftools -e 'File::makedirs(*ARGV)' INSTALL_PROG = $(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)' INSTALL_DATA = $(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0644, true)' -EXEEXT = #{CONFIG["EXEEXT"]} +#### End of system configuration section. #### +} +end + +def makerules(target, target_prefix = "") + mk = [] + if target + mk << %{ +target_prefix = #{target_prefix} +LOCAL_LIBS = #{$LOCAL_LIBS} +LIBS = #{$LIBRUBYARG} #{$libs} #{$LIBS} +OBJS = #{$objs} +TARGET = #{target} +DLLIB = $(TARGET).#{$static ? $LIBEXT : CONFIG['DLEXT']} +} + if $extmk + mk << %{ +RUBYCOMMONDIR = $(rubylibdir) +RUBYLIBDIR = $(rubylibdir)$(target_prefix) +RUBYARCHDIR = $(archdir)$(target_prefix) +} + else + mk << %{ +RUBYCOMMONDIR = $(sitedir)$(target_prefix) +RUBYLIBDIR = $(sitelibdir)$(target_prefix) +RUBYARCHDIR = $(sitearchdir)$(target_prefix) +} + end + mk << %{ all: $(DLLIB) clean: - @$(RM) *.#{$OBJEXT} *.so *.sl *.a $(DLLIB) -#{ -if /bccwin32/ =~ RUBY_PLATFORM - " @$(RM) $(TARGET).lib $(TARGET).def $(TARGET).ilc $(TARGET).ild $(TARGET).ilf $(TARGET).ils $(TARGET).tds $(TARGET).map $(CLEANFILES)\n"+ - " @if exist $(target).def.org ren $(target).def.org $(target).def" -else - " @$(RM) $(TARGET).lib $(TARGET).exp $(TARGET).ilk *.pdb $(CLEANFILES)" -end + @$(RM) $(TARGET).lib $(TARGET).exp $(TARGET).il? $(TARGET).tds $(TARGET).map +} + else + mk << %{ +all: Makefile + +clean: } - + end + mk << %{\ + @$(RM) *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB) + @$(RM) *.pdb *.bak $(CLEANFILES) + distclean: clean @$(RM) Makefile extconf.h conftest.* mkmf.log @$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) realclean: distclean -install: $(archdir)$(target_prefix)/$(DLLIB) +} +end -site-install: $(sitearchdir)$(target_prefix)/$(DLLIB) +def create_makefile(target, srcprefix = nil) + $target = target + libpath = $LIBPATH + message "creating Makefile\n" + rm_f "conftest*" + if CONFIG["DLEXT"] == $OBJEXT + for lib in $libs.split + lib.sub!(/-l(.*)/, %%"lib\\1.#{$LIBEXT}"%) + end + $defs.push(format("-DEXTLIB='%s'", libs.join(","))) + end -$(archdir)$(target_prefix)/$(DLLIB): $(DLLIB) - @$(MAKEDIRS) $(rubylibdir) $(archdir)$(target_prefix) - @$(INSTALL_PROG) $(DLLIB) $(archdir)$(target_prefix)/$(DLLIB) + if target.include?('/') + target_prefix, target = File.split(target) + target_prefix[0,0] = '/' + else + target_prefix = "" + end -$(sitearchdir)$(target_prefix)/$(DLLIB): $(DLLIB) - @$(MAKEDIRS) $(sitearchdir)$(target_prefix) - @$(INSTALL_PROG) $(DLLIB) $(sitearchdir)$(target_prefix)/$(DLLIB) + srcprefix ||= '$(srcdir)' + Config::expand(srcdir = srcprefix.dup) -EOMF - mfile.print "install:\n" - install_rb(mfile, "$(rubylibdir)$(target_prefix)", srcprefix) - install_files(mfile, $INSTALLFILES, INSTALL_DIRS, srcprefix) - mfile.print "\n" - mfile.print "site-install:\n" - install_rb(mfile, "$(sitelibdir)$(target_prefix)", srcprefix) - install_files(mfile, $INSTALLFILES, SITEINSTALL_DIRS, srcprefix) + cleanfiles = [] + if EXPORT_PREFIX + origdef = target + '.def' + deffile = EXPORT_PREFIX + origdef + unless File.exist? deffile + if File.exist? File.join(srcdir, deffile) + deffile = File.join srcdir, deffile + elsif !EXPORT_PREFIX.empty? and File.exist?(origdef = File.join(srcdir, origdef)) + open(origdef) do |d| + open(deffile, 'wb') do |f| + d.each do |l| + f.print l + break if /^EXPORTS$/i =~ l + end + d.each do |l| + f.print l.sub(/\S/, EXPORT_PREFIX+'\&') + end + end + end + cleanfiles << deffile + else + open(deffile, 'wb') do |f| + f.print "EXPORTS\n", EXPORT_PREFIX, "Init_", target, "\n" + end + cleanfiles << deffile + end + end + end - unless /mswin32/ =~ RUBY_PLATFORM - if /bccwin32/ =~ RUBY_PLATFORM - src = '$(<:\\=/)' - else - src = '$<' + libpath = libpathflag(libpath) + + unless $objs then + $objs = [] + for f in Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")] + $objs.push(File.basename(f, ".*") << "." << $OBJEXT) end - copt = cxxopt = '' else - if /nmake/i =~ $make - src = '$(<:\\=/)' - else - src = '$(subst /,\\\\,$<)' + for i in $objs + i.sub!(/\.o\z/, ".#{$OBJEXT}") end - copt = '-Tc' - cxxopt = '-Tp' end + $objs = $objs.join(" ") - mfile.print ".SUFFIXES: .#{SRC_EXT.join(' .')} .#{$OBJEXT}\n" - unless /nmake/i =~ $make - if /bccwin32/ =~ RUBY_PLATFORM - mfile.print " -{$(srcdir)}.cc{}.@OBJEXT@: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -{$(srcdir)}.cpp{}.@OBJEXT@: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -{$(srcdir)}.cxx{}.@OBJEXT@: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -{$(srcdir)}.c{}.@OBJEXT@: - $(CC) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src} -" + mfile = open("Makefile", "wb") + mfile.print configuration(srcdir) + mfile.print %{ +LIBPATH = #{libpath} +DEFFILE = #{deffile} + +CLEANFILES = #{cleanfiles.join(' ')} +DISTCLEANFILES = +} + mfile.print makerules(target, target_prefix) + dirs = [] + unless $static + dirs << (dir = "$(RUBYARCHDIR)") + mfile.print("install: #{dir}\n") + f = "$(DLLIB)" + dest = "#{dir}/#{f}" + mfile.print "install: #{dest}\n" + mfile.print "#{dest}: #{f}\n\t@$(INSTALL_PROG) #{f} #{dir}\n" + end + for i in [[["lib/**/*.rb", "$(RUBYLIBDIR)", "lib"]], $INSTALLFILES] + files = install_files(mfile, i, nil, srcprefix) or next + for dir, *files in files + unless dirs.include?(dir) + dirs << dir + mfile.print("install: #{dir}\n") + end + files.each do |f| + dest = "#{dir}/#{File.basename(f)}" + mfile.print("install: #{dest}\n") + mfile.print("#{dest}: #{f}\n\t@$(INSTALL_DATA) #{f} #{dir}\n") + end end - mfile.puts " -.cc.#{$OBJEXT}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.cpp.#{$OBJEXT}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.cxx.#{$OBJEXT}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.C.#{$OBJEXT}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.c.#{$OBJEXT}: - $(CC) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src} -" + end + if dirs.empty? + mfile.print("install:\n") else - mfile.print " -{$(srcdir)}.c{}.#{$OBJEXT}: - $(CC) -I. -I$(<D) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src} -.c.#{$OBJEXT}: - $(CC) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src} -{$(srcdir)}.cc{}.#{$OBJEXT}: - $(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.cc.#{$OBJEXT}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -{$(srcdir)}.cpp{}.#{$OBJEXT}: - $(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.cpp.#{$OBJEXT}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -{$(srcdir)}.cxx{}.#{$OBJEXT}: - $(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -.cxx.#{$OBJEXT}: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} -" - end - - if CONFIG["DLEXT"] != $OBJEXT - mfile.print "$(DLLIB): $(OBJS)\n" - if /bccwin32/ =~ RUBY_PLATFORM - mfile.print "\t$(LDSHARED) $(DLDFLAGS) C0D32.OBJ $(OBJS), $@,, CW32.LIB IMPORT32.LIB WS2_32.LIB $(LIBS), #{deffile}\n" - else - if /mswin32|bccwin32/ =~ RUBY_PLATFORM - if /nmake/i =~ $make - mfile.print "\tset LIB=$(LIBPATH:/=\\);$(LIB)\n" - else - mfile.print "\tenv LIB='$(subst /,\\\\,$(LIBPATH));$(LIB)' \\\n" - end - end - mfile.print "\t$(LDSHARED) $(DLDFLAGS) #{OUTFLAG}$(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n" + dirs.each {|dir| mfile.print "#{dir}:\n\t@$(MAKEDIRS) #{dir}\n"} + end + + mfile.print "\n" + + mfile.print ".SUFFIXES: .#{SRC_EXT.join(' .')} .#{$OBJEXT}\n" + mfile.print "\n" + + %w[cc cpp cxx C].each do |ext| + COMPILE_RULES.each do |rule| + mfile.printf(rule, ext, $OBJEXT) + mfile.printf("\n\t%s\n\n", COMPILE_CXX) end - elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc") - mfile.print "$(DLLIB): $(OBJS)\n" - case RUBY_PLATFORM - when "m68k-human" - mfile.printf "ar cru $(DLLIB) $(OBJS)\n" - else - mfile.printf "ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS)\n" + end + %w[c].each do |ext| + COMPILE_RULES.each do |rule| + mfile.printf(rule, ext, $OBJEXT) + mfile.printf("\n\t%s\n\n", COMPILE_C) + end + end + + mfile.print "$(DLLIB): $(OBJS)\n\t" + if $static + mfile.print "$(AR) #{config_string('ARFLAGS') || 'cru '}$(DLLIB) $(OBJS)" + if ranlib = config_string('RANLIB') + mfile.print "\n\t@-#{ranlib} $(DLLIB) 2> /dev/null || true" end + else + mfile.print LINK_SO end + mfile.print "\n\n" depend = File.join(srcdir, "depend") if File.exist?(depend) - dfile = open(depend, "r") - mfile.printf "###\n" - while line = dfile.gets() - line.gsub!(/\.o\b/, ".#{$OBJEXT}") - line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') if /nmake/i =~ $make - mfile.printf "%s", line + open(depend, "r") do |dfile| + mfile.printf "###\n" + while line = dfile.gets() + line.gsub!(/\.o\b/, ".#{$OBJEXT}") + line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') if $nmake + line.gsub!(/\$\(hdrdir\)\/config.h/, $config_h) if $config_h + mfile.print line + end end - dfile.close end mfile.close - $libs = save_libs - $LIBPATH = save_libpath end -$OBJEXT = CONFIG["OBJEXT"] -$objs = nil -$libs = CONFIG["DLDLIBS"] -$local_flags = "" -case RUBY_PLATFORM -when /mswin32/ - $local_flags = "-link /INCREMENTAL:no /EXPORT:Init_$(TARGET)" -end -$LOCAL_LIBS = "" -$defs = [] +def init_mkmf(config = CONFIG) + $defs = [] + $CFLAGS = with_config("cflags", arg_config("CFLAGS", config["CFLAGS"])).dup + $CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS", config["CPPFLAGS"])).dup + $LDFLAGS = with_config("ldflags", arg_config("LDFLAGS", config["LDFLAGS"])).dup + $INCFLAGS = "-I#{$topdir}" + $DLDFLAGS = "" + $LIBEXT = config['LIBEXT'].dup + $OBJEXT = config["OBJEXT"].dup + $LIBS = "#{config['LIBS']} #{config['DLDLIBS']}" + $LIBRUBYARG = config['LIBRUBYARG'] -$make = with_config("make-prog", ENV["MAKE"] || "make") + $objs = nil + $libs = "" + if $configure_args['--enable-shared'] or config["LIBRUBY"] != config["LIBRUBY_A"] + $LIBPATH = ["$(topdir)"] + $LIBPATH << "$(libdir)" unless $extmk or defined? CROSS_COMPILING + end + $LIBPATH << "$(archdir)" -$CFLAGS = with_config("cflags", arg_config("CFLAGS", "")) -$CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS", "")) -$LDFLAGS = with_config("ldflags", arg_config("LDFLAGS", "")) -$LIBPATH = [] -$INCFLAGS = "" + $LOCAL_LIBS = "" +end +init_mkmf dir_config("opt") +$make = with_config("make-prog", ENV["MAKE"] || "make") +$nmake = nil +case +when $mswin + $nmake = ?m if /nmake/i =~ $make +when $bccwin + $nmake = ?b if /\bbcc/i =~ $make or /\bbcc/i =~ find_executable0($make) +end + Config::CONFIG["srcdir"] = CONFIG["srcdir"] = $srcdir = arg_config("--srcdir", File.dirname($0)) $configure_args["--topsrcdir"] ||= $srcdir Config::CONFIG["topdir"] = CONFIG["topdir"] = $curdir = arg_config("--curdir", Dir.pwd) $configure_args["--topdir"] ||= $curdir +$ruby = arg_config("--ruby", CONFIG["ruby_install_name"]) + +def config_string(key) + return unless s = CONFIG[key] and !s.empty? + return s unless block_given? + yield s +end + +split = Shellwords.method(:shellwords).to_proc + +EXPORT_PREFIX = config_string('EXPORT_PREFIX') {|s| s.strip} + +hdr = [] +config_string('COMMON_MACROS') do |s| + Shellwords.shellwords(s).each do |s| + /(.*?)(?:=(.*))/ =~ s + hdr << "#define #$1 #$2" + end +end +config_string('COMMON_HEADERS') do |s| + Shellwords.shellwords(s).each {|s| hdr << "#include <#{s}>"} +end +COMMON_HEADERS = (hdr.join("\n") unless hdr.empty?) +COMMON_LIBS = config_string('COMMON_LIBS', &split) || [] + +COMPILE_RULES = config_string('COMPILE_RULES', &split) || %w[.%s.%s:] +COMPILE_C = config_string('COMPILE_C') || '$(CC) $(CFLAGS) $(CPPFLAGS) -c $<' +COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<' +TRY_LINK = config_string('TRY_LINK') || + "$(CC) #{OUTFLAG}conftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS) " \ + "$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(LOCAL_LIBS) $(LIBS)" +LINK_SO = config_string('LINK_SO') || + if CONFIG["DLEXT"] == $OBJEXT + "ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS)\n" + else + "$(LDSHARED) $(DLDFLAGS) $(LIBPATH) #{OUTFLAG}$(DLLIB) " \ + "$(OBJS) $(LOCAL_LIBS) $(LIBS)" + end +LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L%s' +LIBARG = config_string('LIBARG') || '-l%s' diff --git a/win32/Makefile.sub b/win32/Makefile.sub index fc0c9c4c65..653aad32a8 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -25,11 +25,14 @@ iconinc=-I$(icondirs: = -I) ############### VPATH = $(srcdir):$(srcdir)/missing -.SUFFIXES: .y +.SUFFIXES: .y .def .lib !if !defined(CC) CC = cl !endif +!if !defined(CPP) +CPP = $(CC) -E +!endif !if !defined(YACC) YACC = byacc !endif @@ -75,14 +78,11 @@ prefix = /usr DESTDIR = $(prefix) !endif !if !defined(CFLAGS) -CFLAGS = -nologo -MD -DNT=1 $(DEBUGFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG) +CFLAGS = -MD -DNT=1 $(DEBUGFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG) !endif !if !defined(CPPFLAGS) CPPFLAGS = -I. -I$(srcdir) -I$(srcdir)/missing -DLIBRUBY_SO=\"$(LIBRUBY_SO)\" !endif -!if !defined(LDFLAGS) -LDFLAGS = $(CFLAGS) -Fm -!endif !if !defined(XLDFLAGS) XLDFLAGS = !endif @@ -94,15 +94,25 @@ EXTLIBS = !endif LIBS = user32.lib advapi32.lib wsock32.lib $(EXTLIBS) MISSING = acosh.obj crypt.obj win32.obj isinf.obj isnan.obj -LDSHARED = $(CC) -LD -DLDFLAGS = + +ARFLAGS = -machine:$(MACHINE) -out: +CC = $(CC) -nologo +LD = $(CC) +LDSHARED = $(LD) -LD +XCFLAGS = +LDFLAGS = -link -incremental:no -pdb:none +DLDFLAGS = $(LDFLAGS) -dll +XLDFLAGS = -stack:$(STACK) SOLIBS = +LIBRUBY_LDSHARED = $(LDSHARED) +LIBRUBY_DLDFLAGS = $(EXTLDFLAGS) -def:$(RUBYDEF) + EXEEXT = .exe PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT) WPROGRAM=$(RUBYW_INSTALL_NAME)$(EXEEXT) RUBYDEF = $(RUBY_SO_NAME).def -MINIRUBY=miniruby$(EXEEXT) +MINIRUBY = .\miniruby$(EXEEXT) !if !defined(STACK) STACK = 0x2000000 @@ -116,7 +126,7 @@ LIBRUBY_SO = $(RUBY_SO_NAME).dll LIBRUBY = $(RUBY_SO_NAME).lib LIBRUBYARG = $(LIBRUBY) -EXTOBJS = dmyext.obj +EXTOBJS = MAINOBJ = main.obj WINMAINOBJ = winmain.obj @@ -161,7 +171,7 @@ OBJS = array.obj \ all: ext miniruby$(EXEEXT) rbconfig.rb \ $(LIBRUBY) $(MISCLIBS) - @.\miniruby$(EXEEXT) $(srcdir)/ext/extmk.rb + @$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTSTATIC) $(MAKE) -$(MFLAGS)$(MAKEFLAGS) ext: @mkdir $@ @@ -264,17 +274,16 @@ config.h: Makefile $(srcdir)/win32/Makefile.sub #define RUBY_SITE_ARCHLIB "/lib/ruby/site_ruby/1.7/$(ARCH)-$(RT)" <<KEEP -config.status: Makefile $(srcdir)/win32/Makefile.sub $(MINIRUBY) - @echo Creating config.status - @$(MINIRUBY) -pe "~/@CFLAGS@/||$$_.sub!(/#{Regexp.quote('$(CFLAGS)')}/o, '$$(CFLAGS)')" << > $@ +config.status: Makefile $(srcdir)/win32/Makefile.sub + @echo Creating <<$@ # Generated automatically by Makefile.sub. s,@SHELL@,$$(COMSPEC),;t t s,@CFLAGS@,$(CFLAGS),;t t s,@CPPFLAGS@,$(CPPFLAGS),;t t s,@CXXFLAGS@,$(CXXFLAGS),;t t s,@FFLAGS@,$(FFLAGS),;t t -s,@LDFLAGS@,$(LDFLAGS),;t t -s,@LIBS@,user32.lib advapi32.lib wsock32.lib,;t t +s,@LDFLAGS@,,;t t +s,@LIBS@,$(LIBS),;t t s,@exec_prefix@,$${prefix},;t t s,@prefix@,,;t t s,@program_transform_name@,s,,,,;t t @@ -306,10 +315,11 @@ s,@target_cpu@,$(ARCH),;t t s,@target_vendor@,pc,;t t s,@target_os@,$(OS),;t t s,@CC@,$(CC),;t t -s,@CPP@,$$(CC) -E,;t t +s,@CPP@,$(CPP),;t t s,@YACC@,$(YACC),;t t s,@RANLIB@,rem,;t t s,@AR@,$(AR),;t t +s,@ARFLAGS@,$(ARFLAGS):,;t t s,@LN_S@,$(LN_S),;t t s,@SET_MAKE@,$(SET_MAKE),;t t s,@LIBOBJS@, acosh.obj crypt.obj win32.obj isinf.obj isnan.obj,;t t @@ -318,12 +328,13 @@ s,@DEFAULT_KCODE@,$(DEFAULT_KCODE),;t t s,@EXEEXT@,.exe,;t t s,@OBJEXT@,obj,;t t s,@XLDFLAGS@,$(XLDFLAGS),;t t -s,@DLDFLAGS@,$$(CFLAGS),;t t +s,@DLDFLAGS@,$(DLDFLAGS) $$(LIBPATH) -def:$$(DEFFILE),;t t s,@STATIC@,$(STATIC),;t t s,@CCDLFLAGS@,-DIMPORT,;t t -s,@LDSHARED@,$$(CC) -LD,;t t +s,@LDSHARED@,$(LDSHARED),;t t s,@DLEXT@,so,;t t s,@DLEXT2@,dll,;t t +s,@LIBEXT@,lib,;t t s,@STRIP@,$(STRIP),;t t s,@EXTSTATIC@,$(EXTSTATIC),;t t s,@setup@,Setup,;t t @@ -331,6 +342,8 @@ s,@MINIRUBY@,$(MINIRUBY),;t t s,@LIBRUBY_LDSHARED@,$(LIBRUBY_LDSHARED),;t t s,@LIBRUBY_DLDFLAGS@,$(LIBRUBY_DLDFLAGS),;t t s,@RUBY_INSTALL_NAME@,$(RUBY_INSTALL_NAME),;t t +s,@rubyw_install_name@,$(RUBYW_INSTALL_NAME),;t t +s,@RUBYW_INSTALL_NAME@,$(RUBYW_INSTALL_NAME),;t t s,@RUBY_SO_NAME@,$(RUBY_SO_NAME),;t t s,@LIBRUBY_A@,lib$$(RUBY_INSTALL_NAME).lib,;t t s,@LIBRUBY_SO@,$$(RUBY_SO_NAME).dll,;t t @@ -342,6 +355,17 @@ s,@DLDLIBS@,$(DLDLIBS),;t t s,@ENABLE_SHARED@,yes,;t t s,@OUTFLAG@,-Fe,;t t s,@CPPOUTFILE@,-P,;t t +s,@LIBPATHFLAG@, -libpath:%s,;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_RULES@,{$$(srcdir)}.%s{}.%s: .%s.%s:,;t t +s,@TRY_LINK@,$$(CC) -Feconftest $$(INCFLAGS) -I$$(hdrdir) $$(CPPFLAGS) $$(CFLAGS) $$(src) $$(LOCAL_LIBS) $$(LIBS) $$(LDFLAGS) $$(XLDFLAGS),;t t +s,@COMMON_LIBS@,m,;t t +s,@COMMON_MACROS@,WIN32_LEAN_AND_MEAN;t t +s,@COMMON_HEADERS@,winsock2.h windows.h,;t t +s,@EXPORT_PREFIX@, ,;t t s,@arch@,$(ARCH)-$(OS),;t t s,@sitearch@,$(ARCH)-$(RT),;t t s,@sitedir@,$${prefix}/lib/ruby/site_ruby,;t t @@ -349,36 +373,40 @@ s,@configure_args@,--with-make-prog=nmake --enable-shared $(configure_args),;t t s,@configure_input@,$$configure_input,;t t s,@srcdir@,$(srcdir),;t t s,@top_srcdir@,$(srcdir),;t t -<< +<<KEEP miniruby$(EXEEXT): $(OBJS) $(MAINOBJ) dmyext.obj - @echo $(EXTOBJS) - @echo $(LIBS) - $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) dmyext.obj $(OBJS) $(LIBS) -Fe$@ + @echo. $(LIBS) + $(PURIFY) $(CC) $(MAINOBJ) dmyext.obj $(OBJS) $(LIBS) -Fe$@ $(LDFLAGS) $(PROGRAM): $(MAINOBJ) $(LIBRUBY_SO) $*.res - $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $*.res \ - -Fe$@ $(LIBRUBYARG) -link -stack:$(STACK) -incremental:no + $(PURIFY) $(CC) $(MAINOBJ) $*.res \ + -Fe$@ $(LIBRUBYARG) $(LDFLAGS) $(XLDFLAGS) $(WPROGRAM): $(MAINOBJ) $(WINMAINOBJ) $(LIBRUBY_SO) $*.res - $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(WINMAINOBJ) $*.res \ - -Fe$@ $(LIBRUBYARG) -link -stack:$(STACK) -subsystem:Windows -incremental:no + $(PURIFY) $(CC) $(MAINOBJ) $(WINMAINOBJ) $*.res \ + -Fe$@ $(LIBRUBYARG) $(LDFLAGS) $(XLDFLAGS) -subsystem:Windows $(LIBRUBY_A): $(OBJS) dmyext.obj - $(AR) -out:$@ -machine:$(MACHINE) $(OBJS) dmyext.obj + $(AR) $(ARFLAGS)$@ $(OBJS) dmyext.obj $(LIBRUBY): $(RUBYDEF) - $(AR) -out:$@ -def:$(RUBYDEF) -machine:$(MACHINE) + $(AR) $(ARFLAGS)$@ -def:$(RUBYDEF) $(LIBRUBY_SO): $(LIBRUBY_A) $(EXTOBJS) $(RUBYDEF) $*.res - $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY_A) $*.res $(LIBS) \ - -Fe$@ -link -dll -def:$(RUBYDEF) + @echo. $(EXTOBJS) + $(LIBRUBY_LDSHARED) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY_A) $*.res $(LIBS) \ + -Fe$@ $(LDFLAGS) $(LIBRUBY_DLDFLAGS) $(RUBYDEF): $(LIBRUBY_A) miniruby$(EXEEXT) - .\miniruby$(EXEEXT) $(srcdir)/win32/mkexports.rb -output=$@ $(LIBRUBY_A) + $(MINIRUBY) $(srcdir)/win32/mkexports.rb -output=$@ $(LIBRUBY_A) + +{$(srcdir)/win32}.def.lib: + $(AR) $(ARFLAGS)$@ -def:$< install: rbconfig.rb - .\miniruby.exe $(srcdir)/instruby.rb $(DESTDIR) + $(MINIRUBY) $(srcdir)/instruby.rb $(DESTDIR) + $(MINIRUBY) $(srcdir)/ext/extmk.rb $(MAKE) -$(MFLAGS)$(MAKEFLAGS) DESTDIR=$(DESTDIR) install clean: clean-ext clean-local @@ -393,7 +421,7 @@ clean-local: @if exist *.res del *.res clean-ext: - @-.\miniruby$(EXEEXT) $(srcdir)/ext/extmk.rb clean + @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(MAKE) -$(MFLAGS)$(MAKEFLAGS) clean distclean: distclean-ext distclean-local @@ -427,35 +455,35 @@ distclean-local: clean-local @if exist miniruby$(EXEEXT) del miniruby$(EXEEXT) distclean-ext: - @-.\miniruby$(EXEEXT) $(srcdir)/ext/extmk.rb distclean + @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(MAKE) -$(MFLAGS)$(MAKEFLAGS) distclean realclean: distclean @if exist parse.c del parse.c @if exist lex.c del lex.c test: miniruby$(EXEEXT) - @.\miniruby$(EXEEXT) $(srcdir)/rubytest.rb + @miniruby$(EXEEXT) $(srcdir)/rubytest.rb rbconfig.rb: miniruby$(EXEEXT) config.status - @.\miniruby$(EXEEXT) $(srcdir)/mkconfig.rb -srcdir=$(srcdir) \ + @$(MINIRUBY) $(srcdir)/mkconfig.rb -srcdir=$(srcdir) \ -install_name=$(RUBY_INSTALL_NAME) \ -so_name=$(RUBY_SO_NAME) rbconfig.rb $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc: rbconfig.rb - @.\miniruby$(EXEEXT) $(srcdir)/win32/resource.rb \ + @$(MINIRUBY) $(srcdir)/win32/resource.rb \ -ruby_name=$(RUBY_INSTALL_NAME) \ -rubyw_name=$(RUBYW_INSTALL_NAME) \ -so_name=$(RUBY_SO_NAME) \ . $(icondirs) $(srcdir)/win32 {$(srcdir)/missing}.c.obj: - $(CC) $(CFLAGS) -I. -I$(<D) $(CPPFLAGS) -c -Tc$(<:\=/) + $(CC) $(CFLAGS) $(XCFLAGS) -I. -I$(<D) $(CPPFLAGS) -c -Tc$(<:\=/) {$(srcdir)/win32}.c.obj: - $(CC) $(CFLAGS) -I. -I$(<D) $(CPPFLAGS) -c -Tc$(<:\=/) + $(CC) $(CFLAGS) $(XCFLAGS) -I. -I$(<D) $(CPPFLAGS) -c -Tc$(<:\=/) {$(srcdir)}.c.obj: - $(CC) $(CFLAGS) -I. -I$(<D) $(CPPFLAGS) -c -Tc$(<:\=/) + $(CC) $(CFLAGS) $(XCFLAGS) -I. -I$(<D) $(CPPFLAGS) -c -Tc$(<:\=/) .c.obj: - $(CC) $(CFLAGS) -I. $(CPPFLAGS) -c -Tc$(<:\=/) + $(CC) $(CFLAGS) $(XCFLAGS) -I. $(CPPFLAGS) -c -Tc$(<:\=/) .rc.res: $(RC) -I. -I$(<D) $(iconinc) -I$(srcdir)/win32 $(RFLAGS) -fo$@ $(<:\=/) @@ -467,6 +495,9 @@ $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc: rbconfig.rb {$(srcdir)}parse.c: parse.y +ext/extinit.obj: ext/extinit.c $(SETUP) + $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -Fo$@ -c ext/extinit.c + acosh.obj: {$(srcdir)}missing/acosh.c alloca.obj: {$(srcdir)}missing/alloca.c crypt.obj: {$(srcdir)}missing/crypt.c diff --git a/win32/setup.mak b/win32/setup.mak index 88c5822a37..328afa0d78 100644 --- a/win32/setup.mak +++ b/win32/setup.mak @@ -1,58 +1,82 @@ # -*- makefile -*- -!IF "$(WIN32DIR)" == "win32" +!if "$(srcdir)" != "" +WIN32DIR = $(srcdir)/win32 +!elseif "$(WIN32DIR)" == "win32" srcdir = . -!ELSEIF "$(WIN32DIR)" == "$(WIN32DIR:/win32=)/win32" +!elseif "$(WIN32DIR)" == "$(WIN32DIR:/win32=)/win32" srcdir = $(WIN32DIR:/win32=) -!ELSE +!else srcdir = $(WIN32DIR)/.. -!ENDIF +!endif OS = mswin32 RT = msvcrt INCLUDE = !include -MAKEFILE = $(WIN32DIR)/setup.mak - -!if "$(target)" == "" -all: Makefile - @echo type `$(MAKE)' to make ruby for $(OS). +APPEND = echo>>$(MAKEFILE) +!ifdef MAKEFILE +MAKE = $(MAKE) -f $(MAKEFILE) !else -all: $(target) +MAKEFILE = Makefile !endif +ARCH = PROCESSOR_ARCHITECTURE +CPU = PROCESSOR_LEVEL -i386-$(OS): - @$(MAKE) -$(MAKEFLAGS) -f $(MAKEFILE) target= \ - PROCESSOR_ARCHITECTURE=x86 PROCESSOR_LEVEL=3 -i486-$(OS): - @$(MAKE) -$(MAKEFLAGS) -f $(MAKEFILE) target= \ - PROCESSOR_ARCHITECTURE=x86 PROCESSOR_LEVEL=4 -i586-$(OS): - @$(MAKE) -$(MAKEFLAGS) -f $(MAKEFILE) target= \ - PROCESSOR_ARCHITECTURE=x86 PROCESSOR_LEVEL=5 -i686-$(OS): - @$(MAKE) -$(MAKEFLAGS) -f $(MAKEFILE) target= \ - PROCESSOR_ARCHITECTURE=x86 PROCESSOR_LEVEL=6 -alpha-$(OS): - @$(MAKE) -$(MAKEFLAGS) -f $(MAKEFILE) target= \ - PROCESSOR_ARCHITECTURE=alpha PROCESSOR_LEVEL= - -Makefile: - @echo Creating <<$@ +all: -prologue- -generic- -epilogue- +i386-$(OS): -prologue- -i386- -epilogue- +i486-$(OS): -prologue- -i486- -epilogue- +i586-$(OS): -prologue- -i586- -epilogue- +i686-$(OS): -prologue- -i686- -epilogue- +alpha-$(OS): -prologue- -alpha- -epilogue- + +-prologue-: nul + @echo Creating <<$(MAKEFILE) ### Makefile for ruby $(OS) ### srcdir = $(srcdir:\=/) -!if defined(PROCESSOR_ARCHITECTURE) -PROCESSOR_ARCHITECTURE = $(PROCESSOR_ARCHITECTURE) + +<<KEEP + +-generic-: nul +!if defined($(ARCH)) || defined($(CPU)) + @type << >>$(MAKEFILE) +!if defined($(ARCH)) +$(ARCH) = $(PROCESSOR_ARCHITECTURE) !endif -!if defined(PROCESSOR_LEVEL) -PROCESSOR_LEVEL = $(PROCESSOR_LEVEL) +!if defined($(CPU)) +$(CPU) = $(PROCESSOR_LEVEL) !endif -RUBY_INSTALL_NAME = ruby -RUBY_SO_NAME = $(RT)-$$(RUBY_INSTALL_NAME)17 -prefix = /usr -CFLAGS = -nologo -MD -DNT=1 $$(DEBUGFLAGS) $$(OPTFLAGS) $$(PROCESSOR_FLAG) -CPPFLAGS = -I. -I$$(srcdir) -I$$(srcdir)/missing -DLIBRUBY_SO=\"$$(LIBRUBY_SO)\" -LDFLAGS = $$(CFLAGS) -Fm -XLDFLAGS = -RFLAGS = -r -EXTLIBS = + +<< +!endif + +-alpha-: nul + @$(APPEND) $(ARCH) = alpha +-ix86-: nul + @$(APPEND) $(ARCH) = x86 + +-i386-: -ix86- + @$(APPEND) $(CPU) = 3 +-i486-: -ix86- + @$(APPEND) $(CPU) = 4 +-i586-: -ix86- + @$(APPEND) $(CPU) = 5 +-i686-: -ix86- + @$(APPEND) $(CPU) = 6 + +-epilogue-: nul + @type << >>$(MAKEFILE) +# OS = $(OS) +# RT = $(RT) +# RUBY_INSTALL_NAME = ruby +# RUBY_SO_NAME = $$(RT)-$$(RUBY_INSTALL_NAME)17 +# prefix = /usr +# CFLAGS = -nologo -MD $$(DEBUGFLAGS) $$(OPTFLAGS) $$(PROCESSOR_FLAG) +# CPPFLAGS = -I. -I$$(srcdir) -I$$(srcdir)/missing -DLIBRUBY_SO=\"$$(LIBRUBY_SO)\" +# STACK = 0x2000000 +# LDFLAGS = $$(CFLAGS) -Fm +# XLDFLAGS = +# RFLAGS = -r +# EXTLIBS = + $(INCLUDE) $$(srcdir)/win32/Makefile.sub -<<KEEP +<< + @echo type `$(MAKE)' to make ruby for $(OS). |