This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
The metaconfig unit change for #11705.
[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 i_langinfo d_nl_langinfo \
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         I18N/Langinfo|i18n_lan)
123                 case "$i_langinfo$d_nl_langinfo" in 
124                 $define$define) avail_ext="$avail_ext $xxx" ;;
125                 esac
126                 ;;
127         NDBM_File|ndbm_fil)
128                 case "$i_ndbm" in
129                 $define)
130                     case "$osname-$use64bitint" in
131                     cygwin-*|hpux-define)
132                         case "$libs" in
133                         *-lndbm*) avail_ext="$avail_ext $xxx" ;;
134                         esac
135                         ;;
136                     *) avail_ext="$avail_ext $xxx" ;;
137                     esac
138                     ;;
139                 esac
140                 ;;
141         ODBM_File|odbm_fil) 
142                 case "${i_dbm}${i_rpcsvcdbm}" in
143                 *"${define}"*)
144                     case "$osname-$use64bitint" in
145                     cygwin-*|hpux-define)
146                         case "$libs" in
147                         *-ldbm*) avail_ext="$avail_ext $xxx" ;;
148                         esac
149                         ;;
150                     *) avail_ext="$avail_ext $xxx" ;;
151                     esac
152                     ;;
153                 esac
154                 ;;
155         POSIX|posix)
156                 case "$useposix" in
157                 true|define|y) avail_ext="$avail_ext $xxx" ;;
158                 esac
159                 ;;
160         Opcode|opcode)
161                 case "$useopcode" in
162                 true|define|y) avail_ext="$avail_ext $xxx" ;;
163                 esac
164                 ;;
165         Socket|socket)
166                 case "$d_socket" in 
167                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
168                 esac
169                 ;;
170         Sys/Syslog|sys/syslog)
171                 : XXX syslog requires socket
172                 case "$d_socket" in 
173                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
174                 esac
175                 ;;
176         Thread|thread)
177                 case "$usethreads" in
178                 true|$define|y)
179                         case "$useithreads" in
180                         $undef|false|[nN]*) avail_ext="$avail_ext $xxx" ;;
181                         esac
182                 esac
183                 ;;
184         threads)
185                 case "$usethreads" in
186                 true|$define|y)
187                         case "$useithreads" in
188                         $define|true|[yY]*) avail_ext="$avail_ext $xxx" ;;
189                         esac
190                 esac
191                 ;;
192         IPC/SysV|ipc/sysv)
193                 : XXX Do we need a useipcsysv variable here
194                 case "${d_msg}${d_sem}${d_shm}" in 
195                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
196                 esac
197                 ;;
198         *)      avail_ext="$avail_ext $xxx"
199                 ;;
200         esac
201 done
202
203 set X $avail_ext
204 shift
205 avail_ext="$*"
206
207 : Now see which nonxs extensions are supported on this system.
208 : For now assume all are.
209 nonxs_ext=''
210 for xxx in $nonxs_extensions ; do
211         case "$xxx" in
212         *)      nonxs_ext="$nonxs_ext $xxx"
213                 ;;
214         esac
215 done
216
217 set X $nonxs_ext
218 shift
219 nonxs_ext="$*"
220
221 case $usedl in
222 $define)
223         $cat <<EOM
224 A number of extensions are supplied with $package.  You may choose to
225 compile these extensions for dynamic loading (the default), compile
226 them into the $package executable (static loading), or not include
227 them at all.  Answer "none" to include no extensions.
228 Note that DynaLoader is always built and need not be mentioned here.
229
230 EOM
231         case "$dynamic_ext" in
232         '') dflt="$avail_ext" ;;
233         *)      dflt="$dynamic_ext"
234                 # Perhaps we are reusing an old out-of-date config.sh.
235                 case "$hint" in
236                 previous)
237                         if test X"$dynamic_ext" != X"$avail_ext"; then
238                                 $cat <<EOM
239 NOTICE:  Your previous config.sh list may be incorrect. 
240 The extensions now available to you are 
241         ${avail_ext}
242 but the default list from your previous config.sh is
243         ${dynamic_ext} 
244
245 EOM
246                         fi
247                         ;;
248                 esac
249                 ;;
250         esac
251         case "$dflt" in
252         '')     dflt=none;;
253         esac
254         rp="What extensions do you wish to load dynamically?"
255         . ./myread
256         case "$ans" in
257 ?X: Use ' ' so a subsequent Configure will preserve that value.
258         none) dynamic_ext=' ' ;;
259         *) dynamic_ext="$ans" ;;
260         esac
261
262         case "$static_ext" in
263         '')
264                 : Exclude those already listed in dynamic linking
265                 dflt=''
266                 for xxx in $avail_ext; do
267                         case " $dynamic_ext " in
268                         *" $xxx "*) ;;
269                         *) dflt="$dflt $xxx" ;;
270                         esac
271                 done
272                 set X $dflt
273                 shift
274                 dflt="$*"
275                 ;;
276         *)  dflt="$static_ext" 
277                 ;;
278         esac
279
280         case "$dflt" in
281         '')     dflt=none;;
282         esac
283         rp="What extensions do you wish to load statically?"
284         . ./myread
285         case "$ans" in
286 ?X: Use ' ' so a subsequent Configure will preserve that value.
287         none) static_ext=' ' ;;
288         *) static_ext="$ans" ;;
289         esac
290         ;;
291 *)
292         $cat <<EOM
293 A number of extensions are supplied with $package.  Answer "none" 
294 to include no extensions. 
295 Note that DynaLoader is always built and need not be mentioned here.
296
297 EOM
298         case "$static_ext" in
299         '') dflt="$avail_ext" ;;
300         *)      dflt="$static_ext"
301                 # Perhaps we are reusing an old out-of-date config.sh.
302                 case "$hint" in
303                 previous)
304                         if test X"$static_ext" != X"$avail_ext"; then
305                                 $cat <<EOM
306 NOTICE:  Your previous config.sh list may be incorrect. 
307 The extensions now available to you are 
308         ${avail_ext}
309 but the default list from your previous config.sh is
310         ${static_ext} 
311
312 EOM
313                         fi
314                         ;;
315                 esac
316                 ;;
317         esac
318         : Exclude those that are not xs extensions
319         case "$dflt" in
320         '')     dflt=none;;
321         esac
322         rp="What extensions do you wish to include?"
323         . ./myread
324         case "$ans" in
325 ?X: Use ' ' so a subsequent Configure will preserve that value.
326         none) static_ext=' ' ;;
327         *) static_ext="$ans" ;;
328         esac
329         ;;
330 esac
331
332 set X $dynamic_ext $static_ext $nonxs_ext
333 shift
334 extensions="$*"
335