Fix file-descriptor leak when pipes fail via taint checks:
[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
9$spitshell >>Makefile <<!GROK!THIS!
10
dd96f567 11AOUT_OPTIMIZE = $optimize
12AOUT_CCCMD = \$(CC) $aout_ccflags \$(AOUT_OPTIMIZE)
e95c8f0e 13AOUT_AR = $aout_ar
14AOUT_OBJ_EXT = $aout_obj_ext
15AOUT_LIB_EXT = $aout_lib_ext
f9c39ab5 16AOUT_LIBPERL = libperl$aout_lib_ext
e95c8f0e 17AOUT_CLDFLAGS = $aout_ldflags
18
dd3366de 19AOUT_LIBPERL_DLL = libperl_dll$aout_lib_ext
72ea3524 20AOUT_CCCMD_DLL = \$(CC) -DDOSISH -DOS2=2 -DEMBED -I. -DPACK_MALLOC -DDEBUGGING_MSTATS -DTWO_POT_OPTIMIZE -DPERL_EMERGENCY_SBRK
dd3366de 21AOUT_CLDFLAGS_DLL = -Zexe -Zmt -Zcrtdll
22
84902520 23LD_OPT = $optimize
24
e95c8f0e 25!GROK!THIS!
82835e01 26
27$spitshell >>Makefile <<'!NO!SUBS!'
f9c39ab5 28$(LIBPERL): perl.imp perl.dll perl5.def
29 emximp -o $(LIBPERL) perl.imp
82835e01 30
dd3366de 31$(AOUT_LIBPERL_DLL): perl.imp perl.dll perl5.def
32 emximp -o $(AOUT_LIBPERL_DLL) perl.imp
33
82835e01 34perl.imp: perl5.def
35 emximp -o perl.imp perl5.def
df3ef7a9 36 echo 'emx_calloc emxlibcm 400 ?' >> $@
37 echo 'emx_free emxlibcm 401 ?' >> $@
38 echo 'emx_malloc emxlibcm 402 ?' >> $@
39 echo 'emx_realloc emxlibcm 403 ?' >> $@
82835e01 40
41perl.dll: $(obj) perl5.def perl$(OBJ_EXT)
84902520 42 $(LD) $(LD_OPT) $(LDDLFLAGS) -o $@ perl$(OBJ_EXT) $(obj) $(libs) perl5.def
82835e01 43
44perl5.def: perl.linkexp
45 echo "LIBRARY 'Perl' INITINSTANCE TERMINSTANCE" > $@
46 echo DESCRIPTION "'Perl interpreter, export autogenerated'" >>$@
47 echo STACKSIZE 32768 >>$@
48 echo CODE LOADONCALL >>$@
49 echo DATA LOADONCALL NONSHARED MULTIPLE >>$@
50 echo EXPORTS >>$@
82835e01 51!NO!SUBS!
52
53if [ ! -z "$myttyname" ] ; then
54 $spitshell >>Makefile <<'!NO!SUBS!'
55 echo ' "ttyname"' >>$@
56!NO!SUBS!
57fi
58
59$spitshell >>Makefile <<'!NO!SUBS!'
60 cat perl.linkexp >>$@
61
62# grep -v '"\(malloc\|realloc\|free\)"' perl.linkexp >>$@
63
64
82835e01 65perl.exports: perl.exp EXTERN.h perl.h
ff68c719 66 (echo "#include \"EXTERN.h\" \n#include \"perl.h\" \n#include \"perl.exp\""; \
67 echo "malloc\nrealloc\ncalloc\nfree") | \
82835e01 68 $(CC) -DEMBED -E - | \
69 awk '{if ($$2 == "") print $$1}' | sort | uniq > $@
70
82835e01 71perl.linkexp: perl.exports perl.map
dd96f567 72 cat perl.exports os2/os2.sym perl.map | sort | uniq -d | sed -e 's/\w\+/ "\0"/' > perl.linkexp
82835e01 73
84902520 74# We link miniperl statically, since .DLL depends on $(DYNALOADER)
75
76perl.map miniperl: $(obj) perl$(OBJ_EXT) miniperlmain$(OBJ_EXT)
77 $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) perl$(OBJ_EXT) $(obj) $(libs) -Zmap -Zlinker /map
78 awk '{if ($$3 == "") print $$2}' <miniperl.map | sort | uniq > perl.map
79 rm miniperl.map
80 @./miniperl -w -Ilib -MExporter -e 0 || $(MAKE) minitest
82835e01 81
dd96f567 82depend: os2ish.h dlfcn.h os2thread.h os2.c
82835e01 83
84# Stupid make? Needed...
85os2$(OBJ_EXT) : os2.c
86
87os2.c: os2/os2.c os2ish.h
88 cp $< $@
89
e95c8f0e 90dl_os2.c: os2/dl_os2.c os2ish.h
91 cp $< $@
92
82835e01 93os2ish.h: os2/os2ish.h
94 cp $< $@
95
dd96f567 96os2thread.h: os2/os2thread.h
97 cp $< $@
98
e95c8f0e 99dlfcn.h: os2/dlfcn.h
100 cp $< $@
101
dd3366de 102# This one is compiled OMF, so cannot fork():
103
104perl___: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
105 $(SHRPENV) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl___ perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs)
e95c8f0e 106
82835e01 107installcmd :
108 perl -e 'die qq{Give the option INSTALLCMDDIR=... to make!} if $$ARGV[0] eq ""' $(INSTALLCMDDIR)
109 perl os2/perl2cmd.pl $(INSTALLCMDDIR)
110
e95c8f0e 111# Aout section:
112
113aout_obj = $(addsuffix $(AOUT_OBJ_EXT),$(basename $(obj)))
114AOUT_DYNALOADER = $(addsuffix $(AOUT_LIB_EXT),$(basename $(DYNALOADER)))
115aout_static_ext = $(addsuffix $(AOUT_LIB_EXT),$(basename $(dynamic_ext)))
116aout_static_lib = $(addsuffix $(LIB_EXT),$(basename $(dynamic_ext)))
117
dd3366de 118aout_static_ext_dll = $(addsuffix $(AOUT_LIB_EXT),$(basename $(static_ext)))
119DYNALOADER_OBJ = ext/DynaLoader/DynaLoader$(OBJ_EXT)
120aout_static_ext_dll = $(addsuffix $(AOUT_LIB_EXT),$(basename $(static_ext)))
121AOUT_DYNALOADER_OBJ = $(addsuffix $(AOUT_OBJ_EXT),$(basename $(DYNALOADER_OBJ)))
122
123$(AOUT_DYNALOADER_OBJ) : $(DYNALOADER_OBJ)
124 emxaout -o $@ $<
125
126$(DYNALOADER_OBJ) : $(DYNALOADER)
127 @sh -c true
128
f9c39ab5 129$(AOUT_LIBPERL) : $(aout_obj) perl$(AOUT_OBJ_EXT)
dd3366de 130 rm -f $@
131 $(AOUT_AR) rcu $@ perl$(AOUT_OBJ_EXT) $(aout_obj)
e95c8f0e 132
133.c$(AOUT_OBJ_EXT):
134 $(AOUT_CCCMD) $(PLDLFLAGS) -c $*.c
135
dd3366de 136perlmain(AOUT_OBJ_EXT): perlmain.c
137 $(AOUT_CCCMD_DLL) $(PLDLFLAGS) -c perlmain.c
138
e95c8f0e 139aout_perlmain.c: miniperlmain.c config.sh makefile $(static_ext_autoinit)
140 sh writemain $(DYNALOADER) $(aout_static_lib) > tmp
141 sh mv-if-diff tmp aout_perlmain.c
142
f9c39ab5 143miniperl_: $& miniperlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) ext.libs
144 $(CC) $(LARGE) $(AOUT_CLDFLAGS) $(CCDLFLAGS) -o miniperl_ miniperlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) `cat ext.libs` $(libs)
e95c8f0e 145
f9c39ab5 146perl_: $& aout_perlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) $(AOUT_DYNALOADER) $(aout_static_ext) ext.libs
147 $(CC) $(LARGE) $(AOUT_CLDFLAGS) $(CCDLFLAGS) -o perl_ aout_perlmain$(AOUT_OBJ_EXT) $(AOUT_DYNALOADER) $(aout_static_ext) $(AOUT_LIBPERL) `cat ext.libs` $(libs)
e95c8f0e 148
dd3366de 149perl : perl__ perl___
760ac839 150
f9c39ab5 151perl__: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
152 $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl__ perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs) -Zlinker /PM:PM
760ac839 153
dd3366de 154# Forking dynamically loaded perl:
155
156perl: $& perlmain$(AOUT_OBJ_EXT) $(AOUT_DYNALOADER_OBJ) $(aout_static_ext_dll) $(AOUT_LIBPERL_DLL) ext.libs
157 $(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)
158
159clean: aout_clean
160
e95c8f0e 161aout_clean:
162 -rm *perl_.* *.o *.a lib/auto/*/*.a ext/*/Makefile.aout
163
164aout_install: perl_ aout_install.perl
165
166aout_install.perl: perl_ installperl
167 ./perl_ installperl
168
169aout_test: perl_
760ac839 170 - cd t && (rm -f perl_$(EXE_EXT); $(LNS) ../perl_$(EXE_EXT) perl$(EXE_EXT)) && ./perl TEST </dev/tty
171
172lib/auto/OS2/*/%.a : ext/OS2/%/Makefile.aout
173 cd ext/OS2/$(basename $(notdir $@)) ; make -f Makefile.aout config || echo "$make config failed, continuing anyway..."
174 cd ext/OS2/$(basename $(notdir $@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
e95c8f0e 175
176lib/auto/*/%.a : ext/%/Makefile.aout
177 cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout config || echo "$make config failed, continuing anyway..."
178 cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=
179
760ac839 180.PRECIOUS : ext/%/Makefile.aout ext/OS2/%/Makefile.aout
181
182ext/OS2/%/Makefile.aout : miniperl_
183 cd $(dir $@) ; ../../../miniperl_ -I ../../../lib Makefile.PL MAKEFILE=Makefile.aout INSTALLDIRS=perl
184
e95c8f0e 185ext/%/Makefile.aout : miniperl_
760ac839 186 cd $(dir $@) ; ../../miniperl_ -I ../../lib Makefile.PL MAKEFILE=Makefile.aout INSTALLDIRS=perl
e95c8f0e 187
82835e01 188!NO!SUBS!