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