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