This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport 83f8bb564961ee8fba35156e720bef403d8fa9a7
[metaconfig.git] / U / perl / Extensions.U
index 8f08312..d1787c2 100644 (file)
@@ -9,13 +9,14 @@
 ?RCS:
 ?MAKE:known_extensions extensions dynamic_ext static_ext nonxs_ext \
        useposix useopcode : \
-       Myread hint usedl d_sem d_socket i_db i_dbm i_rpcsvcdbm i_gdbm \ 
-       i_ndbm usethreads package test cat rsrc d_msg d_shm osname use64bitint \
-       libs
+       Myread hint usedl d_sem d_socket i_db i_dbm i_rpcsvcdbm i_gdbm \
+       d_ndbm usethreads use5005threads package test cat rsrc \
+       d_msg d_shm osname use64bitint i_langinfo d_nl_langinfo \
+       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:    This variable holds a list of all XS extensions included in
 ?S:    the package.
 ?S:.
 ?S:dynamic_ext:
@@ -33,7 +34,7 @@
 ?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:    and is typically used to test whether a particular extesion
 ?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
+?T:xxx avail_ext this_ext leaf tdir 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
+?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
@@ -68,39 +73,73 @@ 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; 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
-           ;;
-       esac;
+       case "$xxx" in
+           DynaLoader|dynaload) ;;
+           *)
+           this_ext=`echo $xxx | $sed -e s/-/\\\//g`;
+           leaf=`echo $xxx | $sed -e s/.*-//`;
+           if $test -d File; then
+               if $test -f $xxx/$leaf.xs -o -f $xxx/$leaf.c; then
+                   known_extensions="$known_extensions $1$this_ext";
+               elif $test -f $xxx/Makefile.PL; then
+                   nonxs_extensions="$nonxs_extensions $1$this_ext";
+               else
+                   if $test -d $xxx -a $# -lt 10; then
+                       set $1$xxx/ $*;
+                       cd "$xxx";
+                       eval $find_extensions;
+                       cd ..;
+                       shift;
+                   fi;
+               fi;
+           else
+               $ls -1 $xxx > $$.tmp;
+               if   $contains "\.xs$" $$.tmp > /dev/null 2>&1; then
+                   known_extensions="$known_extensions $this_ext";
+               elif $contains "\.c$"  $$.tmp > /dev/null 2>&1; then
+                   known_extensions="$known_extensions $this_ext";
+               elif $test -d $xxx; then
+                   nonxs_extensions="$nonxs_extensions $this_ext";
+               fi;
+               $rm -f $$.tmp;
+           fi
+           ;;
+       esac;
     done'
 tdir=`pwd`
-cd $rsrc/ext
+cd "$rsrc/cpan"
 set X
 shift
 eval $find_extensions
-set X $nonxs_extensions
+cd "$rsrc/dist"
+set X
 shift
-nonxs_extensions="$*"
+eval $find_extensions
+cd "$rsrc/ext"
+set X
+shift
+eval $find_extensions
+if $test -d File-Glob; then
+    : All ext/ flattened
+else
+    # Special case:  Add in modules that nest beyond the first level.
+    # Currently threads/shared and Hash/Util/FieldHash, since they are
+    # not picked up by the recursive find above (and adding in general
+    # recursive finding breaks SDBM_File/sdbm).
+    # A.D. 20011025 (SDBM), ajgough 20071008 (FieldHash)
+    known_extensions="$known_extensions threads/shared Hash/Util/FieldHash"
+fi
 set X $known_extensions
 shift
-known_extensions="$*"
-cd $tdir
+known_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
+set X $nonxs_extensions
+shift
+nonxs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
+cd "$tdir"
 
 : Now see which are supported on this system.
 ?X: avail_ext lists available XS extensions.
@@ -114,12 +153,23 @@ for xxx in $known_extensions ; do
                esac
                ;;
        GDBM_File|gdbm_fil)
-               case "$i_gdbm" in 
+               case "$i_gdbm" in
                $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" ;;
+               esac
+               ;;
+       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)
@@ -132,44 +182,90 @@ for xxx in $known_extensions ; do
                    ;;
                esac
                ;;
-       ODBM_File|odbm_fil) 
+       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 
+               case "$d_socket" in
+               true|$define|y)
+                   case "$osname" in
+                   beos) ;; # not unless BONE
+                   *) avail_ext="$avail_ext $xxx" ;;
+                   esac
+                   ;;
+               esac
+               ;;
+       Sys/Syslog|sys/syslog)
+               : XXX syslog requires socket
+               case "$d_socket" in
                true|$define|y) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
        Thread|thread)
-               case "$usethreads" in 
-               true|$define|y) avail_ext="$avail_ext $xxx" ;;
+                case "$usethreads" in
+                true|$define|y)
+                        case "$use5005threads" in
+                        $define|true|[yY]*) avail_ext="$avail_ext $xxx" ;;
+                        esac
                esac
                ;;
-       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" ;;
+       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" ;;
+               esac
+               ;;
+       XS/APItest|xs/apitest)
+               # This is just for testing.  Skip it unless we have dynamic loading.
+
+               case "$usedl" in
+               $define) avail_ext="$avail_ext $xxx" ;;
+               esac
+               ;;
+       XS/Typemap|xs/typemap)
+               # This is just for testing.  Skip it unless we have dynamic loading.
+               case "$usedl" in
+               $define) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
        *)      avail_ext="$avail_ext $xxx"
@@ -181,6 +277,39 @@ set X $avail_ext
 shift
 avail_ext="$*"
 
+case "$onlyextensions" in
+'') ;;
+*)  keepextensions=''
+    echo "You have requested that only certains extensions be included..." >&4
+    for i in $onlyextensions; do
+        case " $avail_ext " in
+        *" $i "*)
+            echo "Keeping extension $i."
+            keepextensions="$keepextensions $i"
+            ;;
+        *) echo "Ignoring extension $i." ;;
+        esac
+    done
+    avail_ext="$keepextensions"
+    ;;
+esac
+
+case "$noextensions" in
+'') ;;
+*)  keepextensions=''
+    echo "You have requested that certain extensions be ignored..." >&4
+    for i in $avail_ext; do
+        case " $noextensions " in
+        *" $i "*) echo "Ignoring extension $i." ;;
+        *) echo "Keeping extension $i.";
+           keepextensions="$keepextensions $i"
+           ;;
+        esac
+    done
+    avail_ext="$keepextensions"
+    ;;
+esac
+
 : Now see which nonxs extensions are supported on this system.
 : For now assume all are.
 nonxs_ext=''
@@ -206,18 +335,30 @@ Note that DynaLoader is always built and need not be mentioned here.
 
 EOM
        case "$dynamic_ext" in
-       '') dflt="$avail_ext" ;;
+       '')
+               : Exclude those listed in static_ext
+               dflt=''
+               for xxx in $avail_ext; do
+                       case " $static_ext " in
+                       *" $xxx "*) ;;
+                       *) dflt="$dflt $xxx" ;;
+                       esac
+               done
+               set X $dflt
+               shift
+               dflt="$*"
+               ;;
        *)      dflt="$dynamic_ext"
                # Perhaps we are reusing an old out-of-date config.sh.
                case "$hint" in
                previous)
                        if test X"$dynamic_ext" != X"$avail_ext"; then
                                $cat <<EOM
-NOTICE:  Your previous config.sh list may be incorrect. 
-The extensions now available to you are 
+NOTICE:  Your previous config.sh list may be incorrect.
+The extensions now available to you are
        ${avail_ext}
 but the default list from your previous config.sh is
-       ${dynamic_ext} 
+       ${dynamic_ext}
 
 EOM
                        fi
@@ -250,7 +391,7 @@ EOM
                shift
                dflt="$*"
                ;;
-       *)  dflt="$static_ext" 
+       *)  dflt="$static_ext"
                ;;
        esac
 
@@ -267,8 +408,8 @@ EOM
        ;;
 *)
        $cat <<EOM
-A number of extensions are supplied with $package.  Answer "none" 
-to include no extensions. 
+A number of extensions are supplied with $package.  Answer "none"
+to include no extensions.
 Note that DynaLoader is always built and need not be mentioned here.
 
 EOM
@@ -280,11 +421,11 @@ EOM
                previous)
                        if test X"$static_ext" != X"$avail_ext"; then
                                $cat <<EOM
-NOTICE:  Your previous config.sh list may be incorrect. 
-The extensions now available to you are 
+NOTICE:  Your previous config.sh list may be incorrect.
+The extensions now available to you are
        ${avail_ext}
 but the default list from your previous config.sh is
-       ${static_ext} 
+       ${static_ext}
 
 EOM
                        fi
@@ -305,8 +446,39 @@ EOM
        esac
        ;;
 esac
+#
+# Encode is a special case.  If we are building Encode as a static
+# extension, we need to explicitly list its subextensions as well.
+# For other nested extensions, this is handled automatically by
+# the appropriate Makefile.PL.
+case " $static_ext " in
+       *" Encode "*) # Add the subextensions of Encode
+       cd "$rsrc/cpan"
+       for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do
+               static_ext="$static_ext Encode/$xxx"
+       done
+       cd "$tdir"
+       ;;
+esac
 
 set X $dynamic_ext $static_ext $nonxs_ext
 shift
 extensions="$*"
 
+# Sanity check:  We require an extension suitable for use with
+# AnyDBM_File, as well as Fcntl and IO.  (Failure to have these
+# should show up as failures in the test suite, but it's helpful to
+# catch them now.) The 'extensions' list is normally sorted
+# alphabetically, so we need to accept either
+#    DB_File ... Fcntl ... IO  ....
+# or something like
+#    Fcntl ... NDBM_File ... IO  ....
+case " $extensions"  in
+*"_File "*" Fcntl "*" IO "*) ;; # DB_File
+*" 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
+   ;;
+esac
+