1 # This file is read by Makefile.SH to produce rules for $(LIBPERL) (and
2 # some additional rules as well).
4 # Rerun `sh Makefile.SH; make depend' after making any change.
6 # Additional rules supported: perl_, aout_test, aout_install, use them
7 # for a.out style perl (which may fork).
9 perl_fullversion="5.00${PERL_VERSION}_$PERL_SUBVERSION"
11 *-thread*) perl_fullversion="${perl_fullversion}-threaded";;
14 dll_post="`echo $perl_fullversion | sum | sed -e 's/^0*//' | awk '{print $1}'`"
15 dll_post="`printf '%x' $dll_post | tr '[a-z]' '[A-Z]'`"
19 for xxx in $aout_extra_static_ext; do
20 aout_extra_dir=`echo "$xxx" | sed -e 's/::/\//g'`
21 aout_extra_lib="lib/auto/$aout_extra_dir/"`basename "$aout_extra_dir"`
22 aout_extra_libs="$aout_extra_libs$aout_extra_sep$aout_extra_lib$aout_lib_ext"
26 $spitshell >>Makefile <<!GROK!THIS!
28 PERL_FULLVERSION = $perl_fullversion
30 AOUT_OPTIMIZE = \$(OPTIMIZE)
31 AOUT_CCCMD = \$(CC) -DPERL_CORE $aout_ccflags \$(AOUT_OPTIMIZE)
33 AOUT_OBJ_EXT = $aout_obj_ext
34 AOUT_LIB_EXT = $aout_lib_ext
35 AOUT_LIBPERL = libperl$aout_lib_ext
36 AOUT_CLDFLAGS = $aout_ldflags
38 AOUT_LIBPERL_DLL = libperl_dll$aout_lib_ext
39 AOUT_CCCMD_DLL = \$(CC) -DDOSISH -DOS2=2 -DEMBED -I. -DPACK_MALLOC -DDEBUGGING_MSTATS -DTWO_POT_OPTIMIZE -DPERL_EMERGENCY_SBRK
40 AOUT_CLDFLAGS_DLL = -Zexe -Zmt -Zcrtdll -Zstack 32000
43 SO_CCCMD = \$(CC) $ccflags \$(OPTIMIZE)
46 PERL_DLL_LD_OPT = -Zmap -Zlinker /map/li
48 PERL_DLL_BASE = perl$dll_post
49 PERL_DLL = \$(PERL_DLL_BASE)\$(DLSUFFIX)
50 TEST_PERL_DLL = perl_dll_t
51 CONFIG_ARGS = $config_args
52 AOUT_EXTRA_LIBS = $aout_extra_libs
56 $spitshell >>Makefile <<'!NO!SUBS!'
57 PREPLIBRARY_LIBPERL = $(LIBPERL)
58 $(LIBPERL): perl.imp perl5.def libperl_override.lib
59 emximp -o $(LIBPERL) perl.imp
60 cp $(LIBPERL) perl.lib
62 imp_version: $(FIRSTMAKEFILE)
63 echo $(PERL_DLL_BASE) > $@
65 libperl_override.imp: os2/os2add.sym miniperl imp_version
66 ./miniperl -wnle 'print "$$_\t$(PERL_DLL_BASE)\t$$_\t?"' os2/os2add.sym > $@
67 echo 'strdup $(PERL_DLL_BASE) Perl_strdup ?' >> $@
68 echo 'putenv $(PERL_DLL_BASE) Perl_putenv ?' >> $@
70 libperl_override.lib: libperl_override.imp
71 emximp -o $@ libperl_override.imp
73 libperl_dllmain.imp: imp_version
74 echo 'main $(PERL_DLL_BASE) dll_perlmain ?' >> $@
76 libperl_dllmain.lib: libperl_dllmain.imp
77 emximp -o $@ libperl_dllmain.imp
79 libperl_dllmain.a: libperl_dllmain.imp
80 emximp -o $@ libperl_dllmain.imp
82 $(AOUT_LIBPERL_DLL): perl.imp $(PERL_DLL) perl5.def
83 emximp -o $(AOUT_LIBPERL_DLL) perl.imp
85 perl.imp: perl5.def imp_version
86 emximp -o perl.imp perl5.def
87 echo 'emx_calloc emxlibcm 400 ?' >> $@
88 echo 'emx_free emxlibcm 401 ?' >> $@
89 echo 'emx_malloc emxlibcm 402 ?' >> $@
90 echo 'emx_realloc emxlibcm 403 ?' >> $@
92 .PHONY: perl_dll installcmd aout_clean aout_install aout_install.perl \
93 perlrexx test_prep_perl_ test_prep_perl_sys test_prep_perl_stat \
94 test_prep_perl_stat_aout test_prep_various \
95 stat_aout_harness aout_harness stat_harness sys_harness all_harness \
96 stat_aout_test aout_test stat_test sys_test all_test \
97 perl___harness test_harness_redir
101 perl_dll_t: t/$(PERL_DLL)
103 t/$(PERL_DLL): $(PERL_DLL)
104 $(LNS) $(PERL_DLL) t/$(PERL_DLL)
106 $(PERL_DLL): $(obj) perl5.def perl$(OBJ_EXT) perlmain$(OBJ_EXT) $(DYNALOADER)
107 $(LD) $(LD_OPT) $(LDDLFLAGS) $(PERL_DLL_LD_OPT) -o $@ perl$(OBJ_EXT) $(obj) perlmain$(OBJ_EXT) $(DYNALOADER) $(libs) perl5.def || ( rm $(PERL_DLL) && sh -c false )
109 perl5.olddef: perl.linkexp
110 echo "LIBRARY '$(PERL_DLL_BASE)' INITINSTANCE TERMINSTANCE" > $@
111 echo DESCRIPTION "'Perl interpreter v$(PERL_FULLVERSION), export autogenerated'" >>$@
112 echo STACKSIZE 32768 >>$@
113 echo CODE LOADONCALL >>$@
114 echo DATA LOADONCALL NONSHARED MULTIPLE >>$@
118 if [ ! -z "$myttyname" ] ; then
119 $spitshell >>Makefile <<'!NO!SUBS!'
120 echo ' "ttyname"' >>$@
124 $spitshell >>Makefile <<'!NO!SUBS!'
125 cat perl.linkexp >>$@
127 # grep -v '"\(malloc\|realloc\|free\)"' perl.linkexp >>$@
130 perl.exports: perl.exp EXTERN.h perl.h
131 (echo "#include \"EXTERN.h\" \n#include \"perl.h\" \n#include \"perl.exp\""; \
132 echo "malloc\nrealloc\ncalloc\nfree") | \
133 $(CC) -DEMBED -E - | \
134 awk '{if ($$2 == "") print $$1}' | sort | uniq > $@
136 perl.linkexp: perl.exports perl.map os2/os2.sym
137 cat perl.exports os2/os2.sym perl.map | sort | uniq -d | sed -e 's/\w\+/ "\0"/' > perl.linkexp
139 # We link miniperl statically, since .DLL depends on $(DYNALOADER)
141 miniperl.map: miniperl
143 miniperl.exe: miniperl
145 miniperl: $(obj) perl$(OBJ_EXT) miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT)
146 $(CC) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) perl$(OBJ_EXT) `echo $(obj)|sed -e 's/\bop\./opmini./g'` $(libs) -Zmap -Zlinker /map/PM:VIO
147 @./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
149 depend: os2ish.h dlfcn.h os2thread.h os2.c
151 # Stupid make? Needed...
152 os2$(OBJ_EXT) : os2.c
154 os2.c: os2/os2.c os2ish.h
157 dl_os2.c: os2/dl_os2.c os2ish.h
160 os2ish.h: os2/os2ish.h
163 os2thread.h: os2/os2thread.h
169 # Non-Forking dynamically loaded perl
170 # Make many: they are useful in low-memory conditions (floppy boot? Lot of shared memory used?)
172 perl___$(EXE_EXT) perl___: $& libperl_dllmain$(LIB_EXT)
173 $(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl___ libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
174 $(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 8192 -o perl___8 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
175 $(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 4096 -o perl___4 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
176 $(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 2048 -o perl___2 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
177 $(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 1024 -o perl___1 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
178 $(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 512 -o perl___05 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
179 $(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 320 -o perl___03 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
181 # This one is compiled -Zsys, so cannot do many things:
184 STAT_CLDFLAGS = -Zexe -Zomf -Zmt -Zstack 32000
186 # Non-forking dynamically loaded perl with a wrong CRT library:
188 perl_stat perl_stat$(EXE_EXT): $& libperl_dllmain$(LIB_EXT)
189 $(SHRPENV) $(CC) $(STAT_CLDFLAGS) $(CCDLFLAGS) -o perl_stat libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
191 # Remove -Zcrtdll, add -Zsys
192 SYS_CLDFLAGS = $(STAT_CLDFLAGS) -Zsys
194 # Non-Forking dynamically loaded perl without EMX - so with wrong CRT library
196 perl_sys perl_sys$(EXE_EXT): $& libperl_dllmain$(LIB_EXT)
197 $(SHRPENV) $(CC) $(SYS_CLDFLAGS) $(CCDLFLAGS) -o perl_sys libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
200 @perl -e 'die qq{Give the option INSTALLCMDDIR=... to make!} if $$ARGV[0] eq ""' $(INSTALLCMDDIR)
201 ./miniperl -Ilib os2/perl2cmd.pl $(INSTALLCMDDIR)
205 aout_obj = $(addsuffix $(AOUT_OBJ_EXT),$(basename $(obj)))
206 AOUT_DYNALOADER = $(addsuffix $(AOUT_LIB_EXT),$(basename $(DYNALOADER)))
207 aout_ext = $(static_ext) $(dynamic_ext) $(AOUT_EXTRA_LIBS)
208 aout_static_ext = $(addsuffix $(AOUT_LIB_EXT),$(basename $(aout_ext)))
209 aout_static_lib = $(addsuffix $(LIB_EXT),$(basename $(aout_ext)))
211 aout_static_ext_dll = $(addsuffix $(AOUT_LIB_EXT),$(basename $(static_ext)))
212 DYNALOADER_OBJ = ext/DynaLoader/DynaLoader$(OBJ_EXT)
213 aout_static_ext_dll = $(addsuffix $(AOUT_LIB_EXT),$(basename $(static_ext)))
214 AOUT_DYNALOADER_OBJ = $(addsuffix $(AOUT_OBJ_EXT),$(basename $(DYNALOADER_OBJ)))
216 $(AOUT_DYNALOADER_OBJ) : $(DYNALOADER_OBJ)
219 $(DYNALOADER_OBJ) : $(DYNALOADER)
222 $(AOUT_LIBPERL) : $(aout_obj) perl$(AOUT_OBJ_EXT)
224 $(AOUT_AR) rcu $@ perl$(AOUT_OBJ_EXT) $(aout_obj)
225 cp $@ perl$(AOUT_LIB_EXT)
228 $(AOUT_CCCMD) $(PLDLFLAGS) -c $*.c
230 opmini$(AOUT_OBJ_EXT): op.c
231 $(AOUT_CCCMD) $(PLDLFLAGS) -DPERL_EXTERNAL_GLOB -o opmini$(AOUT_OBJ_EXT) -c op.c
233 perlmain(AOUT_OBJ_EXT): perlmain.c
234 $(AOUT_CCCMD_DLL) $(PLDLFLAGS) -c perlmain.c
236 # Assume that extensions are at most 4 deep (this is so with 5.8.1)
237 aout_extlist: $(aout_static_ext) $(AOUT_DYNALOADER)
238 echo lib/auto/*.a lib/auto/*/*.a lib/auto/*/*/*.a lib/auto/*/*/*/*.a | tr ' ' '\n' | grep -v '\*' > $@
240 aout_perlmain.c: miniperlmain.c config.sh makefile $(static_ext_autoinit) $(aout_static_ext) writemain aout_extlist
241 sh writemain `cat aout_extlist` > aout_perlmain.c
243 _preplibrary = miniperl lib/Config.pm lib/lib.pm lib/re.pm
245 miniperl_: $& miniperlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) opmini$(AOUT_OBJ_EXT) $(_preplibrary)
246 $(CC) $(AOUT_CLDFLAGS) $(CCDLFLAGS) -o miniperl_ miniperlmain$(AOUT_OBJ_EXT) opmini$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) $(libs)
248 # Forking statically loaded perl
250 # Need a miniperl_ dependency, since $(AOUT_DYNALOADER) is build via implicit
251 # rules, thus would not rebuild miniperl_ via an explicit rule
253 perl_$(EXE_EXT) perl_: $& miniperl_ aout_perlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) $(AOUT_DYNALOADER) $(aout_static_ext) ext.libs aout_extlist
254 $(CC) $(AOUT_CLDFLAGS) $(CCDLFLAGS) $(OPTIMIZE) -o perl_ aout_perlmain$(AOUT_OBJ_EXT) `cat aout_extlist` $(AOUT_LIBPERL) `cat ext.libs` $(libs)
257 STAT_AOUT_CLDFLAGS = -Zexe -Zmt -Zstack 32000
259 # Forking dynamically loaded perl with a wrong CRT library:
261 perl_stat_aout$(EXE_EXT) perl_stat_aout: $& libperl_dllmain$(AOUT_LIB_EXT)
262 $(SHRPENV) $(CC) $(STAT_AOUT_CLDFLAGS) $(CCDLFLAGS) $(OPTIMIZE) -o perl_stat_aout libperl_dllmain$(AOUT_LIB_EXT)
264 PERLREXX_DLL = perlrexx.dll
266 perl perl$(EXE_EXT) : perl__ perl___ $(PERLREXX_DLL) $(PERL_DLL)
268 # Dynamically loaded PM-application perl:
270 perl__$(EXE_EXT) perl__: $& libperl_dllmain$(LIB_EXT)
271 $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl__ libperl_dllmain$(LIB_EXT) -Zlinker /PM:PM
273 # Forking dynamically loaded perl:
275 perl$(EXE_EXT) perl: $& libperl_dllmain$(AOUT_LIB_EXT)
276 $(CC) $(AOUT_CLDFLAGS_DLL) $(CCDLFLAGS) -o perl libperl_dllmain$(AOUT_LIB_EXT)
281 -rm *perl_.* *.o *.a lib/auto/*/*.a lib/auto/*/*/*.a lib/auto/*/*/*/*.a ext/*/Makefile.aout ext/*/*/Makefile.aout ext/*/*/*/Makefile.aout
283 aout_install: perl_ aout_install.perl
285 aout_install.perl: perl_ installperl
286 ./perl_ installperl --destdir="$(DESTDIR)"
288 perlrexx: $(PERLREXX_DLL)
291 perlrexx.c: os2/perlrexx.c
294 # Remove -Zexe, add -Zdll -Zso. No stack needed
295 SO_CLDFLAGS = -Zdll -Zso -Zomf -Zmt -Zsys
297 # A callable-from-REXX DLL
299 $(PERLREXX_DLL): perlrexx$(OBJ_EXT) perlrexx.def
300 $(SHRPENV) $(CC) $(SO_CLDFLAGS) $(CCDLFLAGS) -o $@ perlrexx$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs) perlrexx.def
302 perlrexx.def: miniperl $(_preplibrary)
303 echo "LIBRARY 'perlrexx' INITINSTANCE TERMINSTANCE" > $@
304 echo "DESCRIPTION '@#perl5-porters@perl.org:`miniperl -Ilib -MConfig -e 'print \$$]'`#@ REXX to Perl `miniperl -Ilib -MConfig -e 'print \$$Config{version}'` interface'" >> $@
307 echo ' "PERLTERM"' >> $@
308 echo ' "PERLINIT"' >> $@
309 echo ' "PERLEXIT"' >> $@
310 echo ' "PERLEVAL"' >> $@
311 echo ' "PERLLASTERROR"' >> $@
312 echo ' "PERLEVALSUBCOMMAND"' >> $@
313 echo ' "PERLEXPORTALL"' >> $@
314 echo ' "PERLDROPALL"' >> $@
315 echo ' "PERLDROPALLEXIT"' >> $@
318 perlrexx$(OBJ_EXT): perlrexx.c
319 $(SO_CCCMD) $(PLDLFLAGS) -c perlrexx.c
321 # To test with harness, one needed to HARNESS_IGNORE_EXITCODE=2
323 # Define to be empty to get a TTY test
324 REDIR_TEST = 2>&1 | tee 00_$@
326 test_prep_perl_: test_prep_pre miniperl_ ./perl_$(EXE_EXT)
327 PERL=./perl_ $(MAKE) _test_prep
329 test_prep_various: test_prep_pre miniperl $(dynamic_ext) $(TEST_PERL_DLL)
331 test_prep_perl_sys: test_prep_various ./perl_sys$(EXE_EXT)
332 PERL=./perl_sys $(MAKE) _test_prep
334 test_prep_perl___: test_prep_various ./perl___$(EXE_EXT)
335 PERL=./perl___ $(MAKE) _test_prep
337 test_prep_perl_stat: test_prep_various ./perl_stat$(EXE_EXT)
338 PERL=./perl_stat $(MAKE) _test_prep
340 test_prep_perl_stat_aout: test_prep_various ./perl_stat_aout$(EXE_EXT)
341 PERL=./perl_stat_aout $(MAKE) _test_prep
343 aout_test: test_prep_perl_
344 PERL=./perl_ $(MAKE) _test
346 aout_harness: test_prep_perl_
347 -PERL=./perl_ $(MAKE) TESTFILE=harness _test $(REDIR_TEST)
349 sys_test: test_prep_perl_sys
350 PERL=./perl_sys $(MAKE) _test
352 sys_harness: test_prep_perl_sys
353 -PERL=./perl_sys $(MAKE) TESTFILE=harness _test $(REDIR_TEST)
355 stat_test: test_prep_perl_stat
356 PERL=./perl_stat $(MAKE) _test
358 stat_harness: test_prep_perl_stat
359 -PERL=./perl_stat $(MAKE) TESTFILE=harness _test $(REDIR_TEST)
361 stat_aout_test: test_prep_perl_stat_aout
362 PERL=./perl_stat_aout $(MAKE) _test
364 stat_aout_harness: test_prep_perl_stat_aout
365 -PERL=./perl_stat_aout $(MAKE) TESTFILE=harness _test $(REDIR_TEST)
367 perl___test: test_prep_perl___
368 PERL=./perl___ $(MAKE) _test
370 perl___harness: test_prep_perl___
371 -PERL=./perl___ $(MAKE) TESTFILE=harness _test $(REDIR_TEST)
373 all_test: test aout_test perl___test sys_test stat_test stat_aout_test
375 test_harness_redir: test_prep
376 -PERL=./perl $(MAKE) TESTFILE=harness _test $(REDIR_TEST)
378 all_harness: test_harness_redir aout_harness perl___harness sys_harness stat_harness stat_aout_harness
382 # Now we need to find directories in ./ext/ which are up to 3 level deep
383 # Currently (2001/06) there is no directories 4 levels deep.
384 # (Only directories so that there is no Makefile.PL some levels up matter.)
388 preci='ext/%/Makefile.aout '
391 # echo "...Checking '$d'..."
392 # skip the kid if the parent exists: cmp SDBFile/sdbm, done by MakeMaker
393 if test ! -e "$d/Makefile.PL"; then
394 # Need to treat subdirectories manually
395 # echo "...Checking subdirs of '$d'..."
399 if test ! -d $dd; then
402 if test -e "$dd/Makefile.PL"; then
403 if test "X$d_treated" = "X"; then
405 # echo "...Found parentless 2-level deep Makefile.PL's in $d/*/:" $d/*/Makefile.PL
407 preci="$preci $d/%/Makefile.aout"
410 # Need to treat subsubdirectories manually
412 for ddd in $dd/* # ext/*/*/*/Makefile.PL
414 if test ! -d $ddd; then
417 if test -e "$ddd/Makefile.PL"; then
418 if test "X$dd_treated" = "X"; then
420 # echo "...Found parentless 3-level deep Makefile.PL's in $dd/*/:" $dd/*/Makefile.PL
422 preci="$preci $dd/%/Makefile.aout"
431 # ext/threads is marked as NORECURS, so we need to specialcase it
432 if echo "$static_ext $dynamic_ext" | grep -q threads/shared ; then
433 preci="$preci ext/threads/%/Makefile.aout"
434 dirs="$dirs ext/threads"
437 $spitshell >>Makefile <<!GROK!THIS!
440 # Set this to FORCE to force a rebuilt of aout extensions
442 AOUT_EXTENSIONS_FORCE =
448 # Remove the leading component ext/
452 $spitshell >>Makefile <<!GROK!THIS!
453 lib/auto/$p/*/%.a : $d/%/Makefile.aout
454 @cd $d/\$(basename \$(notdir \$@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
455 cd $d/\$(basename \$(notdir \$@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
457 $d/%/Makefile.aout : miniperl_ \$(_preplibrary) \$(AOUT_EXTENSIONS_FORCE)
458 cd \$(dir \$@) ; ../../../../miniperl_ -I ../../../../lib Makefile.PL FIRST_MAKEFILE=Makefile.aout INSTALLDIRS=perl PERL_CORE=1
467 $spitshell >>Makefile <<!GROK!THIS!
468 lib/auto/$p/*/%.a : $d/%/Makefile.aout
469 @cd $d/\$(basename \$(notdir \$@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
470 cd $d/\$(basename \$(notdir \$@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
472 $d/%/Makefile.aout : miniperl_ \$(_preplibrary) \$(AOUT_EXTENSIONS_FORCE)
473 cd \$(dir \$@) ; ../../../miniperl_ -I ../../../lib Makefile.PL FIRST_MAKEFILE=Makefile.aout INSTALLDIRS=perl PERL_CORE=1
479 # We need to special-case OS2/DLL/DLL.a, since the recipe above will
480 # try to find it in ext/OS2/DLL
482 $spitshell >>Makefile <<'!NO!SUBS!'
483 lib/auto/OS2/DLL/DLL.a : lib/auto/OS2/REXX/REXX.a
486 lib/auto/*/%.a : ext/%/Makefile.aout
487 @cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
488 cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
490 ext/%/Makefile.aout : miniperl_ $(_preplibrary) $(AOUT_EXTENSIONS_FORCE)
491 cd $(dir $@) ; ../../miniperl_ -I ../../lib Makefile.PL FIRST_MAKEFILE=Makefile.aout INSTALLDIRS=perl PERL_CORE=1