This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
This is my patch patch.1h for perl5.001.
[perl5.git] / Makefile.SH
CommitLineData
2304df62
AD
1case $CONFIG in
2'')
3 if test -f config.sh; then TOP=.;
4 elif test -f ../config.sh; then TOP=..;
5 elif test -f ../../config.sh; then TOP=../..;
6 elif test -f ../../../config.sh; then TOP=../../..;
7 elif test -f ../../../../config.sh; then TOP=../../../..;
8 else
9 echo "Can't find config.sh."; exit 1
10 fi
11 . $TOP/config.sh
12 ;;
13esac
14: This forces SH files to create target in same directory as SH file.
15: This is so that make depend always knows where to find SH derivatives.
16case "$0" in
17*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
18esac
19
2304df62
AD
20case "$d_dosuid" in
21*define*) suidperl='suidperl' ;;
22*) suidperl='';;
23esac
24
ecfc5424
AD
25shrpenv=""
26case "$d_shrplib" in
27*define*)
28 patchlevel=`egrep '^#define[ ]+PATCHLEVEL' patchlevel.h \
29 | awk '{print $3}'`
30 case "$patchlevel" in
31 *[0-9]) plibsuf=.$so.$patchlevel;;
32 *) plibsuf=.$so;;
33 esac
34 case "$shrpdir" in
35 /usr/lib) ;;
36 "") ;;
37 *) shrpenv="env LD_RUN_PATH=$shrpdir";;
38 esac
39 pldlflags="$cccdlflags";;
40*) plibsuf=.a
41 pldlflags="";;
42esac
43
a0d0e21e
LW
44: Prepare dependency lists for Makefile.
45dynamic_list=' '
46for f in $dynamic_ext; do
47 : the dependency named here will never exist
ecfc5424 48 base=`echo "$f" | sed 's/.*\///'`
75f92628 49 dynamic_list="$dynamic_list lib/auto/$f/$base.$dlext"
a0d0e21e
LW
50done
51
52static_list=' '
53static_ai_list=' '
54for f in $static_ext; do
55 base=`echo "$f" | sed 's/.*\///'`
75f92628 56 static_list="$static_list lib/auto/$f/$base.a"
a0d0e21e
LW
57 if test -f ext/$f/AutoInit.c; then
58 static_ai_list="$static_ai_list ext/$f/AutoInit.c"
59 fi
60 if test -f ext/$f/AutoInit.pl; then
61 static_ai_list="$static_ai_list ext/$f/AutoInit.pl"
62 fi
63done
64
2304df62 65echo "Extracting Makefile (with variable substitutions)"
a0d0e21e
LW
66$spitshell >Makefile <<'!NO!SUBS!'
67# Makefile.SH
85e6fe83
LW
68# This file is derived from Makefile.SH. Any changes made here will
69# be lost the next time you run Configure.
70# Makefile is used to generate makefile. The only difference
71# is that makefile has the dependencies filled in at the end.
2304df62 72#
fed7345c 73#
a0d0e21e 74!NO!SUBS!
2304df62 75
a0d0e21e 76$spitshell >>Makefile <<!GROK!THIS!
2304df62
AD
77# I now supply perly.c with the kits, so don't remake perly.c without byacc
78BYACC = $byacc
79CC = $cc
232e078e 80LD = $ld
2304df62
AD
81bin = $installbin
82scriptdir = $scriptdir
83privlib = $installprivlib
84mansrc = $mansrc
85manext = $manext
86LDFLAGS = $ldflags
87CLDFLAGS = $ldflags
85e6fe83 88
2304df62
AD
89SMALL = $small
90LARGE = $large $split
91mallocsrc = $mallocsrc
92mallocobj = $mallocobj
85e6fe83 93LNS = $lns
2304df62 94RMS = rm -f
85e6fe83
LW
95ranlib = $ranlib
96
97# The following are used to build and install shared libraries for
98# dynamic loading.
99LDDLFLAGS = $lddlflags
100CCDLFLAGS = $ccdlflags
a0d0e21e 101DLSUFFIX = .$dlext
ecfc5424
AD
102PLDLFLAGS = $pldlflags
103PLIBSUF = $plibsuf
104SHRPENV = $shrpenv
a0d0e21e
LW
105
106dynamic_ext = $dynamic_list
107static_ext = $static_list
108ext = \$(dynamic_ext) \$(static_ext)
109static_ext_autoinit = $static_ai_list
75f92628
AD
110DYNALOADER = lib/auto/DynaLoader/DynaLoader.a
111
2304df62
AD
112
113libs = $libs $cryptlib
114
115public = perl $suidperl
116
117shellflags = $shellflags
118
a0d0e21e 119## To use an alternate make, set \$altmake in config.sh.
2304df62
AD
120MAKE = ${altmake-make}
121!GROK!THIS!
122
85e6fe83 123## In the following dollars and backticks do not need the extra backslash.
2304df62
AD
124$spitshell >>Makefile <<'!NO!SUBS!'
125
a0d0e21e 126CCCMD = `sh $(shellflags) cflags $(perllib) $@`
2304df62 127
fed7345c 128private = preplibrary lib/ExtUtils/Miniperl.pm lib/Config.pm
2304df62 129
a0d0e21e 130scripts =
2304df62 131
a0d0e21e 132manpages = perl.man
2304df62
AD
133
134util =
135
3edbfbe5 136sh = Makefile.SH cflags.SH makedepend.SH makedir.SH writemain.SH
2304df62 137
fed7345c 138h1 = EXTERN.h INTERN.h XSUB.h av.h config.h cop.h cv.h dosish.h
a0d0e21e 139h2 = embed.h form.h gv.h handy.h hv.h keywords.h mg.h op.h
2304df62
AD
140h3 = opcode.h patchlevel.h perl.h perly.h pp.h proto.h regcomp.h
141h4 = regexp.h scope.h sv.h unixish.h util.h
142h = $(h1) $(h2) $(h3) $(h4)
143
a0d0e21e
LW
144c1 = $(mallocsrc) av.c scope.c op.c doop.c doio.c dump.c hv.c mg.c
145c2 = perl.c perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c
ecfc5424 146c3 = gv.c sv.c taint.c toke.c util.c deb.c run.c globals.c
2304df62 147
a0d0e21e 148c = $(c1) $(c2) $(c3) miniperlmain.c perlmain.c
2304df62 149
a0d0e21e
LW
150obj1 = $(mallocobj) gv.o toke.o perly.o op.o regcomp.o dump.o util.o mg.o
151obj2 = hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o
ecfc5424 152obj3 = doop.o doio.o regexec.o taint.o deb.o globals.o
2304df62 153
85e6fe83 154obj = $(obj1) $(obj2) $(obj3)
2304df62 155
a0d0e21e
LW
156# Once perl has been Configure'd and built ok you build different
157# perl variants (Debugging, Embedded, Multiplicity etc) by saying:
158# make clean; make perllib=libperl<type>.a
159# where <type> is some combination of 'd' and(or) 'e' or 'm'.
160# See cflags to understand how this works.
161#
162# Eventually some form of 'make-a-perl' script will automate this
163# together with linking a perl executable with any desired
164# static modules.
ecfc5424 165perllib = libperl$(PLIBSUF)
a0d0e21e 166
2304df62
AD
167lintflags = -hbvxac
168
a0d0e21e 169addedbyconf = UU
2304df62
AD
170
171# grrr
172SHELL = /bin/sh
173
2304df62 174.c.o:
ecfc5424 175 $(CCCMD) $(PLDLFLAGS) $*.c
2304df62 176
fed7345c 177all: makefile miniperl $(private) $(public) $(dynamic_ext)
a0d0e21e
LW
178 @echo " "; echo " Making x2p stuff"; cd x2p; $(MAKE) all
179 @echo " "; echo " Making docs"; cd pod; $(MAKE) all;
85e6fe83
LW
180
181# Phony target to force checking subdirectories.
182FORCE:
183
2304df62 184!NO!SUBS!
85e6fe83 185
a0d0e21e 186: Now on to the rest of the Makefile.
2304df62
AD
187$spitshell >>Makefile <<'!NO!SUBS!'
188# The $& notation tells Sequent machines that it can do a parallel make,
189# and is harmless otherwise.
190
a0d0e21e
LW
191miniperl: $& miniperlmain.o $(perllib)
192 $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain.o $(perllib) $(libs)
2304df62 193
ecfc5424
AD
194miniperlmain.o: miniperlmain.c
195 $(CCCMD) $(PLDLFLAGS) $*.c
196
a0d0e21e
LW
197perlmain.c: miniperlmain.c config.sh makefile $(static_ext_autoinit)
198 sh writemain $(DYNALOADER) $(static_ext) > tmp
199 sh mv-if-diff tmp perlmain.c
85e6fe83 200
2304df62 201perlmain.o: perlmain.c
ecfc5424 202 $(CCCMD) $(PLDLFLAGS) $*.c
85e6fe83 203
a0d0e21e
LW
204# The file ext.libs is a list of libraries that must be linked in
205# for static extensions, e.g. -lm -lgdbm, etc. The individual
206# static extension Makefile's add to it.
fed7345c 207ext.libs: $(static_ext)
a0d0e21e 208 -@test -f ext.libs || touch ext.libs
85e6fe83 209
a0d0e21e 210perl: $& perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
ecfc5424 211 $(SHRPENV) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
85e6fe83 212
a0d0e21e
LW
213pureperl: $& perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
214 purify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
2304df62 215
a0d0e21e
LW
216quantperl: $& perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
217 quantify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
2304df62 218
a0d0e21e 219$(perllib): $& perl.o $(obj)
ecfc5424
AD
220!NO!SUBS!
221
222case "$d_shrplib" in
223*define*)
224$spitshell >>Makefile <<'!NO!SUBS!'
232e078e 225 $(LD) $(LDDLFLAGS) -o $@ perl.o $(obj)
ecfc5424
AD
226!NO!SUBS!
227;;
228*)
229$spitshell >>Makefile <<'!NO!SUBS!'
5d94fbed 230 rm -f $(perllib)
a0d0e21e
LW
231 ar rcu $(perllib) perl.o $(obj)
232 @$(ranlib) $(perllib)
ecfc5424
AD
233!NO!SUBS!
234;;
235esac
236
237$spitshell >>Makefile <<'!NO!SUBS!'
2304df62
AD
238
239# This version, if specified in Configure, does ONLY those scripts which need
240# set-id emulation. Suidperl must be setuid root. It contains the "taint"
241# checks as well as the special code to validate that the script in question
242# has been invoked correctly.
243
a0d0e21e
LW
244suidperl: $& sperl.o perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
245 $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o suidperl perlmain.o sperl.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
2304df62
AD
246
247sperl.o: perl.c perly.h patchlevel.h $(h)
248 $(RMS) sperl.c
85e6fe83 249 $(LNS) perl.c sperl.c
2304df62
AD
250 $(CCCMD) -DIAMSUID sperl.c
251 $(RMS) sperl.c
252
2304df62 253opcode.h: opcode.pl
85e6fe83 254 - perl opcode.pl
2304df62 255
3edbfbe5
TB
256embed.h: embed_h.sh global.sym interp.sym
257 sh embed_h.sh
2304df62 258
fec02dd3
AD
259# We have to call our ./makedir because Ultrix 4.3 make can't handle the line
260# test -d lib/auto || mkdir lib/auto
261#
a0d0e21e 262preplibrary: miniperl lib/Config.pm
ecfc5424 263 @./makedir lib/auto
a0d0e21e
LW
264 @echo " AutoSplitting perl library"
265 @./miniperl -Ilib -e 'use AutoSplit; \
266 autosplit_lib_modules(@ARGV)' lib/*.pm lib/*/*.pm
2304df62 267
75f92628 268# Take care to avoid modifying lib/Config.pm without reason
a0d0e21e 269lib/Config.pm: config.sh miniperl
75f92628
AD
270 ./miniperl configpm tmp
271 sh mv-if-diff tmp lib/Config.pm
2304df62 272
fed7345c
AD
273lib/ExtUtils/Miniperl.pm: miniperlmain.c miniperl minimod.PL lib/Config.pm
274 ./miniperl minimod.PL > tmp && mv tmp $@
275
2304df62
AD
276install: all
277 ./perl installperl
a0d0e21e
LW
278
279# I now supply perly.c with the kits, so the following section is
56febc5e
AD
280# used only if you force byacc to run by saying
281# make run_byacc
282# Since we patch up the byacc output, the perly.fixer script needs
283# to run with precisely the same version of byacc as I use. You
284# normally shouldn't remake perly.[ch].
285
232e078e 286run_byacc: FORCE
56febc5e
AD
287 @ echo 'Expect' 109 shift/reduce and 1 reduce/reduce conflict
288 $(BYACC) -d perly.y
289 sh $(shellflags) ./perly.fixer y.tab.c perly.c
290 mv y.tab.h perly.h
291 echo 'extern YYSTYPE yylval;' >>perly.h
292
293# We don't want to regenerate perly.c and perly.h, but they might
294# appear out-of-date after a patch is applied or a new distribution is
295# made.
296perly.c: perly.y
232e078e 297 -@touch perly.c
56febc5e
AD
298
299perly.h: perly.y
232e078e 300 -@touch perly.h
a0d0e21e 301
a0d0e21e
LW
302# Extensions:
303# Names added to $(dynamic_ext) or $(static_ext) will automatically
fed7345c 304# get built. There should ordinarily be no need to change any of
a0d0e21e
LW
305# this part of makefile.
306#
307# The dummy dependency is a place holder in case $(dynamic_ext) or
308# $(static_ext) is empty.
309#
310# DynaLoader may be needed for extensions that use Makefile.PL.
311
312$(DYNALOADER): miniperl preplibrary FORCE
40000a8c 313 @sh ext/util/make_ext static $@ LIBPERL_A=$(perllib)
a0d0e21e
LW
314
315d_dummy $(dynamic_ext): miniperl preplibrary $(DYNALOADER) FORCE
40000a8c 316 @sh ext/util/make_ext dynamic $@ LIBPERL_A=$(perllib)
a0d0e21e
LW
317
318s_dummy $(static_ext): miniperl preplibrary $(DYNALOADER) FORCE
40000a8c 319 @sh ext/util/make_ext static $@ LIBPERL_A=$(perllib)
2304df62
AD
320
321clean:
42793c05 322 rm -f *.o *.a all perlmain.c
fed7345c 323 rm -f perl.exp ext.libs
a0d0e21e
LW
324 -cd x2p; $(MAKE) clean
325 -cd pod; $(MAKE) clean
75f92628 326 -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) ; do \
42793c05 327 sh ext/util/make_ext clean $$x ; \
a0d0e21e 328 done
ecfc5424 329 rm -f perl suidperl miniperl $(perllib)
2304df62
AD
330
331realclean: clean
a0d0e21e 332 -cd x2p; $(MAKE) realclean
5d94fbed 333 -cd pod; $(MAKE) realclean
42793c05
TB
334 @for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) ; do \
335 sh ext/util/make_ext realclean $$x ; \
a0d0e21e 336 done
42793c05 337 rm -f *.orig */*.orig *~ */*~ core t/core t/c t/perl
a0d0e21e
LW
338 rm -rf $(addedbyconf)
339 rm -f Makefile cflags makedepend makedir writemain
42793c05 340 rm -f config.h makefile makefile.old
fed7345c 341 rm -f $(private)
a0d0e21e 342 rm -rf lib/auto
232e078e 343 rm -f lib/.exists
94b6baf5 344 rm -f h2ph h2ph.man c2ph pstruct h2xs makeaperl
a0d0e21e 345 rm -rf .config
75f92628 346 @echo "Note that make realclean does not delete config.sh"
2304df62 347
ecfc5424
AD
348clobber: realclean
349 rm -f config.sh cppstdin
fed7345c 350
ecfc5424
AD
351distclean: clobber
352
2304df62
AD
353# The following lint has practically everything turned on. Unfortunately,
354# you have to wade through a lot of mumbo jumbo that can't be suppressed.
355# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
356# for that spot.
357
358lint: perly.c $(c)
359 lint $(lintflags) $(defs) perly.c $(c) > perl.fuzz
360
a0d0e21e 361makefile: Makefile
1aef975c 362 $(MAKE) depend
a0d0e21e 363
75f92628
AD
364config.h: config.sh
365 /bin/sh config_h.SH
366
a0d0e21e 367# When done, touch perlmain.c so that it doesn't get remade each time.
2304df62 368depend: makedepend
2304df62 369 ./makedepend
a0d0e21e 370 - test -s perlmain.c && touch perlmain.c
2304df62
AD
371 cd x2p; $(MAKE) depend
372
a0d0e21e 373test: miniperl perl preplibrary $(dynamic_ext)
2304df62 374 - cd t && chmod +x TEST */*.t
85e6fe83 375 - cd t && (rm -f perl; $(LNS) ../perl perl) && ./perl TEST </dev/tty
2304df62 376
85e6fe83 377clist: $(c)
2304df62
AD
378 echo $(c) | tr ' ' '\012' >.clist
379
85e6fe83 380hlist: $(h)
2304df62
AD
381 echo $(h) | tr ' ' '\012' >.hlist
382
85e6fe83 383shlist: $(sh)
2304df62
AD
384 echo $(sh) | tr ' ' '\012' >.shlist
385
386# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
387# If this runs make out of memory, delete /usr/include lines.
388!NO!SUBS!
389
85e6fe83 390$eunicefix Makefile
2304df62
AD
391case `pwd` in
392*SH)
85e6fe83
LW
393 $rm -f ../Makefile
394 ln Makefile ../Makefile
2304df62
AD
395 ;;
396esac
397rm -f makefile