This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Unroll the libs scan thanks to HP-UX.
[metaconfig.git] / U / perl / Extensions.U
1 ?RCS: $Id: Extensions.U,v$
2 ?RCS:
3 ?RCS: Copyright (c) 1996-1998, Andy Dougherty
4 ?RCS:
5 ?RCS: You may distribute under the terms of either the GNU General Public
6 ?RCS: License or the Artistic License, as specified in the README file.
7 ?RCS:
8 ?RCS: $Log: Extensions.U,v $
9 ?RCS:
10 ?MAKE:known_extensions extensions dynamic_ext static_ext nonxs_ext \
11         useposix useopcode : \
12         Myread hint usedl d_sem d_socket i_db i_dbm i_rpcsvcdbm i_gdbm \ 
13         i_ndbm usethreads package test cat rsrc d_msg d_shm
14 ?MAKE:  -pick add $@ %<
15 ?Y:BOTTOM
16 ?S:known_extensions:
17 ?S:     This variable holds a list of all XS extensions included in 
18 ?S:     the package.
19 ?S:.
20 ?S:dynamic_ext:
21 ?S:     This variable holds a list of XS extension files we want to
22 ?S:     link dynamically into the package.  It is used by Makefile.
23 ?S:.
24 ?S:static_ext:
25 ?S:     This variable holds a list of XS extension files we want to
26 ?S:     link statically into the package.  It is used by Makefile.
27 ?S:.
28 ?S:nonxs_ext:
29 ?S:     This variable holds a list of all non-xs extensions included
30 ?S:     in the package.  All of them will be built.
31 ?S:.
32 ?S:extensions:
33 ?S:     This variable holds a list of all extension files (both XS and
34 ?S:     non-xs linked into the package.  It is propagated to Config.pm
35 ?S:     and is typically used to test whether a particular extesion 
36 ?S:     is available.
37 ?S:.
38 ?S:useposix:
39 ?S:     This variable holds either 'true' or 'false' to indicate
40 ?S:     whether the POSIX extension should be used.  The sole
41 ?S:     use for this currently is to allow an easy mechanism
42 ?S:     for hints files to indicate that POSIX will not compile
43 ?S:     on a particular system.
44 ?S:.
45 ?S:useopcode:
46 ?S:     This variable holds either 'true' or 'false' to indicate
47 ?S:     whether the Opcode extension should be used.  The sole
48 ?S:     use for this currently is to allow an easy mechanism
49 ?S:     for users to skip the Opcode extension from the Configure
50 ?S:     command line.
51 ?S:.
52 ?T:xxx avail_ext tdir nonxs_extensions find_extensions
53 ?INIT:: set useposix=false in your hint file to disable the POSIX extension.
54 ?INIT:useposix=true
55 ?INIT:: set useopcode=false in your hint file to disable the Opcode extension.
56 ?INIT:useopcode=true
57 echo " "
58 echo "Looking for extensions..." >&4
59 : If we are using the old config.sh, known_extensions may contain
60 : old or inaccurate or duplicate values.
61 known_extensions=''
62 nonxs_extensions=''
63 : We do not use find because it might not be available.
64 : We do not just use MANIFEST because the user may have dropped
65 : some additional extensions into the source tree and expect them
66 : to be built.
67
68 : Function to recursively find available extensions, ignoring DynaLoader
69 : NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
70 find_extensions='
71     for xxx in *; do
72        case "$xxx" in
73            DynaLoader|dynaload) ;;
74            *)
75            if $test -f $xxx/$xxx.xs; then
76                known_extensions="$known_extensions $1$xxx";
77            elif $test -f $xxx/Makefile.PL; then
78                nonxs_extensions="$nonxs_extensions $1$xxx";
79            else
80                if $test -d $xxx -a $# -lt 10; then
81                    set $1$xxx/ $*;
82                    cd $xxx;
83                    eval $find_extensions;
84                    cd ..;
85                    shift;
86                fi;
87            fi
88            ;;
89        esac;
90     done'
91 tdir=`pwd`
92 cd $rsrc/ext
93 set X
94 shift
95 eval $find_extensions
96 set X $nonxs_extensions
97 shift
98 nonxs_extensions="$*"
99 set X $known_extensions
100 shift
101 known_extensions="$*"
102 cd $tdir
103
104 : Now see which are supported on this system.
105 ?X: avail_ext lists available XS extensions.
106 avail_ext=''
107 for xxx in $known_extensions ; do
108         case "$xxx" in
109 ?X: Handle possible DOS 8.3 filename and case alterations
110         DB_File|db_file)
111                 case "$i_db" in
112                 $define) avail_ext="$avail_ext $xxx" ;;
113                 esac
114                 ;;
115         GDBM_File|gdbm_fil)
116                 case "$i_gdbm" in 
117                 $define) avail_ext="$avail_ext $xxx" ;;
118                 esac
119                 ;;
120         NDBM_File|ndbm_fil)
121                 case "$i_ndbm" in
122                 $define)
123                     case "$osname-$use64bits" in
124                     hpux-define)
125                         case "$libs" in
126                         *-lndbm*) avail_ext="$avail_ext $xxx" ;;
127                         esac
128                         ;;
129                     *) avail_ext="$avail_ext $xxx" ;;
130                     esac
131                     ;;
132                 esac
133                 ;;
134         ODBM_File|odbm_fil) 
135                 case "${i_dbm}${i_rpcsvcdbm}" in
136                 *"${define}"*)
137                     case "$osname-$use64bits" in
138                     hpux-define)
139                         case "$libs" in
140                         *-ldbm*) avail_ext="$avail_ext $xxx" ;;
141                         esac
142                         ;;
143                     *) avail_ext="$avail_ext $xxx" ;;
144                     esac
145                     ;;
146                 esac
147                 ;;
148         POSIX|posix)
149                 case "$useposix" in
150                 true|define|y) avail_ext="$avail_ext $xxx" ;;
151                 esac
152                 ;;
153         Opcode|opcode)
154                 case "$useopcode" in
155                 true|define|y) avail_ext="$avail_ext $xxx" ;;
156                 esac
157                 ;;
158         Socket|socket)
159                 case "$d_socket" in 
160                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
161                 esac
162                 ;;
163         Thread|thread)
164                 case "$usethreads" in 
165                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
166                 esac
167                 ;;
168         IPC/SysV|ipc/sysv)
169                 : XXX Do we need a useipcsysv variable here
170                 case "${d_msg}${d_sem}${d_shm}" in 
171                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
172                 esac
173                 ;;
174         *)      avail_ext="$avail_ext $xxx"
175                 ;;
176         esac
177 done
178
179 set X $avail_ext
180 shift
181 avail_ext="$*"
182
183 : Now see which nonxs extensions are supported on this system.
184 : For now assume all are.
185 nonxs_ext=''
186 for xxx in $nonxs_extensions ; do
187         case "$xxx" in
188         *)      nonxs_ext="$nonxs_ext $xxx"
189                 ;;
190         esac
191 done
192
193 set X $nonxs_ext
194 shift
195 nonxs_ext="$*"
196
197 case $usedl in
198 $define)
199         $cat <<EOM
200 A number of extensions are supplied with $package.  You may choose to
201 compile these extensions for dynamic loading (the default), compile
202 them into the $package executable (static loading), or not include
203 them at all.  Answer "none" to include no extensions.
204 Note that DynaLoader is always built and need not be mentioned here.
205
206 EOM
207         case "$dynamic_ext" in
208         '') dflt="$avail_ext" ;;
209         *)      dflt="$dynamic_ext"
210                 # Perhaps we are reusing an old out-of-date config.sh.
211                 case "$hint" in
212                 previous)
213                         if test X"$dynamic_ext" != X"$avail_ext"; then
214                                 $cat <<EOM
215 NOTICE:  Your previous config.sh list may be incorrect. 
216 The extensions now available to you are 
217         ${avail_ext}
218 but the default list from your previous config.sh is
219         ${dynamic_ext} 
220
221 EOM
222                         fi
223                         ;;
224                 esac
225                 ;;
226         esac
227         case "$dflt" in
228         '')     dflt=none;;
229         esac
230         rp="What extensions do you wish to load dynamically?"
231         . ./myread
232         case "$ans" in
233 ?X: Use ' ' so a subsequent Configure will preserve that value.
234         none) dynamic_ext=' ' ;;
235         *) dynamic_ext="$ans" ;;
236         esac
237
238         case "$static_ext" in
239         '')
240                 : Exclude those already listed in dynamic linking
241                 dflt=''
242                 for xxx in $avail_ext; do
243                         case " $dynamic_ext " in
244                         *" $xxx "*) ;;
245                         *) dflt="$dflt $xxx" ;;
246                         esac
247                 done
248                 set X $dflt
249                 shift
250                 dflt="$*"
251                 ;;
252         *)  dflt="$static_ext" 
253                 ;;
254         esac
255
256         case "$dflt" in
257         '')     dflt=none;;
258         esac
259         rp="What extensions do you wish to load statically?"
260         . ./myread
261         case "$ans" in
262 ?X: Use ' ' so a subsequent Configure will preserve that value.
263         none) static_ext=' ' ;;
264         *) static_ext="$ans" ;;
265         esac
266         ;;
267 *)
268         $cat <<EOM
269 A number of extensions are supplied with $package.  Answer "none" 
270 to include no extensions. 
271 Note that DynaLoader is always built and need not be mentioned here.
272
273 EOM
274         case "$static_ext" in
275         '') dflt="$avail_ext" ;;
276         *)      dflt="$static_ext"
277                 # Perhaps we are reusing an old out-of-date config.sh.
278                 case "$hint" in
279                 previous)
280                         if test X"$static_ext" != X"$avail_ext"; then
281                                 $cat <<EOM
282 NOTICE:  Your previous config.sh list may be incorrect. 
283 The extensions now available to you are 
284         ${avail_ext}
285 but the default list from your previous config.sh is
286         ${static_ext} 
287
288 EOM
289                         fi
290                         ;;
291                 esac
292                 ;;
293         esac
294         : Exclude those that are not xs extensions
295         case "$dflt" in
296         '')     dflt=none;;
297         esac
298         rp="What extensions do you wish to include?"
299         . ./myread
300         case "$ans" in
301 ?X: Use ' ' so a subsequent Configure will preserve that value.
302         none) static_ext=' ' ;;
303         *) static_ext="$ans" ;;
304         esac
305         ;;
306 esac
307
308 set X $dynamic_ext $static_ext $nonxs_ext
309 shift
310 extensions="$*"
311