Resync with mainline
[p5sagit/p5-mst-13.2.git] / os2 / Makefile.SHs
index fd3766e..3a50dc7 100644 (file)
@@ -6,19 +6,21 @@
 # Additional rules supported: perl_, aout_test, aout_install, use them
 # for a.out style perl (which may fork).
 
-perl_version="5.00${PATCHLEVEL}_$SUBVERSION"
+perl_fullversion="5.00${PERL_VERSION}_$PERL_SUBVERSION"
 case "$archname" in
- *-thread)     dll_post=_thr 
-               perl_version="${perl_version}-threaded";;
- *)            dll_post='' ;;
+ *-thread*)    perl_fullversion="${perl_fullversion}-threaded";;
 esac
 
+dll_post="`echo $perl_fullversion | sum | sed -e 's/^0*//' | awk '{print $1}'`"
+dll_post="`printf '%x' $dll_post | tr '[a-z]' '[A-Z]'`"
+
 $spitshell >>Makefile <<!GROK!THIS!
 
-PERL_VERSION = $perl_version
+PERL_FULLVERSION = $perl_fullversion
 
-AOUT_OPTIMIZE = $optimize
-AOUT_CCCMD     = \$(CC) $aout_ccflags \$(AOUT_OPTIMIZE)
+OPTIMIZE       = $optimize
+AOUT_OPTIMIZE  = \$(OPTIMIZE)
+AOUT_CCCMD     = \$(CC) -DPERL_CORE $aout_ccflags \$(AOUT_OPTIMIZE)
 AOUT_AR                = $aout_ar
 AOUT_OBJ_EXT   = $aout_obj_ext
 AOUT_LIB_EXT   = $aout_lib_ext
@@ -33,6 +35,8 @@ LD_OPT                = $optimize
 
 PERL_DLL_BASE  = perl$dll_post
 PERL_DLL       = \$(PERL_DLL_BASE)\$(DLSUFFIX)
+TEST_PERL_DLL  = perl_dll_t
+CONFIG_ARGS    = $config_args
 
 !GROK!THIS!
 
@@ -50,12 +54,19 @@ perl.imp: perl5.def
        echo    'emx_malloc             emxlibcm        402     ?' >> $@
        echo    'emx_realloc            emxlibcm        403     ?' >> $@
 
+perl_dll: $(PERL_DLL)
+
+perl_dll_t: t/$(PERL_DLL)
+
+t/$(PERL_DLL): $(PERL_DLL)
+       $(LNS) $(PERL_DLL) t/$(PERL_DLL)
+
 $(PERL_DLL): $(obj) perl5.def perl$(OBJ_EXT)
-       $(LD) $(LD_OPT) $(LDDLFLAGS) -o $@ perl$(OBJ_EXT) $(obj) $(libs) perl5.def
+       $(LD) $(LD_OPT) $(LDDLFLAGS) -o $@ perl$(OBJ_EXT) $(obj) $(libs) perl5.def || ( rm $(PERL_DLL) && sh -c false )
 
-perl5.def: perl.linkexp
+perl5.olddef: perl.linkexp
        echo "LIBRARY '$(PERL_DLL_BASE)' INITINSTANCE TERMINSTANCE"     > $@
-       echo DESCRIPTION "'Perl interpreter v$(PERL_VERSION), export autogenerated'"    >>$@
+       echo DESCRIPTION "'Perl interpreter v$(PERL_FULLVERSION), export autogenerated, built with $(CONFIG_ARGS)'"     >>$@
        echo STACKSIZE 32768                            >>$@
        echo CODE LOADONCALL                            >>$@
        echo DATA LOADONCALL NONSHARED MULTIPLE         >>$@
@@ -85,11 +96,9 @@ perl.linkexp: perl.exports perl.map  os2/os2.sym
 
 # We link miniperl statically, since .DLL depends on $(DYNALOADER) 
 
-perl.map miniperl: $(obj) perl$(OBJ_EXT) miniperlmain$(OBJ_EXT)
-       $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) perl$(OBJ_EXT) $(obj) $(libs) -Zmap -Zlinker /map
-       awk '{if ($$3 == "") print $$2}' <miniperl.map | sort | uniq > perl.map
-       rm miniperl.map
-       @./miniperl -w -Ilib -MExporter -e 0 || $(MAKE) minitest
+miniperl.map miniperl: $(obj) perl$(OBJ_EXT) miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT)
+       $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) perl$(OBJ_EXT) `echo $(obj)|sed -e 's/\bop\./opmini./g'` $(libs) -Zmap -Zlinker /map/PM:VIO
+       @./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
 
 depend: os2ish.h dlfcn.h os2thread.h os2.c
 
@@ -116,6 +125,14 @@ dlfcn.h: os2/dlfcn.h
 perl___: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
        $(SHRPENV) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl___ perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs)
 
+# This one is compiled -Zsys, so cannot do many things:
+
+# Remove -Zcrtdll, add -Zsys
+SYS_CLDFLAGS = -Zexe -Zomf -Zmt -Zsys -Zstack 32000
+
+perl_sys: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
+       $(SHRPENV) $(CC) $(LARGE) $(SYS_CLDFLAGS) $(CCDLFLAGS) -o perl_sys perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs)
+
 installcmd : 
        perl -e 'die qq{Give the option INSTALLCMDDIR=... to make!} if $$ARGV[0] eq ""' $(INSTALLCMDDIR)
        perl os2/perl2cmd.pl $(INSTALLCMDDIR)
@@ -145,6 +162,9 @@ $(AOUT_LIBPERL) : $(aout_obj) perl$(AOUT_OBJ_EXT)
 .c$(AOUT_OBJ_EXT):
        $(AOUT_CCCMD) $(PLDLFLAGS) -c $*.c
 
+opmini$(AOUT_OBJ_EXT): op.c
+       $(AOUT_CCCMD) $(PLDLFLAGS) -DPERL_EXTERNAL_GLOB -o opmini$(AOUT_OBJ_EXT) -c op.c
+
 perlmain(AOUT_OBJ_EXT): perlmain.c
        $(AOUT_CCCMD_DLL) $(PLDLFLAGS) -c perlmain.c
 
@@ -152,8 +172,8 @@ aout_perlmain.c: miniperlmain.c config.sh makefile $(static_ext_autoinit)
        sh writemain $(DYNALOADER) $(aout_static_lib) > tmp
        sh mv-if-diff tmp aout_perlmain.c
 
-miniperl_: $& miniperlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) ext.libs
-       $(CC) $(LARGE) $(AOUT_CLDFLAGS) $(CCDLFLAGS) -o miniperl_ miniperlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) `cat ext.libs` $(libs)
+miniperl_: $& miniperlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) opmini$(AOUT_OBJ_EXT)
+       $(CC) $(LARGE) $(AOUT_CLDFLAGS) $(CCDLFLAGS) -o miniperl_ miniperlmain$(AOUT_OBJ_EXT) opmini$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) $(libs)
 
 perl_: $& aout_perlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) $(AOUT_DYNALOADER) $(aout_static_ext) ext.libs
        $(CC) $(LARGE) $(AOUT_CLDFLAGS) $(CCDLFLAGS) -o perl_ aout_perlmain$(AOUT_OBJ_EXT) $(AOUT_DYNALOADER) $(aout_static_ext) $(AOUT_LIBPERL) `cat ext.libs` $(libs)
@@ -181,18 +201,55 @@ aout_install.perl: perl_ installperl
 aout_test: perl_
        - cd t && (rm -f perl_$(EXE_EXT); $(LNS) ../perl_$(EXE_EXT) perl$(EXE_EXT)) && ./perl TEST </dev/tty
 
-lib/auto/OS2/*/%.a : ext/OS2/%/Makefile.aout
-       cd ext/OS2/$(basename $(notdir $@)) ; make -f Makefile.aout config || echo "$make config failed, continuing anyway..."
-       cd ext/OS2/$(basename $(notdir $@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
+# To test with harness, set HARNESS_BAD_EXITCODE=2
 
-lib/auto/*/%.a : ext/%/Makefile.aout
-       cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout config || echo "$make config failed, continuing anyway..."
-       cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
+sys_test: perl_sys
+       - cd t && (rm -f perl_$(EXE_EXT); $(LNS) ../perl_sys$(EXE_EXT) perl$(EXE_EXT)) && ./perl TEST </dev/tty
+
+sys_harness: perl_sys
+       - cd t && (rm -f perl_$(EXE_EXT); $(LNS) ../perl_sys$(EXE_EXT) perl$(EXE_EXT)) && env HARNESS_BAD_EXITCODE=2 ./perl harness </dev/tty
+
+!NO!SUBS!
 
-.PRECIOUS : ext/%/Makefile.aout ext/OS2/%/Makefile.aout
+# Now we need to find directories in ./ext/ which are two level deep
+
+dirs=''
+preci='ext/%/Makefile.aout '
+for d in ext/*
+do
+       # echo "Checking '$d'..."
+       f="`echo $d/*/Makefile.PL`"
+       # SDBFile/sdbm, skip kid makefile
+       if test ! -e "$d/Makefile.PL" -a ! "$f" = ""; then
+           dirs="$dirs $d"
+           preci="$preci $d/%/Makefile.aout"
+       fi
+done
 
-ext/OS2/%/Makefile.aout : miniperl_
-       cd $(dir $@) ; ../../../miniperl_ -I ../../../lib Makefile.PL MAKEFILE=Makefile.aout INSTALLDIRS=perl 
+$spitshell >>Makefile <<!GROK!THIS!
+.PRECIOUS : $preci
+
+!GROK!THIS!
+
+for d in $dirs
+do
+    p=`basename $d`
+    $spitshell >>Makefile <<!GROK!THIS!
+lib/auto/$p/*/%.a : ext/$p/%/Makefile.aout
+       @cd ext/$p/\$(basename \$(notdir \$@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
+       cd ext/$p/\$(basename \$(notdir \$@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
+
+$d/%/Makefile.aout : miniperl_
+       cd \$(dir \$@) ; ../../../miniperl_ -I ../../../lib Makefile.PL MAKEFILE=Makefile.aout INSTALLDIRS=perl 
+
+!GROK!THIS!
+
+done
+
+$spitshell >>Makefile <<'!NO!SUBS!'
+lib/auto/*/%.a : ext/%/Makefile.aout
+       @cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
+       cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
 
 ext/%/Makefile.aout : miniperl_
        cd $(dir $@) ; ../../miniperl_ -I ../../lib Makefile.PL MAKEFILE=Makefile.aout INSTALLDIRS=perl