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