This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
9ef70bd5aa419a627528609f29dc20e1d78295d5
[perl5.git] / Makefile.SH
1 #!/bin/sh
2
3 # quote() - Creates a shell literal
4 # Usage:  echo "...` quote "..." `..."
5 quote() {
6         case "$1" in
7         '') echo "''" ;;
8         *)  echo "$1" | sed 's/\([^a-zA-Z0-9.:_\-\/]\)/\\\1/g' ;;
9         esac
10 }
11
12 case $PERL_CONFIG_SH in
13 '')
14         if test -f config.sh
15                 then TOP=.
16         else
17                 echo "Can't find config.sh."; exit 1
18         fi
19         . $TOP/config.sh
20         ;;
21 esac
22
23 case $CROSS_NAME in
24 '')
25         Makefile=Makefile
26         ;;
27 *)
28         # if cross-compilation, the Makefile named accordingly
29         Makefile=Makefile-cross-$CROSS_NAME
30         . Cross/config-${CROSS_NAME}.sh
31         ;;
32 esac
33
34 : This forces SH files to create target in same directory as SH file.
35 : This is so that make depend always knows where to find SH derivatives.
36 case "$0" in
37 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
38 esac
39
40 pwd="`pwd`"
41 linklibperl='$(LIBPERL)'
42 linklibperl_nonshr=''
43 shrpldflags='$(LDDLFLAGS)'
44 ldlibpth=''
45 DPERL_EXTERNAL_GLOB='-DPERL_EXTERNAL_GLOB'
46 DPERL_IS_MINIPERL='-DPERL_IS_MINIPERL'
47 case "$useshrplib" in
48 true)
49         # Prefix all runs of 'miniperl' and 'perl' with
50         # $ldlibpth so that ./perl finds *this* shared libperl.
51         case "$LD_LIBRARY_PATH" in
52         '')  ldlibpth="LD_LIBRARY_PATH=` quote "$pwd" `" ;;
53         *)   ldlibpth="LD_LIBRARY_PATH=` quote "$pwd" `:` quote "$LD_LIBRARY_PATH" `" ;;
54         esac
55
56         pldlflags="$cccdlflags"
57         static_ldflags=''
58         case "${osname}${osvers}" in
59         next4*)
60                 ld=libtool
61                 lddlflags="-dynamic -undefined warning -framework System \
62                 -compatibility_version 1 -current_version $patchlevel \
63                 -prebind -seg1addr 0x27000000 -install_name \$(shrpdir)/\$@"
64                 ;;
65         darwin*)
66                 shrpldflags="${ldflags} -dynamiclib \
67                             -compatibility_version \
68                                 ${api_revision}.${api_version}.${api_subversion} \
69                              -current_version \
70                                 ${revision}.${patchlevel}.${subversion} \
71                              -install_name \$(shrpdir)/\$@"
72                 ;;
73         cygwin*)
74                 shrpldflags="$shrpldflags -Wl,--out-implib=libperl.dll.a -Wl,--image-base,0x52000000"
75                 linklibperl="-L. -lperl"
76                 ;;
77         sunos*)
78                 linklibperl="-lperl"
79                 ;;
80         netbsd*|freebsd[234]*|openbsd*|dragonfly*)
81                 linklibperl="-L. -lperl"
82                 ;;
83         interix*)
84                 linklibperl="-L. -lperl"
85                 shrpldflags="$shrpldflags -Wl,--image-base,0x57000000"
86                 ;;
87         aix*)
88                 case "$cc" in
89                 gcc*)
90                         shrpldflags="-shared -Wl,-H512 -Wl,-T512 -Wl,-bhalt:4 -Wl,-bM:SRE -Wl,-bE:perl.exp"
91                         case "$osvers" in
92                         3*)     shrpldflags="$shrpldflags -e _nostart"
93                                 ;;
94                         *)      shrpldflags="$shrpldflags -Wl,-bnoentry"
95                                 ;;
96                         esac
97                         shrpldflags="$shrpldflags $ldflags $perllibs $cryptlib"
98                         linklibperl="-L $archlibexp/CORE -L `pwd | sed 's/\/UU$//'` -lperl"
99                         linklibperl_nonshr='-lperl_nonshr'
100                         ;;
101                 *)
102                         shrpldflags="-H512 -T512 -bhalt:4 -bM:SRE -bE:perl.exp"
103                         case "$osvers" in
104                         3*)     shrpldflags="$shrpldflags -e _nostart"
105                                 ;;
106                         *)      shrpldflags="$shrpldflags -b noentry"
107                                 ;;
108                         esac
109                         shrpldflags="$shrpldflags $ldflags $perllibs $cryptlib"
110                         linklibperl="-L $archlibexp/CORE -L `pwd | sed 's/\/UU$//'` -lperl"
111                         linklibperl_nonshr='-lperl_nonshr'
112                         ;;
113                 esac
114                 ;;
115         hpux*)
116                 linklibperl="-L `pwd | sed 's/\/UU$//'` -Wl,+s -Wl,+b$archlibexp/CORE -lperl"
117                 ;;
118         os390*)
119             shrpldflags='-W l,XPLINK,dll'
120             linklibperl='libperl.x'
121             DPERL_EXTERNAL_GLOB=''
122             ;;
123         esac
124         case "$ldlibpthname" in
125         '') ;;
126         *)
127             case "$osname" in
128             os2)
129                 ldlibpth=''
130                 ;;
131             *)
132                 eval "ldlibpthval=\"\$$ldlibpthname\""
133
134                 case "$ldlibpthval" in
135                 '')  ldlibpth="$ldlibpthname=` quote "$pwd" `" ;;
136                 *)   ldlibpth="$ldlibpthname=` quote "$pwd" `:` quote "$ldlibpthval" `" ;;
137                 esac
138
139                 ;;
140             esac
141
142             ;;
143         esac
144
145         case "$osname" in
146         linux)
147             # If there is a pre-existing $libperl from a previous
148             # installation, Linux needs to use LD_PRELOAD to
149             # override the LD_LIBRARY_PATH setting.  See the
150             # INSTALL file, under "Building a shared perl library".
151             # If there is no pre-existing $libperl, we don't need
152             # to do anything further.
153             if test -f $archlib/CORE/$libperl; then
154                 rm -f preload
155                 cat <<'EOT' > preload
156 #! /bin/sh
157 lib=$1
158 shift
159 test -r $lib && export LD_PRELOAD="$lib $LD_PRELOAD"
160 exec "$@"
161 EOT
162                 chmod 755 preload
163                 ldlibpth="$ldlibpth `pwd`/preload `pwd`/$libperl"
164             fi
165             ;;
166         os390)  test -f /bin/env && ldlibpth="/bin/env $ldlibpth"
167                 ;;
168         esac
169
170         ;;
171
172 *)      pldlflags=''
173         static_ldflags='CCCDLFLAGS='
174         ;;
175 esac
176
177 : is Cwd static or dynamic
178 static_cwd='define'
179 list_util_dep='$(PERL_EXE)'
180 for f in $dynamic_ext; do
181    case $f in
182        Cwd) static_cwd='undef' ;;
183        List/Util) list_util_dep=lib/auto/List/Util/Util.$dlext
184    esac
185 done
186
187 : Prepare dependency lists for Makefile.
188 dynamic_list=' '
189 dynamic_ext_re="lib/auto/re/re.$dlext"
190 extra_dep='
191 ext/Pod-Functions/pm_to_blib: cpan/Pod-Simple/pm_to_blib cpan/Pod-Escapes/pm_to_blib pod/perlfunc.pod
192 '
193 for f in $dynamic_ext; do
194     : the dependency named here will never exist
195       base=`echo "$f" | sed 's/.*\///'`
196     this_target="lib/auto/$f/$base.$dlext"  
197     dynamic_list="$dynamic_list $this_target"
198
199     : Parallel makes reveal that we have some interdependencies
200     case $f in
201         Math/BigInt/FastCalc|Devel/NYTProf) extra_dep="$extra_dep
202 $this_target: $list_util_dep" ;;
203         Unicode/Normalize) extra_dep="$extra_dep
204 $this_target: uni.data" ;;
205     esac
206 done
207
208 static_list=' '
209 for f in $static_ext; do
210         base=`echo "$f" | sed 's/.*\///'`
211         static_list="$static_list lib/auto/$f/$base\$(LIB_EXT)"
212     : Parallel makes reveal that we have some interdependencies
213     this_target="lib/auto/$f/$base\$(LIB_EXT)"
214     case $f in
215         Math/BigInt/FastCalc|Devel/NYTProf) extra_dep="$extra_dep
216 $this_target: lib/auto/List/Util/Util\$(LIB_EXT)" ;;
217         Unicode/Normalize) extra_dep="$extra_dep
218 $this_target: uni.data" ;;
219     esac
220 done
221
222 nonxs_list=' '
223 for f in $nonxs_ext; do
224     p=`echo "$f" | tr / -`
225     for d in ext dist cpan; do
226         if test -d $d/$p; then
227             nonxs_list="$nonxs_list $d/$p/pm_to_blib"
228         fi
229     done
230 done
231
232 dtrace_h=''
233 dtrace_o=''
234 minidtrace_o=''
235 case "$usedtrace" in
236 define|true)
237         dtrace_h='perldtrace.h' 
238         $dtrace -G -s perldtrace.d -o perldtrace.tmp >/dev/null 2>&1 \
239                 && rm -f perldtrace.tmp && dtrace_o='perldtrace$(OBJ_EXT)' \
240                 && minidtrace_o='miniperldtrace$(OBJ_EXT)'
241         ;;
242 esac
243
244 echo "Extracting $Makefile (with variable substitutions)"
245 $spitshell >$Makefile <<!GROK!THIS!
246 # $Makefile
247 # This file is derived from Makefile.SH.  Any changes made here will
248 # be lost the next time you run Configure.
249 #  Makefile is used to generate $firstmakefile.  The only difference
250 #  is that $firstmakefile has the dependencies filled in at the end.
251
252 CC = $cc
253 LD = $ld
254
255 LDFLAGS = $ldflags
256 CLDFLAGS = $ldflags
257
258 mallocsrc = $mallocsrc
259 mallocobj = $mallocobj
260 madlysrc = $madlysrc
261 madlyobj = $madlyobj
262 LNS = $lns
263 # NOTE: some systems don't grok "cp -f". XXX Configure test needed?
264 CPS = $cp
265 RMS = rm -f
266 ranlib = $ranlib
267
268 # The following are mentioned only to make metaconfig include the
269 # appropriate questions in Configure.  If you want to change these,
270 # edit config.sh instead, or specify --man1dir=/wherever on
271 # installman commandline.
272 bin = $installbin
273 scriptdir = $scriptdir
274 shrpdir = $archlibexp/CORE
275 privlib = $installprivlib
276 man1dir = $man1dir
277 man1ext = $man1ext
278 man3dir = $man3dir
279 man3ext = $man3ext
280
281 # The following are used to build and install shared libraries for
282 # dynamic loading.
283 LDDLFLAGS = $lddlflags
284 SHRPLDFLAGS = $shrpldflags
285 CCDLFLAGS = $ccdlflags
286 DLSUFFIX = .$dlext
287 PLDLFLAGS = $pldlflags
288 LIBPERL = $libperl
289 LLIBPERL= $linklibperl
290 LLIBPERL_NONSHR= $linklibperl_nonshr
291 SHRPENV = $shrpenv
292
293 # Static targets are ordinarily built without CCCDLFLAGS.  However,
294 # if building a shared libperl.so that might later be linked into
295 # another application, then it might be appropriate to also build static
296 # extensions (usually just DynaLoader) with relocatable code (e.g. -fPIC
297 # for GNU cc).
298 STATIC_LDFLAGS = $static_ldflags
299
300 # The following is used to include the current directory in
301 # the dynamic loader path you are building a shared libperl.
302 LDLIBPTH = $ldlibpth
303
304 # Sometimes running an executable is an adventure.
305 RUN = $run
306
307 # These variables may need to be manually set for non-Unix systems.
308 AR = $full_ar
309 HOST_EXE_EXT = $_exe
310 EXE_EXT = $_exe
311 LIB_EXT = $_a
312 OBJ_EXT = $_o
313 PATH_SEP = $p_
314
315 # Macros to invoke a copy of miniperl during the build.  Targets which
316 # are built using these macros should depend on \$(MINIPERL_EXE)
317 MINIPERL_EXE = miniperl\$(EXE_EXT)
318 MINIPERL = \$(LDLIBPTH) \$(RUN) ./miniperl\$(EXE_EXT) -Ilib
319
320 # Macros to invoke a copy of our fully operational perl during the build.
321 PERL_EXE = perl\$(EXE_EXT)
322 RUN_PERL = \$(LDLIBPTH) \$(RUN) ./perl\$(EXE_EXT)
323
324 # Macros to run our tests
325 RUN_TESTS = \$(LDLIBPTH) ./runtests
326
327 dynamic_ext = $dynamic_list
328 dynamic_ext_re = $dynamic_ext_re
329 static_ext = $static_list
330 nonxs_ext = $nonxs_list
331 ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
332 DYNALOADER = DynaLoader\$(OBJ_EXT)
333
334 libs = $perllibs $cryptlib
335
336 public = \$(PERL_EXE) utilities translators
337
338 shellflags = $shellflags
339
340 # This is set to  MAKE=$make if your $make command doesn't
341 # do it for you.
342 $make_set_make
343
344 # Mention $gmake here so it gets probed for by Configure.
345
346 !GROK!THIS!
347
348 case "${osname}" in
349 linux*|darwin)
350 $spitshell >>$Makefile <<!GROK!THIS!
351 # If you're going to use valgrind and it can't be invoked as plain valgrind
352 # then you'll need to change this, or override it on the make command line.
353 VALGRIND ?= valgrind
354 VG_TEST  ?= ./perl -e 1 2>/dev/null
355
356 !GROK!THIS!
357         ;;
358 esac
359
360 $spitshell >>$Makefile <<!GROK!THIS!
361 DTRACE = $dtrace
362 DTRACE_H = $dtrace_h
363 DTRACE_O = $dtrace_o
364 MINIDTRACE_O = $minidtrace_o
365
366 FIRSTMAKEFILE = $firstmakefile
367
368 # Any special object files needed by this architecture, e.g. os2/os2.obj
369 ARCHOBJS = $archobjs
370
371 .SUFFIXES: .c \$(OBJ_EXT) .i .s
372
373 # grrr
374 SHELL = $sh
375
376 # how to tr(anslate) newlines
377 TRNL = '$trnl'
378
379 OPTIMIZE = $optimize
380
381 EXTRAS = $extras
382
383 INSTALLPREFIXEXP = $prefix
384
385 !GROK!THIS!
386 # not used by Makefile but by installperl;
387 # mentioned here so that metaconfig picks these up
388 # $installusrbinperl
389 # $versiononly
390
391 case "${osname}:${osvers}" in
392 darwin:*)
393 $spitshell >>$Makefile <<EOF
394
395 # Your locales are broken (osname $osname, osvers $osvers)
396 # and to avoid the numerous
397 # perl: warning: Setting locale failed.
398 # warnings during the build process we reset the locale variables.
399
400 LC_ALL=C
401 LANG=C
402 LANGUAGE=C
403 EOF
404         ;;
405 esac
406
407 case $CROSS_NAME in
408 '')
409 ## In the following dollars and backticks do not need the extra backslash.
410 $spitshell >>$Makefile <<'!NO!SUBS!'
411
412 CCCMD    = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $@`
413
414 CCCMDSRC = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $<`
415
416 CONFIGPM_FROM_CONFIG_SH = lib/Config.pm lib/Config_heavy.pl
417 CONFIGPM = $(CONFIGPM_FROM_CONFIG_SH) lib/Config_git.pl
418
419 CONFIGPOD = lib/Config.pod
420
421 CONFIGH = config.h
422 !NO!SUBS!
423         ;;
424 *)
425         # if cross-compilation
426 $spitshell >>$Makefile <<!GROK!THIS!
427 CROSS_NAME = $CROSS_NAME
428 CROSS_LIB = xlib/$CROSS_NAME
429
430 CCCMD    = \`sh \$(shellflags) cflags-cross-$CROSS_NAME "optimize='\$(OPTIMIZE)'" \$@\` -I\$(CROSS_LIB)
431 CCCMDSRC = \`sh \$(shellflags) cflags-cross-$CROSS_NAME "optimize='\$(OPTIMIZE)'" \$<\` -I\$(CROSS_LIB)
432 CONFIGPM = xlib/\$(CROSS_NAME)/Config.pm
433 CONFIGPOD = xlib/\$(CROSS_NAME)/Config.pod
434 CONFIGH = xconfig.h
435
436 xconfig.h: config_h.SH Cross/config-\$(CROSS_NAME).sh
437         CONFIG_SH=Cross/config-\$(CROSS_NAME).sh CONFIG_H=xconfig.h \$(SHELL) config_h.SH
438         #TODO \$(LDLIBPTH) ./miniperl$(EXE_EXT) -Ilib -MCross=\$(CROSS_NAME) config_h.PL "INST_VER=\$(INST_VER)" "CORE_DIR=\$(CROSS_LIB)" "CONFIG_H=xconfig.h"
439         cp xconfig.h \$(CROSS_LIB)/
440         cp xconfig.h \$(CROSS_LIB)/config.h
441
442 !GROK!THIS!
443         ;;
444 esac
445
446 SH_to_target() {
447     echo $@ | sed -e s/\\\.SH//g -e s/_/./g
448 }
449
450 SH='Makefile.SH cflags.SH config_h.SH makedepend.SH myconfig.SH runtests.SH pod/Makefile.SH x2p/Makefile.SH'
451 shextract=`SH_to_target $SH`
452
453 ## In the following dollars and backticks do not need the extra backslash.
454 $spitshell >>$Makefile <<!GROK!THIS!
455
456 private = preplibrary \$(CONFIGPM) \$(CONFIGPOD) git_version.h lib/buildcustomize.pl
457
458 # Files to be built with variable substitution before miniperl
459 # is available.
460 sh = $SH
461
462 shextract = $shextract
463 !GROK!THIS!
464
465 ## In the following dollars and backticks do not need the extra backslash.
466 $spitshell >>$Makefile <<'!NO!SUBS!'
467
468 addedbyconf = UU $(shextract) pstruct
469
470 # Unicode data files generated by mktables
471 unidatafiles = lib/unicore/Decomposition.pl lib/unicore/TestProp.pl \
472         lib/unicore/CombiningClass.pl lib/unicore/Name.pl \
473         lib/unicore/UCD.pl lib/unicore/Name.pm \
474         lib/unicore/Heavy.pl lib/unicore/mktables.lst
475
476 # Directories of Unicode data files generated by mktables
477 unidatadirs = lib/unicore/To lib/unicore/lib
478
479 h1 = EXTERN.h INTERN.h XSUB.h av.h $(CONFIGH) cop.h cv.h dosish.h
480 h2 = embed.h form.h gv.h handy.h hv.h hv_func.h keywords.h mg.h op.h opcode.h
481 h3 = pad.h patchlevel.h perl.h perlapi.h perly.h pp.h proto.h regcomp.h
482 h4 = regexp.h scope.h sv.h unixish.h util.h iperlsys.h thread.h
483 h5 = utf8.h warnings.h mydtrace.h op_reg_common.h l1_char_class_tab.h
484 h6 = charclass_invlists.h
485 h = $(h1) $(h2) $(h3) $(h4) $(h5) $(h6)
486
487 c1 = av.c scope.c op.c doop.c doio.c dump.c gv.c hv.c mg.c reentr.c mro.c perl.c
488 c2 = perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c utf8.c sv.c
489 c3 = taint.c toke.c util.c deb.c run.c universal.c pad.c globals.c keywords.c
490 c4 = perlio.c perlapi.c numeric.c mathoms.c locale.c pp_pack.c pp_sort.c
491 c5 = $(madlysrc) $(mallocsrc)
492
493 c = $(c1) $(c2) $(c3) $(c4) $(c5) miniperlmain.c opmini.c perlmini.c
494
495 obj0 = op$(OBJ_EXT) perl$(OBJ_EXT)
496 obj0mini = perlmini$(OBJ_EXT) opmini$(OBJ_EXT) miniperlmain$(OBJ_EXT)
497 obj1 = $(madlyobj) $(mallocobj) gv$(OBJ_EXT) toke$(OBJ_EXT) perly$(OBJ_EXT) pad$(OBJ_EXT) regcomp$(OBJ_EXT) dump$(OBJ_EXT) util$(OBJ_EXT) mg$(OBJ_EXT) reentr$(OBJ_EXT) mro$(OBJ_EXT) keywords$(OBJ_EXT)
498 obj2 = 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)
499 obj3 = 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) perlapi$(OBJ_EXT) numeric$(OBJ_EXT) mathoms$(OBJ_EXT) locale$(OBJ_EXT) pp_pack$(OBJ_EXT) pp_sort$(OBJ_EXT)
500
501 minindt_obj = $(obj0mini) $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
502 mini_obj = $(minindt_obj) $(MINIDTRACE_O)
503 ndt_obj = $(obj0) $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
504 obj = $(ndt_obj) $(DTRACE_O)
505
506 perltoc_pod_prereqs = extra.pods pod/perl5192delta.pod pod/perlapi.pod pod/perlintern.pod pod/perlmodlib.pod pod/perluniprops.pod
507 generated_pods = pod/perltoc.pod $(perltoc_pod_prereqs)
508 generated_headers = uudmap.h bitcount.h mg_data.h
509
510 lintflags = \
511     -b \
512     -n \
513     -p \
514     -Ncheck=%all \
515     -Nlevel=4 \
516     -errchk=parentheses \
517     -errhdr=%all \
518     -errfmt=src \
519     -errtags \
520     -erroff=E_ASSIGN_NARROW_CONV \
521     -erroff=E_BAD_PTR_CAST \
522     -erroff=E_BAD_PTR_CAST_ALIGN \
523     -erroff=E_BAD_PTR_INT_COMBINATION \
524     -erroff=E_BAD_SIGN_EXTEND \
525     -erroff=E_BLOCK_DECL_UNUSED \
526     -erroff=E_CASE_FALLTHRU \
527     -erroff=E_CONST_EXPR \
528     -erroff=E_CONSTANT_CONDITION \
529     -erroff=E_END_OF_LOOP_CODE_NOT_REACHED \
530     -erroff=E_EQUALITY_NOT_ASSIGNMENT \
531     -erroff=E_EXPR_NULL_EFFECT \
532     -erroff=E_FALSE_LOGICAL_EXPR \
533     -erroff=E_INCL_NUSD \
534     -erroff=E_LOOP_EMPTY \
535     -erroff=E_MAIN_PARAM \
536     -erroff=E_POINTER_TO_OBJECT \
537     -erroff=E_PTRDIFF_OVERFLOW \
538     -erroff=E_SHIFT_CNT_NEG_TOO_BIG_L \
539     -erroff=E_STATIC_UNUSED \
540     -erroff=E_TRUE_LOGICAL_EXPR
541
542 splintflags = \
543     -I/usr/lib/gcc/i486-linux-gnu/4.0.2/include/ \
544     -D__builtin_va_list=va_list \
545     -Dsigjmp_buf=jmp_buf \
546     -warnposix \
547     \
548     +boolint \
549     +charintliteral \
550     -fixedformalarray \
551     -mustfreefresh \
552     -nestedextern \
553     -predboolint \
554     -predboolothers \
555     -preproc \
556     -boolops \
557     -shadow \
558     -nullstate \
559     +longintegral \
560     +matchanyintegral \
561     -type \
562     \
563     +line-len 999 \
564     +weak
565
566 splintfiles = $(c1)
567
568 .c$(OBJ_EXT): 
569         $(CCCMD) $(PLDLFLAGS) $*.c
570
571 .c.i: 
572         $(CCCMDSRC) -E $*.c > $*.i
573
574 .c.s:
575         $(CCCMDSRC) -S $*.c
576
577 all: $(FIRSTMAKEFILE) $(MINIPERL_EXE) $(generated_pods) $(private) $(unidatafiles) $(public) $(dynamic_ext) $(nonxs_ext) extras.make
578         @echo " ";
579         @echo " Everything is up to date. Type '$(MAKE) test' to run test suite."
580
581 .PHONY: all translators utilities
582
583 # Both git_version.h and lib/Config_git.pl are built
584 # by make_patchnum.pl.
585 git_version.h: lib/Config_git.pl
586
587 lib/Config_git.pl: $(MINIPERL_EXE) make_patchnum.pl
588         $(MINIPERL) make_patchnum.pl
589
590 # make sure that we recompile perl.c if the git version changes
591 perl$(OBJ_EXT): git_version.h
592
593 !NO!SUBS!
594
595 # Making utilities and translators require Cwd.  If we have dynamic
596 # loading, we only need miniperl and Cwd.$dlext.  If we have static
597 # loading, we need to build perl first.
598 case "$usedl$static_cwd" in
599 defineundef)
600     util_deps='$(MINIPERL_EXE) $(CONFIGPM) lib/auto/Cwd/Cwd$(DLSUFFIX) FORCE'
601      x2p_deps="\$(MINIPERL_EXE) \$(CONFIGPM) \$(dynamic_ext) x2p/$firstmakefile FORCE"
602     ;;
603 definedefine)
604     util_deps='$(PERL_EXE) $(CONFIGPM) FORCE'
605      x2p_deps="\$(PERL_EXE) \$(CONFIGPM) \$(dynamic_ext) x2p/$firstmakefile FORCE"
606     ;;
607 *)  util_deps='$(PERL_EXE) $(CONFIGPM) FORCE'
608      x2p_deps="\$(PERL_EXE) \$(CONFIGPM) x2p/$firstmakefile FORCE"
609     ;;
610 esac
611
612 $spitshell >>$Makefile <<!GROK!THIS!
613 x2p/$firstmakefile:     makedepend
614         cd x2p; \$(MAKE) depend
615
616 translators:    $x2p_deps
617         @echo " "; echo "       Making x2p stuff"; cd x2p; \$(LDLIBPTH) \$(MAKE) all
618
619 x2p/s2p: $x2p_deps
620         cd x2p; \$(LDLIBPTH) \$(MAKE) s2p
621
622 x2p/find2perl: $x2p_deps
623         cd x2p; \$(LDLIBPTH) \$(MAKE) find2perl
624
625 utils/Makefile: \$(MINIPERL_EXE) \$(CONFIGPM) utils/Makefile.PL
626         \$(MINIPERL) -Ilib utils/Makefile.PL
627
628 utilities:      utils/Makefile $util_deps
629         @echo " "; echo "       Making utilities"; cd utils; \$(LDLIBPTH) \$(MAKE) all
630
631 !GROK!THIS!
632
633 $spitshell >>$Makefile <<'!NO!SUBS!'
634
635 # This is now done by installman only if you actually want the man pages.
636 #       @echo " "; echo "       Making docs"; cd pod; $(MAKE) all;
637
638 # Phony target to force checking subdirectories.
639 # Apparently some makes require an action for the FORCE target.
640 .PHONY: FORCE
641 FORCE:
642         @sh -c true
643 !NO!SUBS!
644
645 for file in op perl; do
646     if $issymlink $file.c; then
647         $spitshell >>$Makefile <<!GROK!THIS!
648
649 # We do a copy of the $file.c instead of a symlink because gcc gets huffy
650 # if we have a symlink forest to another disk (it complains about too many
651 # levels of symbolic links, even if we have only two)
652
653 ${file}mini.c: $file.c
654         \$(RMS) ${file}mini.c
655         \$(CPS) ${file}.c ${file}mini.c
656 !GROK!THIS!
657     else
658         $spitshell >>$Makefile <<!GROK!THIS!
659
660 ${file}mini.c: $file.c
661         \$(RMS) ${file}mini.c
662         \$(LNS) ${file}.c ${file}mini.c
663 !GROK!THIS!
664     fi
665
666     $spitshell >>$Makefile <<!GROK!THIS!
667
668 ${file}mini\$(OBJ_EXT): ${file}mini.c
669         \$(CCCMD) \$(PLDLFLAGS) $DPERL_IS_MINIPERL $DPERL_EXTERNAL_GLOB ${file}mini.c
670 !GROK!THIS!
671 done
672
673 $spitshell >>$Makefile <<'!NO!SUBS!'
674
675 globals$(OBJ_EXT): $(generated_headers)
676
677 uudmap.h mg_data.h: bitcount.h
678
679 bitcount.h: generate_uudmap$(HOST_EXE_EXT)
680         $(RUN) ./generate_uudmap$(HOST_EXE_EXT) $(generated_headers)
681
682 generate_uudmap$(OBJ_EXT): mg_raw.h
683
684 generate_uudmap$(HOST_EXE_EXT): generate_uudmap$(OBJ_EXT)
685         $(CC) -o generate_uudmap$(EXE_EXT) $(LDFLAGS) generate_uudmap$(OBJ_EXT) $(libs)
686
687 perlmain.c: $(MINIPERL_EXE) ext/ExtUtils-Miniperl/pm_to_blib
688         $(MINIPERL) -Ilib -MExtUtils::Miniperl -e 'writemain(@ARGV)' DynaLoader $(static_ext) > perlmain.c
689
690 # The file ext.libs is a list of libraries that must be linked in
691 # for static extensions, e.g. -lm -lgdbm, etc.  The individual
692 # static extension Makefile's add to it.
693 ext.libs: $(static_ext)
694         -@test -f ext.libs || touch ext.libs
695
696 !NO!SUBS!
697
698 # How to build libperl.  This is still rather convoluted.
699 # Load up custom Makefile.SH fragment for shared loading and executables:
700 case "$osname" in
701 *)
702         Makefile_s="$osname/Makefile.SHs"
703         ;;
704 esac
705
706 case "$osname" in
707 aix)
708         $spitshell >>$Makefile <<!GROK!THIS!
709 LIBS                    = $perllibs
710 # In AIX we need to change this for building Perl itself from
711 # its earlier definition (which is for building external
712 # extensions *after* Perl has been built and installed)
713 CCDLFLAGS               = `echo $ccdlflags|sed -e 's@-bE:.*/perl\.exp@-bE:perl.exp@'`
714
715 !GROK!THIS!
716         case "$useshrplib" in
717         define|true|[yY]*)
718                 $spitshell >>$Makefile <<'!NO!SUBS!'
719
720 LIBPERL_NONSHR          = libperl_nonshr$(LIB_EXT)
721 MINIPERL_NONSHR         = miniperl_nonshr$(EXE_EXT)
722
723 $(LIBPERL_NONSHR): $(obj)
724         $(RMS) $(LIBPERL_NONSHR)
725         $(AR) rcu $(LIBPERL_NONSHR) $(obj)
726
727 $(MINIPERL_NONSHR): $(LIBPERL_NONSHR) miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT)  perlmini$(OBJ_EXT)
728         $(CC) $(LDFLAGS) -o $(MINIPERL_NONSHR) miniperlmain$(OBJ_EXT) \
729             opmini$(OBJ_EXT) perlmini$(OBJ_EXT) $(LIBPERL_NONSHR) $(LIBS)
730
731 MINIPERLEXP             = $(MINIPERL_NONSHR)
732
733 LIBPERLEXPORT           = perl.exp
734
735 !NO!SUBS!
736                 
737                 ;;
738         *)      
739                 $spitshell >>$Makefile <<'!NO!SUBS!'
740 MINIPERLEXP             = $(MINIPERL_EXE)
741
742 PERLEXPORT              = perl.exp
743
744 !NO!SUBS!
745         ;;
746         esac
747         $spitshell >>$Makefile <<'!NO!SUBS!'
748 perl.exp: $(MINIPERLEXP) makedef.pl $(CONFIGPM) $(SYM) $(SYMH)
749         ./$(MINIPERLEXP) makedef.pl --sort-fold PLATFORM=aix CC_FLAGS="$(OPTIMIZE)" > perl.exp
750
751 !NO!SUBS!
752         ;;
753 os2)
754         $spitshell >>$Makefile <<'!NO!SUBS!'
755 MINIPERLEXP             = miniperl
756
757 perl5.def: $(MINIPERLEXP) makedef.pl $(CONFIGPM) $(SYM) $(SYMH) miniperl.map
758         ./$(MINIPERLEXP) makedef.pl PLATFORM=os2 -DPERL_DLL=$(PERL_DLL) CC_FLAGS="$(OPTIMIZE)" > perl5.def
759
760 !NO!SUBS!
761         ;;
762 cygwin)
763         $spitshell >>$Makefile <<'!NO!SUBS!'
764 cygwin.c: cygwin/cygwin.c
765         $(LNS) cygwin/cygwin.c
766
767 LIBPERL_NONSHR          = libperl$(LIB_EXT)
768
769 $(LIBPERL_NONSHR): $(obj)
770         $(RMS) $(LIBPERL_NONSHR)
771         $(AR) rcu $(LIBPERL_NONSHR) $(obj)
772
773 !NO!SUBS!
774         ;;
775 esac
776
777 if test -s $Makefile_s ; then
778         . $Makefile_s
779         $spitshell >>$Makefile <<!GROK!THIS!
780
781 Makefile: $Makefile_s
782 !GROK!THIS!
783 else
784         case "$dtrace_h" in
785         ?*)
786                 $spitshell >>$Makefile <<'!NO!SUBS!'
787 # dtrace dicards const qualifiers from arguments, put them back
788 $(DTRACE_H): perldtrace.d
789         $(DTRACE) -h -s perldtrace.d -o $(DTRACE_H).in
790         sed -e '/const/!s/char \*/const char */g' $(DTRACE_H).in >$(DTRACE_H)
791         $(RMS) $(DTRACE_H).in
792
793 mydtrace.h: $(DTRACE_H)
794
795 !NO!SUBS!
796                 ;;
797         esac
798         case "$dtrace_o" in
799         ?*)
800                 $spitshell >>$Makefile <<'!NO!SUBS!'
801 $(DTRACE_O): perldtrace.d $(ndt_obj)
802         $(DTRACE) -G -s perldtrace.d -o $(DTRACE_O) $(ndt_obj)
803
804 $(MINIDTRACE_O): perldtrace.d $(minindt_obj) perlmini$(OBJ_EXT)
805         $(DTRACE) -G -s perldtrace.d -o $(MINIDTRACE_O) $(minindt_obj) perlmini$(OBJ_EXT)
806
807 !NO!SUBS!
808                 ;;
809     esac
810         $spitshell >>$Makefile <<'!NO!SUBS!'
811 $(LIBPERL): $& $(obj) $(DYNALOADER) $(LIBPERLEXPORT)
812 !NO!SUBS!
813         case "$useshrplib" in
814         true)
815                 $spitshell >>$Makefile <<'!NO!SUBS!'
816         rm -f $@
817         $(LD) -o $@ $(SHRPLDFLAGS) $(obj) $(DYNALOADER) $(libs)
818 !NO!SUBS!
819                 case "$osname" in
820                 aix)
821                         $spitshell >>$Makefile <<'!NO!SUBS!'
822         rm -f libperl$(OBJ_EXT)
823         mv $@ libperl$(OBJ_EXT)
824         $(AR) qv $(LIBPERL) libperl$(OBJ_EXT)
825 !NO!SUBS!
826                         ;;
827                 esac
828                 ;;
829         *)
830                 $spitshell >>$Makefile <<'!NO!SUBS!'
831         rm -f $(LIBPERL)
832         $(AR) rcu $(LIBPERL) $(obj) $(DYNALOADER)
833         @$(ranlib) $(LIBPERL)
834 !NO!SUBS!
835                 ;;
836         esac
837         $spitshell >>$Makefile <<'!NO!SUBS!'
838
839 # How to build executables.
840
841 # The $& notation tells Sequent machines that it can do a parallel make,
842 # and is harmless otherwise.
843 # The miniperl -w -MExporter line is a basic cheap test to catch errors
844 # before make goes on to run preplibrary and then MakeMaker on extensions.
845 # This is very handy because later errors are often caused by miniperl
846 # build problems but that's not obvious to the novice.
847 # The Module used here must not depend on Config or any extensions.
848
849 # The seemingly cranky ordering of having $(MINIPERL_EXE) depend on
850 # lib/buildcustomize.pl despite the reality that lib/buildcustomize.pl needs
851 # miniperl to exist first permits us to
852 # a) have one rule generate both miniperl and lib/buildcustomize.pl
853 #    (so that lib/buildcustomise.pl is always available. This simplifies things)
854 # b) have the rest of the Makefile depend on the more obvious $(MINIPERL_EXE)
855
856 $(MINIPERL_EXE): lib/buildcustomize.pl
857
858 !NO!SUBS!
859
860         case "${osname}${osvers}" in
861         aix*)
862                 $spitshell >>$Makefile <<'!NO!SUBS!'
863 lib/buildcustomize.pl: $& $(mini_obj)
864         $(CC) -o $(MINIPERL_EXE) $(CLDFLAGS) $(mini_obj) $(libs)
865         $(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>' || sh -c 'echo >&2 Failed to build miniperl.  Please run make minitest; exit 1'
866         $(MINIPERL) -f write_buildcustomize.pl
867 !NO!SUBS!
868                 ;;
869         next4*)
870                 $spitshell >>$Makefile <<'!NO!SUBS!'
871 lib/buildcustomize.pl: $& $(mini_obj) write    ldcustomize.pl
872         $(CC) -o $(MINIPERL_EXE) $(mini_obj    libs)
873         $(LDLIBPTH) $(RUN) ./miniperl$(HOST    _EXT) -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>' || sh -c 'echo >&2 Failed to build miniperl.  Please run make minitest; exit 1'
874         $(MINIPERL) -f write_buildcustomize.pl    
875 !NO!SUBS!
876                 ;;
877         darwin*)
878                 case "$osvers" in
879                 [1-6].*) ;;
880                 *) case "$ldflags" in
881                     *"-flat_namespace"*) ;;
882                     *) # to allow opmini.o to override stuff in libperl.dylib
883                 $spitshell >>$Makefile <<!NO!SUBS!
884 NAMESPACEFLAGS = -force_flat_namespace
885 !NO!SUBS!
886                        ;;
887                     esac
888                     ;;
889                 esac
890                 $spitshell >>$Makefile <<'!NO!SUBS!'
891 lib/buildcustomize.pl: $& $(mini_obj) write_buildcustomize.pl
892         -@rm -f miniperl.xok
893         $(CC) $(CLDFLAGS) $(NAMESPACEFLAGS) -o $(MINIPERL_EXE) \
894             $(mini_obj) $(libs)
895         $(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>' || sh -c 'echo >&2 Failed to build miniperl.  Please run make minitest; exit 1'
896         $(MINIPERL) -f write_buildcustomize.pl
897 !NO!SUBS!
898                 ;;
899         *)
900                 $spitshell >>$Makefile <<'!NO!SUBS!'
901 lib/buildcustomize.pl: $& $(mini_obj) write_buildcustomize.pl
902         -@rm -f miniperl.xok
903         $(LDLIBPTH) $(CC) $(CLDFLAGS) -o $(MINIPERL_EXE) \
904             $(mini_obj) $(libs)
905         $(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>' || sh -c 'echo >&2 Failed to build miniperl.  Please run make minitest; exit 1'
906         $(MINIPERL) -f write_buildcustomize.pl
907 !NO!SUBS!
908                 ;;
909         esac
910
911         $spitshell >>$Makefile <<'!NO!SUBS!'
912
913 $(PERL_EXE): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs $(PERLEXPORT) write_buildcustomize.pl
914         -@rm -f miniperl.xok
915         $(SHRPENV) $(LDLIBPTH) $(CC) -o perl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
916
917 !NO!SUBS!
918
919 case "${osname}${osvers}" in
920 linux*|darwin*)
921         $spitshell >>$Makefile <<'!NO!SUBS!'
922 # Valgrind perl (currently Linux, Darwin only)
923
924 perl.valgrind.config: config.sh
925         @echo "Checking usemymalloc='n' in config.sh..."
926         @grep "^usemymalloc="    config.sh
927         @grep "^usemymalloc='n'" config.sh >/dev/null || exit 1
928         @echo "And of course you have to have valgrind..."
929         $(VALGRIND) $(VG_TEST) || exit 1
930 !NO!SUBS!
931         ;;
932 esac    
933
934 $spitshell >>$Makefile <<'!NO!SUBS!'
935
936 # Microperl.  This is just a convenience thing if one happens to
937 # build also the full Perl and therefore the real big Makefile:
938 # usually one should manually explicitly issue the below command.
939
940 .PHONY: microperl
941 microperl:
942         $(MAKE) -f Makefile.micro
943
944 !NO!SUBS!
945
946 fi
947
948 # Some environment have no system(), which mkpport uses.
949 # Let's try running the commands with shell.
950 case "${osname}" in
951 catamount)
952 $spitshell >>$Makefile <<!GROK!THIS!
953 .PHONY: makeppport
954 makeppport: \$(MINIPERL_EXE) \$(CONFIGPM)
955         -@for f in Makefile.PL PPPort_pm.PL PPPort_xs.PL ppport_h.PL; do \
956         (cd ext/Devel-PPPort && `pwd`/run.sh ../../$(MINIPERL_EXE) -I../../lib \$\$f); \
957         done
958
959 !GROK!THIS!
960 ;;
961 *)
962 $spitshell >>$Makefile <<'!NO!SUBS!'
963 .PHONY: makeppport
964 makeppport: $(MINIPERL_EXE) $(CONFIGPM) $(nonxs_ext)
965         $(MINIPERL) mkppport
966
967 !NO!SUBS!
968 ;;
969 esac
970
971 $spitshell >>$Makefile <<'!NO!SUBS!'
972
973 .PHONY: preplibrary
974 preplibrary: $(MINIPERL_EXE) $(CONFIGPM) $(PREPLIBRARY_LIBPERL)
975
976 $(CONFIGPM_FROM_CONFIG_SH): $(CONFIGPOD)
977
978 $(CONFIGPOD): config.sh $(MINIPERL_EXE) configpm Porting/Glossary lib/Config_git.pl
979         $(MINIPERL) configpm
980
981 unidatafiles $(unidatafiles) pod/perluniprops.pod: uni.data
982
983 uni.data: $(MINIPERL_EXE) $(CONFIGPM) lib/unicore/mktables $(nonxs_ext)
984         $(MINIPERL) lib/unicore/mktables -C lib/unicore -P pod -maketest -makelist -p
985 #       Commented out so always runs, mktables looks at far more files than we
986 #       can in this makefile to decide if needs to run or not
987 #       touch uni.data
988
989 # $(PERL_EXE) and ext because pod_lib.pl needs Digest::MD5
990 # But also this ensures that all extensions are built before we try to scan
991 # them, which picks up Devel::PPPort's documentation.
992 pod/perltoc.pod: $(perltoc_pod_prereqs)  $(PERL_EXE) $(ext) pod/buildtoc
993         $(RUN_PERL) -f -Ilib pod/buildtoc -q
994
995 pod/perlapi.pod: pod/perlintern.pod
996
997 pod/perlintern.pod: $(MINIPERL_EXE) autodoc.pl embed.fnc
998         $(MINIPERL) autodoc.pl
999
1000 pod/perlmodlib.pod: $(MINIPERL_EXE) pod/perlmodlib.PL MANIFEST
1001         $(MINIPERL) pod/perlmodlib.PL -q
1002
1003 pod/perl5192delta.pod: pod/perldelta.pod
1004         $(RMS) pod/perl5192delta.pod
1005         $(LNS) perldelta.pod pod/perl5192delta.pod
1006
1007 extra.pods: $(MINIPERL_EXE)
1008         -@test ! -f extra.pods || rm -f `cat extra.pods`
1009         -@rm -f extra.pods
1010         -@for x in `grep -l '^=[a-z]' README.* | grep -v README.vms` ; do \
1011             nx=`echo $$x | sed -e "s/README\.//"`; \
1012             $(LNS) ../$$x "pod/perl"$$nx".pod" ; \
1013             echo "pod/perl"$$nx".pod" >> extra.pods ; \
1014         done
1015
1016 extras.make: $(PERL_EXE)
1017         -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib -MCPAN -e '@ARGV&&make(@ARGV)' `cat extras.lst`
1018
1019 extras.test: $(PERL_EXE)
1020         -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib -MCPAN -e '@ARGV&&test(@ARGV)' `cat extras.lst`
1021
1022 extras.install: $(PERL_EXE)
1023         -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib -MCPAN -e '@ARGV&&install(@ARGV)' `cat extras.lst`
1024
1025 .PHONY: install install-strip install-all install-verbose install-silent \
1026         no-install install.perl install.man install.html
1027
1028 install_strip install-strip:
1029         $(MAKE) STRIPFLAGS=-s install DESTDIR="$(DESTDIR)"
1030
1031 install install_all install-all:
1032         $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) DESTDIR="$(DESTDIR)"
1033
1034 install_verbose install-verbose:
1035         $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-V DESTDIR="$(DESTDIR)"
1036
1037 install_silent install-silent:
1038         $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-S DESTDIR="$(DESTDIR)"
1039
1040 no_install no-install:
1041         $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-n DESTDIR="$(DESTDIR)"
1042
1043 # Set this to an empty string to avoid an attempt of rebuild before install
1044 INSTALL_DEPENDENCE = all
1045
1046 install.perl:   $(INSTALL_DEPENDENCE) installperl
1047         $(RUN_PERL) installperl --destdir=$(DESTDIR) $(INSTALLFLAGS) $(STRIPFLAGS)
1048         -@test ! -s extras.lst || $(MAKE) extras.install
1049
1050 install.man:    all installman
1051         $(RUN_PERL) installman --destdir=$(DESTDIR) $(INSTALLFLAGS)
1052
1053 # XXX Experimental. Hardwired values, but useful for testing.
1054 # Eventually Configure could ask for some of these values.
1055 install.html: all installhtml
1056         -@test -f README.vms && cd vms && $(LNS) ../README.vms README_vms.pod && cd ..
1057         $(RUN_PERL) installhtml   \
1058       --podroot=. --podpath=. --recurse  \
1059       --htmldir=$(privlib)/html   \
1060       --htmlroot=$(privlib)/html  \
1061       --splithead=pod/perlipc     \
1062       --splititem=pod/perlfunc    \
1063       --ignore=Porting/Maintainers.pm,Porting/pumpkin.pod,Porting/repository.pod \
1064       --verbose
1065
1066
1067 # I now supply perly.c with the kits, so the following section is
1068 # used only if you force bison to run by saying
1069 #       make regen_perly
1070 # You normally shouldn't remake perly.[ch].
1071
1072 .PHONY: regen_perly
1073
1074 run_byacc run-byacc:
1075         @echo "run_byacc is obsolete; try 'make regen_perly' instead"
1076
1077 # this outputs perly.h, perly.act and perly.tab
1078 regen_perly regen-perly:
1079         perl regen_perly.pl
1080
1081 # We don't want to regenerate perly.c and perly.h, but they might
1082 # appear out-of-date after a patch is applied or a new distribution is
1083 # made.
1084 perly.c: perly.y
1085         -@sh -c true
1086
1087 perly.h: perly.y
1088         -@sh -c true
1089
1090 SYM  = globvar.sym perlio.sym
1091
1092 SYMH = perlvars.h intrpvar.h
1093
1094 CHMOD_W = chmod +w
1095
1096 # The following files are generated automatically
1097 #       embed.pl:       proto.h embed.h embedvar.h perlapi.h perlapi.c
1098 #       opcode.pl:      opcode.h opnames.h pp_proto.h
1099 #       regcomp.pl:     regnodes.h
1100 #       warnings.pl:    warnings.h lib/warnings.pm
1101 #       feature.pl:     feature.h lib/feature.pm
1102 # The correct versions should be already supplied with the perl kit,
1103 # in case you don't have perl available.
1104 # To force them to be regenerated, run
1105 #       perl regen.pl
1106 # with your existing copy of perl
1107 # (make regen_headers is kept for backwards compatibility)
1108
1109 AUTOGEN_FILES = opcode.h opnames.h pp_proto.h proto.h embed.h embedvar.h \
1110                 perlapi.h perlapi.c regnodes.h warnings.h lib/warnings.pm \
1111                 lib/feature.pm feature.h
1112
1113 .PHONY: regen_headers regen_all
1114
1115 regen:  FORCE
1116         -perl regen.pl
1117         -perl regen/uconfig_h.pl
1118
1119 regen_headers regen-headers:    FORCE
1120         -perl regen.pl -v
1121         -perl regen/uconfig_h.pl -v
1122
1123 regen_meta regen-meta:  META.yml META.json
1124
1125 META.yml:   FORCE
1126         PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib Porting/makemeta -y
1127
1128 META.json:   FORCE
1129         PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib Porting/makemeta -j
1130
1131
1132 regen_all regen-all: regen regen_meta
1133
1134 .PHONY: manisort manicheck
1135
1136 manisort:       FORCE
1137         @perl Porting/manisort -q || (echo "WARNING: re-sorting MANIFEST"; \
1138                 perl Porting/manisort -q -o MANIFEST; sh -c true)
1139
1140 manicheck:      FORCE
1141         perl Porting/manicheck
1142
1143 # Extensions:
1144 # Names added to $(dynamic_ext) or $(static_ext) or $(nonxs_ext) will
1145 # automatically get built.  There should ordinarily be no need to change
1146 # any of this part of makefile.
1147 #
1148 # The dummy dependency is a place holder in case $(dynamic_ext) or
1149 # $(static_ext) is empty.
1150 #
1151 # DynaLoader may be needed for extensions that use Makefile.PL.
1152
1153 $(DYNALOADER):  $(MINIPERL_EXE) lib/buildcustomize.pl preplibrary FORCE $(nonxs_ext)
1154         $(MINIPERL) make_ext.pl $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=static $(STATIC_LDFLAGS)
1155
1156 d_dummy $(dynamic_ext): $(MINIPERL_EXE) lib/buildcustomize.pl preplibrary makeppport $(DYNALOADER) FORCE $(PERLEXPORT) $(LIBPERL)
1157         $(MINIPERL) make_ext.pl $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=dynamic
1158
1159 s_dummy $(static_ext):  $(MINIPERL_EXE) lib/buildcustomize.pl preplibrary makeppport $(DYNALOADER) FORCE
1160         $(MINIPERL) make_ext.pl $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=static $(STATIC_LDFLAGS)
1161
1162 n_dummy $(nonxs_ext):   $(MINIPERL_EXE) lib/buildcustomize.pl preplibrary FORCE
1163         $(MINIPERL) make_ext.pl $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
1164 !NO!SUBS!
1165
1166 $spitshell >>$Makefile <<EOF
1167 $extra_dep
1168 EOF
1169
1170 $spitshell >>$Makefile <<'!NO!SUBS!'
1171
1172 .PHONY: printconfig
1173 printconfig:
1174         @eval `$(RUN_PERL) -Ilib -V:$(CONFIGVAR)`; echo $$$(CONFIGVAR)
1175
1176 .PHONY: clean _tidy _mopup _cleaner1 _cleaner2 \
1177         realclean _realcleaner clobber _clobber \
1178         distclean veryclean _verycleaner
1179
1180 clean:          _tidy _mopup 
1181
1182 realclean:      _realcleaner _mopup
1183         @echo "Note that '$(MAKE) realclean' does not delete config.sh or Policy.sh"
1184
1185 _clobber:
1186         -@rm -f Cross/run-* Cross/to-* Cross/from-*
1187         rm -f t/test_state
1188         rm -f config.sh cppstdin Policy.sh extras.lst
1189
1190 clobber:        _realcleaner _mopup _clobber
1191
1192 distclean:      clobber
1193
1194 # Like distclean but also removes emacs backups and *.orig.
1195 veryclean:      _verycleaner _mopup _clobber
1196         -@rm -f Obsolete Wanted
1197
1198 # Do not 'make _mopup' directly.
1199 _mopup:
1200         rm -f *$(OBJ_EXT) *$(LIB_EXT) all perlmain.c opmini.c perlmini.c generate_uudmap$(EXE_EXT) $(generated_headers)
1201         -rmdir .depending
1202         -@test -f extra.pods && rm -f `cat extra.pods`
1203         -@test -f vms/README_vms.pod && rm -f vms/README_vms.pod
1204         -rm -f perl.exp ext.libs $(generated_pods) uni.data opmini.o perlmini.o pod/roffitall
1205         -rm -f perl.export perl.dll perl.libexp perl.map perl.def
1206         -rm -f *perl.xok
1207         -rm -f cygwin.c libperl*.def libperl*.dll cygperl*.dll *.exe.stackdump
1208         -rm -f $(PERL_EXE) $(MINIPERL_EXE) $(LIBPERL) libperl.* microperl
1209         -rm -f config.arch config.over $(DTRACE_H)
1210
1211 # Do not 'make _tidy' directly.
1212 _tidy:
1213         -cd pod; $(LDLIBPTH) $(MAKE) clean
1214         -cd utils; $(LDLIBPTH) $(MAKE) clean
1215         -cd x2p; $(LDLIBPTH) $(MAKE) clean
1216         -rm -f lib/Config_git.pl git_version.h
1217         -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
1218         $(MINIPERL) make_ext.pl --target=clean $$x MAKE=$(MAKE) ; \
1219         done
1220
1221 _cleaner1:
1222         -cd os2; rm -f Makefile
1223         -cd pod; $(LDLIBPTH) $(MAKE) $(CLEAN)
1224         -cd utils; $(LDLIBPTH) $(MAKE) $(CLEAN)
1225         -cd x2p; $(LDLIBPTH) $(MAKE) $(CLEAN)
1226         -@if test -f $(MINIPERL_EXE) ; then \
1227         for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
1228         $(MINIPERL) make_ext.pl --target=$(CLEAN) $$x MAKE=$(MAKE) ; \
1229         done ; \
1230         else \
1231         sh $(CLEAN).sh ; \
1232         fi
1233         rm -f realclean.sh veryclean.sh
1234         -rm -f `grep -v ^# mkppport.lst | grep . | sed -e 's/$$/\/ppport.h/'`
1235
1236 # Dear POSIX, thanks for making the default to xargs to be
1237 # run once if nothhing is passed in. It is such a great help.
1238
1239 # Some systems do not support "?", so keep these files separate.
1240 _cleaner2:
1241         -rm -f core.*perl.*.? t/core.perl.*.? .?*.c
1242         rm -f core *perl.core t/core t/*perl.core core.* t/core.*
1243         rm -f t/$(PERL_EXE) t/rantests
1244         rm -rf t/tmp*
1245         rm -f so_locations $(LIBPERL_NONSHR) $(MINIPERL_NONSHR)
1246         rm -rf $(addedbyconf)
1247         rm -f $(FIRSTMAKEFILE) $(FIRSTMAKEFILE).old makefile.old utils/Makefile
1248         rm -f $(private)
1249         rm -rf $(unidatafiles) $(unidatadirs)
1250         rm -rf lib/auto
1251         rm -f lib/.exists lib/*/.exists lib/*/*/.exists
1252         rm -f h2ph.man pstruct
1253         rm -rf .config
1254         rm -f preload
1255         rm -rf lib/Encode lib/Compress lib/Hash lib/re
1256         rm -rf lib/TAP lib/Module/Pluggable lib/App
1257         rm -rf lib/mro
1258         rm -rf lib/IO/Compress lib/IO/Uncompress
1259         rm -f lib/ExtUtils/ParseXS/t/XSTest.c
1260         rm -f lib/ExtUtils/ParseXS/t/XSTest$(OBJ_EXT)
1261         rm -f lib/ExtUtils/ParseXS/t/XSTest$(DLSUFFIX)
1262         rm -fr lib/B
1263         rm -fr lib/CPAN
1264         rm -fr lib/ExtUtils/CBuilder
1265         rm -f pod2htmd.tmp
1266         rm -rf pod/perlfunc pod/perlipc
1267         -rmdir ext/B/lib
1268         -rmdir lib/Archive/Tar lib/Archive lib/Attribute
1269         -rmdir lib/CGI lib/Carp
1270         -rmdir lib/Data lib/Devel lib/Digest
1271         -rmdir lib/ExtUtils/Command lib/ExtUtils/Constant lib/ExtUtils/Liblist lib/ExtUtils/MakeMaker
1272         -rmdir lib/File/Spec lib/Filter/Util lib/Filter
1273         -rmdir lib/I18N/LangTags lib/IO/Socket lib/IO lib/IPC
1274         -rmdir lib/List/Util lib/List
1275         -rmdir lib/Locale/Maketext lib/Locale
1276         -rmdir lib/Log/Message lib/Log
1277         -rmdir lib/Math/Big* lib/Math
1278         -rmdir lib/Memoize lib/MIME
1279         -rmdir lib/Module/Build/Platform lib/Module/Build lib/Module/Load lib/Module
1280         -rmdir lib/Net/FTP lib/Object
1281         -rmdir lib/Parse/CPAN lib/Parse
1282         -rmdir lib/PerlIO/via lib/PerlIO
1283         -rmdir lib/Package lib/Params
1284         -rmdir lib/Pod/Perldoc lib/Pod/Simple lib/Pod/Text
1285         -rmdir lib/Sys lib/Scalar/Util lib/Scalar
1286         -rmdir lib/Term/UI lib/Thread lib/Tie/Hash
1287         -rmdir lib/Test/Builder/Tester lib/Test/Builder lib/Test
1288         -rmdir lib/Unicode/Collate
1289         -rmdir lib/XS/APItest lib/XS
1290         -rmdir lib/inc/latest lib/inc
1291         -rmdir lib/autodie/exception lib/autodie lib/encoding lib/threads
1292         -rm -f lib/ExtUtils/CBuilder/t/libcompilet.dll.a
1293         -rm -f lib/ExtUtils/ParseXS/t/libXSTest.dll.a
1294
1295 _realcleaner:
1296         @$(LDLIBPTH) $(MAKE) _cleaner1 CLEAN=distclean
1297         @$(LDLIBPTH) $(MAKE) _cleaner2
1298
1299 _verycleaner:
1300         @$(LDLIBPTH) $(MAKE) _cleaner1 CLEAN=veryclean
1301         @$(LDLIBPTH) $(MAKE) _cleaner2
1302         -rm -f *~ *.orig */*~ */*.orig */*/*~ */*/*.orig
1303
1304 .PHONY: lint
1305 lint: $(c)
1306         rm -f *.ln
1307         lint $(lintflags) -DPERL_CORE -D_REENTRANT -DDEBUGGING -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(c)
1308
1309 .PHONY: splint
1310 splint: $(c)
1311         splint $(splintflags) -DPERL_CORE -D_REENTRANT -DDEBUGGING -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(splintfiles)
1312
1313 # Need to unset during recursion to go out of loop.
1314 # The README below ensures that the dependency list is never empty and
1315 # that when MAKEDEPEND is empty $(FIRSTMAKEFILE) doesn't need rebuilding.
1316
1317 MAKEDEPEND = Makefile makedepend
1318
1319 $(FIRSTMAKEFILE):       README $(MAKEDEPEND)
1320         $(MAKE) depend MAKEDEPEND=
1321 !NO!SUBS!
1322
1323 for f in $SH; do
1324     file=`SH_to_target $f`
1325     $spitshell >>$Makefile <<!GROK!THIS!
1326
1327 $file: $f config.sh
1328         \$(SHELL) $f
1329 !GROK!THIS!
1330 done
1331
1332 $spitshell >>$Makefile <<'!NO!SUBS!'
1333
1334 .PHONY: depend
1335 depend: makedepend
1336         sh ./makedepend MAKE=$(MAKE) cflags
1337
1338 .PHONY: test check test_prep test_prep_nodll test_prep_pre \
1339         test_prep_reonly test_tty test-tty test_notty test-notty \
1340         test_harness test_harness_notty minitest test-reonly _test
1341
1342 _test:
1343         echo >&2 The _test target is deprecated. Please upgrade your smoker
1344         $(RUN_TESTS) choose
1345
1346 # Cannot delegate rebuilding of t/perl to make
1347 # to allow interlaced test and minitest
1348
1349 # Architecture-neutral stuff:
1350
1351 test_prep_pre: preplibrary utilities $(nonxs_ext)
1352
1353 test_prep test-prep: test_prep_pre $(MINIPERL_EXE) $(unidatafiles) $(PERL_EXE) \
1354         $(dynamic_ext) $(TEST_PERL_DLL) runtests x2p/s2p x2p/find2perl \
1355         $(generated_pods)
1356         cd t && (rm -f $(PERL_EXE); $(LNS) ../$(PERL_EXE) $(PERL_EXE))
1357
1358 test_prep_reonly: $(MINIPERL_EXE) $(PERL_EXE) $(dynamic_ext_re) $(TEST_PERL_DLL)
1359         $(MINIPERL) make_ext.pl $(dynamic_ext_re) MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=dynamic
1360         cd t && (rm -f $(PERL_EXE); $(LNS) ../$(PERL_EXE) $(PERL_EXE))
1361
1362 test check: test_prep
1363         $(RUN_TESTS) choose
1364
1365 test_tty test-tty: test_prep
1366         $(RUN_TESTS) tty
1367
1368 test_notty test-notty: test_prep
1369         $(RUN_TESTS) no-tty
1370
1371 !NO!SUBS!
1372
1373 case "${osname}${osvers}" in
1374 linux*|darwin*)
1375         $spitshell >>$Makefile <<'!NO!SUBS!'
1376 # Targets for valgrind testing:
1377
1378 test_prep.valgrind: test_prep perl.valgrind
1379
1380 test.valgrind check.valgrind:   test_prep perl.valgrind.config
1381         PERL_VALGRIND=1 VALGRIND='$(VALGRIND)' $(RUN_TESTS) choose
1382
1383 test_notty.valgrind: test_prep.valgrind perl.valgrind.config
1384         PERL_VALGRIND=1 $(RUN_TESTS) no-tty
1385 !NO!SUBS!
1386         ;;
1387 esac
1388
1389 $spitshell >>$Makefile <<'!NO!SUBS!'
1390
1391 # Can't depend on lib/Config.pm because that might be where miniperl
1392 # is crashing.
1393 minitest: $(MINIPERL_EXE)
1394         -@test -f lib/Config.pm || $(MAKE) lib/Config.pm $(unidatafiles)
1395         @echo " "
1396         @echo "You may see some irrelevant test failures if you have been unable"
1397         @echo "to build lib/Config.pm, or the Unicode data files."
1398         @echo " "
1399         - cd t && (rm -f $(PERL_EXE); $(LNS) ../$(MINIPERL_EXE) $(PERL_EXE)) \
1400                 && $(RUN_PERL) TEST base/*.t comp/*.t cmd/*.t run/*.t io/*.t re/*.t opbasic/*.t op/*.t uni/*.t </dev/tty
1401
1402 # Test via harness
1403
1404 test_harness test-harness: test_prep
1405         TESTFILE=harness $(RUN_TESTS) choose
1406
1407 test_harness_notty: test_prep
1408         HARNESS_NOTTY=1 TESTFILE=harness $(RUN_TESTS) choose
1409
1410 test_reonly test-reonly: test_prep_reonly
1411         TEST_ARGS='-re \bre\/' TESTFILE=harness $(RUN_TESTS) choose
1412
1413
1414 # Porting tests (well-formedness of pod, manifest, etc)
1415
1416 test_porting test-porting: test_prep
1417         cd t && $(RUN_PERL) harness porting/*.t ../lib/diagnostics.t
1418
1419 # Handy way to run perlbug -ok without having to install and run the
1420 # installed perlbug. We don't re-run the tests here - we trust the user.
1421 # Please *don't* use this unless all tests pass.
1422 # If you want to report test failures, use "make nok" instead.
1423
1424 .PHONY: ok okfile oknack okfilenack nok nokfile noknack nokfilenack
1425
1426 ok:     utilities
1427         $(RUN_PERL) -Ilib utils/perlbug -ok -s '(UNINSTALLED)'
1428
1429 okfile: utilities
1430         $(RUN_PERL) -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok
1431
1432 oknack: utilities
1433         $(RUN_PERL) -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -A
1434
1435 okfilenack:     utilities
1436         $(RUN_PERL) -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok -A
1437
1438 nok:    utilities
1439         $(RUN_PERL) -Ilib utils/perlbug -nok -s '(UNINSTALLED)'
1440
1441 nokfile:        utilities
1442         $(RUN_PERL) -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -F perl.nok
1443
1444 noknack:        utilities
1445         $(RUN_PERL) -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -A
1446
1447 nokfilenack:    utilities
1448         $(RUN_PERL) -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -F perl.nok -A
1449
1450 .PHONY: clist hlist
1451
1452 clist:  $(c)
1453         echo $(c) | tr ' ' $(TRNL) >.clist
1454
1455 hlist:  $(h)
1456         echo $(h) | tr ' ' $(TRNL) >.hlist
1457
1458 .PHONY: distcheck
1459 distcheck: FORCE
1460         perl '-MExtUtils::Manifest=&fullcheck' -e 'fullcheck()'
1461
1462 .PHONY: ctags
1463
1464 ctags:
1465         ctags -f Tags -N --totals --languages=c --langmap=c:+.h --exclude=opmini.c --exclude=perlmini.c *.c *.h
1466
1467 # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
1468 # If this runs make out of memory, delete /usr/include lines.
1469 !NO!SUBS!
1470
1471 $eunicefix Makefile
1472 $rm -f $firstmakefile
1473
1474 # Now do any special processing required before building.
1475
1476 case "$ebcdic" in
1477 define)
1478     xxx=''
1479     echo "This is an EBCDIC system, checking if any parser files need regenerating." >&2
1480 case "$osname" in
1481 os390|posix-bc)
1482     if cd x2p
1483     then
1484         rm -f y.tab.c y.tab.h
1485         case "$osname" in
1486         posix-bc)
1487            # we are using two different yaccs in BS2000 Posix!
1488            byacc a2p.y >/dev/null 2>&1
1489            ;;
1490         *) # e.g. os390
1491            yacc  a2p.y >/dev/null 2>&1
1492            ;;
1493         esac
1494         if cmp -s y.tab.c a2p.c
1495         then
1496             rm -f y.tab.c
1497         else
1498             echo "a2p.y -> a2p.c" >&2
1499             mv -f y.tab.c a2p.c
1500             chmod u+w a2p.c
1501             sed -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' \
1502                 -e 's|^static void __YY_YACC_MAIN.*BS2000.*|/*static main deleted*/|' \
1503                 -e 's/y\.tab/a2p/g' a2p.c >a2p.tmp && mv a2p.tmp a2p.c
1504             xxx="$xxx a2p.c"
1505         fi
1506         # In case somebody yacc -d:ed the a2p.y.
1507         if test -f y.tab.h
1508         then
1509             if cmp -s y.tab.h a2p.h
1510             then
1511                 rm -f y.tab.h
1512             else
1513                 echo "a2p.h -> a2p.h" >&2
1514                 mv -f y.tab.h a2p.h
1515                 xxx="$xxx a2p.h"
1516             fi
1517         fi
1518         cd ..
1519     fi
1520     ;;
1521 *)
1522     echo "'$osname' is an EBCDIC system I don't know that well." >&4
1523     ;;
1524 esac
1525     case "$xxx" in
1526     '') echo "No parser files were regenerated.  That's okay." >&2 ;;
1527     esac
1528     ;;
1529 esac
1530
1531 # ex: set ts=8 sts=4 sw=4 noet: