This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Metaconfig unit change for #11207.
[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         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         IPC/SysV|ipc/sysv)
185                 : XXX Do we need a useipcsysv variable here
186                 case "${d_msg}${d_sem}${d_shm}" in 
187                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
188                 esac
189                 ;;
190         *)      avail_ext="$avail_ext $xxx"
191                 ;;
192         esac
193 done
194
195 set X $avail_ext
196 shift
197 avail_ext="$*"
198
199 : Now see which nonxs extensions are supported on this system.
200 : For now assume all are.
201 nonxs_ext=''
202 for xxx in $nonxs_extensions ; do
203         case "$xxx" in
204         *)      nonxs_ext="$nonxs_ext $xxx"
205                 ;;
206         esac
207 done
208
209 set X $nonxs_ext
210 shift
211 nonxs_ext="$*"
212
213 case $usedl in
214 $define)
215         $cat <<EOM
216 A number of extensions are supplied with $package.  You may choose to
217 compile these extensions for dynamic loading (the default), compile
218 them into the $package executable (static loading), or not include
219 them at all.  Answer "none" to include no extensions.
220 Note that DynaLoader is always built and need not be mentioned here.
221
222 EOM
223         case "$dynamic_ext" in
224         '') dflt="$avail_ext" ;;
225         *)      dflt="$dynamic_ext"
226                 # Perhaps we are reusing an old out-of-date config.sh.
227                 case "$hint" in
228                 previous)
229                         if test X"$dynamic_ext" != X"$avail_ext"; then
230                                 $cat <<EOM
231 NOTICE:  Your previous config.sh list may be incorrect. 
232 The extensions now available to you are 
233         ${avail_ext}
234 but the default list from your previous config.sh is
235         ${dynamic_ext} 
236
237 EOM
238                         fi
239                         ;;
240                 esac
241                 ;;
242         esac
243         case "$dflt" in
244         '')     dflt=none;;
245         esac
246         rp="What extensions do you wish to load dynamically?"
247         . ./myread
248         case "$ans" in
249 ?X: Use ' ' so a subsequent Configure will preserve that value.
250         none) dynamic_ext=' ' ;;
251         *) dynamic_ext="$ans" ;;
252         esac
253
254         case "$static_ext" in
255         '')
256                 : Exclude those already listed in dynamic linking
257                 dflt=''
258                 for xxx in $avail_ext; do
259                         case " $dynamic_ext " in
260                         *" $xxx "*) ;;
261                         *) dflt="$dflt $xxx" ;;
262                         esac
263                 done
264                 set X $dflt
265                 shift
266                 dflt="$*"
267                 ;;
268         *)  dflt="$static_ext" 
269                 ;;
270         esac
271
272         case "$dflt" in
273         '')     dflt=none;;
274         esac
275         rp="What extensions do you wish to load statically?"
276         . ./myread
277         case "$ans" in
278 ?X: Use ' ' so a subsequent Configure will preserve that value.
279         none) static_ext=' ' ;;
280         *) static_ext="$ans" ;;
281         esac
282         ;;
283 *)
284         $cat <<EOM
285 A number of extensions are supplied with $package.  Answer "none" 
286 to include no extensions. 
287 Note that DynaLoader is always built and need not be mentioned here.
288
289 EOM
290         case "$static_ext" in
291         '') dflt="$avail_ext" ;;
292         *)      dflt="$static_ext"
293                 # Perhaps we are reusing an old out-of-date config.sh.
294                 case "$hint" in
295                 previous)
296                         if test X"$static_ext" != X"$avail_ext"; then
297                                 $cat <<EOM
298 NOTICE:  Your previous config.sh list may be incorrect. 
299 The extensions now available to you are 
300         ${avail_ext}
301 but the default list from your previous config.sh is
302         ${static_ext} 
303
304 EOM
305                         fi
306                         ;;
307                 esac
308                 ;;
309         esac
310         : Exclude those that are not xs extensions
311         case "$dflt" in
312         '')     dflt=none;;
313         esac
314         rp="What extensions do you wish to include?"
315         . ./myread
316         case "$ans" in
317 ?X: Use ' ' so a subsequent Configure will preserve that value.
318         none) static_ext=' ' ;;
319         *) static_ext="$ans" ;;
320         esac
321         ;;
322 esac
323
324 set X $dynamic_ext $static_ext $nonxs_ext
325 shift
326 extensions="$*"
327