@@ -18,6 +18,8 @@ $lib_cache = {}
1818$func_cache = { }
1919$hdr_cache = { }
2020
21+ $dllopt = '-MD'
22+
2123if File . exist? ( "config.cache" ) then
2224 f = open ( "config.cache" , "r" )
2325 while f . gets
@@ -47,7 +49,7 @@ def older(file1, file2)
4749end
4850
4951LINK = "cl -o conftest -I../.. -Zi -O -I. %s %s conftest.c %s > nul"
50- CPP = "cl -E -I../.. -Zi -O -I. %s conftest.c > nul"
52+ CPP = "cl -E -I../.. -I../../missing -I. -Zi -O %s conftest.c > nul"
5153
5254def try_link ( libs )
5355 system ( format ( LINK , $CFLAGS, $LDFLAGS, libs ) )
@@ -201,10 +203,18 @@ VPATH = .
201203
202204CC = cl
203205
204- CFLAGS = %s -I../.. -Zi -O -I. -DNT -MD #$CFLAGS %s
206+ CFLAGS = %s -I../.. -I../../missing -I. -O -DNT %s #$CFLAGS %s
207+
208+ RUBYLIB = ../../ruby.lib
205209DLDFLAGS = /DLL
206210LDSHARED =
207- " , if $static then "" else "-fpic" end , $defs. join ( " " )
211+ " , if $static then "" else "-fpic" end , $dllopt, $defs. join ( " " )
212+
213+ if $force_static
214+ print "static\n "
215+ else
216+ print "non static\n "
217+ end
208218
209219 mfile . printf "\
210220
@@ -231,14 +241,16 @@ TARGET = %s.%s
231241
232242INSTALL = %sginstall -c
233243
244+ DEFFILE = %s.def
245+
234246all: $(TARGET)
235247
236248clean:; @rm -f *.obj *.lib *.exp *.pdb *.bak
237249 @rm -f Makefile extconf.h conftest.*
238250
239251realclean: clean
240252" , target ,
241- if $static then "obj " else "obj " end , dots
253+ if $force_static then "lib " else "dll " end , dots , target
242254
243255 if !$static
244256 mfile . printf "\
@@ -256,17 +268,18 @@ install:;
256268"
257269 end
258270
259- if !$static && "obj" != "obj"
271+ if $force_static
260272 mfile . printf "\
261273 $(TARGET): $(OBJS)
262- $(LDSHARED) $(DLDFLAGS) -o $(TARGET) $(OBJS) $(LOCAL_LIBS) $(LIBS)
263- "
264- elsif not File . exist? ( target + ".c" )
265- mfile . printf "\
266- $(TARGET): $(OBJS)
267- # ld $(DLDFLAGS) -r -o $(TARGET) $(OBJS)
268- cl -c $(OBJS)
269274 lib /OUT:$(TARGET) $(OBJS)
275+ "
276+ else
277+ mfile . printf "\
278+ $(DEFFILE):
279+ echo $(DEFFILE)
280+
281+ $(TARGET): $(OBJS) $(DEFFILE)
282+ cl -DLL -o$(TARGET) $(OBJS) $(RUBYLIB) -link /DEF:$(DEFFILE)
270283"
271284 end
272285
@@ -318,6 +331,11 @@ def extmake(target)
318331 if File . exist? ( "./Makefile" )
319332 if $install
320333 system "nmake install"
334+ if File . directory? "./lib"
335+ for i in Dir [ "./lib/*.rb" ]
336+ system "ginstall -c #{ i } /usr/local/lib/ruby/i386-mswin32"
337+ end
338+ end
321339 elsif $clean
322340 system "nmake clean"
323341 else
@@ -386,15 +404,17 @@ if $extlist.size > 0
386404 #for s,t in $extlist
387405 for s , t in $static_ext
388406 #f = format("%s/%s.obj", s, t)
389- f = format ( "%s/%s.obj" , s , s )
407+ #f = format("%s/%s.obj", s, s)
408+ l = format ( "%s/%s.lib" , s , s )
390409 #print format("%s/%s.obj\n", s, s) ##debug print##
391- if File . exist? ( f )
410+ if File . exist? ( l )
392411 $extinit += format ( "\
393412\t Init_%s();\n \
394413\t rb_provide(\" %s.o\" );\n \
395414 ", s , s )
396415 $extobjs += "ext/"
397- $extobjs += f
416+ #$extobjs += f # *.obj
417+ $extobjs += l # *.lib
398418 $extobjs += " "
399419 else
400420 FALSE
@@ -431,6 +451,30 @@ else
431451 end
432452end
433453
454+ #template of .def file.
455+ #LIBRARY kconv.dll
456+ #CODE LOADONCALL
457+ #DATA LOADONCALL
458+ #DESCRIPTION 'win32 kconv.dll'
459+ #EXPORTS
460+ #
461+ # Init_kconv
462+ def makedef ( basename )
463+ defname = sprintf ( "%s.def" , basename )
464+ f = open ( defname , "w" )
465+ f . printf "\
466+ LIBRARY %s.dll
467+ CODE LOADONCALL
468+ DATA LOADONCALL
469+ DESCRIPTION 'win32 %s.dll'
470+ EXPORTS
471+
472+ Init_%s
473+ " , basename , basename
474+ f . close
475+
476+ end
477+
434478#Local variables:
435479# mode: ruby
436480#end:
0 commit comments