This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
/\=/ does not require \ even in older awk
[metaconfig.git] / U / perl / Extensions.U
index 0feaf33..a6052d5 100644 (file)
@@ -8,16 +8,20 @@
 ?RCS: $Log: Extensions.U,v $
 ?RCS:
 ?MAKE:known_extensions extensions dynamic_ext static_ext nonxs_ext \
-       useposix useopcode : \
+       useposix useopcode uselanginfo : \
        Myread hint usedl d_sem d_socket i_db i_dbm i_rpcsvcdbm i_gdbm \
-       i_ndbm usethreads use5005threads package test cat rsrc \
-       d_msg d_shm osname use64bitint i_langinfo d_nl_langinfo \
-       libs
+       d_ndbm package test cat rsrc \
+       d_msg d_shm osname use64bitint \
+       libs d_cplusplus sed ls rm contains trnl sort
 ?MAKE: -pick add $@ %<
 ?Y:BOTTOM
 ?S:known_extensions:
-?S:    This variable holds a list of all XS extensions included in
-?S:    the package.
+?S:    This variable holds a list of all extensions (both XS and non-xs)
+?S:    included in the package source distribution.  This information is
+?S:    only really of use during the Perl build, as the list makes no
+?S:    distinction between extensions which were build and installed, and
+?S:    those which where not.  See "extensions" for the list of extensions
+?S:    actually built and available.
 ?S:.
 ?S:dynamic_ext:
 ?S:    This variable holds a list of XS extension files we want to
 ?S:    link statically into the package.  It is used by Makefile.
 ?S:.
 ?S:nonxs_ext:
-?S:    This variable holds a list of all non-xs extensions included
-?S:    in the package.  All of them will be built.
+?S:    This variable holds a list of all non-xs extensions built and
+?S:    installed by the package.  By default, all non-xs extensions
+?S:    distributed will be built, with the exception of platform-specific
+?S:    extensions (currently only one VMS specific extension).
 ?S:.
 ?S:extensions:
 ?S:    This variable holds a list of all extension files (both XS and
-?S:    non-xs linked into the package.  It is propagated to Config.pm
-?S:    and is typically used to test whether a particular extesion
+?S:    non-xs) installed with the package.  It is propagated to Config.pm
+?S:    and is typically used to test whether a particular extension
 ?S:    is available.
 ?S:.
 ?S:useposix:
 ?S:    for users to skip the Opcode extension from the Configure
 ?S:    command line.
 ?S:.
-?T:xxx avail_ext tdir nonxs_extensions find_extensions
+?S:uselanginfo:
+?S:    This variable holds either 'true' or 'false' to indicate
+?S:    whether the I18N::Langinfo extension should be used.  The sole
+?S:    use for this currently is to allow an easy mechanism for users to skip
+?S:    this extension from the Configure command line.
+?S:.
+?T:xxx avail_ext this_ext tdir xs_extensions nonxs_extensions find_extensions
 ?INIT:: set useposix=false in your hint file to disable the POSIX extension.
 ?INIT:useposix=true
 ?INIT:: set useopcode=false in your hint file to disable the Opcode extension.
 ?INIT:useopcode=true
+?INIT:: set uselanginfo=false in your hint file to disable the I18N::Langinfo extension.
+?INIT:uselanginfo=true
 ?LINT:extern noextensions
 ?LINT:extern onlyextensions
 ?T:keepextensions i
+: Check extensions
 echo " "
 echo "Looking for extensions..." >&4
-: If we are using the old config.sh, known_extensions may contain
-: old or inaccurate or duplicate values.
-known_extensions=''
+: If we are using the old config.sh, nonxs_extensions and xs_extensions may
+: contain old or inaccurate or duplicate values.
 nonxs_extensions=''
+xs_extensions=''
 : We do not use find because it might not be available.
 : We do not just use MANIFEST because the user may have dropped
 : some additional extensions into the source tree and expect them
@@ -72,50 +87,82 @@ nonxs_extensions=''
 
 : Function to recursively find available extensions, ignoring DynaLoader
 : NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
+: In 5.10.1 and later, extensions are stored in directories
+: like File-Glob instead of the older File/Glob/.
 find_extensions='
     for xxx in *; do
        case "$xxx" in
            DynaLoader|dynaload) ;;
            *)
-           if $test -f $xxx/$xxx.xs -o -f $xxx/$xxx.c; then
-               known_extensions="$known_extensions $1$xxx";
-           elif $test -f $xxx/Makefile.PL; then
-               nonxs_extensions="$nonxs_extensions $1$xxx";
-           else
-               if $test -d $xxx -a $# -lt 10; then
-                   set $1$xxx/ $*;
-                   cd "$xxx";
-                   eval $find_extensions;
-                   cd ..;
-                   shift;
-               fi;
-           fi
+           this_ext=`echo "$xxx" | $sed -e s/-/\\\//g`;
+           case "$this_ext" in
+               Scalar/List/Utils) this_ext="List/Util" ;;
+               PathTools)         this_ext="Cwd"       ;;
+           esac;
+           echo " $xs_extensions $nonxs_extensions" > "$tdir/$$.tmp";
+           if $contains " $this_ext " "$tdir/$$.tmp"; then
+               echo >&4;
+               echo "Duplicate directories detected for extension $xxx" >&4;
+               echo "Configure cannot correctly recover from this - shall I abort?" >&4;
+               case "$knowitall" in
+               "") dflt=y;;
+               *) dflt=n;;
+               esac;
+               . ../UU/myread;
+               case "$ans" in
+               n*|N*) ;;
+               *) echo >&4;
+                   echo "Ok.  Stopping Configure." >&4;
+                   echo "Please remove the duplicate directory (e.g. using git clean) and then re-run Configure" >&4;
+                   exit 1;;
+               esac;
+               echo "Ok.  You will need to correct config.sh before running make." >&4;
+           fi;
+           $ls -1 "$xxx" > "$tdir/$$.tmp";
+           if   $contains "\.xs$" "$tdir/$$.tmp" > /dev/null 2>&1; then
+               xs_extensions="$xs_extensions $this_ext";
+           elif $contains "\.c$"  "$tdir/$$.tmp" > /dev/null 2>&1; then
+               xs_extensions="$xs_extensions $this_ext";
+           elif $test -d "$xxx"; then
+               nonxs_extensions="$nonxs_extensions $this_ext";
+           fi;
+           $rm -f "$tdir/$$.tmp";
            ;;
        esac;
     done'
 tdir=`pwd`
+cd "$rsrc/cpan"
+set X
+shift
+eval $find_extensions
+cd "$rsrc/dist"
+set X
+shift
+eval $find_extensions
 cd "$rsrc/ext"
 set X
 shift
 eval $find_extensions
-# Special case:  Add in threads/shared since it is not picked up by the
-# recursive find above (and adding in general recursive finding breaks
-# SDBM_File/sdbm).  A.D.  10/25/2001.
-known_extensions="$known_extensions threads/shared"
-set X $known_extensions
+set X $xs_extensions
 shift
-known_extensions="$*"
+xs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
 set X $nonxs_extensions
 shift
-nonxs_extensions="$*"
+nonxs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
 cd "$tdir"
+known_extensions=`echo $nonxs_extensions $xs_extensions  | tr ' ' $trnl | $sort | tr $trnl ' '`
 
 : Now see which are supported on this system.
 ?X: avail_ext lists available XS extensions.
 avail_ext=''
-for xxx in $known_extensions ; do
+for xxx in $xs_extensions ; do
        case "$xxx" in
 ?X: Handle possible DOS 8.3 filename and case alterations
+       Amiga*)
+               case "$osname" in
+               amigaos) avail_ext="$avail_ext $xxx" ;;
+               esac
+               ;;
        DB_File|db_file)
                case "$i_db" in
                $define) avail_ext="$avail_ext $xxx" ;;
@@ -126,13 +173,14 @@ for xxx in $known_extensions ; do
                $define) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
-       I18N/Langinfo|i18n_lan)
-               case "$i_langinfo$d_nl_langinfo" in
-               $define$define) avail_ext="$avail_ext $xxx" ;;
+       IPC/SysV|ipc/sysv)
+               : XXX Do we need a useipcsysv variable here
+               case "${d_msg}${d_sem}${d_shm}" in
+               *"${define}"*) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
        NDBM_File|ndbm_fil)
-               case "$i_ndbm" in
+               case "$d_ndbm" in
                $define)
                    case "$osname-$use64bitint" in
                    hpux-define)
@@ -148,51 +196,68 @@ for xxx in $known_extensions ; do
        ODBM_File|odbm_fil)
                case "${i_dbm}${i_rpcsvcdbm}" in
                *"${define}"*)
-                   case "$osname-$use64bitint" in
-                   hpux-define)
-                       case "$libs" in
-                       *-ldbm*) avail_ext="$avail_ext $xxx" ;;
+                   case "$d_cplusplus" in
+                   define) ;; # delete as a function name will not work
+                   *)  case "$osname-$use64bitint" in
+                       hpux-define)
+                           case "$libs" in
+                           *-ldbm*) avail_ext="$avail_ext $xxx" ;;
+                           esac
+                           ;;
+                       *) avail_ext="$avail_ext $xxx" ;;
                        esac
                        ;;
-                   *) avail_ext="$avail_ext $xxx" ;;
                    esac
                    ;;
                esac
                ;;
-       POSIX|posix)
-               case "$useposix" in
+       Opcode|opcode)
+               case "$useopcode" in
                true|define|y) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
-       Opcode|opcode)
-               case "$useopcode" in
+       POSIX|posix)
+               case "$useposix" in
                true|define|y) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
        Socket|socket)
                case "$d_socket" in
-               true|$define|y)
-                   case "$osname" in
-                   beos) ;; # not unless BONE
-                   *) avail_ext="$avail_ext $xxx" ;;
-                   esac
-                   ;;
+               true|$define|y) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
-       Sys/Syslog|sys/syslog)
-               : XXX syslog requires socket
-               case "$d_socket" in
-               true|$define|y) avail_ext="$avail_ext $xxx" ;;
+       I18N/Langinfo|langinfo)
+               case "$uselanginfo" in
+               true|define|y) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
-       Thread|thread)
-                case "$usethreads" in
-                true|$define|y)
-                        case "$use5005threads" in
-                        $define|true|[yY]*) avail_ext="$avail_ext $xxx" ;;
-                        esac
+       Sys/Syslog|sys/syslog)
+               case $osname in
+                       amigaos) ;; # not really very useful on AmigaOS
+                       *)
+                       : XXX syslog requires socket
+                       case "$d_socket" in
+                       true|$define|y) avail_ext="$avail_ext $xxx" ;;
+                       esac
+                       ;;
                esac
                ;;
+       threads|threads/shared)
+               # threads and threads::shared are special cases.
+               # To stop people from asking "Perl 5.8.0 was supposed
+               # to have this new fancy threads implementation but my
+               # perl doesn't have it" and from people trying to
+               # (re)install the threads module using CPAN.pm and
+               # CPAN.pm then offering to reinstall Perl 5.8.0,
+               # the threads.pm and threads/shared.pm will always be
+               # there, croaking informatively ("you need to rebuild
+               # all of Perl with threads, sorry") when threads haven't
+               # been compiled in.
+               # --jhi
+               avail_ext="$avail_ext $xxx"
+               ;;
+       VMS*)
+               ;;
        Win32*)
                case "$osname" in
                cygwin) avail_ext="$avail_ext $xxx" ;;
@@ -211,26 +276,6 @@ for xxx in $known_extensions ; do
                $define) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
-       threads|threads/shared)
-               # threads and threads::shared are special cases.
-               # To stop people from asking "Perl 5.8.0 was supposed
-               # to have this new fancy threads implementation but my
-               # perl doesn't have it" and from people trying to
-               # (re)install the threads module using CPAN.pm and
-               # CPAN.pm then offering to reinstall Perl 5.8.0,
-               # the threads.pm and threads/shared.pm will always be
-               # there, croaking informatively ("you need to rebuild
-               # all of Perl with threads, sorry") when threads haven't
-               # been compiled in.
-               # --jhi
-               avail_ext="$avail_ext $xxx"
-               ;;
-       IPC/SysV|ipc/sysv)
-               : XXX Do we need a useipcsysv variable here
-               case "${d_msg}${d_sem}${d_shm}" in
-               *"${define}"*) avail_ext="$avail_ext $xxx" ;;
-               esac
-               ;;
        *)      avail_ext="$avail_ext $xxx"
                ;;
        esac
@@ -243,7 +288,7 @@ avail_ext="$*"
 case "$onlyextensions" in
 '') ;;
 *)  keepextensions=''
-    echo "You have requested that only certains extensions be included..." >&4
+    echo "You have requested that only certain extensions be included..." >&4
     for i in $onlyextensions; do
         case " $avail_ext " in
         *" $i "*)
@@ -278,6 +323,8 @@ esac
 nonxs_ext=''
 for xxx in $nonxs_extensions ; do
        case "$xxx" in
+       VMS*)
+               ;;
        *)      nonxs_ext="$nonxs_ext $xxx"
                ;;
        esac
@@ -416,9 +463,10 @@ esac
 # the appropriate Makefile.PL.
 case " $static_ext " in
        *" Encode "*) # Add the subextensions of Encode
-       cd "$rsrc/ext"
+       cd "$rsrc/cpan"
        for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do
                static_ext="$static_ext Encode/$xxx"
+               known_extensions="$known_extensions Encode/$xxx"
        done
        cd "$tdir"
        ;;
@@ -441,7 +489,7 @@ case " $extensions"  in
 *" Fcntl "*"_File "*" IO "*) ;; # GDBM_File
 *" Fcntl "*" IO "*"_File "*) ;; # NDBM_File
 *) echo "WARNING: Extensions DB_File or *DBM_File, Fcntl, and IO not configured." >&4
-   echo "WARNING: The Perl you are building will be quite crippled." >& 4
+   echo "WARNING: The Perl you are building will be quite crippled." >&4
    ;;
 esac