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