Add fallback to tmpfile for use in cases where user's relying on
[p5sagit/p5-mst-13.2.git] / os2 / Makefile.SHs
CommitLineData
f9c39ab5 1# This file is read by Makefile.SH to produce rules for $(LIBPERL) (and
e95c8f0e 2# some additional rules as well).
3
4# Rerun `sh Makefile.SH; make depend' after making any change.
5
6# Additional rules supported: perl_, aout_test, aout_install, use them
7# for a.out style perl (which may fork).
8
cceca5ed 9perl_fullversion="5.00${PERL_VERSION}_$PERL_SUBVERSION"
3aefca04 10case "$archname" in
cceca5ed 11 *-thread*) perl_fullversion="${perl_fullversion}-threaded";;
3aefca04 12esac
13
3cfae81b 14dll_post="`echo $perl_fullversion | sum | sed -e 's/^0*//' | awk '{print $1}'`"
017f25f1 15dll_post="`printf '%x' $dll_post | tr '[a-z]' '[A-Z]'`"
16
e95c8f0e 17$spitshell >>Makefile <<!GROK!THIS!
18
cceca5ed 19PERL_FULLVERSION = $perl_fullversion
3aefca04 20
e96326af 21OPTIMIZE = $optimize
6756f2f0 22AOUT_OPTIMIZE = \$(OPTIMIZE)
146174a9 23AOUT_CCCMD = \$(CC) -DPERL_CORE $aout_ccflags \$(AOUT_OPTIMIZE)
e95c8f0e 24AOUT_AR = $aout_ar
25AOUT_OBJ_EXT = $aout_obj_ext
26AOUT_LIB_EXT = $aout_lib_ext
f9c39ab5 27AOUT_LIBPERL = libperl$aout_lib_ext
e95c8f0e 28AOUT_CLDFLAGS = $aout_ldflags
29
dd3366de 30AOUT_LIBPERL_DLL = libperl_dll$aout_lib_ext
72ea3524 31AOUT_CCCMD_DLL = \$(CC) -DDOSISH -DOS2=2 -DEMBED -I. -DPACK_MALLOC -DDEBUGGING_MSTATS -DTWO_POT_OPTIMIZE -DPERL_EMERGENCY_SBRK
491527d0 32AOUT_CLDFLAGS_DLL = -Zexe -Zmt -Zcrtdll -Zstack 32000
dd3366de 33
84902520 34LD_OPT = $optimize
35
3aefca04 36PERL_DLL_BASE = perl$dll_post
37PERL_DLL = \$(PERL_DLL_BASE)\$(DLSUFFIX)
d6a255e6 38TEST_PERL_DLL = perl_dll_t
017f25f1 39CONFIG_ARGS = $config_args
3aefca04 40
e95c8f0e 41!GROK!THIS!
82835e01 42
43$spitshell >>Makefile <<'!NO!SUBS!'
cb50131a 44$(LIBPERL): perl.imp $(PERL_DLL) perl5.def
f9c39ab5 45 emximp -o $(LIBPERL) perl.imp
82835e01 46
3aefca04 47$(AOUT_LIBPERL_DLL): perl.imp $(PERL_DLL) perl5.def
dd3366de 48 emximp -o $(AOUT_LIBPERL_DLL) perl.imp
49
82835e01 50perl.imp: perl5.def
51 emximp -o perl.imp perl5.def
df3ef7a9 52 echo 'emx_calloc emxlibcm 400 ?' >> $@
53 echo 'emx_free emxlibcm 401 ?' >> $@
54 echo 'emx_malloc emxlibcm 402 ?' >> $@
55 echo 'emx_realloc emxlibcm 403 ?' >> $@
82835e01 56
017f25f1 57perl_dll: $(PERL_DLL)
58
d6a255e6 59perl_dll_t: t/$(PERL_DLL)
60
61t/$(PERL_DLL): $(PERL_DLL)
62 $(LNS) $(PERL_DLL) t/$(PERL_DLL)
63
3aefca04 64$(PERL_DLL): $(obj) perl5.def perl$(OBJ_EXT)
3cfae81b 65 $(LD) $(LD_OPT) $(LDDLFLAGS) -o $@ perl$(OBJ_EXT) $(obj) $(libs) perl5.def || ( rm $(PERL_DLL) && sh -c false )
82835e01 66
3cfae81b 67perl5.olddef: perl.linkexp
3aefca04 68 echo "LIBRARY '$(PERL_DLL_BASE)' INITINSTANCE TERMINSTANCE" > $@
cceca5ed 69 echo DESCRIPTION "'Perl interpreter v$(PERL_FULLVERSION), export autogenerated, built with $(CONFIG_ARGS)'" >>$@
82835e01 70 echo STACKSIZE 32768 >>$@
71 echo CODE LOADONCALL >>$@
72 echo DATA LOADONCALL NONSHARED MULTIPLE >>$@
73 echo EXPORTS >>$@
82835e01 74!NO!SUBS!
75
76if [ ! -z "$myttyname" ] ; then
77 $spitshell >>Makefile <<'!NO!SUBS!'
78 echo ' "ttyname"' >>$@
79!NO!SUBS!
80fi
81
82$spitshell >>Makefile <<'!NO!SUBS!'
83 cat perl.linkexp >>$@
84
85# grep -v '"\(malloc\|realloc\|free\)"' perl.linkexp >>$@
86
87
82835e01 88perl.exports: perl.exp EXTERN.h perl.h
ff68c719 89 (echo "#include \"EXTERN.h\" \n#include \"perl.h\" \n#include \"perl.exp\""; \
90 echo "malloc\nrealloc\ncalloc\nfree") | \
82835e01 91 $(CC) -DEMBED -E - | \
92 awk '{if ($$2 == "") print $$1}' | sort | uniq > $@
93
3aefca04 94perl.linkexp: perl.exports perl.map os2/os2.sym
dd96f567 95 cat perl.exports os2/os2.sym perl.map | sort | uniq -d | sed -e 's/\w\+/ "\0"/' > perl.linkexp
82835e01 96
84902520 97# We link miniperl statically, since .DLL depends on $(DYNALOADER)
98
146174a9 99miniperl.map miniperl: $(obj) perl$(OBJ_EXT) miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT)
100 $(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
101 @./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
82835e01 102
dd96f567 103depend: os2ish.h dlfcn.h os2thread.h os2.c
82835e01 104
105# Stupid make? Needed...
106os2$(OBJ_EXT) : os2.c
107
108os2.c: os2/os2.c os2ish.h
491527d0 109 cp -f $< $@
82835e01 110
e95c8f0e 111dl_os2.c: os2/dl_os2.c os2ish.h
491527d0 112 cp -f $< $@
e95c8f0e 113
82835e01 114os2ish.h: os2/os2ish.h
491527d0 115 cp -f $< $@
82835e01 116
dd96f567 117os2thread.h: os2/os2thread.h
491527d0 118 cp -f $< $@
dd96f567 119
e95c8f0e 120dlfcn.h: os2/dlfcn.h
491527d0 121 cp -f $< $@
e95c8f0e 122
dd3366de 123# This one is compiled OMF, so cannot fork():
124
125perl___: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
126 $(SHRPENV) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl___ perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs)
e95c8f0e 127
53285a48 128# This one is compiled -Zsys, so cannot do many things:
129
130# Remove -Zcrtdll, add -Zsys
131SYS_CLDFLAGS = -Zexe -Zomf -Zmt -Zsys -Zstack 32000
132
133perl_sys: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
134 $(SHRPENV) $(CC) $(LARGE) $(SYS_CLDFLAGS) $(CCDLFLAGS) -o perl_sys perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs)
135
82835e01 136installcmd :
137 perl -e 'die qq{Give the option INSTALLCMDDIR=... to make!} if $$ARGV[0] eq ""' $(INSTALLCMDDIR)
138 perl os2/perl2cmd.pl $(INSTALLCMDDIR)
139
e95c8f0e 140# Aout section:
141
142aout_obj = $(addsuffix $(AOUT_OBJ_EXT),$(basename $(obj)))
143AOUT_DYNALOADER = $(addsuffix $(AOUT_LIB_EXT),$(basename $(DYNALOADER)))
144aout_static_ext = $(addsuffix $(AOUT_LIB_EXT),$(basename $(dynamic_ext)))
145aout_static_lib = $(addsuffix $(LIB_EXT),$(basename $(dynamic_ext)))
146
dd3366de 147aout_static_ext_dll = $(addsuffix $(AOUT_LIB_EXT),$(basename $(static_ext)))
148DYNALOADER_OBJ = ext/DynaLoader/DynaLoader$(OBJ_EXT)
149aout_static_ext_dll = $(addsuffix $(AOUT_LIB_EXT),$(basename $(static_ext)))
150AOUT_DYNALOADER_OBJ = $(addsuffix $(AOUT_OBJ_EXT),$(basename $(DYNALOADER_OBJ)))
151
152$(AOUT_DYNALOADER_OBJ) : $(DYNALOADER_OBJ)
153 emxaout -o $@ $<
154
155$(DYNALOADER_OBJ) : $(DYNALOADER)
156 @sh -c true
157
f9c39ab5 158$(AOUT_LIBPERL) : $(aout_obj) perl$(AOUT_OBJ_EXT)
dd3366de 159 rm -f $@
160 $(AOUT_AR) rcu $@ perl$(AOUT_OBJ_EXT) $(aout_obj)
e95c8f0e 161
162.c$(AOUT_OBJ_EXT):
163 $(AOUT_CCCMD) $(PLDLFLAGS) -c $*.c
164
146174a9 165opmini$(AOUT_OBJ_EXT): op.c
166 $(AOUT_CCCMD) $(PLDLFLAGS) -DPERL_EXTERNAL_GLOB -o opmini$(AOUT_OBJ_EXT) -c op.c
167
dd3366de 168perlmain(AOUT_OBJ_EXT): perlmain.c
169 $(AOUT_CCCMD_DLL) $(PLDLFLAGS) -c perlmain.c
170
e95c8f0e 171aout_perlmain.c: miniperlmain.c config.sh makefile $(static_ext_autoinit)
172 sh writemain $(DYNALOADER) $(aout_static_lib) > tmp
173 sh mv-if-diff tmp aout_perlmain.c
174
146174a9 175miniperl_: $& miniperlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) opmini$(AOUT_OBJ_EXT)
176 $(CC) $(LARGE) $(AOUT_CLDFLAGS) $(CCDLFLAGS) -o miniperl_ miniperlmain$(AOUT_OBJ_EXT) opmini$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) $(libs)
e95c8f0e 177
f9c39ab5 178perl_: $& aout_perlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) $(AOUT_DYNALOADER) $(aout_static_ext) ext.libs
179 $(CC) $(LARGE) $(AOUT_CLDFLAGS) $(CCDLFLAGS) -o perl_ aout_perlmain$(AOUT_OBJ_EXT) $(AOUT_DYNALOADER) $(aout_static_ext) $(AOUT_LIBPERL) `cat ext.libs` $(libs)
e95c8f0e 180
dd3366de 181perl : perl__ perl___
760ac839 182
f9c39ab5 183perl__: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
184 $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl__ perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs) -Zlinker /PM:PM
760ac839 185
dd3366de 186# Forking dynamically loaded perl:
187
188perl: $& perlmain$(AOUT_OBJ_EXT) $(AOUT_DYNALOADER_OBJ) $(aout_static_ext_dll) $(AOUT_LIBPERL_DLL) ext.libs
189 $(CC) $(LARGE) $(AOUT_CLDFLAGS_DLL) $(CCDLFLAGS) -o perl perlmain$(AOUT_OBJ_EXT) $(AOUT_DYNALOADER_OBJ) $(aout_static_ext_dll) $(AOUT_LIBPERL_DLL) `cat ext.libs` $(libs)
190
191clean: aout_clean
192
e95c8f0e 193aout_clean:
194 -rm *perl_.* *.o *.a lib/auto/*/*.a ext/*/Makefile.aout
195
196aout_install: perl_ aout_install.perl
197
198aout_install.perl: perl_ installperl
199 ./perl_ installperl
200
201aout_test: perl_
760ac839 202 - cd t && (rm -f perl_$(EXE_EXT); $(LNS) ../perl_$(EXE_EXT) perl$(EXE_EXT)) && ./perl TEST </dev/tty
203
53285a48 204# To test with harness, set HARNESS_BAD_EXITCODE=2
205
206sys_test: perl_sys
207 - cd t && (rm -f perl_$(EXE_EXT); $(LNS) ../perl_sys$(EXE_EXT) perl$(EXE_EXT)) && ./perl TEST </dev/tty
208
209sys_harness: perl_sys
210 - cd t && (rm -f perl_$(EXE_EXT); $(LNS) ../perl_sys$(EXE_EXT) perl$(EXE_EXT)) && env HARNESS_BAD_EXITCODE=2 ./perl harness </dev/tty
211
017f25f1 212!NO!SUBS!
e95c8f0e 213
017f25f1 214# Now we need to find directories in ./ext/ which are two level deep
215
216dirs=''
217preci='ext/%/Makefile.aout '
218for d in ext/*
219do
220 # echo "Checking '$d'..."
221 f="`echo $d/*/Makefile.PL`"
222 # SDBFile/sdbm, skip kid makefile
223 if test ! -e "$d/Makefile.PL" -a ! "$f" = ""; then
224 dirs="$dirs $d"
225 preci="$preci $d/%/Makefile.aout"
226 fi
227done
228
229$spitshell >>Makefile <<!GROK!THIS!
230.PRECIOUS : $preci
231
232!GROK!THIS!
233
234for d in $dirs
235do
236 p=`basename $d`
237 $spitshell >>Makefile <<!GROK!THIS!
238lib/auto/$p/*/%.a : ext/$p/%/Makefile.aout
239 @cd ext/$p/\$(basename \$(notdir \$@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
240 cd ext/$p/\$(basename \$(notdir \$@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
241
242$d/%/Makefile.aout : miniperl_
243 cd \$(dir \$@) ; ../../../miniperl_ -I ../../../lib Makefile.PL MAKEFILE=Makefile.aout INSTALLDIRS=perl
244
245!GROK!THIS!
e95c8f0e 246
017f25f1 247done
760ac839 248
017f25f1 249$spitshell >>Makefile <<'!NO!SUBS!'
250lib/auto/*/%.a : ext/%/Makefile.aout
251 @cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
252 cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
760ac839 253
e95c8f0e 254ext/%/Makefile.aout : miniperl_
760ac839 255 cd $(dir $@) ; ../../miniperl_ -I ../../lib Makefile.PL MAKEFILE=Makefile.aout INSTALLDIRS=perl
e95c8f0e 256
82835e01 257!NO!SUBS!