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