Better place for nop IN_LOCALE_NUMERIC, pointed out
[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
5f929d0c 234# Now we need to find directories in ./ext/ which are up to 3 level deep
235# Currently (2001/06) there is no directories 4 levels deep.
236# (Only directories so that there is no Makefile.PL some levels up matter.)
017f25f1 237
238dirs=''
5f929d0c 239ddirs=''
017f25f1 240preci='ext/%/Makefile.aout '
241for d in ext/*
242do
5f929d0c 243 # echo "...Checking '$d'..."
244 # skip the kid if the parent exists: cmp SDBFile/sdbm, done by MakeMaker
245 if test ! -e "$d/Makefile.PL"; then
246 # Need to treat subdirectories manually
247 # echo "...Checking subdirs of '$d'..."
248 d_treated=''
249 for dd in $d/*
250 do
251 if test ! -d $dd; then
252 continue
253 fi
254 if test -e "$dd/Makefile.PL"; then
255 if test "X$d_treated" = "X"; then
256 d_treated=1
257 # echo "...Found parentless 2-level deep Makefile.PL's in $d/*/:" $d/*/Makefile.PL
258 dirs="$dirs $d"
259 preci="$preci $d/%/Makefile.aout"
260 fi
261 else
262 # Need to treat subsubdirectories manually
263 dd_treated=''
264 for ddd in $dd/*
265 do
266 if test ! -d $ddd; then
267 continue
268 fi
269 if test -e "$ddd/Makefile.PL"; then
270 if test "X$dd_treated" = "X"; then
271 dd_treated=1
272 # echo "...Found parentless 3-level deep Makefile.PL's in $dd/*/:" $dd/*/Makefile.PL
273 ddirs="$ddirs $dd"
274 preci="$preci $dd/%/Makefile.aout"
275 fi
276 fi
277 done
278 fi
279 done
017f25f1 280 fi
281done
282
283$spitshell >>Makefile <<!GROK!THIS!
284.PRECIOUS : $preci
285
286!GROK!THIS!
287
5f929d0c 288for d in $ddirs
289do
290 # Remove the leading component ext/
291 dd=`dirname $d`
292 pp=`basename $dd`
293 p=$pp/`basename $d`
294 $spitshell >>Makefile <<!GROK!THIS!
295lib/auto/$p/*/%.a : $d/%/Makefile.aout
296 @cd $d/\$(basename \$(notdir \$@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
297 cd $d/\$(basename \$(notdir \$@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
298
299$d/%/Makefile.aout : miniperl_
300 cd \$(dir \$@) ; ../../../../miniperl_ -I ../../../../lib Makefile.PL MAKEFILE=Makefile.aout INSTALLDIRS=perl
301
302!GROK!THIS!
303
304done
305
017f25f1 306for d in $dirs
307do
308 p=`basename $d`
309 $spitshell >>Makefile <<!GROK!THIS!
5f929d0c 310lib/auto/$p/*/%.a : $d/%/Makefile.aout
311 @cd $d/\$(basename \$(notdir \$@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
312 cd $d/\$(basename \$(notdir \$@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
017f25f1 313
314$d/%/Makefile.aout : miniperl_
315 cd \$(dir \$@) ; ../../../miniperl_ -I ../../../lib Makefile.PL MAKEFILE=Makefile.aout INSTALLDIRS=perl
316
317!GROK!THIS!
e95c8f0e 318
017f25f1 319done
760ac839 320
017f25f1 321$spitshell >>Makefile <<'!NO!SUBS!'
322lib/auto/*/%.a : ext/%/Makefile.aout
323 @cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
324 cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
760ac839 325
e95c8f0e 326ext/%/Makefile.aout : miniperl_
760ac839 327 cd $(dir $@) ; ../../miniperl_ -I ../../lib Makefile.PL MAKEFILE=Makefile.aout INSTALLDIRS=perl
e95c8f0e 328
82835e01 329!NO!SUBS!