This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
allow distinct prefix for versioned executables
[perl5.git] / Makefile.SH
CommitLineData
599a829f 1#! /bin/sh
2000072c 2case $CONFIGDOTSH in
2304df62
AD
3'')
4 if 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 elif test -f ../../../../config.sh; then TOP=../../../..;
9 else
10 echo "Can't find config.sh."; exit 1
11 fi
12 . $TOP/config.sh
13 ;;
14esac
15: This forces SH files to create target in same directory as SH file.
16: This is so that make depend always knows where to find SH derivatives.
17case "$0" in
18*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
19esac
20
2304df62
AD
21case "$d_dosuid" in
22*define*) suidperl='suidperl' ;;
23*) suidperl='';;
24esac
25
d5d19f97 26linklibperl='$(LIBPERL)'
3c321fdc 27shrpldflags='$(LDDLFLAGS)'
6ee623d5 28ldlibpth=''
d96ebe2e
PP
29case "$useshrplib" in
30true)
6ee623d5
GS
31 # Prefix all runs of 'miniperl' and 'perl' with
32 # $ldlibpth so that ./perl finds *this* libperl.so.
33 ldlibpth="LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH"
34
d5d19f97 35 pldlflags="$cccdlflags"
f0efd8cf 36 # NeXT-4 specific stuff. Can't we do this in the hint file?
d96ebe2e
PP
37 case "${osname}${osvers}" in
38 next4*)
3c321fdc
PP
39 ld=libtool
40 lddlflags="-dynamic -undefined warning -framework System \
41 -compatibility_version 1 -current_version $patchlevel \
42 -prebind -seg1addr 0x27000000 -install_name \$(shrpdir)/\$@"
6ee623d5
GS
43 # NeXT uses a different name.
44 ldlibpth="DYLD_LIBRARY_PATH=`pwd`:$DYLD_LIBRARY_PATH"
45 ;;
8f1f23e8
W
46 rhapsody*)
47 ldlibpth="DYLD_LIBRARY_PATH=`pwd`/Perl:$DYLD_LIBRARY_PATH"
48 ;;
6ee623d5
GS
49 os2*) # OS/2 doesn't need anything special for LD_LIBRARY_PATH.
50 ldlibpth=''
d96ebe2e 51 ;;
73d40b3e 52 sunos*)
d5d19f97
UP
53 linklibperl="-lperl"
54 ;;
73d40b3e 55 netbsd*|freebsd[234]*)
099685bc
JH
56 linklibperl="-L. -lperl"
57 ;;
3c321fdc
PP
58 aix*)
59 shrpldflags="-H512 -T512 -bhalt:4 -bM:SRE -bE:perl.exp"
1553ab04
TB
60 case "$osvers" in
61 3*)
62 shrpldflags="$shrpldflags -e _nostart $ldflags $libs $cryptlib"
63 ;;
64 *)
65 shrpldflags="$shrpldflags -b noentry $ldflags $libs $cryptlib"
66 ;;
67 esac
3c321fdc
PP
68 aixinstdir=`pwd | sed 's/\/UU$//'`
69 linklibperl="-L $archlibexp/CORE -L $aixinstdir -lperl"
70 ;;
a297ace2 71 hpux10*|hpux11*)
fb73857a
PP
72 linklibperl="-L `pwd | sed 's/\/UU$//'` -Wl,+b$archlibexp/CORE -lperl"
73 ;;
46193409
JH
74 beos*) ldlibpth="LIBRARY_PATH=`pwd`:$LIBRARY_PATH"
75 ;;
655635e8 76 esac
d5d19f97 77 ;;
f0efd8cf 78*) pldlflags=''
d96ebe2e 79 ;;
ecfc5424
AD
80esac
81
a0d0e21e
LW
82: Prepare dependency lists for Makefile.
83dynamic_list=' '
84for f in $dynamic_ext; do
85 : the dependency named here will never exist
ecfc5424 86 base=`echo "$f" | sed 's/.*\///'`
75f92628 87 dynamic_list="$dynamic_list lib/auto/$f/$base.$dlext"
a0d0e21e
LW
88done
89
90static_list=' '
a0d0e21e
LW
91for f in $static_ext; do
92 base=`echo "$f" | sed 's/.*\///'`
cd4d8a96 93 static_list="$static_list lib/auto/$f/$base\$(LIB_EXT)"
a0d0e21e
LW
94done
95
4318d5a0
GB
96nonxs_list=' '
97for f in $nonxs_ext; do
98 base=`echo "$f" | sed 's/.*\///'`
99 nonxs_list="$nonxs_list ext/$f/pm_to_blib"
100done
101
2304df62 102echo "Extracting Makefile (with variable substitutions)"
655635e8 103$spitshell >Makefile <<!GROK!THIS!
a0d0e21e 104# Makefile.SH
85e6fe83
LW
105# This file is derived from Makefile.SH. Any changes made here will
106# be lost the next time you run Configure.
655635e8
PP
107# Makefile is used to generate $firstmakefile. The only difference
108# is that $firstmakefile has the dependencies filled in at the end.
2304df62 109#
fed7345c 110#
2304df62
AD
111# I now supply perly.c with the kits, so don't remake perly.c without byacc
112BYACC = $byacc
113CC = $cc
232e078e 114LD = $ld
16d20bd9 115
2304df62
AD
116LDFLAGS = $ldflags
117CLDFLAGS = $ldflags
85e6fe83 118
2304df62
AD
119SMALL = $small
120LARGE = $large $split
121mallocsrc = $mallocsrc
122mallocobj = $mallocobj
85e6fe83 123LNS = $lns
2304df62 124RMS = rm -f
85e6fe83
LW
125ranlib = $ranlib
126
16d20bd9
AD
127# The following are mentioned only to make metaconfig include the
128# appropriate questions in Configure. If you want to change these,
8e07c86e 129# edit config.sh instead, or specify --man1dir=/wherever on
16d20bd9
AD
130# installman commandline.
131bin = $installbin
132scriptdir = $scriptdir
d96ebe2e 133shrpdir = $archlibexp/CORE
16d20bd9
AD
134privlib = $installprivlib
135man1dir = $man1dir
136man1ext = $man1ext
137man3dir = $man3dir
138man3ext = $man3ext
139
85e6fe83
LW
140# The following are used to build and install shared libraries for
141# dynamic loading.
142LDDLFLAGS = $lddlflags
3c321fdc 143SHRPLDFLAGS = $shrpldflags
85e6fe83 144CCDLFLAGS = $ccdlflags
a0d0e21e 145DLSUFFIX = .$dlext
ecfc5424 146PLDLFLAGS = $pldlflags
d96ebe2e 147LIBPERL = $libperl
d5d19f97 148LLIBPERL= $linklibperl
ecfc5424 149SHRPENV = $shrpenv
a0d0e21e 150
6ee623d5
GS
151# The following is used to include the current directory in
152# LD_LIBRARY_PATH if you are building a shared libperl.so.
153LDLIBPTH = $ldlibpth
154
a0d0e21e
LW
155dynamic_ext = $dynamic_list
156static_ext = $static_list
4318d5a0
GB
157nonxs_ext = $nonxs_list
158ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
cd4d8a96 159DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
2304df62
AD
160
161libs = $libs $cryptlib
162
909b3858 163public = perl $suidperl utilities translators
2304df62
AD
164
165shellflags = $shellflags
166
d96ebe2e
PP
167# This is set to MAKE=$make if your $make command doesn't
168# do it for you.
169$make_set_make
4633a7c4 170
dfe9444c 171# These variables may need to be manually set for non-Unix systems.
ccc7f9b3 172AR = $full_ar
dfe9444c
AD
173EXE_EXT = $_exe
174LIB_EXT = $_a
175OBJ_EXT = $_o
176PATH_SEP = $p_
4633a7c4
LW
177
178FIRSTMAKEFILE = $firstmakefile
179
180# Any special object files needed by this architecture, e.g. os2/os2.obj
181ARCHOBJS = $archobjs
182
cd4d8a96
PP
183.SUFFIXES: .c \$(OBJ_EXT)
184
d96ebe2e
PP
185# grrr
186SHELL = $sh
655635e8 187
28e8609d
JH
188# how to tr(anslate) newlines
189TRNL = '$trnl'
190
2304df62
AD
191!GROK!THIS!
192
85e6fe83 193## In the following dollars and backticks do not need the extra backslash.
2304df62
AD
194$spitshell >>Makefile <<'!NO!SUBS!'
195
d96ebe2e 196CCCMD = `sh $(shellflags) cflags $(LIBPERL) $@`
2304df62 197
fed7345c 198private = preplibrary lib/ExtUtils/Miniperl.pm lib/Config.pm
2304df62 199
4633a7c4
LW
200# Files to be built with variable substitution before miniperl
201# is available.
202sh = Makefile.SH cflags.SH config_h.SH makeaperl.SH makedepend.SH \
203 makedir.SH perl_exp.SH writemain.SH
204
205shextract = Makefile cflags config.h makeaperl makedepend \
655635e8 206 makedir perl.exp writemain
4633a7c4
LW
207
208# Files to be built with variable substitution after miniperl is
209# available. Dependencies handled manually below (for now).
2304df62 210
efb12ca0
GS
211pl = pod/pod2html.PL pod/pod2latex.PL pod/pod2man.PL pod/pod2text.PL \
212 pod/pod2usage.PL pod/podchecker.PL pod/podselect.PL
4633a7c4 213
efb12ca0
GS
214plextract = pod/pod2html pod/pod2latex pod/pod2man pod/pod2text \
215 pod/pod2usage pod/podchecker pod/podselect
4633a7c4
LW
216
217addedbyconf = UU $(shextract) $(plextract) pstruct
2304df62 218
fed7345c 219h1 = EXTERN.h INTERN.h XSUB.h av.h config.h cop.h cv.h dosish.h
a0d0e21e 220h2 = embed.h form.h gv.h handy.h hv.h keywords.h mg.h op.h
2304df62 221h3 = opcode.h patchlevel.h perl.h perly.h pp.h proto.h regcomp.h
219f41b1 222h4 = regexp.h scope.h sv.h unixish.h util.h iperlsys.h thread.h
599cee73 223h5 = bytecode.h byterun.h utf8.h warning.h
33b839e2 224h = $(h1) $(h2) $(h3) $(h4) $(h5)
2304df62 225
33b839e2 226c1 = $(mallocsrc) av.c scope.c op.c doop.c doio.c dump.c hv.c mg.c byterun.c
a0ed51b3 227c2 = perl.c perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c utf8.c
760ac839 228c3 = gv.c sv.c taint.c toke.c util.c deb.c run.c universal.c globals.c perlio.c
2304df62 229
a0d0e21e 230c = $(c1) $(c2) $(c3) miniperlmain.c perlmain.c
2304df62 231
33b839e2 232obj1 = $(mallocobj) gv$(OBJ_EXT) toke$(OBJ_EXT) perly$(OBJ_EXT) op$(OBJ_EXT) regcomp$(OBJ_EXT) dump$(OBJ_EXT) util$(OBJ_EXT) mg$(OBJ_EXT) byterun$(OBJ_EXT)
cd4d8a96 233obj2 = hv$(OBJ_EXT) av$(OBJ_EXT) run$(OBJ_EXT) pp_hot$(OBJ_EXT) sv$(OBJ_EXT) pp$(OBJ_EXT) scope$(OBJ_EXT) pp_ctl$(OBJ_EXT) pp_sys$(OBJ_EXT)
a0ed51b3 234obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) universal$(OBJ_EXT) globals$(OBJ_EXT) perlio$(OBJ_EXT)
655635e8 235
4633a7c4 236obj = $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
2304df62 237
a0d0e21e
LW
238# Once perl has been Configure'd and built ok you build different
239# perl variants (Debugging, Embedded, Multiplicity etc) by saying:
d96ebe2e 240# make clean; make LIBPERL=libperl<type>.a
a0d0e21e
LW
241# where <type> is some combination of 'd' and(or) 'e' or 'm'.
242# See cflags to understand how this works.
243#
d96ebe2e
PP
244# This mechanism is getting clunky and might not even work any more.
245# EMBEDDING is on by default, and MULTIPLICITY doesn't work.
246#
a0d0e21e 247
2304df62
AD
248lintflags = -hbvxac
249
cd4d8a96 250.c$(OBJ_EXT):
d96ebe2e 251 $(CCCMD) $(PLDLFLAGS) $*.c
2304df62 252
4318d5a0 253all: $(FIRSTMAKEFILE) miniperl $(private) $(plextract) $(public) $(dynamic_ext) $(nonxs_ext)
248e23d9
GS
254 @echo " ";
255 @echo " Everything is up to date. 'make test' to run test suite."
909b3858 256
6ee623d5
GS
257compile: all
258 echo "testing compilation" > testcompile;
259 cd utils; $(MAKE) compile;
260 cd x2p; $(MAKE) compile;
261 cd pod; $(MAKE) compile;
262
909b3858 263translators: miniperl lib/Config.pm FORCE
6ee623d5 264 @echo " "; echo " Making x2p stuff"; cd x2p; $(LDLIBPTH) $(MAKE) all
8e07c86e 265
909b3858 266utilities: miniperl lib/Config.pm FORCE
6ee623d5 267 @echo " "; echo " Making utilities"; cd utils; $(LDLIBPTH) $(MAKE) all
909b3858
PP
268
269
16d20bd9
AD
270# This is now done by installman only if you actually want the man pages.
271# @echo " "; echo " Making docs"; cd pod; $(MAKE) all;
85e6fe83
LW
272
273# Phony target to force checking subdirectories.
e50aee73 274# Apparently some makes require an action for the FORCE target.
85e6fe83 275FORCE:
4633a7c4 276 @sh -c true
85e6fe83 277
cd4d8a96 278miniperlmain$(OBJ_EXT): miniperlmain.c
d96ebe2e 279 $(CCCMD) $(PLDLFLAGS) $*.c
ecfc5424 280
655635e8 281perlmain.c: miniperlmain.c config.sh $(FIRSTMAKEFILE)
a0d0e21e
LW
282 sh writemain $(DYNALOADER) $(static_ext) > tmp
283 sh mv-if-diff tmp perlmain.c
85e6fe83 284
cd4d8a96 285perlmain$(OBJ_EXT): perlmain.c
d96ebe2e 286 $(CCCMD) $(PLDLFLAGS) $*.c
85e6fe83 287
a0d0e21e
LW
288# The file ext.libs is a list of libraries that must be linked in
289# for static extensions, e.g. -lm -lgdbm, etc. The individual
290# static extension Makefile's add to it.
fed7345c 291ext.libs: $(static_ext)
a0d0e21e 292 -@test -f ext.libs || touch ext.libs
85e6fe83 293
ecfc5424 294!NO!SUBS!
599a829f 295
d96ebe2e 296# How to build libperl. This is still rather convoluted.
599a829f 297# Load up custom Makefile.SH fragment for shared loading and executables:
d96ebe2e
PP
298if test -r $osname/Makefile.SHs ; then
299 . $osname/Makefile.SHs
300 $spitshell >>Makefile <<!GROK!THIS!
cd4d8a96
PP
301
302Makefile: $osname/Makefile.SHs
cd4d8a96
PP
303!GROK!THIS!
304else
f0efd8cf 305 $spitshell >>Makefile <<'!NO!SUBS!'
9c9e9f08
PP
306$(LIBPERL): $& perl$(OBJ_EXT) $(obj)
307!NO!SUBS!
d96ebe2e
PP
308 case "$useshrplib" in
309 true)
310 $spitshell >>Makefile <<'!NO!SUBS!'
3c321fdc
PP
311 $(LD) $(SHRPLDFLAGS) -o $@ perl$(OBJ_EXT) $(obj)
312!NO!SUBS!
313 case "$osname" in
314 aix)
315 $spitshell >>Makefile <<'!NO!SUBS!'
28e8609d 316 rm -f libperl$(OBJ_EXT)
3c321fdc
PP
317 mv $@ libperl$(OBJ_EXT)
318 $(AR) qv $(LIBPERL) libperl$(OBJ_EXT)
ecfc5424 319!NO!SUBS!
3c321fdc
PP
320 ;;
321 esac
d96ebe2e
PP
322 ;;
323 *)
324 $spitshell >>Makefile <<'!NO!SUBS!'
325 rm -f $(LIBPERL)
326 $(AR) rcu $(LIBPERL) perl$(OBJ_EXT) $(obj)
327 @$(ranlib) $(LIBPERL)
655635e8 328!NO!SUBS!
d96ebe2e
PP
329 ;;
330 esac
599a829f
IZ
331 $spitshell >>Makefile <<'!NO!SUBS!'
332
333# How to build executables.
334
335# The $& notation tells Sequent machines that it can do a parallel make,
336# and is harmless otherwise.
337# The miniperl -w -MExporter line is a basic cheap test to catch errors
338# before make goes on to run preplibrary and then MakeMaker on extensions.
339# This is very handy because later errors are often caused by miniperl
340# build problems but that's not obvious to the novice.
341# The Module used here must not depend on Config or any extensions.
342
343miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)
6ee623d5 344 $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) $(LLIBPERL) $(libs)
bfc6b1eb 345 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e 0 || $(MAKE) minitest
599a829f
IZ
346
347perl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
6ee623d5 348 $(SHRPENV) $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
599a829f
IZ
349
350pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
6ee623d5 351 $(SHRPENV) $(LDLIBPTH) purify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
599a829f 352
dbadb36a 353purecovperl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
6ee623d5 354 $(SHRPENV) $(LDLIBPTH) purecov $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o purecovperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
dbadb36a 355
599a829f 356quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
6ee623d5 357 $(SHRPENV) $(LDLIBPTH) quantify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
2304df62
AD
358
359# This version, if specified in Configure, does ONLY those scripts which need
360# set-id emulation. Suidperl must be setuid root. It contains the "taint"
361# checks as well as the special code to validate that the script in question
362# has been invoked correctly.
363
d96ebe2e 364suidperl: $& sperl$(OBJ_EXT) perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
6ee623d5 365 $(SHRPENV) $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o suidperl perlmain$(OBJ_EXT) sperl$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
2304df62 366
599a829f
IZ
367!NO!SUBS!
368
369fi
370
371$spitshell >>Makefile <<'!NO!SUBS!'
372
cd4d8a96 373sperl$(OBJ_EXT): perl.c perly.h patchlevel.h $(h)
2304df62 374 $(RMS) sperl.c
85e6fe83 375 $(LNS) perl.c sperl.c
d96ebe2e 376 $(CCCMD) -DIAMSUID sperl.c
2304df62
AD
377 $(RMS) sperl.c
378
fec02dd3
AD
379# We have to call our ./makedir because Ultrix 4.3 make can't handle the line
380# test -d lib/auto || mkdir lib/auto
381#
4633a7c4 382preplibrary: miniperl lib/Config.pm $(plextract)
cd4d8a96 383 @sh ./makedir lib/auto
a0d0e21e 384 @echo " AutoSplitting perl library"
bfc6b1eb 385 $(LDLIBPTH) ./miniperl -Ilib -e 'use AutoSplit; \
a0d0e21e 386 autosplit_lib_modules(@ARGV)' lib/*.pm lib/*/*.pm
2304df62 387
75f92628 388# Take care to avoid modifying lib/Config.pm without reason
fb73857a
PP
389# (If trying to create a new port and having problems with the configpm script,
390# try 'make minitest' and/or commenting out the tests at the end of configpm.)
655635e8 391lib/Config.pm: config.sh miniperl configpm
6ee623d5 392 $(LDLIBPTH) ./miniperl configpm tmp
a3f9223b 393 sh mv-if-diff tmp $@
2304df62 394
37120919 395lib/ExtUtils/Miniperl.pm: miniperlmain.c miniperl minimod.pl lib/Config.pm
a3f9223b
GS
396 $(LDLIBPTH) ./miniperl minimod.pl > tmp
397 sh mv-if-diff tmp $@
fed7345c 398
56953603 399lib/re.pm: ext/re/re.pm
ceb0239c 400 rm -f $@
56953603
IZ
401 cat ext/re/re.pm > $@
402
403$(plextract): miniperl lib/Config.pm lib/re.pm
474d7bc5 404 $(LDLIBPTH) ./miniperl -Ilib $@.PL
6ee623d5 405
16d20bd9
AD
406install: all install.perl install.man
407
cd4d8a96 408install.perl: all installperl
6ee623d5
GS
409 if [ -n "$(COMPILE)" ]; \
410 then \
411 cd utils; $(MAKE) compile; \
412 cd ../x2p; $(MAKE) compile; \
413 cd ../pod; $(MAKE) compile; \
83673e1f 414 else :; \
6ee623d5
GS
415 fi
416 $(LDLIBPTH) ./perl installperl
a0d0e21e 417
cd4d8a96 418install.man: all installman
6ee623d5 419 $(LDLIBPTH) ./perl installman
16d20bd9 420
84902520
TB
421# XXX Experimental. Hardwired values, but useful for testing.
422# Eventually Configure could ask for some of these values.
423install.html: all installhtml
6ee623d5 424 $(LDLIBPTH) ./perl installhtml \
84902520
TB
425 --podroot=. --podpath=. --recurse \
426 --htmldir=$(privlib)/html \
427 --htmlroot=$(privlib)/html \
428 --splithead=pod/perlipc \
429 --splititem=pod/perlfunc \
430 --libpods=perlfunc:perlguts:perlvar:perlrun:perlop \
431 --verbose
432
16d20bd9 433
a0d0e21e 434# I now supply perly.c with the kits, so the following section is
56febc5e
AD
435# used only if you force byacc to run by saying
436# make run_byacc
437# Since we patch up the byacc output, the perly.fixer script needs
438# to run with precisely the same version of byacc as I use. You
439# normally shouldn't remake perly.[ch].
440
232e078e 441run_byacc: FORCE
28757baa 442 @ echo 'Expect' 113 shift/reduce and 1 reduce/reduce conflict
56febc5e 443 $(BYACC) -d perly.y
fb73857a 444 chmod 664 perly.c
56febc5e 445 sh $(shellflags) ./perly.fixer y.tab.c perly.c
55497cff
PP
446 sed -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' \
447 -e 's/y\.tab/perly/g' perly.c >perly.tmp && mv perly.tmp perly.c
ebb99254 448 sed -e '/^extern YYSTYPE yy/D' y.tab.h >yh.tmp && mv yh.tmp y.tab.h
55497cff 449 cmp -s y.tab.h perly.h && rm -f y.tab.h || mv y.tab.h perly.h
fb73857a
PP
450 chmod 664 vms/perly_c.vms vms/perly_h.vms
451 perl vms/vms_yfix.pl perly.c perly.h vms/perly_c.vms vms/perly_h.vms
56febc5e
AD
452
453# We don't want to regenerate perly.c and perly.h, but they might
454# appear out-of-date after a patch is applied or a new distribution is
455# made.
456perly.c: perly.y
cd4d8a96 457 -@sh -c true
56febc5e
AD
458
459perly.h: perly.y
cd4d8a96 460 -@sh -c true
a0d0e21e 461
bd656b61 462# No compat3.sym here since and including the 5.004_50.
e4d5a464 463# No interp.sym since 5.005_03.
22c35a8c 464SYM = global.sym globvar.sym perlio.sym pp.sym
419eaf7b 465
22c35a8c 466SYMH = perlvars.h intrpvar.h thrdvar.h
419eaf7b 467
a8581515 468# The following files are generated automatically
e50aee73
AD
469# keywords.h: keywords.pl
470# opcode.h: opcode.pl
22c35a8c
GS
471# pp_proto.h: opcode.pl
472# pp.sym: opcode.pl
473# embed.h: embed.pl [* needs pp.sym generated by opcode.pl! *]
474# embedvar.h: embed.pl [* needs pp.sym generated by opcode.pl! *]
a8581515
MB
475# byterun.h: bytecode.pl
476# byterun.c: bytecode.pl
477# lib/B/Asmdata.pm: bytecode.pl
d09b2d29 478# regnodes.h: regcomp.pl
599cee73 479# warning.h lib/warning.pm: warning.pl
e50aee73
AD
480# The correct versions should be already supplied with the perl kit,
481# in case you don't have perl available.
482# To force them to run, type
483# make regen_headers
484regen_headers: FORCE
485 perl keywords.pl
486 perl opcode.pl
487 perl embed.pl
a8581515 488 perl bytecode.pl
d09b2d29 489 perl regcomp.pl
599cee73 490 perl warning.pl
8e07c86e 491
a0d0e21e 492# Extensions:
4318d5a0
GB
493# Names added to $(dynamic_ext) or $(static_ext) or $(nonxs_ext) will
494# automatically get built. There should ordinarily be no need to change
495# any of this part of makefile.
a0d0e21e
LW
496#
497# The dummy dependency is a place holder in case $(dynamic_ext) or
498# $(static_ext) is empty.
499#
500# DynaLoader may be needed for extensions that use Makefile.PL.
501
502$(DYNALOADER): miniperl preplibrary FORCE
6ee623d5 503 @$(LDLIBPTH) sh ext/util/make_ext static $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
a0d0e21e
LW
504
505d_dummy $(dynamic_ext): miniperl preplibrary $(DYNALOADER) FORCE
6ee623d5 506 @$(LDLIBPTH) sh ext/util/make_ext dynamic $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
a0d0e21e
LW
507
508s_dummy $(static_ext): miniperl preplibrary $(DYNALOADER) FORCE
6ee623d5 509 @$(LDLIBPTH) sh ext/util/make_ext static $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
2304df62 510
4318d5a0
GB
511n_dummy $(nonxs_ext): miniperl preplibrary $(DYNALOADER) FORCE
512 @$(LDLIBPTH) sh ext/util/make_ext nonxs $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
513
17b893d8 514clean: _tidy _mopup
70af249b
CS
515
516realclean: _cleaner _mopup
4e2a5f63 517 @echo "Note that make realclean does not delete config.sh or Policy.sh"
70af249b
CS
518
519clobber: _cleaner _mopup
4e2a5f63 520 rm -f config.sh cppstdin Policy.sh
70af249b
CS
521
522distclean: clobber
523
524# Do not 'make _mopup' directly.
525_mopup:
cd4d8a96 526 rm -f *$(OBJ_EXT) *$(LIB_EXT) all perlmain.c
fed7345c 527 rm -f perl.exp ext.libs
d96ebe2e 528 -rm -f perl.export perl.dll perl.libexp perl.map perl.def
1cfa4ec7 529 -rm -f perl.loadmap miniperl.loadmap perl.prelmap miniperl.prelmap
70af249b
CS
530 rm -f perl suidperl miniperl $(LIBPERL)
531
532# Do not 'make _tidy' directly.
533_tidy:
e3f83878
JH
534 -cd pod; $(LDLIBPTH) $(MAKE) clean
535 -cd utils; $(LDLIBPTH) $(MAKE) clean
536 -cd x2p; $(LDLIBPTH) $(MAKE) clean
4318d5a0 537 -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
e3f83878 538 $(LDLIBPTH) sh ext/util/make_ext clean $$x MAKE=$(MAKE) ; \
a0d0e21e 539 done
6ee623d5 540 rm -f testcompile compilelog
ff68c719
PP
541
542# Do not 'make _cleaner' directly.
543_cleaner:
4633a7c4 544 -cd os2; rm -f Makefile
e3f83878
JH
545 -cd pod; $(LDLIBPTH) $(MAKE) realclean
546 -cd utils; $(LDLIBPTH) $(MAKE) realclean
547 -cd x2p; $(LDLIBPTH) $(MAKE) realclean
4318d5a0 548 -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
e3f83878 549 $(LDLIBPTH) sh ext/util/make_ext realclean $$x MAKE=$(MAKE) ; \
a0d0e21e 550 done
8544a514 551 rm -f *.orig */*.orig *~ */*~ core core.perl.*.? core.miniperl.*.? perl.core miniperl.core t/core t/core.perl.*.? t/perl.core t/tmp???? t/c t/perl so_locations t/nonexistent1
a0d0e21e 552 rm -rf $(addedbyconf)
cd4d8a96 553 rm -f $(FIRSTMAKEFILE) $(FIRSTMAKEFILE).old
fed7345c 554 rm -f $(private)
a0d0e21e 555 rm -rf lib/auto
181ea953 556 rm -f lib/.exists lib/*/.exists
16d20bd9 557 rm -f h2ph.man pstruct
a0d0e21e 558 rm -rf .config
6ee623d5 559 rm -f testcompile compilelog
ecfc5424 560
2304df62
AD
561# The following lint has practically everything turned on. Unfortunately,
562# you have to wade through a lot of mumbo jumbo that can't be suppressed.
563# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
564# for that spot.
565
566lint: perly.c $(c)
567 lint $(lintflags) $(defs) perly.c $(c) > perl.fuzz
568
fb73857a
PP
569# Need to unset during recursion to go out of loop.
570# The README below ensures that the dependency list is never empty and
571# that when MAKEDEPEND is empty $(FIRSTMAKEFILE) doesn't need rebuilding.
cd4d8a96 572
84902520 573MAKEDEPEND = Makefile makedepend
cd4d8a96 574
fb73857a 575$(FIRSTMAKEFILE): README $(MAKEDEPEND)
cd4d8a96 576 $(MAKE) depend MAKEDEPEND=
a0d0e21e 577
599a829f 578config.h: config_h.SH config.sh
655635e8
PP
579 $(SHELL) config_h.SH
580
419eaf7b
JH
581# This is an AIXism.
582perl.exp: perl_exp.SH config.sh $(SYM) $(SYMH)
655635e8 583 $(SHELL) perl_exp.SH
75f92628 584
a0d0e21e 585# When done, touch perlmain.c so that it doesn't get remade each time.
2304df62 586depend: makedepend
fb73857a 587 sh ./makedepend MAKE=$(MAKE)
a0d0e21e 588 - test -s perlmain.c && touch perlmain.c
2304df62
AD
589 cd x2p; $(MAKE) depend
590
cd4d8a96
PP
591# Cannot postpone this until $firstmakefile is ready ;-)
592makedepend: makedepend.SH config.sh
593 sh ./makedepend.SH
594
4318d5a0 595test-prep: miniperl perl preplibrary utilities $(dynamic_ext) $(nonxs_ext)
3e3baf6d
TB
596 cd t && (rm -f perl$(EXE_EXT); $(LNS) ../perl$(EXE_EXT) perl$(EXE_EXT))
597
598test check: test-prep
6ee623d5 599 cd t && $(LDLIBPTH) ./perl TEST </dev/tty
3e3baf6d 600
a0ed51b3
LW
601utest ucheck: test-prep
602 cd t && $(LDLIBPTH) ./perl UTEST </dev/tty
603
3e3baf6d
TB
604# For testing without a tty or controling terminal. See t/op/stat.t
605test-notty: test-prep
6ee623d5 606 cd t && PERL_SKIP_TTY_TEST=1 $(LDLIBPTH) ./perl TEST
2304df62 607
d96ebe2e
PP
608# Can't depend on lib/Config.pm because that might be where miniperl
609# is crashing.
a35c6d74 610minitest: miniperl lib/re.pm
d96ebe2e
PP
611 @echo "You may see some irrelevant test failures if you have been unable"
612 @echo "to build lib/Config.pm."
cd4d8a96 613 - cd t && (rm -f perl$(EXE_EXT); $(LNS) ../miniperl$(EXE_EXT) perl$(EXE_EXT)) \
6ee623d5 614 && $(LDLIBPTH) ./perl TEST base/*.t comp/*.t cmd/*.t io/*.t op/*.t pragma/*.t </dev/tty
16d20bd9 615
fb73857a 616# Handy way to run perlbug -ok without having to install and run the
84902520 617# installed perlbug. We don't re-run the tests here - we trust the user.
fb73857a 618# Please *don't* use this unless all tests pass.
1d2dff63 619# If you want to report test failures, use "make nok" instead.
188cd53f 620ok: utilities
39fa2da7 621 $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)'
84902520 622
105f9295 623okfile: utilities
39fa2da7 624 $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok
105f9295 625
1d2dff63 626nok: utilities
39fa2da7 627 $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)'
1d2dff63 628
85e6fe83 629clist: $(c)
28e8609d 630 echo $(c) | tr ' ' $(TRNL) >.clist
2304df62 631
85e6fe83 632hlist: $(h)
28e8609d 633 echo $(h) | tr ' ' $(TRNL) >.hlist
2304df62 634
85e6fe83 635shlist: $(sh)
28e8609d 636 echo $(sh) | tr ' ' $(TRNL) >.shlist
2304df62 637
4633a7c4 638pllist: $(pl)
28e8609d 639 echo $(pl) | tr ' ' $(TRNL) >.pllist
4633a7c4 640
599a829f 641Makefile: Makefile.SH ./config.sh
760ac839
LW
642 $(SHELL) Makefile.SH
643
599a829f 644distcheck: FORCE
760ac839
LW
645 perl '-MExtUtils::Manifest=&fullcheck' -e 'fullcheck()'
646
771c4874
IZ
647elc: emacs/cperl-mode.elc
648
649emacs/cperl-mode.elc: emacs/cperl-mode.el
650 -cd emacs; emacs -batch -q -no-site-file -f batch-byte-compile cperl-mode.el
651
652etags: emacs/cperl-mode.elc
3ee700d1 653 sh emacs/ptags
01e22528
CK
654 perl emacs/e2ctags.pl TAGS > tags
655
656ctags: etags
3ee700d1 657
2304df62
AD
658# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
659# If this runs make out of memory, delete /usr/include lines.
660!NO!SUBS!
661
85e6fe83 662$eunicefix Makefile
2304df62
AD
663case `pwd` in
664*SH)
85e6fe83 665 $rm -f ../Makefile
cd4d8a96 666 $ln Makefile ../Makefile
2304df62
AD
667 ;;
668esac
cd4d8a96 669$rm -f $firstmakefile
5ff3f7a4
GS
670
671# Now do any special processing required before building.
672
673case "$ebcdic" in
674$define)
675 xxx=''
676 echo "This is an EBCDIC system, checking if any parser files need regenerating." >&4
7a66b286 677case "$osname" in
25e9a2e3 678os390|posix-bc)
5ff3f7a4 679 rm -f y.tab.c y.tab.h
e9d08790 680 # yacc must be a reentrant ("pure") Bison in BS2000 Posix!
5ff3f7a4
GS
681 yacc -d perly.y >/dev/null 2>&1
682 if cmp -s y.tab.c perly.c; then
683 rm -f y.tab.c
684 else
685 echo "perly.y -> perly.c" >&2
686 mv -f y.tab.c perly.c
687 chmod u+w perly.c
c8dba6f3
GS
688 sed -e '/^#include "perl\.h"/a\
689\
690#define yydebug PL_yydebug\
691#define yynerrs PL_yynerrs\
692#define yyerrflag PL_yyerrflag\
693#define yychar PL_yychar\
c8dba6f3
GS
694#define yyval PL_yyval\
695#define yylval PL_yylval' \
696 -e '/YYSTYPE *yyval;/D' \
697 -e '/YYSTYPE *yylval;/D' \
698 -e '/int yychar,/,/yynerrs;/D' \
699 -e 's/int yydebug = 0;/yydebug = 0;/' \
700 -e 's/[^_]realloc(/PerlMem_realloc(/g' \
701 -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' \
5ff3f7a4
GS
702 -e 's/y\.tab/perly/g' perly.c >perly.tmp && mv perly.tmp perly.c
703 xxx="$xxx perly.c"
704 fi
705 if cmp -s y.tab.h perly.h; then
706 rm -f y.tab.h
707 else
708 echo "perly.y -> perly.h" >&2
709 mv -f y.tab.h perly.h
710 xxx="$xxx perly.h"
711 fi
e9d08790 712 if cd x2p
5ff3f7a4 713 then
e9d08790 714 rm -f y.tab.c y.tab.h
5928ee40
JH
715 case "$osname" in
716 posix-bc)
717 # we are using two different yaccs in BS2000 Posix!
718 byacc a2p.y >/dev/null 2>&1
719 ;;
720 *) # e.g. os390
721 yacc a2p.y >/dev/null 2>&1
722 ;;
723 esac
e9d08790
JH
724 if cmp -s y.tab.c a2p.c
725 then
726 rm -f y.tab.c
727 else
728 echo "a2p.y -> a2p.c" >&2
729 mv -f y.tab.c a2p.c
730 chmod u+w a2p.c
731 sed -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' \
732 -e 's/y\.tab/a2p/g' a2p.c >a2p.tmp && mv a2p.tmp a2p.c
733 xxx="$xxx a2p.c"
734 fi
735 # In case somebody yacc -d:ed the a2p.y.
736 if test -f y.tab.h
737 then
738 if cmp -s y.tab.h a2p.h
739 then
740 rm -f y.tab.h
741 else
742 echo "a2p.h -> a2p.h" >&2
743 mv -f y.tab.h a2p.h
744 xxx="$xxx a2p.h"
745 fi
746 fi
747 cd ..
5ff3f7a4 748 fi
7a66b286
JH
749 ;;
750vmesa)
751 # Do nothing in VM/ESA.
752 ;;
aa34f189 753*)
e9d08790 754 echo "'$osname' is an EBCDIC system I don't know that well." >&4
aa34f189 755 ;;
fe572743 756esac
5ff3f7a4
GS
757 case "$xxx" in
758 '') echo "No parser files were regenerated. That's okay." >&2 ;;
759 esac
760 ;;
761esac
762