This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Some minor changes for Cygwin
[perl5.git] / Makefile.SH
CommitLineData
599a829f 1#! /bin/sh
a02608de 2case $PERL_CONFIG_SH in
2304df62 3'')
66b99216
JH
4 if test -f config.sh
5 then TOP=.
2304df62
AD
6 else
7 echo "Can't find config.sh."; exit 1
8 fi
9 . $TOP/config.sh
10 ;;
11esac
12: This forces SH files to create target in same directory as SH file.
13: This is so that make depend always knows where to find SH derivatives.
14case "$0" in
15*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
16esac
17
2304df62
AD
18case "$d_dosuid" in
19*define*) suidperl='suidperl' ;;
20*) suidperl='';;
21esac
22
d5d19f97 23linklibperl='$(LIBPERL)'
3c321fdc 24shrpldflags='$(LDDLFLAGS)'
6ee623d5 25ldlibpth=''
ac9901e0 26DPERL_EXTERNAL_GLOB='-DPERL_EXTERNAL_GLOB'
d96ebe2e
PP
27case "$useshrplib" in
28true)
f4db5405 29 # Prefix all runs of 'miniperl' and 'perl' with
5cf1d1f1 30 # $ldlibpth so that ./perl finds *this* shared libperl.
c1b49bc0
GS
31 case "$LD_LIBRARY_PATH" in
32 '')
33 ldlibpth="LD_LIBRARY_PATH=`pwd`";;
34 *)
35 ldlibpth="LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}";;
36 esac
6ee623d5 37
d5d19f97 38 pldlflags="$cccdlflags"
d96ebe2e
PP
39 case "${osname}${osvers}" in
40 next4*)
3c321fdc
PP
41 ld=libtool
42 lddlflags="-dynamic -undefined warning -framework System \
43 -compatibility_version 1 -current_version $patchlevel \
44 -prebind -seg1addr 0x27000000 -install_name \$(shrpdir)/\$@"
6ee623d5 45 ;;
f556e5b9
JH
46 rhapsody*|darwin*)
47 shrpldflags="${ldflags} -dynamiclib \
c1e7a127
W
48 -compatibility_version \
49 ${api_revision}.${api_version}.${api_subversion} \
f556e5b9 50 -current_version \
c1e7a127 51 ${revision}.${patchlevel}.${subversion} \
f556e5b9
JH
52 -install_name \$(shrpdir)/\$@"
53 ;;
5cf1d1f1 54 cygwin*)
8736538c
AS
55 linklibperl="-lperl"
56 ;;
73d40b3e 57 sunos*)
d5d19f97
UP
58 linklibperl="-lperl"
59 ;;
43039de7 60 netbsd*|freebsd[234]*|openbsd*)
099685bc
JH
61 linklibperl="-L. -lperl"
62 ;;
3c321fdc
PP
63 aix*)
64 shrpldflags="-H512 -T512 -bhalt:4 -bM:SRE -bE:perl.exp"
1553ab04 65 case "$osvers" in
549a6b10 66 3*) shrpldflags="$shrpldflags -e _nostart"
1553ab04 67 ;;
549a6b10 68 *) shrpldflags="$shrpldflags -b noentry"
1553ab04
TB
69 ;;
70 esac
9c839522 71 shrpldflags="$shrpldflags $ldflags $perllibs $cryptlib"
549a6b10 72 linklibperl="-L $archlibexp/CORE -L `pwd | sed 's/\/UU$//'` -lperl"
3c321fdc 73 ;;
1c7d1a19
GS
74 hpux*)
75 linklibperl="-L `pwd | sed 's/\/UU$//'` -Wl,+s -Wl,+b$archlibexp/CORE -lperl"
46193409 76 ;;
ac9901e0 77 os390*)
f2766b05 78 shrpldflags='-W l,dll'
ac9901e0
PP
79 linklibperl='libperl.x'
80 DPERL_EXTERNAL_GLOB=''
81 ;;
655635e8 82 esac
5cf1d1f1
JH
83 case "$ldlibpthname" in
84 '') ;;
85 *)
86 case "$osname" in
87 os2)
88 ldlibpth=''
89 ;;
5cf1d1f1
JH
90 *)
91 eval "ldlibpth=\"$ldlibpthname=`pwd`:\$$ldlibpthname\""
92 ;;
93 esac
c1b49bc0
GS
94 # Strip off any trailing :'s
95 ldlibpth=`echo $ldlibpth | sed 's/:*$//'`
5cf1d1f1
JH
96 ;;
97 esac
d5d19f97 98 ;;
f0efd8cf 99*) pldlflags=''
d96ebe2e 100 ;;
ecfc5424
AD
101esac
102
6904989c
JH
103case "`pwd`" in
104# Protect any spaces
105*" "*) ldlibpth=`echo $ldlibpth|sed 's/ /\\\\ /g'` ;;
106esac
107
b1f5ad7d
JH
108case "$osname" in
109os390) test -f /bin/env && ldlibpth="/bin/env $ldlibpth"
110 ;;
111esac
112
a0d0e21e
LW
113: Prepare dependency lists for Makefile.
114dynamic_list=' '
115for f in $dynamic_ext; do
116 : the dependency named here will never exist
ecfc5424 117 base=`echo "$f" | sed 's/.*\///'`
75f92628 118 dynamic_list="$dynamic_list lib/auto/$f/$base.$dlext"
a0d0e21e
LW
119done
120
121static_list=' '
a0d0e21e
LW
122for f in $static_ext; do
123 base=`echo "$f" | sed 's/.*\///'`
cd4d8a96 124 static_list="$static_list lib/auto/$f/$base\$(LIB_EXT)"
a0d0e21e
LW
125done
126
4318d5a0
GB
127nonxs_list=' '
128for f in $nonxs_ext; do
129 base=`echo "$f" | sed 's/.*\///'`
130 nonxs_list="$nonxs_list ext/$f/pm_to_blib"
131done
132
f1f802f7
JH
133# Handle the usage of different yaccs in posix-bc (During Configure we
134# us yacc for perly.y and byacc for a2p.y. The makefiles must use the
135# same configuration for run_byacc!):
136case "$osname" in
137 posix-bc)
138 byacc=$yacc
139 ;;
140esac
141
2304df62 142echo "Extracting Makefile (with variable substitutions)"
655635e8 143$spitshell >Makefile <<!GROK!THIS!
a0d0e21e 144# Makefile.SH
85e6fe83
LW
145# This file is derived from Makefile.SH. Any changes made here will
146# be lost the next time you run Configure.
655635e8
PP
147# Makefile is used to generate $firstmakefile. The only difference
148# is that $firstmakefile has the dependencies filled in at the end.
2304df62 149#
fed7345c 150#
2304df62
AD
151# I now supply perly.c with the kits, so don't remake perly.c without byacc
152BYACC = $byacc
153CC = $cc
232e078e 154LD = $ld
16d20bd9 155
2304df62
AD
156LDFLAGS = $ldflags
157CLDFLAGS = $ldflags
85e6fe83 158
2304df62
AD
159mallocsrc = $mallocsrc
160mallocobj = $mallocobj
85e6fe83 161LNS = $lns
4c901d04
JH
162# NOTE: some systems don't grok "cp -f". XXX Configure test needed?
163CPS = $cp
2304df62 164RMS = rm -f
85e6fe83
LW
165ranlib = $ranlib
166
16d20bd9
AD
167# The following are mentioned only to make metaconfig include the
168# appropriate questions in Configure. If you want to change these,
8e07c86e 169# edit config.sh instead, or specify --man1dir=/wherever on
16d20bd9
AD
170# installman commandline.
171bin = $installbin
172scriptdir = $scriptdir
d96ebe2e 173shrpdir = $archlibexp/CORE
16d20bd9
AD
174privlib = $installprivlib
175man1dir = $man1dir
176man1ext = $man1ext
177man3dir = $man3dir
178man3ext = $man3ext
179
85e6fe83
LW
180# The following are used to build and install shared libraries for
181# dynamic loading.
182LDDLFLAGS = $lddlflags
3c321fdc 183SHRPLDFLAGS = $shrpldflags
85e6fe83 184CCDLFLAGS = $ccdlflags
a0d0e21e 185DLSUFFIX = .$dlext
ecfc5424 186PLDLFLAGS = $pldlflags
d96ebe2e 187LIBPERL = $libperl
d5d19f97 188LLIBPERL= $linklibperl
ecfc5424 189SHRPENV = $shrpenv
a0d0e21e 190
6ee623d5 191# The following is used to include the current directory in
5cf1d1f1 192# the dynamic loader path you are building a shared libperl.
6ee623d5
GS
193LDLIBPTH = $ldlibpth
194
a0d0e21e
LW
195dynamic_ext = $dynamic_list
196static_ext = $static_list
4318d5a0
GB
197nonxs_ext = $nonxs_list
198ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
cd4d8a96 199DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
2304df62 200
9c839522 201libs = $perllibs $cryptlib
2304df62 202
443a5b98 203public = perl\$(EXE_EXT) $suidperl utilities translators
2304df62
AD
204
205shellflags = $shellflags
206
d96ebe2e
PP
207# This is set to MAKE=$make if your $make command doesn't
208# do it for you.
209$make_set_make
4633a7c4 210
1fef16b3
JH
211# Mention $gmake here so it gets probed for by Configure.
212
dfe9444c 213# These variables may need to be manually set for non-Unix systems.
ccc7f9b3 214AR = $full_ar
dfe9444c
AD
215EXE_EXT = $_exe
216LIB_EXT = $_a
217OBJ_EXT = $_o
218PATH_SEP = $p_
4633a7c4
LW
219
220FIRSTMAKEFILE = $firstmakefile
221
222# Any special object files needed by this architecture, e.g. os2/os2.obj
223ARCHOBJS = $archobjs
224
89ada9f2 225.SUFFIXES: .c \$(OBJ_EXT) .i .s
cd4d8a96 226
d96ebe2e
PP
227# grrr
228SHELL = $sh
655635e8 229
28e8609d
JH
230# how to tr(anslate) newlines
231TRNL = '$trnl'
232
82240bfc
JH
233OPTIMIZE = $optimize
234
3343e82c
JH
235EXTRAS = $extras
236
bf35c3f6
JH
237INSTALLPREFIXEXP = $prefix
238
d56c5707 239!GROK!THIS!
b7b35fc2 240# not used by Makefile but by installperl;
d56c5707
JH
241# mentioned here so that metaconfig picks these up
242# $installusrbinperl
243# $versiononly
b7b35fc2 244
8170cb12
JH
245case "${osname}:${osvers}" in
246darwin:*)
247$spitshell >>Makefile <<EOF
248
249# Your locales are broken (osname $osname, osvers $osvers)
250# and to avoid the numerous
251# perl: warning: Setting locale failed.
252# warnings during the build process we reset the locale variables.
253
254LC_ALL=C
255LANG=C
256LANGUAGE=C
257EOF
258 ;;
259esac
2304df62 260
85e6fe83 261## In the following dollars and backticks do not need the extra backslash.
2304df62
AD
262$spitshell >>Makefile <<'!NO!SUBS!'
263
1167a30e 264CCCMD = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $(LIBPERL) $@`
89ada9f2 265
1167a30e 266CCCMDSRC = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $(LIBPERL) $<`
2304df62 267
abae58a6 268private = preplibrary lib/Config.pm lib/ExtUtils/Miniperl.pm
2304df62 269
4633a7c4
LW
270# Files to be built with variable substitution before miniperl
271# is available.
272sh = Makefile.SH cflags.SH config_h.SH makeaperl.SH makedepend.SH \
4755096e 273 makedir.SH myconfig.SH writemain.SH pod/Makefile.SH
4633a7c4 274
3ebb1980 275shextract = Makefile cflags config.h makeaperl makedepend \
4755096e 276 makedir myconfig writemain pod/Makefile
4633a7c4
LW
277
278# Files to be built with variable substitution after miniperl is
279# available. Dependencies handled manually below (for now).
2304df62 280
efb12ca0 281pl = pod/pod2html.PL pod/pod2latex.PL pod/pod2man.PL pod/pod2text.PL \
4755096e
GS
282 pod/pod2usage.PL pod/podchecker.PL pod/podselect.PL \
283 pod/buildtoc.PL
4633a7c4 284
4755096e 285# lib/lib.pm is not listed here because it has a rule of its own.
efb12ca0 286plextract = pod/pod2html pod/pod2latex pod/pod2man pod/pod2text \
4755096e
GS
287 pod/pod2usage pod/podchecker pod/podselect \
288 pod/buildtoc
4633a7c4 289
4755096e 290addedbyconf = UU $(shextract) $(plextract) lib/lib.pm pstruct
2304df62 291
fed7345c 292h1 = EXTERN.h INTERN.h XSUB.h av.h config.h cop.h cv.h dosish.h
a0d0e21e 293h2 = embed.h form.h gv.h handy.h hv.h keywords.h mg.h op.h
6f4183fe 294h3 = opcode.h patchlevel.h perl.h perlapi.h perly.h pp.h proto.h regcomp.h
219f41b1 295h4 = regexp.h scope.h sv.h unixish.h util.h iperlsys.h thread.h
68795e93 296h5 = utf8.h warnings.h
33b839e2 297h = $(h1) $(h2) $(h3) $(h4) $(h5)
2304df62 298
e8edd1e6 299c1 = $(mallocsrc) av.c scope.c op.c doop.c doio.c dump.c hv.c mg.c
a0ed51b3 300c2 = perl.c perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c utf8.c
09bef843 301c3 = gv.c sv.c taint.c toke.c util.c deb.c run.c universal.c xsutils.c
68795e93 302c4 = globals.c perlio.c perlapi.c numeric.c locale.c pp_pack.c pp_sort.c
2304df62 303
09bef843 304c = $(c1) $(c2) $(c3) $(c4) miniperlmain.c perlmain.c
2304df62 305
e8edd1e6 306obj1 = $(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)
cd4d8a96 307obj2 = 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)
68795e93 308obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) universal$(OBJ_EXT) xsutils$(OBJ_EXT) globals$(OBJ_EXT) perlio$(OBJ_EXT) perlapi$(OBJ_EXT) numeric$(OBJ_EXT) locale$(OBJ_EXT) pp_pack$(OBJ_EXT) pp_sort$(OBJ_EXT)
655635e8 309
4633a7c4 310obj = $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
2304df62 311
a0d0e21e
LW
312# Once perl has been Configure'd and built ok you build different
313# perl variants (Debugging, Embedded, Multiplicity etc) by saying:
d96ebe2e 314# make clean; make LIBPERL=libperl<type>.a
a0d0e21e
LW
315# where <type> is some combination of 'd' and(or) 'e' or 'm'.
316# See cflags to understand how this works.
317#
d96ebe2e
PP
318# This mechanism is getting clunky and might not even work any more.
319# EMBEDDING is on by default, and MULTIPLICITY doesn't work.
320#
a0d0e21e 321
2304df62
AD
322lintflags = -hbvxac
323
cd4d8a96 324.c$(OBJ_EXT):
d96ebe2e 325 $(CCCMD) $(PLDLFLAGS) $*.c
2304df62 326
89ada9f2
JH
327.c.i:
328 $(CCCMDSRC) -E $*.c > $*.i
329
330.c.s:
331 $(CCCMDSRC) -S $*.c
332
869a466c
JH
333.PHONY: all compile translators utilities
334
443a5b98 335all: $(FIRSTMAKEFILE) miniperl$(EXE_EXT) extra.pods $(private) $(public) $(dynamic_ext) $(nonxs_ext) extras.make
248e23d9 336 @echo " ";
fcfe1ab7 337 @echo " Everything is up to date. Type '$(MAKE) test' to run test suite."
909b3858 338
6ee623d5
GS
339compile: all
340 echo "testing compilation" > testcompile;
341 cd utils; $(MAKE) compile;
f4db5405 342 cd x2p; $(MAKE) compile;
6ee623d5
GS
343 cd pod; $(MAKE) compile;
344
443a5b98 345translators: miniperl$(EXE_EXT) lib/Config.pm FORCE
6ee623d5 346 @echo " "; echo " Making x2p stuff"; cd x2p; $(LDLIBPTH) $(MAKE) all
8e07c86e 347
443a5b98 348utilities: miniperl$(EXE_EXT) lib/Config.pm $(plextract) lib/lib.pm FORCE
6ee623d5 349 @echo " "; echo " Making utilities"; cd utils; $(LDLIBPTH) $(MAKE) all
909b3858
PP
350
351
16d20bd9
AD
352# This is now done by installman only if you actually want the man pages.
353# @echo " "; echo " Making docs"; cd pod; $(MAKE) all;
85e6fe83
LW
354
355# Phony target to force checking subdirectories.
e50aee73 356# Apparently some makes require an action for the FORCE target.
869a466c 357.PHONY: FORCE
85e6fe83 358FORCE:
4633a7c4 359 @sh -c true
ac9901e0
PP
360!NO!SUBS!
361$spitshell >>Makefile <<!GROK!THIS!
85e6fe83 362
4ba7095c
JH
363# We do a copy of the op.c instead of a symlink because gcc gets huffy
364# if we have a symlink forest to another disk (it complains about too many
365# levels of symbolic links, even if we have only two)
366
ac9901e0
PP
367opmini\$(OBJ_EXT): op.c config.h
368 \$(RMS) opmini.c
369 \$(CPS) op.c opmini.c
370 \$(CCCMD) \$(PLDLFLAGS) $DPERL_EXTERNAL_GLOB opmini.c
371 \$(RMS) opmini.c
bd0dd1d8 372
ac9901e0
PP
373!GROK!THIS!
374$spitshell >>Makefile <<'!NO!SUBS!'
517e7c64 375miniperlmain$(OBJ_EXT): miniperlmain.c patchlevel.h
92c28edd 376 $(CCCMD) $(PLDLFLAGS) $*.c
ecfc5424 377
92c28edd 378perlmain.c: miniperlmain.c config.sh $(FIRSTMAKEFILE)
e8827f64 379 sh writemain $(DYNALOADER) $(static_ext) > writemain.tmp
92c28edd 380 sh mv-if-diff writemain.tmp perlmain.c
85e6fe83 381
cd4d8a96 382perlmain$(OBJ_EXT): perlmain.c
92c28edd 383 $(CCCMD) $(PLDLFLAGS) $*.c
85e6fe83 384
a0d0e21e
LW
385# The file ext.libs is a list of libraries that must be linked in
386# for static extensions, e.g. -lm -lgdbm, etc. The individual
387# static extension Makefile's add to it.
fed7345c 388ext.libs: $(static_ext)
a0d0e21e 389 -@test -f ext.libs || touch ext.libs
85e6fe83 390
ecfc5424 391!NO!SUBS!
599a829f 392
d96ebe2e 393# How to build libperl. This is still rather convoluted.
599a829f 394# Load up custom Makefile.SH fragment for shared loading and executables:
8736538c 395case "$osname" in
8736538c
AS
396*)
397 Makefile_s="$osname/Makefile.SHs"
398 ;;
399esac
400
549a6b10
JH
401case "$osname" in
402aix)
403 $spitshell >>Makefile <<!GROK!THIS!
9c839522 404LIBS = $perllibs
5f9d9a17
ME
405# In AIX we need to change this for building Perl itself from
406# its earlier definition (which is for building external
407# extensions *after* Perl has been built and installed)
408CCDLFLAGS = `echo $ccdlflags|sed -e 's@-bE:.*/perl\.exp@-bE:perl.exp@'`
549a6b10
JH
409
410!GROK!THIS!
411 case "$useshrplib" in
412 define|true|[yY]*)
413 $spitshell >>Makefile <<'!NO!SUBS!'
414
415LIBPERL_NONSHR = libperl_nonshr$(LIB_EXT)
416MINIPERL_NONSHR = miniperl_nonshr$(EXE_EXT)
417
418$(LIBPERL_NONSHR): perl$(OBJ_EXT) $(obj)
419 $(RMS) $(LIBPERL_NONSHR)
420 $(AR) rcu $(LIBPERL_NONSHR) perl$(OBJ_EXT) $(obj)
421
bd0dd1d8 422$(MINIPERL_NONSHR): $(LIBPERL_NONSHR) miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT)
a7089531
GS
423 $(CC) $(LDFLAGS) -o $(MINIPERL_NONSHR) miniperlmain$(OBJ_EXT) \
424 opmini$(OBJ_EXT) $(LIBPERL_NONSHR) $(LIBS)
549a6b10
JH
425
426MINIPERLEXP = $(MINIPERL_NONSHR)
427
428LIBPERLEXPORT = perl.exp
429
430!NO!SUBS!
431
432 ;;
433 *)
434 $spitshell >>Makefile <<'!NO!SUBS!'
435MINIPERLEXP = miniperl$(EXE_EXT)
436
437PERLEXPORT = perl.exp
438
439!NO!SUBS!
440 ;;
441 esac
442 $spitshell >>Makefile <<'!NO!SUBS!'
443perl.exp: $(MINIPERLEXP) makedef.pl config.sh $(SYM) $(SYMH)
444 ./$(MINIPERLEXP) makedef.pl PLATFORM=aix | sort -u | sort -f > perl.exp.tmp
445 sh mv-if-diff perl.exp.tmp perl.exp
446
447!NO!SUBS!
448 ;;
2c2d71f5
JH
449os2)
450 $spitshell >>Makefile <<'!NO!SUBS!'
451MINIPERLEXP = miniperl
452
453perl5.def: $(MINIPERLEXP) makedef.pl config.sh $(SYM) $(SYMH) miniperl.map
454 ./$(MINIPERLEXP) makedef.pl PLATFORM=os2 -DPERL_DLL=$(PERL_DLL) > perl.exp.tmp
455 sh mv-if-diff perl.exp.tmp perl5.def
456
457!NO!SUBS!
458 ;;
549a6b10
JH
459esac
460
8736538c
AS
461if test -r $Makefile_s ; then
462 . $Makefile_s
d96ebe2e 463 $spitshell >>Makefile <<!GROK!THIS!
cd4d8a96 464
8736538c 465Makefile: $Makefile_s
cd4d8a96
PP
466!GROK!THIS!
467else
f0efd8cf 468 $spitshell >>Makefile <<'!NO!SUBS!'
549a6b10 469$(LIBPERL): $& perl$(OBJ_EXT) $(obj) $(LIBPERLEXPORT)
9c9e9f08 470!NO!SUBS!
d96ebe2e
PP
471 case "$useshrplib" in
472 true)
473 $spitshell >>Makefile <<'!NO!SUBS!'
f2766b05 474 $(LD) -o $@ $(SHRPLDFLAGS) perl$(OBJ_EXT) $(obj)
3c321fdc
PP
475!NO!SUBS!
476 case "$osname" in
477 aix)
478 $spitshell >>Makefile <<'!NO!SUBS!'
28e8609d 479 rm -f libperl$(OBJ_EXT)
3c321fdc
PP
480 mv $@ libperl$(OBJ_EXT)
481 $(AR) qv $(LIBPERL) libperl$(OBJ_EXT)
ecfc5424 482!NO!SUBS!
3c321fdc
PP
483 ;;
484 esac
d96ebe2e
PP
485 ;;
486 *)
487 $spitshell >>Makefile <<'!NO!SUBS!'
488 rm -f $(LIBPERL)
489 $(AR) rcu $(LIBPERL) perl$(OBJ_EXT) $(obj)
490 @$(ranlib) $(LIBPERL)
655635e8 491!NO!SUBS!
d96ebe2e
PP
492 ;;
493 esac
599a829f
IZ
494 $spitshell >>Makefile <<'!NO!SUBS!'
495
496# How to build executables.
497
498# The $& notation tells Sequent machines that it can do a parallel make,
499# and is harmless otherwise.
500# The miniperl -w -MExporter line is a basic cheap test to catch errors
501# before make goes on to run preplibrary and then MakeMaker on extensions.
502# This is very handy because later errors are often caused by miniperl
503# build problems but that's not obvious to the novice.
504# The Module used here must not depend on Config or any extensions.
505
ecfb2188
GS
506!NO!SUBS!
507
508 case "${osname}${osvers}" in
8fdf96e1 509 aix*)
ecfb2188 510 $spitshell >>Makefile <<'!NO!SUBS!'
bd0dd1d8 511miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL) opmini$(OBJ_EXT)
8fdf96e1
JH
512 $(CC) -o miniperl $(CLDFLAGS) \
513 `echo $(obj) | sed 's/ op$(OBJ_EXT) / /'` \
ecfb2188 514 miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) perl$(OBJ_EXT) $(libs)
bd0dd1d8 515 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
ecfb2188
GS
516!NO!SUBS!
517 ;;
8fdf96e1 518 beos*|next4*)
535d2540
JH
519 $spitshell >>Makefile <<'!NO!SUBS!'
520miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL) opmini$(OBJ_EXT)
8fdf96e1 521 $(CC) -o miniperl `echo $(obj) | sed 's/ op$(OBJ_EXT) / /'` \
535d2540
JH
522 miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) perl$(OBJ_EXT) $(libs)
523 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
524!NO!SUBS!
525 ;;
ecfb2188
GS
526 *)
527 $spitshell >>Makefile <<'!NO!SUBS!'
443a5b98 528miniperl$(EXE_EXT): $& miniperlmain$(OBJ_EXT) $(LIBPERL) opmini$(OBJ_EXT)
93c0359c 529 -@rm -f miniperl.xok
5869b1f1 530 $(LDLIBPTH) $(CC) $(CLDFLAGS) -o miniperl \
a7089531 531 miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(LLIBPERL) $(libs)
bd0dd1d8 532 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
ecfb2188
GS
533!NO!SUBS!
534 ;;
535 esac
536
537 $spitshell >>Makefile <<'!NO!SUBS!'
599a829f 538
443a5b98 539perl$(EXE_EXT): $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
93c0359c 540 -@rm -f miniperl.xok
51a35ef1 541 $(SHRPENV) $(LDLIBPTH) $(CC) -o perl$(PERL_SUFFIX) $(PERL_PROFILE_LDFLAGS) $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
599a829f 542
4ae3d70a
JH
543# Purify/Quantify Perls.
544
443a5b98 545pureperl$(EXE_EXT): $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
f2766b05 546 $(SHRPENV) $(LDLIBPTH) purify $(CC) -o pureperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
599a829f 547
443a5b98 548purecovperl$(EXE_EXT): $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
f2766b05 549 $(SHRPENV) $(LDLIBPTH) purecov $(CC) -o purecovperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
dbadb36a 550
443a5b98 551quantperl$(EXE_EXT): $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
f2766b05 552 $(SHRPENV) $(LDLIBPTH) quantify $(CC) -o quantperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
2304df62 553
4ae3d70a
JH
554# Third Degree Perl (Tru64 only)
555
719561de 556perl.config.dashg:
83f0ef60
JH
557 @echo "Checking optimize='-g' in config.sh..."
558 @grep "^optimize=" config.sh
559 @grep "^optimize='-g'" config.sh >/dev/null || exit 1
4ae3d70a
JH
560
561perl.third.config: config.sh
562 @echo "To build perl.third you must Configure -Doptimize=-g -Uusemymalloc, checking..."
6e36760b 563 @$(MAKE) perl.config.dashg
83f0ef60
JH
564 @echo "Checking usemymalloc='n' in config.sh..."
565 @grep "^usemymalloc=" config.sh
566 @grep "^usemymalloc='n'" config.sh >/dev/null || exit 1
170ba846 567
412c6516 568perl.third: /usr/bin/atom perl.third.config perl
15615bfd 569 atom -tool third -L. -all -gp -toolargs="-quiet -invalid -uninit heap+stack+partword+copy -min 0" perl
83f0ef60 570 @echo "Now you may run perl.third and then study perl.3log."
15615bfd 571
4ae3d70a
JH
572# Pixie Perls (Tru64 and IRIX only)
573
719561de 574perl.pixie.config: config.sh
4ae3d70a 575 @echo "To build perl.pixie you must Configure -Doptimize=-g, checking..."
6e36760b 576 @$(MAKE) perl.config.dashg
4ae3d70a 577
719561de 578perl.pixie.atom: /usr/bin/atom perl
4ae3d70a
JH
579 atom -tool pixie -L. -all -toolargs="-quiet" perl
580
581perl.pixie.irix: perl
582 pixie perl
583
719561de 584perl.pixie: /usr/bin/pixie perl.pixie.config perl
4ae3d70a
JH
585 if test -x /usr/bin/atom; then \
586 $(MAKE) perl.pixie.atom; \
587 else \
588 $(MAKE) perl.pixie.irix; \
589 fi
83f0ef60
JH
590 @echo "Now you may run perl.pixie and then run pixie."
591
592# Gprof Perl
593
594perl.config.dashpg:
595 @echo "Checking optimize='-pg' in config.sh..."
596 @grep "^optimize=" config.sh
64778e5f 597 @grep "^optimize='.*-pg.*'" config.sh >/dev/null || exit 1
83f0ef60
JH
598
599perl.gprof.config: config.sh
600 @echo "To build perl.gprof you must Configure -Doptimize=-pg, checking..."
601 @$(MAKE) perl.config.dashpg
602
603perl.gprof: /usr/bin/gprof perl.gprof.config
64778e5f 604 @-rm -f perl
51a35ef1 605 $(MAKE) PERL_SUFFIX=.gprof PERL_PROFILE_LDFLAGS=-pg perl
83f0ef60 606 @echo "Now you may run perl.gprof and then run gprof perl.gprof."
4ae3d70a 607
51a35ef1
JH
608# Gcov Perl
609
610perl.config.gcov:
611 @echo "To build perl.gcov you must use gcc 3.0 or newer, checking..."
612 @echo "Checking gccversion in config.sh..."
613 @grep "^gccversion=" config.sh
614 @grep "^gccversion='[3-9]\." config.sh >/dev/null || exit 1
615 @echo "To build perl.gcov you must Configure -Dccflags=-fprofile-arcs -ftest-coverage, checking..."
616 @echo "Checking ccflags='-fprofile-arcs -ftest-coverage' in config.sh..."
617 @grep "^ccflags=" config.sh
618 @grep "^ccflags='.*-fprofile-arcs -ftest-coverage.*'" config.sh >/dev/null || exit 1
619
620perl.gcov: perl.config.gcov
621 @-rm -f perl
622 $(MAKE) PERL_SUFFIX=.gcov PERL_PROFILE_LDFLAGS='' perl
623 @echo "Now you may run perl.gcov and then run gcov some.c."
624
f946bb38
JH
625# Microperl. This is just a convenience thing if one happens to
626# build also the full Perl and therefore the real big Makefile:
f4db5405 627# usually one should manually explicitly issue the below command.
f946bb38 628
869a466c 629.PHONY: microperl
f946bb38
JH
630microperl:
631 $(MAKE) -f Makefile.micro
632
2304df62
AD
633# This version, if specified in Configure, does ONLY those scripts which need
634# set-id emulation. Suidperl must be setuid root. It contains the "taint"
635# checks as well as the special code to validate that the script in question
636# has been invoked correctly.
637
443a5b98 638suidperl$(EXE_EXT): $& sperl$(OBJ_EXT) perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
f2766b05 639 $(SHRPENV) $(LDLIBPTH) $(CC) -o suidperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) sperl$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
2304df62 640
599a829f
IZ
641!NO!SUBS!
642
643fi
644
645$spitshell >>Makefile <<'!NO!SUBS!'
646
bf0dfd28 647sperl$(OBJ_EXT): perl.c $(h)
2304df62 648 $(RMS) sperl.c
85e6fe83 649 $(LNS) perl.c sperl.c
d96ebe2e 650 $(CCCMD) -DIAMSUID sperl.c
2304df62
AD
651 $(RMS) sperl.c
652
fec02dd3
AD
653# We have to call our ./makedir because Ultrix 4.3 make can't handle the line
654# test -d lib/auto || mkdir lib/auto
655#
869a466c 656.PHONY: preplibrary
a64c954a 657preplibrary: miniperl$(EXE_EXT) lib/Config.pm lib/lib.pm $(PREPLIBRARY_LIBPERL)
cd4d8a96 658 @sh ./makedir lib/auto
a0d0e21e 659 @echo " AutoSplitting perl library"
92c28edd
JH
660 $(LDLIBPTH) ./miniperl -Ilib -e 'use AutoSplit; \
661 autosplit_lib_modules(@ARGV)' lib/*.pm lib/*/*.pm
abae58a6 662 $(MAKE) lib/re.pm
2304df62 663
75f92628 664# Take care to avoid modifying lib/Config.pm without reason
f4db5405 665# (If trying to create a new port and having problems with the configpm script,
fb73857a 666# try 'make minitest' and/or commenting out the tests at the end of configpm.)
443a5b98 667lib/Config.pm: config.sh miniperl$(EXE_EXT) configpm
e8827f64 668 $(LDLIBPTH) ./miniperl configpm configpm.tmp
92c28edd 669 sh mv-if-diff configpm.tmp $@
2304df62 670
443a5b98 671lib/ExtUtils/Miniperl.pm: miniperlmain.c miniperl$(EXE_EXT) minimod.pl lib/Config.pm
e8827f64 672 $(LDLIBPTH) ./miniperl minimod.pl > minimod.tmp
92c28edd 673 sh mv-if-diff minimod.tmp $@
abae58a6 674 -touch lib/ExtUtils/Miniperl.pm
fed7345c 675
92c28edd 676lib/re.pm: ext/re/re.pm
abae58a6 677 cp ext/re/re.pm ext/re/re.tmp && sh mv-if-diff ext/re/re.tmp lib/re.pm
7cfc0d09 678
443a5b98 679$(plextract): miniperl$(EXE_EXT) lib/Config.pm
42c30c63 680 @-rm -f $@
92c28edd 681 $(LDLIBPTH) ./miniperl -Ilib $@.PL
72b3d9b4 682
443a5b98 683lib/lib.pm: miniperl$(EXE_EXT) lib/Config.pm
42c30c63 684 @-rm -f $@
4755096e
GS
685 $(LDLIBPTH) ./miniperl -Ilib lib/lib_pm.PL
686
443a5b98 687extra.pods: miniperl$(EXE_EXT)
fec93702 688 -@test -f extra.pods && rm -f `cat extra.pods`
72b3d9b4 689 -@rm -f extra.pods
b4bc034f 690 -@for x in `grep -l '^=[a-z]' README.* | grep -v README.vms` ; do \
72b3d9b4 691 nx=`echo $$x | sed -e "s/README\.//"`; \
40096396 692 cd pod ; $(LNS) ../$$x "perl"$$nx".pod" ; cd .. ; \
72b3d9b4
GS
693 echo "pod/perl"$$nx".pod" >> extra.pods ; \
694 done
bf35c3f6 695 -@rm -f pod/perlvms.pod
40096396 696 -@test -f vms/perlvms.pod && cd pod && $(LNS) ../vms/perlvms.pod perlvms.pod && cd .. && echo "pod/perlvms.pod" >> extra.pods
72b3d9b4 697
443a5b98 698extras.make: perl$(EXE_EXT)
a40613e1 699 -@test -s extras.lst && $(LDLIBPTH) PATH=`pwd`:${PATH} PERL5LIB=`pwd`/lib ./perl -Ilib -MCPAN -e '@ARGV&&make(@ARGV)' `cat extras.lst`
bf35c3f6 700
443a5b98 701extras.test: perl$(EXE_EXT)
a40613e1 702 -@test -s extras.lst && $(LDLIBPTH) PATH=`pwd`:${PATH} PERL5LIB=`pwd`/lib ./perl -Ilib -MCPAN -e '@ARGV&&test(@ARGV)' `cat extras.lst`
bf35c3f6 703
443a5b98 704extras.install: perl$(EXE_EXT)
a40613e1 705 -@test -s extras.lst && $(LDLIBPTH) PATH=`pwd`:${PATH} PERL5LIB=`pwd`/lib ./perl -Ilib -MCPAN -e '@ARGV&&install(@ARGV)' `cat extras.lst`
bf35c3f6 706
869a466c
JH
707.PHONY: install install-strip install-all install-verbose install-silent \
708 no-install install.perl install.man installman install.html installhtml
709
f556e5b9
JH
710install-strip:
711 $(MAKE) STRIPFLAGS=-s install
712
adbebc0b 713install install-all:
c458b76c 714 $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS)
c77385cf 715
4ad019ef
A
716install-verbose:
717 $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-V
c458b76c 718
4ad019ef 719install-silent:
8d0b2130 720 $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-S
4ad019ef
A
721
722no-install:
723 $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-n
16d20bd9 724
bf35c3f6 725install.perl: all installperl
6ee623d5
GS
726 if [ -n "$(COMPILE)" ]; \
727 then \
728 cd utils; $(MAKE) compile; \
729 cd ../x2p; $(MAKE) compile; \
730 cd ../pod; $(MAKE) compile; \
83673e1f 731 else :; \
6ee623d5 732 fi
c77385cf 733 $(LDLIBPTH) ./perl installperl $(INSTALLFLAGS) $(STRIPFLAGS)
bf35c3f6 734 $(MAKE) extras.install
a0d0e21e 735
b1a1e9f1 736install.man: all installman
c77385cf 737 $(LDLIBPTH) ./perl installman $(INSTALLFLAGS)
16d20bd9 738
84902520
TB
739# XXX Experimental. Hardwired values, but useful for testing.
740# Eventually Configure could ask for some of these values.
741install.html: all installhtml
40096396 742 -@test -f README.vms && cd vms && $(LNS) ../README.vms README_vms.pod && cd ..
6ee623d5 743 $(LDLIBPTH) ./perl installhtml \
84902520
TB
744 --podroot=. --podpath=. --recurse \
745 --htmldir=$(privlib)/html \
746 --htmlroot=$(privlib)/html \
747 --splithead=pod/perlipc \
748 --splititem=pod/perlfunc \
749 --libpods=perlfunc:perlguts:perlvar:perlrun:perlop \
750 --verbose
751
16d20bd9 752
a0d0e21e 753# I now supply perly.c with the kits, so the following section is
56febc5e
AD
754# used only if you force byacc to run by saying
755# make run_byacc
756# Since we patch up the byacc output, the perly.fixer script needs
757# to run with precisely the same version of byacc as I use. You
758# normally shouldn't remake perly.[ch].
759
869a466c
JH
760.PHONY: check_byacc run_byacc
761
001465dc
JH
762check_byacc:
763 @$(BYACC) -V 2>&1 | grep 'version 1\.8\.2'
764
765run_byacc: FORCE check_byacc
56febc5e 766 $(BYACC) -d perly.y
cecd0ad1 767 -chmod 664 perly.c perly.h
56febc5e 768 sh $(shellflags) ./perly.fixer y.tab.c perly.c
55497cff
PP
769 sed -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' \
770 -e 's/y\.tab/perly/g' perly.c >perly.tmp && mv perly.tmp perly.c
ebb99254 771 sed -e '/^extern YYSTYPE yy/D' y.tab.h >yh.tmp && mv yh.tmp y.tab.h
55497cff 772 cmp -s y.tab.h perly.h && rm -f y.tab.h || mv y.tab.h perly.h
f4db5405 773 perl -i perlyline.pl perly.c
fb73857a
PP
774 chmod 664 vms/perly_c.vms vms/perly_h.vms
775 perl vms/vms_yfix.pl perly.c perly.h vms/perly_c.vms vms/perly_h.vms
56febc5e
AD
776
777# We don't want to regenerate perly.c and perly.h, but they might
778# appear out-of-date after a patch is applied or a new distribution is
779# made.
92c28edd 780perly.c: perly.y
b233458b
JH
781 -@sh -c true
782
92c28edd 783perly.h: perly.y
b233458b
JH
784 -@sh -c true
785
9fec149b
JH
786PERLYVMS = vms/perly_c.vms vms/perly_h.vms
787
788$(PERLYVMS): perly.c perly.h vms/vms_yfix.pl
789 perl vms/vms_yfix.pl perly.c perly.h vms/perly_c.vms vms/perly_h.vms
790
bd656b61 791# No compat3.sym here since and including the 5.004_50.
e4d5a464 792# No interp.sym since 5.005_03.
22c35a8c 793SYM = global.sym globvar.sym perlio.sym pp.sym
419eaf7b 794
22c35a8c 795SYMH = perlvars.h intrpvar.h thrdvar.h
419eaf7b 796
dae78bb1
IZ
797CHMOD_W = chmod +w
798
a8581515 799# The following files are generated automatically
c83f8f39
JH
800# keywords.pl: keywords.h
801# opcode.pl: opcode.h opnames.h pp_proto.h pp.sym
802# [* embed.pl needs pp.sym generated by opcode.pl! *]
acfe0abc 803# embed.pl: proto.h embed.h embedvar.h global.sym
c83f8f39
JH
804# perlapi.h perlapi.c pod/perlintern.pod
805# pod/perlapi.pod
806# bytecode.pl: ext/ByteLoader/byterun.h ext/ByteLoader/byterun.c
807# ext/B/B/Asmdata.pm
808# regcomp.pl: regnodes.h
809# warnings.pl: warnings.h lib/warnings.pm
e50aee73
AD
810# The correct versions should be already supplied with the perl kit,
811# in case you don't have perl available.
e1354ed6 812# To force them to be regenerated, type
e50aee73 813# make regen_headers
e1354ed6 814
b4d4469a
JH
815AUTOGEN_FILES = keywords.h opcode.h opnames.h pp_proto.h pp.sym proto.h \
816 embed.h embedvar.h global.sym \
817 pod/perlintern.pod pod/perlapi.pod \
acfe0abc 818 perlapi.h perlapi.c ext/ByteLoader/byterun.h \
c83f8f39
JH
819 ext/ByteLoader/byterun.c ext/B/B/Asmdata.pm regnodes.h \
820 warnings.h lib/warnings.pm
e1354ed6 821
869a466c
JH
822.PHONY: regen_headers regen_pods regen_all
823
e50aee73 824regen_headers: FORCE
b4d4469a
JH
825 -$(CHMOD_W) $(AUTOGEN_FILES)
826 -perl keywords.pl
827 -perl opcode.pl
828 -perl embed.pl
829 -perl bytecode.pl
830 -perl regcomp.pl
831 -perl warnings.pl
94bdecf9 832 -perl autodoc.pl
8e07c86e 833
4755096e 834regen_pods: FORCE
fcfe1ab7 835 -cd pod; $(LDLIBPTH) $(MAKE) regen_pods
4755096e 836
9fec149b
JH
837regen_all: $(PERLYVMS) regen_headers regen_pods
838
a0d0e21e 839# Extensions:
4318d5a0
GB
840# Names added to $(dynamic_ext) or $(static_ext) or $(nonxs_ext) will
841# automatically get built. There should ordinarily be no need to change
842# any of this part of makefile.
a0d0e21e
LW
843#
844# The dummy dependency is a place holder in case $(dynamic_ext) or
845# $(static_ext) is empty.
846#
847# DynaLoader may be needed for extensions that use Makefile.PL.
848
443a5b98 849$(DYNALOADER): miniperl$(EXE_EXT) preplibrary FORCE
92c28edd 850 @$(LDLIBPTH) sh ext/util/make_ext static $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
a0d0e21e 851
443a5b98 852d_dummy $(dynamic_ext): miniperl$(EXE_EXT) preplibrary $(DYNALOADER) FORCE
92c28edd 853 @$(LDLIBPTH) sh ext/util/make_ext dynamic $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
a0d0e21e 854
443a5b98 855s_dummy $(static_ext): miniperl$(EXE_EXT) preplibrary $(DYNALOADER) FORCE
92c28edd 856 @$(LDLIBPTH) sh ext/util/make_ext static $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
2304df62 857
443a5b98 858n_dummy $(nonxs_ext): miniperl$(EXE_EXT) preplibrary $(DYNALOADER) FORCE
92c28edd 859 @$(LDLIBPTH) sh ext/util/make_ext nonxs $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
4318d5a0 860
869a466c
JH
861.PHONY: clean _tidy _mopup _cleaner1 _cleaner2 \
862 realclean _realcleaner clobber _clobber \
863 distclean veryclean _verycleaner
864
17b893d8 865clean: _tidy _mopup
70af249b 866
2edbd6da 867realclean: _realcleaner _mopup
fcfe1ab7 868 @echo "Note that '$(MAKE) realclean' does not delete config.sh or Policy.sh"
70af249b 869
b37ebb13 870_clobber:
5440bc8e 871 -@rm -f Cross/run-* Cross/to-* Cross/from-*
bf35c3f6 872 rm -f config.sh cppstdin Policy.sh extras.lst
b37ebb13
JH
873
874clobber: _realcleaner _mopup _clobber
70af249b
CS
875
876distclean: clobber
877
2edbd6da 878# Like distclean but also removes emacs backups and *.orig.
b37ebb13
JH
879veryclean: _verycleaner _mopup _clobber
880 -@rm -f Obsolete Wanted
2edbd6da 881
70af249b
CS
882# Do not 'make _mopup' directly.
883_mopup:
cd4d8a96 884 rm -f *$(OBJ_EXT) *$(LIB_EXT) all perlmain.c
72b3d9b4 885 -@test -f extra.pods && rm -f `cat extra.pods`
b4bc034f 886 -@test -f vms/README_vms.pod && rm -f vms/README_vms.pod
ac83e8b0 887 -rm -f perl.exp ext.libs extra.pods opmini.o
d96ebe2e 888 -rm -f perl.export perl.dll perl.libexp perl.map perl.def
1cfa4ec7 889 -rm -f perl.loadmap miniperl.loadmap perl.prelmap miniperl.prelmap
9d4d067b 890 -rm -f perl.third lib*.so.perl.third perl.3log t/perl.third t/perl.3log
6a966751 891 -rm -f perl.pixie lib*.so.perl.pixie lib*.so.Addrs
93c0359c 892 -rm -f perl.Addrs perl.Counts t/perl.Addrs t/perl.Counts *perl.xok
a0457be1 893 -rm -f perlld cygwin.c ld2 libperl*.def libperl*.dll cygperl*.dll *.exe.stackdump
6189dba1 894 rm -f perl$(EXE_EXT) suidperl$(EXE_EXT) miniperl$(EXE_EXT) $(LIBPERL) libperl.* microperl
70af249b
CS
895
896# Do not 'make _tidy' directly.
897_tidy:
e3f83878
JH
898 -cd pod; $(LDLIBPTH) $(MAKE) clean
899 -cd utils; $(LDLIBPTH) $(MAKE) clean
900 -cd x2p; $(LDLIBPTH) $(MAKE) clean
4318d5a0 901 -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
e3f83878 902 $(LDLIBPTH) sh ext/util/make_ext clean $$x MAKE=$(MAKE) ; \
a0d0e21e 903 done
6ee623d5 904 rm -f testcompile compilelog
ff68c719 905
2edbd6da 906_cleaner1:
4633a7c4 907 -cd os2; rm -f Makefile
2edbd6da
JH
908 -cd pod; $(LDLIBPTH) $(MAKE) $(CLEAN)
909 -cd utils; $(LDLIBPTH) $(MAKE) $(CLEAN)
910 -cd x2p; $(LDLIBPTH) $(MAKE) $(CLEAN)
4318d5a0 911 -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
2edbd6da 912 $(LDLIBPTH) sh ext/util/make_ext $(CLEAN) $$x MAKE=$(MAKE) ; \
a0d0e21e 913 done
2edbd6da 914
2ad994b6 915# Some systems do not support "?", so keep these files separate.
2edbd6da 916_cleaner2:
2ad994b6
PG
917 -rm -f core.*perl.*.? t/core.perl.*.? .?*.c
918 rm -f core *perl.core t/core t/*perl.core
919 rm -f t/misctmp* t/forktmp* t/tmp* t/c t/perl$(EXE_EXT) t/rantests
920 rm -f so_locations $(LIBPERL_NONSHR) $(MINIPERL_NONSHR)
a0d0e21e 921 rm -rf $(addedbyconf)
cd4d8a96 922 rm -f $(FIRSTMAKEFILE) $(FIRSTMAKEFILE).old
fed7345c 923 rm -f $(private)
a0d0e21e 924 rm -rf lib/auto
07a6e20d 925 rm -f lib/.exists lib/*/.exists lib/*/*/.exists
16d20bd9 926 rm -f h2ph.man pstruct
a0d0e21e 927 rm -rf .config
6ee623d5 928 rm -f testcompile compilelog
d0b806d2
MB
929 -rmdir lib/B lib/Data lib/Digest lib/Encode lib/IO/Socket lib/IO/t lib/IO
930 -rmdir lib/Filter/Util lib/List lib/MIME lib/PerlIO lib/Scalar lib/Sys
931 -rmdir lib/Thread lib/XS
ecfc5424 932
f4db5405 933_realcleaner:
2edbd6da
JH
934 @$(LDLIBPTH) $(MAKE) _cleaner1 CLEAN=realclean
935 @$(LDLIBPTH) $(MAKE) _cleaner2
936
f4db5405 937_verycleaner:
2edbd6da
JH
938 @$(LDLIBPTH) $(MAKE) _cleaner1 CLEAN=veryclean
939 @$(LDLIBPTH) $(MAKE) _cleaner2
c94787a5 940 -rm -f *~ *.orig */*~ */*.orig */*/*~ */*/*.orig
2edbd6da 941
2304df62
AD
942# The following lint has practically everything turned on. Unfortunately,
943# you have to wade through a lot of mumbo jumbo that can't be suppressed.
944# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
945# for that spot.
946
869a466c 947.PHONY: lint
bf0dfd28 948lint: $(c)
2304df62
AD
949 lint $(lintflags) $(defs) perly.c $(c) > perl.fuzz
950
fb73857a
PP
951# Need to unset during recursion to go out of loop.
952# The README below ensures that the dependency list is never empty and
953# that when MAKEDEPEND is empty $(FIRSTMAKEFILE) doesn't need rebuilding.
cd4d8a96 954
84902520 955MAKEDEPEND = Makefile makedepend
cd4d8a96 956
fb73857a 957$(FIRSTMAKEFILE): README $(MAKEDEPEND)
cd4d8a96 958 $(MAKE) depend MAKEDEPEND=
a0d0e21e 959
599a829f 960config.h: config_h.SH config.sh
655635e8
PP
961 $(SHELL) config_h.SH
962
a0d0e21e 963# When done, touch perlmain.c so that it doesn't get remade each time.
869a466c 964.PHONY: depend
2304df62 965depend: makedepend
fb73857a 966 sh ./makedepend MAKE=$(MAKE)
a0d0e21e 967 - test -s perlmain.c && touch perlmain.c
2304df62
AD
968 cd x2p; $(MAKE) depend
969
cd4d8a96 970# Cannot postpone this until $firstmakefile is ready ;-)
92c28edd
JH
971makedepend: makedepend.SH config.sh
972 sh ./makedepend.SH
cd4d8a96 973
1167a30e 974.PHONY: test check test_prep test_prep_nodll test_prep_pre _test_prep \
869a466c
JH
975 test_tty test-tty _test_tty test_notty test-notty _test_notty \
976 utest ucheck test.utf8 check.utf8 \
977 test.third check.third utest.third ucheck.third test_notty.third \
978 test.deparse test_notty.deparse \
5a6e071d 979 minitest coretest
869a466c 980
ec861bc1
JH
981# Cannot delegate rebuilding of t/perl to make
982# to allow interlaced test and minitest
3e3baf6d 983
1167a30e
IZ
984TESTFILE=TEST
985
986_test_prep:
ec861bc1 987 cd t && (rm -f $(PERL)$(EXE_EXT); $(LNS) ../$(PERL)$(EXE_EXT) $(PERL)$(EXE_EXT))
3e3baf6d 988
1167a30e
IZ
989# Architecture-neutral stuff:
990
991test_prep_pre: preplibrary utilities $(nonxs_ext)
992
443a5b98 993test_prep: test_prep_pre miniperl$(EXE_EXT) perl$(EXE_EXT) $(dynamic_ext) $(TEST_PERL_DLL)
5fe84fd2 994 PERL=./perl $(MAKE) _test_prep
ec861bc1 995
5fe84fd2 996_test_tty:
1167a30e 997 cd t && $(LDLIBPTH) $(PERL_DEBUG) $(PERL) $(TESTFILE) $(TEST_ARGS) </dev/tty
ec861bc1 998
5fe84fd2 999_test_notty:
1167a30e 1000 cd t && $(LDLIBPTH) $(PERL_DEBUG) PERL_SKIP_TTY_TEST=1 $(PERL) $(TESTFILE) $(TEST_ARGS)
ec861bc1
JH
1001
1002# The second branch is for testing without a tty or controlling terminal,
1003# see t/op/stat.t
1004_test:
994e9bc0 1005 if (true </dev/tty) >/dev/null 2>&1; then \
1167a30e 1006 $(MAKE) TEST_ARGS=$(TEST_ARGS) TESTFILE=$(TESTFILE) _test_tty ; \
994e9bc0 1007 else \
1167a30e 1008 $(MAKE) TEST_ARGS=$(TEST_ARGS) TESTFILE=$(TESTFILE) _test_notty ; \
994e9bc0 1009 fi
3d8f1d64 1010 @echo "Ran tests" > t/rantests
a0ed51b3 1011
937aca76 1012test check: test_prep
ec861bc1
JH
1013 PERL=./perl $(MAKE) _test
1014
937aca76 1015test_tty: test_prep
5fe84fd2 1016 PERL=./perl $(MAKE) _test_tty
ec861bc1 1017
937aca76 1018test_notty: test_prep
5fe84fd2 1019 PERL=./perl $(MAKE) _test_notty
ec861bc1 1020
83f0ef60 1021utest ucheck test.utf8 check.utf8: test_prep
35117553 1022 PERL=./perl TEST_ARGS=-utf8 $(MAKE) _test
ec861bc1 1023
5a6e071d
PJ
1024coretest: test_prep
1025 PERL=./perl TEST_ARGS=-core $(MAKE) _test
1026
48a293f8 1027test-prep: test_prep
5fe84fd2
JH
1028
1029test-tty: test_tty
1030
1031test-notty: test_notty
1032
ec861bc1
JH
1033# Targets for Third Degree testing.
1034
9b99345a 1035test_prep.third: test_prep perl.third
5fe84fd2 1036 PERL=./perl.third $(MAKE) _test_prep
ec861bc1 1037
937aca76 1038test.third check.third: test_prep.third perl.third
ec861bc1
JH
1039 PERL=./perl.third PERL_DEBUG=PERL_3LOG=1 $(MAKE) _test
1040
937aca76 1041utest.third ucheck.third: test_prep.third perl.third
35117553 1042 PERL=./perl.third PERL_DEBUG=PERL_3LOG=1 TEST_ARGS=-utf8 $(MAKE) _test
ec861bc1 1043
937aca76 1044test_notty.third: test_prep.third perl.third
5fe84fd2 1045 PERL=./perl.third $(MAKE) PERL_DEBUG=PERL_3LOG=1 _test_notty
2304df62 1046
35117553
JH
1047# Targets for Deparse testing.
1048
1049test.deparse: test_prep
1050 PERL=./perl TEST_ARGS=-deparse $(MAKE) _test
1051
1052test_notty.deparse: test_prep
1053 PERL=./perl TEST_ARGS=-deparse $(MAKE) _test_notty
1054
d96ebe2e
PP
1055# Can't depend on lib/Config.pm because that might be where miniperl
1056# is crashing.
443a5b98 1057minitest: miniperl$(EXE_EXT) lib/re.pm
4fa3f26e
YST
1058 -@test -f lib/lib.pm && test -f lib/Config.pm || \
1059 $(MAKE) lib/Config.pm lib/lib.pm
1060 @echo " "
d96ebe2e 1061 @echo "You may see some irrelevant test failures if you have been unable"
4fa3f26e
YST
1062 @echo "to build lib/Config.pm or lib/lib.pm."
1063 @echo " "
cd4d8a96 1064 - cd t && (rm -f perl$(EXE_EXT); $(LNS) ../miniperl$(EXE_EXT) perl$(EXE_EXT)) \
4fa3f26e 1065 && $(LDLIBPTH) ./perl TEST base/*.t comp/*.t cmd/*.t run/*.t io/*.t op/*.t uni/*.t </dev/tty
16d20bd9 1066
1167a30e
IZ
1067# Test via harness
1068
1069test_harness: test_prep
1070 PERL=./perl $(MAKE) TESTFILE=harness _test
1071
fb73857a 1072# Handy way to run perlbug -ok without having to install and run the
84902520 1073# installed perlbug. We don't re-run the tests here - we trust the user.
fb73857a 1074# Please *don't* use this unless all tests pass.
1d2dff63 1075# If you want to report test failures, use "make nok" instead.
869a466c
JH
1076
1077.PHONY: ok okfile oknack okfilenack nok nokfile noknack nokfilenack
1078
188cd53f 1079ok: utilities
92c28edd 1080 $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)'
84902520 1081
105f9295 1082okfile: utilities
92c28edd 1083 $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok
105f9295 1084
890b8eb0
NC
1085oknack: utilities
1086 $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -A
1087
1088okfilenack: utilities
1089 $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok -A
1090
1d2dff63 1091nok: utilities
92c28edd 1092 $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)'
1d2dff63 1093
b4e8cfaf
GS
1094nokfile: utilities
1095 $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -F perl.nok
1096
890b8eb0
NC
1097noknack: utilities
1098 $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -A
1099
1100nokfilenack: utilities
1101 $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -F perl.nok -A
1102
869a466c
JH
1103.PHONY: clist hlist shlist pllist
1104
85e6fe83 1105clist: $(c)
92c28edd 1106 echo $(c) | tr ' ' $(TRNL) >.clist
2304df62 1107
85e6fe83 1108hlist: $(h)
92c28edd 1109 echo $(h) | tr ' ' $(TRNL) >.hlist
2304df62 1110
85e6fe83 1111shlist: $(sh)
92c28edd 1112 echo $(sh) | tr ' ' $(TRNL) >.shlist
2304df62 1113
4633a7c4 1114pllist: $(pl)
92c28edd 1115 echo $(pl) | tr ' ' $(TRNL) >.pllist
4633a7c4 1116
92c28edd
JH
1117Makefile: Makefile.SH ./config.sh
1118 $(SHELL) Makefile.SH
760ac839 1119
869a466c 1120.PHONY: distcheck
599a829f 1121distcheck: FORCE
760ac839
LW
1122 perl '-MExtUtils::Manifest=&fullcheck' -e 'fullcheck()'
1123
869a466c 1124.PHONY: elc
771c4874
IZ
1125elc: emacs/cperl-mode.elc
1126
1127emacs/cperl-mode.elc: emacs/cperl-mode.el
1128 -cd emacs; emacs -batch -q -no-site-file -f batch-byte-compile cperl-mode.el
1129
869a466c
JH
1130.PHONY: etags ctags tags
1131
d6a255e6
IZ
1132etags: TAGS
1133
1134TAGS: emacs/cperl-mode.elc
3ee700d1 1135 sh emacs/ptags
01e22528 1136
d6a255e6
IZ
1137ctags: tags
1138
1139# Let's hope make will not go into an infinite loop on case-unsensitive systems
1140# This may also fail if . is in the head of the path, since perl will
1141# require -Ilib
1142tags: TAGS
1143 perl emacs/e2ctags.pl TAGS > tags
3ee700d1 1144
2304df62
AD
1145# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
1146# If this runs make out of memory, delete /usr/include lines.
1147!NO!SUBS!
1148
85e6fe83 1149$eunicefix Makefile
2304df62
AD
1150case `pwd` in
1151*SH)
85e6fe83 1152 $rm -f ../Makefile
cd4d8a96 1153 $ln Makefile ../Makefile
2304df62
AD
1154 ;;
1155esac
cd4d8a96 1156$rm -f $firstmakefile
5ff3f7a4
GS
1157
1158# Now do any special processing required before building.
1159
1160case "$ebcdic" in
1161$define)
1162 xxx=''
1163 echo "This is an EBCDIC system, checking if any parser files need regenerating." >&4
7a66b286 1164case "$osname" in
25e9a2e3 1165os390|posix-bc)
5ff3f7a4 1166 rm -f y.tab.c y.tab.h
e9d08790 1167 # yacc must be a reentrant ("pure") Bison in BS2000 Posix!
5ff3f7a4
GS
1168 yacc -d perly.y >/dev/null 2>&1
1169 if cmp -s y.tab.c perly.c; then
1170 rm -f y.tab.c
1171 else
1172 echo "perly.y -> perly.c" >&2
1173 mv -f y.tab.c perly.c
1174 chmod u+w perly.c
c8dba6f3
GS
1175 sed -e '/^#include "perl\.h"/a\
1176\
1177#define yydebug PL_yydebug\
1178#define yynerrs PL_yynerrs\
1179#define yyerrflag PL_yyerrflag\
1180#define yychar PL_yychar\
c8dba6f3
GS
1181#define yyval PL_yyval\
1182#define yylval PL_yylval' \
1183 -e '/YYSTYPE *yyval;/D' \
1184 -e '/YYSTYPE *yylval;/D' \
1185 -e '/int yychar,/,/yynerrs;/D' \
1186 -e 's/int yydebug = 0;/yydebug = 0;/' \
1187 -e 's/[^_]realloc(/PerlMem_realloc(/g' \
1188 -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' \
5ff3f7a4
GS
1189 -e 's/y\.tab/perly/g' perly.c >perly.tmp && mv perly.tmp perly.c
1190 xxx="$xxx perly.c"
1191 fi
1192 if cmp -s y.tab.h perly.h; then
1193 rm -f y.tab.h
1194 else
1195 echo "perly.y -> perly.h" >&2
1196 mv -f y.tab.h perly.h
1197 xxx="$xxx perly.h"
1198 fi
e9d08790 1199 if cd x2p
5ff3f7a4 1200 then
e9d08790 1201 rm -f y.tab.c y.tab.h
5928ee40
JH
1202 case "$osname" in
1203 posix-bc)
1204 # we are using two different yaccs in BS2000 Posix!
1205 byacc a2p.y >/dev/null 2>&1
1206 ;;
1207 *) # e.g. os390
1208 yacc a2p.y >/dev/null 2>&1
1209 ;;
1210 esac
e9d08790
JH
1211 if cmp -s y.tab.c a2p.c
1212 then
1213 rm -f y.tab.c
1214 else
1215 echo "a2p.y -> a2p.c" >&2
1216 mv -f y.tab.c a2p.c
1217 chmod u+w a2p.c
1218 sed -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' \
f1f802f7 1219 -e 's|^static void __YY_YACC_MAIN.*BS2000.*|/*static main deleted*/|' \
e9d08790
JH
1220 -e 's/y\.tab/a2p/g' a2p.c >a2p.tmp && mv a2p.tmp a2p.c
1221 xxx="$xxx a2p.c"
1222 fi
1223 # In case somebody yacc -d:ed the a2p.y.
1224 if test -f y.tab.h
1225 then
1226 if cmp -s y.tab.h a2p.h
1227 then
1228 rm -f y.tab.h
1229 else
1230 echo "a2p.h -> a2p.h" >&2
1231 mv -f y.tab.h a2p.h
1232 xxx="$xxx a2p.h"
1233 fi
1234 fi
1235 cd ..
5ff3f7a4 1236 fi
7a66b286
JH
1237 ;;
1238vmesa)
1239 # Do nothing in VM/ESA.
1240 ;;
aa34f189 1241*)
e9d08790 1242 echo "'$osname' is an EBCDIC system I don't know that well." >&4
aa34f189 1243 ;;
fe572743 1244esac
5ff3f7a4
GS
1245 case "$xxx" in
1246 '') echo "No parser files were regenerated. That's okay." >&2 ;;
1247 esac
1248 ;;
1249esac
1250