This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Configure now aborts with a diagnostic if it detects a duplicate extension.
[metaconfig.git] / U / perl / Extensions.U
index 1555b68..d43c0d8 100644 (file)
@@ -10,9 +10,9 @@
 ?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 \
 ?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 useithreads package test cat rsrc \
+       d_ndbm usethreads use5005threads package test cat rsrc \
        d_msg d_shm osname use64bitint i_langinfo d_nl_langinfo \
        d_msg d_shm osname use64bitint i_langinfo d_nl_langinfo \
-       libs
+       libs d_cplusplus sed ls rm contains trnl sort
 ?MAKE: -pick add $@ %<
 ?Y:BOTTOM
 ?S:known_extensions:
 ?MAKE: -pick add $@ %<
 ?Y:BOTTOM
 ?S:known_extensions:
@@ -34,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: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 extension
 ?S:    is available.
 ?S:.
 ?S:useposix:
 ?S:    is available.
 ?S:.
 ?S:useposix:
@@ -51,7 +51,7 @@
 ?S:    for users to skip the Opcode extension from the Configure
 ?S:    command line.
 ?S:.
 ?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:: 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.
@@ -59,6 +59,7 @@
 ?LINT:extern noextensions
 ?LINT:extern onlyextensions
 ?T:keepextensions i
 ?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
 echo " "
 echo "Looking for extensions..." >&4
 : If we are using the old config.sh, known_extensions may contain
@@ -72,44 +73,91 @@ nonxs_extensions=''
 
 : Function to recursively find available extensions, ignoring DynaLoader
 : NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
 
 : 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) ;;
            *)
 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";
+           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
            else
-               if $test -d $xxx -a $# -lt 10; then
-                   set $1$xxx/ $*;
-                   cd "$xxx";
-                   eval $find_extensions;
-                   cd ..;
-                   shift;
+               echo " $known_extensions $nonxs_extensions" > $$.tmp;
+               if $contains " $this_ext " $$.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 (eg 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 > $$.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;
                fi;
+               $rm -f $$.tmp;
            fi
            ;;
        esac;
     done'
 tdir=`pwd`
            fi
            ;;
        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
 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"
+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
 set X $known_extensions
 shift
-known_extensions="$*"
-#  Ditto for IO/Compress/Base and IO/Compress/Zlib
-nonxs_extensions="$nonxs_extensions IO/Compress/Base IO/Compress/Zlib"
+known_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
 set X $nonxs_extensions
 shift
 set X $nonxs_extensions
 shift
-nonxs_extensions="$*"
+nonxs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
 cd "$tdir"
 
 : Now see which are supported on this system.
 cd "$tdir"
 
 : Now see which are supported on this system.
@@ -133,8 +181,14 @@ for xxx in $known_extensions ; do
                $define$define) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
                $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)
        NDBM_File|ndbm_fil)
-               case "$i_ndbm" in
+               case "$d_ndbm" in
                $define)
                    case "$osname-$use64bitint" in
                    hpux-define)
                $define)
                    case "$osname-$use64bitint" in
                    hpux-define)
@@ -150,24 +204,28 @@ for xxx in $known_extensions ; do
        ODBM_File|odbm_fil)
                case "${i_dbm}${i_rpcsvcdbm}" in
                *"${define}"*)
        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
                        ;;
                        esac
                        ;;
-                   *) avail_ext="$avail_ext $xxx" ;;
                    esac
                    ;;
                esac
                ;;
                    esac
                    ;;
                esac
                ;;
-       POSIX|posix)
-               case "$useposix" in
+       Opcode|opcode)
+               case "$useopcode" in
                true|define|y) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
                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
                ;;
                true|define|y) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
@@ -190,12 +248,28 @@ for xxx in $known_extensions ; do
        Thread|thread)
                 case "$usethreads" in
                 true|$define|y)
        Thread|thread)
                 case "$usethreads" in
                 true|$define|y)
-                        case "$useithreads" in
-                        $undef|false|[nN]*) avail_ext="$avail_ext $xxx" ;;
+                        case "$use5005threads" in
+                        $define|true|[yY]*) avail_ext="$avail_ext $xxx" ;;
                         esac
                esac
                ;;
                         esac
                esac
                ;;
-       Win32)
+       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
                case "$osname" in
                cygwin) avail_ext="$avail_ext $xxx" ;;
                esac
@@ -213,26 +287,6 @@ for xxx in $known_extensions ; do
                $define) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
                $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
        *)      avail_ext="$avail_ext $xxx"
                ;;
        esac
@@ -245,7 +299,7 @@ avail_ext="$*"
 case "$onlyextensions" in
 '') ;;
 *)  keepextensions=''
 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 "*)
     for i in $onlyextensions; do
         case " $avail_ext " in
         *" $i "*)
@@ -418,7 +472,7 @@ esac
 # the appropriate Makefile.PL.
 case " $static_ext " in
        *" Encode "*) # Add the subextensions of Encode
 # 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"
        done
        for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do
                static_ext="$static_ext Encode/$xxx"
        done