This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Extract some duplicate code into a closure.
[perl5.git] / Makefile.SH
index 7c8b545..bd27892 100755 (executable)
@@ -1,3 +1,14 @@
+#!/bin/sh
+
+# quote() - Creates a shell literal
+# Usage:  echo "...$( quote "..." )..."
+quote() {
+       case "$1" in
+       '') echo "''" ;;
+       *)  echo "$1" | sed 's/\([^a-zA-Z0-9.:_\-\/]\)/\\\1/g' ;;
+       esac
+}
+
 case $PERL_CONFIG_SH in
 '')
        if test -f config.sh
@@ -37,10 +48,8 @@ true)
        # Prefix all runs of 'miniperl' and 'perl' with
        # $ldlibpth so that ./perl finds *this* shared libperl.
        case "$LD_LIBRARY_PATH" in
-       '')
-               ldlibpth="LD_LIBRARY_PATH=`pwd`";;
-       *)
-               ldlibpth="LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}";;
+       '')  ldlibpth="LD_LIBRARY_PATH=$( quote "`pwd`" )" ;;
+       *)   ldlibpth="LD_LIBRARY_PATH=$( quote "`pwd`" ):$( quote "$LD_LIBRARY_PATH" )" ;;
        esac
 
        pldlflags="$cccdlflags"
@@ -119,19 +128,19 @@ true)
                ldlibpth=''
                ;;
            *)
-               eval "ldlibpth=\"$ldlibpthname=`pwd`:\$$ldlibpthname\""
+               eval "ldlibpthval=\"\$$ldlibpthname\""
+
+               case "$ldlibpthval" in
+               '')  ldlibpth="$ldlibpthname=$( quote "`pwd`" )" ;;
+               *)   ldlibpth="$ldlibpthname=$( quote "`pwd`" ):$( quote "$ldlibpthval" )" ;;
+               esac
+
                ;;
            esac
-           # Strip off any trailing :'s
-           ldlibpth=`echo $ldlibpth | sed 's/:*$//'`
+
            ;;
         esac
 
-       case "$ldlibpth" in
-       # Protect any spaces
-       *" "*) ldlibpth=`echo $ldlibpth|sed 's/ /\\\\ /g'` ;;
-       esac
-
        case "$osname" in
        linux)
            # If there is a pre-existing $libperl from a previous
@@ -177,7 +186,9 @@ done
 : Prepare dependency lists for Makefile.
 dynamic_list=' '
 dynamic_ext_re="lib/auto/re/re.$dlext"
-extra_dep=''
+extra_dep='
+ext/Pod-Functions/pm_to_blib: cpan/Pod-Simple/pm_to_blib cpan/Pod-Escapes/pm_to_blib pod/perlfunc.pod
+'
 for f in $dynamic_ext; do
     : the dependency named here will never exist
       base=`echo "$f" | sed 's/.*\///'`
@@ -331,11 +342,21 @@ $make_set_make
 
 # Mention $gmake here so it gets probed for by Configure.
 
+!GROK!THIS!
+
+case "${osname}" in
+linux*|darwin)
+$spitshell >>$Makefile <<!GROK!THIS!
 # If you're going to use valgrind and it can't be invoked as plain valgrind
 # then you'll need to change this, or override it on the make command line.
 VALGRIND ?= valgrind
 VG_TEST  ?= ./perl -e 1 2>/dev/null
 
+!GROK!THIS!
+       ;;
+esac
+
+$spitshell >>$Makefile <<!GROK!THIS!
 DTRACE = $dtrace
 DTRACE_H = $dtrace_h
 DTRACE_O = $dtrace_o
@@ -437,6 +458,7 @@ addedbyconf = UU $(shextract) pstruct
 # Unicode data files generated by mktables
 unidatafiles = lib/unicore/Decomposition.pl lib/unicore/TestProp.pl \
        lib/unicore/CombiningClass.pl lib/unicore/Name.pl \
+       lib/unicore/UCD.pl lib/unicore/Name.pm \
        lib/unicore/Heavy.pl lib/unicore/mktables.lst
 
 # Directories of Unicode data files generated by mktables
@@ -447,7 +469,8 @@ h2 = embed.h form.h gv.h handy.h hv.h keywords.h mg.h op.h opcode.h
 h3 = pad.h patchlevel.h perl.h perlapi.h perly.h pp.h proto.h regcomp.h
 h4 = regexp.h scope.h sv.h unixish.h util.h iperlsys.h thread.h
 h5 = utf8.h warnings.h mydtrace.h op_reg_common.h l1_char_class_tab.h
-h = $(h1) $(h2) $(h3) $(h4) $(h5)
+h6 = charclass_invlists.h
+h = $(h1) $(h2) $(h3) $(h4) $(h5) $(h6)
 
 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
 c2 = perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c utf8.c sv.c
@@ -468,7 +491,7 @@ mini_obj = $(minindt_obj) $(MINIDTRACE_O)
 ndt_obj = $(obj0) $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
 obj = $(ndt_obj) $(DTRACE_O)
 
-perltoc_pod_prereqs = extra.pods pod/perl5153delta.pod pod/perlapi.pod pod/perlintern.pod pod/perlmodlib.pod pod/perluniprops.pod
+perltoc_pod_prereqs = extra.pods pod/perl5178delta.pod pod/perlapi.pod pod/perlintern.pod pod/perlmodlib.pod pod/perluniprops.pod
 generated_pods = pod/perltoc.pod $(perltoc_pod_prereqs)
 generated_headers = uudmap.h bitcount.h mg_data.h
 
@@ -712,8 +735,8 @@ PERLEXPORT          = perl.exp
        ;;
        esac
        $spitshell >>$Makefile <<'!NO!SUBS!'
-perl.exp: $(MINIPERLEXP) makedef.pl config.sh $(SYM) $(SYMH)
-       ./$(MINIPERLEXP) makedef.pl PLATFORM=aix CC_FLAGS="$(OPTIMIZE)" | sort -u | sort -f > perl.exp
+perl.exp: $(MINIPERLEXP) makedef.pl $(CONFIGPM) $(SYM) $(SYMH)
+       ./$(MINIPERLEXP) makedef.pl --sort-fold PLATFORM=aix CC_FLAGS="$(OPTIMIZE)" > perl.exp
 
 !NO!SUBS!
        ;;
@@ -721,7 +744,7 @@ os2)
        $spitshell >>$Makefile <<'!NO!SUBS!'
 MINIPERLEXP            = miniperl
 
-perl5.def: $(MINIPERLEXP) makedef.pl config.sh $(SYM) $(SYMH) miniperl.map
+perl5.def: $(MINIPERLEXP) makedef.pl $(CONFIGPM) $(SYM) $(SYMH) miniperl.map
        ./$(MINIPERLEXP) makedef.pl PLATFORM=os2 -DPERL_DLL=$(PERL_DLL) CC_FLAGS="$(OPTIMIZE)" > perl5.def
 
 !NO!SUBS!
@@ -816,7 +839,7 @@ $(LIBPERL): $& $(obj) $(DYNALOADER) $(LIBPERLEXPORT)
 !NO!SUBS!
 
        case "${osname}${osvers}" in
-       aix*|beos*)
+       aix*)
                $spitshell >>$Makefile <<'!NO!SUBS!'
 $(MINIPERL_EXE): $& $(mini_obj)
        $(CC) -o $(MINIPERL_EXE) $(CLDFLAGS) $(mini_obj) $(libs)
@@ -879,7 +902,12 @@ purecov$(PERL_EXE): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs $(PE
 quant$(PERL_EXE): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs $(PERLEXPORT)
        $(SHRPENV) $(LDLIBPTH) quantify $(CC) -o quantperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
 
-# Valgrind perl (currently Linux only)
+!NO!SUBS!
+
+case "${osname}${osvers}" in
+linux*|darwin*)
+       $spitshell >>$Makefile <<'!NO!SUBS!'
+# Valgrind perl (currently Linux, Darwin only)
 
 perl.valgrind.config: config.sh
        @echo "To build perl.valgrind you must Configure -Doptimize=-g -Uusemymalloc, checking..."
@@ -889,6 +917,11 @@ perl.valgrind.config: config.sh
        @grep "^usemymalloc='n'" config.sh >/dev/null || exit 1
        @echo "And of course you have to have valgrind..."
        $(VALGRIND) $(VG_TEST) || exit 1
+!NO!SUBS!
+       ;;
+esac   
+
+$spitshell >>$Makefile <<'!NO!SUBS!'
 
 # Third Degree Perl (Tru64 only)
 
@@ -1024,7 +1057,7 @@ uni.data: $(MINIPERL_EXE) $(CONFIGPM) lib/unicore/mktables $(nonxs_ext)
 # But also this ensures that all extensions are built before we try to scan
 # them, which picks up Devel::PPPort's documentation.
 pod/perltoc.pod: $(perltoc_pod_prereqs)  $(PERL_EXE) $(ext) pod/buildtoc
-       $(RUN_PERL) -f -Ilib pod/buildtoc --build-toc -q
+       $(RUN_PERL) -f -Ilib pod/buildtoc -q
 
 pod/perlapi.pod: pod/perlintern.pod
 
@@ -1034,8 +1067,9 @@ pod/perlintern.pod: $(MINIPERL_EXE) autodoc.pl embed.fnc
 pod/perlmodlib.pod: $(MINIPERL_EXE) pod/perlmodlib.PL MANIFEST
        $(MINIPERL) $(Icwd) pod/perlmodlib.PL -q
 
-pod/perl5153delta.pod: pod/perldelta.pod
-       $(LNS) perldelta.pod pod/perl5153delta.pod
+pod/perl5178delta.pod: pod/perldelta.pod
+       $(RMS) pod/perl5178delta.pod
+       $(LNS) perldelta.pod pod/perl5178delta.pod
 
 extra.pods: $(MINIPERL_EXE)
        -@test ! -f extra.pods || rm -f `cat extra.pods`
@@ -1058,19 +1092,19 @@ extras.install: $(PERL_EXE)
 .PHONY: install install-strip install-all install-verbose install-silent \
        no-install install.perl install.man install.html
 
-install-strip:
+install_strip install-strip:
        $(MAKE) STRIPFLAGS=-s install DESTDIR="$(DESTDIR)"
 
-install install-all:
+install install_all install-all:
        $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) DESTDIR="$(DESTDIR)"
 
-install-verbose:
+install_verbose install-verbose:
        $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-V DESTDIR="$(DESTDIR)"
 
-install-silent:
+install_silent install-silent:
        $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-S DESTDIR="$(DESTDIR)"
 
-no-install:
+no_install no-install:
        $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-n DESTDIR="$(DESTDIR)"
 
 # Set this to an empty string to avoid an attempt of rebuild before install
@@ -1093,7 +1127,6 @@ install.html: all installhtml
       --htmlroot=$(privlib)/html  \
       --splithead=pod/perlipc     \
       --splititem=pod/perlfunc    \
-      --libpods=perlfunc:perlguts:perlvar:perlrun:perlop \
       --ignore=Porting/Maintainers.pm,Porting/pumpkin.pod,Porting/repository.pod \
       --verbose
 
@@ -1105,11 +1138,11 @@ install.html: all installhtml
 
 .PHONY: regen_perly
 
-run_byacc:
+run_byacc run-byacc:
        @echo "run_byacc is obsolete; try 'make regen_perly' instead"
 
 # this outputs perly.h, perly.act and perly.tab
-regen_perly:
+regen_perly regen-perly:
        perl regen_perly.pl
 
 # We don't want to regenerate perly.c and perly.h, but they might
@@ -1132,6 +1165,7 @@ CHMOD_W = chmod +w
 #      opcode.pl:      opcode.h opnames.h pp_proto.h
 #      regcomp.pl:     regnodes.h
 #      warnings.pl:    warnings.h lib/warnings.pm
+#      feature.pl:     feature.h lib/feature.pm
 # The correct versions should be already supplied with the perl kit,
 # in case you don't have perl available.
 # To force them to be regenerated, run
@@ -1140,7 +1174,8 @@ CHMOD_W = chmod +w
 # (make regen_headers is kept for backwards compatibility)
 
 AUTOGEN_FILES = opcode.h opnames.h pp_proto.h proto.h embed.h embedvar.h \
-               perlapi.h perlapi.c regnodes.h warnings.h lib/warnings.pm
+               perlapi.h perlapi.c regnodes.h warnings.h lib/warnings.pm \
+               lib/feature.pm feature.h
 
 .PHONY: regen_headers regen_all
 
@@ -1148,17 +1183,17 @@ regen:  FORCE
        -perl regen.pl
        -perl regen/uconfig_h.pl
 
-regen_headers: FORCE
+regen_headers regen-headers:   FORCE
        -perl regen.pl -v
        -perl regen/uconfig_h.pl -v
 
-regen_meta:  META.yml
+regen_meta regen-meta:  META.yml
 
 META.yml:   FORCE
        PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib Porting/makemeta
 
 
-regen_all: regen regen_meta
+regen_all regen-all: regen regen_meta
 
 .PHONY:        manisort manicheck
 
@@ -1230,7 +1265,7 @@ _mopup:
        -rmdir .depending
        -@test -f extra.pods && rm -f `cat extra.pods`
        -@test -f vms/README_vms.pod && rm -f vms/README_vms.pod
-       -rm -f perl.exp ext.libs $(generated_pods) uni.data opmini.o perlmini.o
+       -rm -f perl.exp ext.libs $(generated_pods) uni.data opmini.o perlmini.o pod/roffitall
        -rm -f perl.export perl.dll perl.libexp perl.map perl.def
        -rm -f perl.loadmap miniperl.loadmap perl.prelmap miniperl.prelmap
        -rm -f perl.third lib*.so.perl.third perl.3log t/perl.third t/perl.3log
@@ -1294,6 +1329,8 @@ _cleaner2:
        rm -fr lib/B
        rm -fr lib/CPAN lib/CPANPLUS
        rm -fr lib/ExtUtils/CBuilder
+       rm -f pod2htmd.tmp
+       rm -rf pod/perlfunc pod/perlipc
        -rmdir cpan/CPANPLUS-Dist-Build/t/dummy-cpanplus cpan/CPANPLUS/t/dummy-cpanplus cpan/CPANPLUS/t/dummy-localmirror
        -rmdir ext/B/lib
        -rmdir lib/Archive/Tar lib/Archive lib/Attribute
@@ -1384,7 +1421,7 @@ _test:
 
 test_prep_pre: preplibrary utilities $(nonxs_ext)
 
-test_prep: test_prep_pre $(MINIPERL_EXE) $(unidatafiles) $(PERL_EXE) \
+test_prep test-prep: test_prep_pre $(MINIPERL_EXE) $(unidatafiles) $(PERL_EXE) \
        $(dynamic_ext) $(TEST_PERL_DLL) runtests x2p/s2p x2p/find2perl \
        $(generated_pods)
        cd t && (rm -f $(PERL_EXE); $(LNS) ../$(PERL_EXE) $(PERL_EXE))
@@ -1396,10 +1433,10 @@ test_prep_reonly: $(MINIPERL_EXE) $(PERL_EXE) $(dynamic_ext_re) $(TEST_PERL_DLL)
 test check: test_prep
        $(RUN_TESTS) choose
 
-test_tty: test_prep
+test_tty test-tty: test_prep
        $(RUN_TESTS) tty
 
-test_notty: test_prep
+test_notty test-notty: test_prep
        $(RUN_TESTS) no-tty
 
 utest ucheck test.utf8 check.utf8: test_prep
@@ -1408,12 +1445,6 @@ utest ucheck test.utf8 check.utf8: test_prep
 coretest: test_prep
        TEST_ARGS=-core $(RUN_TESTS) choose
 
-test-prep:     test_prep
-
-test-tty:      test_tty
-
-test-notty:    test_notty
-
 # Torture testing
 
 test.torture torturetest:      test_prep
@@ -1423,7 +1454,7 @@ test.torture torturetest: test_prep
 
 minitest.utf16: minitest.prep
        - cd t && (rm -f $(PERL_EXE); $(LNS) ../$(MINIPERL_EXE) $(PERL_EXE)) \
-               && $(RUN_PERL) TEST -utf16 base/*.t comp/*.t cmd/*.t run/*.t io/*.t op/*.t uni/*.t </dev/tty
+               && $(RUN_PERL) TEST -utf16 base/*.t comp/*.t cmd/*.t run/*.t io/*.t opbasic/*.t op/*.t uni/*.t </dev/tty
 
 test.utf16 check.utf16: test_prep
        TEST_ARGS=-utf16 $(RUN_TESTS) choose
@@ -1431,6 +1462,11 @@ test.utf16 check.utf16: test_prep
 utest.utf16 ucheck.utf16: test_prep
        TEST_ARGS="-utf8 -utf16" $(RUN_TESTS) choose
 
+!NO!SUBS!
+
+case "${osname}${osvers}" in
+linux*|darwin*)
+       $spitshell >>$Makefile <<'!NO!SUBS!'
 # Targets for valgrind testing:
 
 test_prep.valgrind: test_prep perl.valgrind
@@ -1443,6 +1479,11 @@ utest.valgrind ucheck.valgrind: test_prep.valgrind perl.valgrind.config
 
 test_notty.valgrind: test_prep.valgrind perl.valgrind.config
        PERL_VALGRIND=1 $(RUN_TESTS) no-tty
+!NO!SUBS!
+       ;;
+esac
+
+$spitshell >>$Makefile <<'!NO!SUBS!'
 
 # Targets for Third Degree testing.
 
@@ -1482,23 +1523,23 @@ minitest.prep:
 # is crashing.
 minitest: $(MINIPERL_EXE) minitest.prep
        - cd t && (rm -f $(PERL_EXE); $(LNS) ../$(MINIPERL_EXE) $(PERL_EXE)) \
-               && $(RUN_PERL) TEST base/*.t comp/*.t cmd/*.t run/*.t io/*.t re/*.t op/*.t uni/*.t </dev/tty
+               && $(RUN_PERL) TEST base/*.t comp/*.t cmd/*.t run/*.t io/*.t re/*.t opbasic/*.t op/*.t uni/*.t </dev/tty
 
 # Test via harness
 
-test_harness: test_prep
+test_harness test-harness: test_prep
        TESTFILE=harness $(RUN_TESTS) choose
 
 test_harness_notty: test_prep
        HARNESS_NOTTY=1 TESTFILE=harness $(RUN_TESTS) choose
 
-test-reonly: test_prep_reonly
+test_reonly test-reonly: test_prep_reonly
        TEST_ARGS='-re \bre\/' TESTFILE=harness $(RUN_TESTS) choose
 
 
 # Porting tests (well-formedness of pod, manifest, etc)
 
-test_porting: test_prep
+test_porting test-porting: test_prep
        cd t && $(RUN_PERL) harness porting/*.t ../lib/diagnostics.t
 
 # Handy way to run perlbug -ok without having to install and run the
@@ -1615,9 +1656,6 @@ os390|posix-bc)
         cd ..
     fi
     ;;
-vmesa)
-    # Do nothing in VM/ESA.
-    ;;
 *)
     echo "'$osname' is an EBCDIC system I don't know that well." >&4
     ;;