This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
This is my patch patch.1n 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
16d20bd9 81
2304df62
AD
82LDFLAGS = $ldflags
83CLDFLAGS = $ldflags
85e6fe83 84
2304df62
AD
85SMALL = $small
86LARGE = $large $split
87mallocsrc = $mallocsrc
88mallocobj = $mallocobj
85e6fe83 89LNS = $lns
2304df62 90RMS = rm -f
85e6fe83
LW
91ranlib = $ranlib
92
16d20bd9
AD
93# The following are mentioned only to make metaconfig include the
94# appropriate questions in Configure. If you want to change these,
8e07c86e 95# edit config.sh instead, or specify --man1dir=/wherever on
16d20bd9
AD
96# installman commandline.
97bin = $installbin
98scriptdir = $scriptdir
99privlib = $installprivlib
100man1dir = $man1dir
101man1ext = $man1ext
102man3dir = $man3dir
103man3ext = $man3ext
104
85e6fe83
LW
105# The following are used to build and install shared libraries for
106# dynamic loading.
107LDDLFLAGS = $lddlflags
108CCDLFLAGS = $ccdlflags
a0d0e21e 109DLSUFFIX = .$dlext
ecfc5424
AD
110PLDLFLAGS = $pldlflags
111PLIBSUF = $plibsuf
112SHRPENV = $shrpenv
a0d0e21e
LW
113
114dynamic_ext = $dynamic_list
115static_ext = $static_list
116ext = \$(dynamic_ext) \$(static_ext)
117static_ext_autoinit = $static_ai_list
75f92628
AD
118DYNALOADER = lib/auto/DynaLoader/DynaLoader.a
119
2304df62
AD
120
121libs = $libs $cryptlib
122
123public = perl $suidperl
124
125shellflags = $shellflags
126
a0d0e21e 127## To use an alternate make, set \$altmake in config.sh.
2304df62
AD
128MAKE = ${altmake-make}
129!GROK!THIS!
130
85e6fe83 131## In the following dollars and backticks do not need the extra backslash.
2304df62
AD
132$spitshell >>Makefile <<'!NO!SUBS!'
133
a0d0e21e 134CCCMD = `sh $(shellflags) cflags $(perllib) $@`
2304df62 135
fed7345c 136private = preplibrary lib/ExtUtils/Miniperl.pm lib/Config.pm
2304df62 137
16d20bd9
AD
138sh = Makefile.SH c2ph.SH cflags.SH config_h.SH h2ph.SH h2xs.SH makeaperl.SH \
139 makedepend.SH makedir.SH perl_exp.SH perldoc.SH writemain.SH
2304df62 140
16d20bd9
AD
141addedbyconf = UU Makefile c2ph cflags config.h h2ph h2xs makeaperl \
142 makedepend makedir perl_exp perldoc writemain
2304df62 143
fed7345c 144h1 = EXTERN.h INTERN.h XSUB.h av.h config.h cop.h cv.h dosish.h
a0d0e21e 145h2 = embed.h form.h gv.h handy.h hv.h keywords.h mg.h op.h
2304df62
AD
146h3 = opcode.h patchlevel.h perl.h perly.h pp.h proto.h regcomp.h
147h4 = regexp.h scope.h sv.h unixish.h util.h
148h = $(h1) $(h2) $(h3) $(h4)
149
a0d0e21e
LW
150c1 = $(mallocsrc) av.c scope.c op.c doop.c doio.c dump.c hv.c mg.c
151c2 = perl.c perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c
ecfc5424 152c3 = gv.c sv.c taint.c toke.c util.c deb.c run.c globals.c
2304df62 153
a0d0e21e 154c = $(c1) $(c2) $(c3) miniperlmain.c perlmain.c
2304df62 155
a0d0e21e
LW
156obj1 = $(mallocobj) gv.o toke.o perly.o op.o regcomp.o dump.o util.o mg.o
157obj2 = hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o
ecfc5424 158obj3 = doop.o doio.o regexec.o taint.o deb.o globals.o
2304df62 159
85e6fe83 160obj = $(obj1) $(obj2) $(obj3)
2304df62 161
a0d0e21e
LW
162# Once perl has been Configure'd and built ok you build different
163# perl variants (Debugging, Embedded, Multiplicity etc) by saying:
164# make clean; make perllib=libperl<type>.a
165# where <type> is some combination of 'd' and(or) 'e' or 'm'.
166# See cflags to understand how this works.
167#
168# Eventually some form of 'make-a-perl' script will automate this
169# together with linking a perl executable with any desired
170# static modules.
ecfc5424 171perllib = libperl$(PLIBSUF)
a0d0e21e 172
2304df62
AD
173lintflags = -hbvxac
174
2304df62
AD
175# grrr
176SHELL = /bin/sh
177
2304df62 178.c.o:
ecfc5424 179 $(CCCMD) $(PLDLFLAGS) $*.c
2304df62 180
fed7345c 181all: makefile miniperl $(private) $(public) $(dynamic_ext)
a0d0e21e 182 @echo " "; echo " Making x2p stuff"; cd x2p; $(MAKE) all
8e07c86e 183
16d20bd9
AD
184# This is now done by installman only if you actually want the man pages.
185# @echo " "; echo " Making docs"; cd pod; $(MAKE) all;
85e6fe83
LW
186
187# Phony target to force checking subdirectories.
e50aee73 188# Apparently some makes require an action for the FORCE target.
85e6fe83 189FORCE:
e50aee73 190 @true
85e6fe83 191
2304df62
AD
192# The $& notation tells Sequent machines that it can do a parallel make,
193# and is harmless otherwise.
194
a0d0e21e
LW
195miniperl: $& miniperlmain.o $(perllib)
196 $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain.o $(perllib) $(libs)
2304df62 197
ecfc5424
AD
198miniperlmain.o: miniperlmain.c
199 $(CCCMD) $(PLDLFLAGS) $*.c
200
a0d0e21e
LW
201perlmain.c: miniperlmain.c config.sh makefile $(static_ext_autoinit)
202 sh writemain $(DYNALOADER) $(static_ext) > tmp
203 sh mv-if-diff tmp perlmain.c
85e6fe83 204
2304df62 205perlmain.o: perlmain.c
ecfc5424 206 $(CCCMD) $(PLDLFLAGS) $*.c
85e6fe83 207
a0d0e21e
LW
208# The file ext.libs is a list of libraries that must be linked in
209# for static extensions, e.g. -lm -lgdbm, etc. The individual
210# static extension Makefile's add to it.
fed7345c 211ext.libs: $(static_ext)
a0d0e21e 212 -@test -f ext.libs || touch ext.libs
85e6fe83 213
a0d0e21e 214perl: $& perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
ecfc5424 215 $(SHRPENV) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
85e6fe83 216
a0d0e21e
LW
217pureperl: $& perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
218 purify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
2304df62 219
a0d0e21e
LW
220quantperl: $& perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
221 quantify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
2304df62 222
a0d0e21e 223$(perllib): $& perl.o $(obj)
ecfc5424
AD
224!NO!SUBS!
225
226case "$d_shrplib" in
227*define*)
228$spitshell >>Makefile <<'!NO!SUBS!'
232e078e 229 $(LD) $(LDDLFLAGS) -o $@ perl.o $(obj)
ecfc5424
AD
230!NO!SUBS!
231;;
232*)
233$spitshell >>Makefile <<'!NO!SUBS!'
5d94fbed 234 rm -f $(perllib)
a0d0e21e
LW
235 ar rcu $(perllib) perl.o $(obj)
236 @$(ranlib) $(perllib)
ecfc5424
AD
237!NO!SUBS!
238;;
239esac
240
241$spitshell >>Makefile <<'!NO!SUBS!'
2304df62
AD
242
243# This version, if specified in Configure, does ONLY those scripts which need
244# set-id emulation. Suidperl must be setuid root. It contains the "taint"
245# checks as well as the special code to validate that the script in question
246# has been invoked correctly.
247
a0d0e21e
LW
248suidperl: $& sperl.o perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
249 $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o suidperl perlmain.o sperl.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
2304df62
AD
250
251sperl.o: perl.c perly.h patchlevel.h $(h)
252 $(RMS) sperl.c
85e6fe83 253 $(LNS) perl.c sperl.c
2304df62
AD
254 $(CCCMD) -DIAMSUID sperl.c
255 $(RMS) sperl.c
256
fec02dd3
AD
257# We have to call our ./makedir because Ultrix 4.3 make can't handle the line
258# test -d lib/auto || mkdir lib/auto
259#
a0d0e21e 260preplibrary: miniperl lib/Config.pm
ecfc5424 261 @./makedir lib/auto
a0d0e21e
LW
262 @echo " AutoSplitting perl library"
263 @./miniperl -Ilib -e 'use AutoSplit; \
264 autosplit_lib_modules(@ARGV)' lib/*.pm lib/*/*.pm
2304df62 265
75f92628 266# Take care to avoid modifying lib/Config.pm without reason
a0d0e21e 267lib/Config.pm: config.sh miniperl
75f92628
AD
268 ./miniperl configpm tmp
269 sh mv-if-diff tmp lib/Config.pm
2304df62 270
fed7345c
AD
271lib/ExtUtils/Miniperl.pm: miniperlmain.c miniperl minimod.PL lib/Config.pm
272 ./miniperl minimod.PL > tmp && mv tmp $@
273
16d20bd9
AD
274install: all install.perl install.man
275
276install.perl: all
2304df62 277 ./perl installperl
a0d0e21e 278
16d20bd9
AD
279install.man: all
280 ./perl installman
281
282# Not implemented yet.
283#install.html: all
284# ./perl installhtml
285
a0d0e21e 286# I now supply perly.c with the kits, so the following section is
56febc5e
AD
287# used only if you force byacc to run by saying
288# make run_byacc
289# Since we patch up the byacc output, the perly.fixer script needs
290# to run with precisely the same version of byacc as I use. You
291# normally shouldn't remake perly.[ch].
292
232e078e 293run_byacc: FORCE
56febc5e
AD
294 @ echo 'Expect' 109 shift/reduce and 1 reduce/reduce conflict
295 $(BYACC) -d perly.y
296 sh $(shellflags) ./perly.fixer y.tab.c perly.c
297 mv y.tab.h perly.h
298 echo 'extern YYSTYPE yylval;' >>perly.h
299
300# We don't want to regenerate perly.c and perly.h, but they might
301# appear out-of-date after a patch is applied or a new distribution is
302# made.
303perly.c: perly.y
232e078e 304 -@touch perly.c
56febc5e
AD
305
306perly.h: perly.y
232e078e 307 -@touch perly.h
a0d0e21e 308
e50aee73
AD
309# The following three header files are generated automatically
310# keywords.h: keywords.pl
311# opcode.h: opcode.pl
312# embed.h: embed.pl global.sym interp.sym
313# The correct versions should be already supplied with the perl kit,
314# in case you don't have perl available.
315# To force them to run, type
316# make regen_headers
317regen_headers: FORCE
318 perl keywords.pl
319 perl opcode.pl
320 perl embed.pl
8e07c86e 321
a0d0e21e
LW
322# Extensions:
323# Names added to $(dynamic_ext) or $(static_ext) will automatically
fed7345c 324# get built. There should ordinarily be no need to change any of
a0d0e21e
LW
325# this part of makefile.
326#
327# The dummy dependency is a place holder in case $(dynamic_ext) or
328# $(static_ext) is empty.
329#
330# DynaLoader may be needed for extensions that use Makefile.PL.
331
332$(DYNALOADER): miniperl preplibrary FORCE
40000a8c 333 @sh ext/util/make_ext static $@ LIBPERL_A=$(perllib)
a0d0e21e
LW
334
335d_dummy $(dynamic_ext): miniperl preplibrary $(DYNALOADER) FORCE
40000a8c 336 @sh ext/util/make_ext dynamic $@ LIBPERL_A=$(perllib)
a0d0e21e
LW
337
338s_dummy $(static_ext): miniperl preplibrary $(DYNALOADER) FORCE
40000a8c 339 @sh ext/util/make_ext static $@ LIBPERL_A=$(perllib)
2304df62
AD
340
341clean:
42793c05 342 rm -f *.o *.a all perlmain.c
fed7345c 343 rm -f perl.exp ext.libs
a0d0e21e
LW
344 -cd x2p; $(MAKE) clean
345 -cd pod; $(MAKE) clean
75f92628 346 -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) ; do \
42793c05 347 sh ext/util/make_ext clean $$x ; \
a0d0e21e 348 done
ecfc5424 349 rm -f perl suidperl miniperl $(perllib)
2304df62
AD
350
351realclean: clean
a0d0e21e 352 -cd x2p; $(MAKE) realclean
5d94fbed 353 -cd pod; $(MAKE) realclean
8e07c86e 354 -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) ; do \
42793c05 355 sh ext/util/make_ext realclean $$x ; \
a0d0e21e 356 done
42793c05 357 rm -f *.orig */*.orig *~ */*~ core t/core t/c t/perl
a0d0e21e 358 rm -rf $(addedbyconf)
16d20bd9 359 rm -f makefile makefile.old
fed7345c 360 rm -f $(private)
a0d0e21e 361 rm -rf lib/auto
232e078e 362 rm -f lib/.exists
16d20bd9 363 rm -f h2ph.man pstruct
a0d0e21e 364 rm -rf .config
75f92628 365 @echo "Note that make realclean does not delete config.sh"
2304df62 366
ecfc5424
AD
367clobber: realclean
368 rm -f config.sh cppstdin
fed7345c 369
ecfc5424
AD
370distclean: clobber
371
2304df62
AD
372# The following lint has practically everything turned on. Unfortunately,
373# you have to wade through a lot of mumbo jumbo that can't be suppressed.
374# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
375# for that spot.
376
377lint: perly.c $(c)
378 lint $(lintflags) $(defs) perly.c $(c) > perl.fuzz
379
a0d0e21e 380makefile: Makefile
1aef975c 381 $(MAKE) depend
a0d0e21e 382
75f92628
AD
383config.h: config.sh
384 /bin/sh config_h.SH
385
a0d0e21e 386# When done, touch perlmain.c so that it doesn't get remade each time.
2304df62 387depend: makedepend
2304df62 388 ./makedepend
a0d0e21e 389 - test -s perlmain.c && touch perlmain.c
2304df62
AD
390 cd x2p; $(MAKE) depend
391
a0d0e21e 392test: miniperl perl preplibrary $(dynamic_ext)
2304df62 393 - cd t && chmod +x TEST */*.t
85e6fe83 394 - cd t && (rm -f perl; $(LNS) ../perl perl) && ./perl TEST </dev/tty
2304df62 395
16d20bd9
AD
396minitest: miniperl
397 - cd t && chmod +x TEST */*.t
398 - cd t && (rm -f perl; $(LNS) ../miniperl perl) \
399 && ./perl TEST base/*.t comp/*.t cmd/*.t io/*.t op/*.t </dev/tty
400
85e6fe83 401clist: $(c)
2304df62
AD
402 echo $(c) | tr ' ' '\012' >.clist
403
85e6fe83 404hlist: $(h)
2304df62
AD
405 echo $(h) | tr ' ' '\012' >.hlist
406
85e6fe83 407shlist: $(sh)
2304df62
AD
408 echo $(sh) | tr ' ' '\012' >.shlist
409
410# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
411# If this runs make out of memory, delete /usr/include lines.
412!NO!SUBS!
413
85e6fe83 414$eunicefix Makefile
2304df62
AD
415case `pwd` in
416*SH)
85e6fe83
LW
417 $rm -f ../Makefile
418 ln Makefile ../Makefile
2304df62
AD
419 ;;
420esac
421rm -f makefile