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