This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport Change 29514
[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 ?LINT:extern noextensions
60 ?LINT:extern onlyextensions
61 ?T:keepextensions i
62 echo " "
63 echo "Looking for extensions..." >&4
64 : If we are using the old config.sh, known_extensions may contain
65 : old or inaccurate or duplicate values.
66 known_extensions=''
67 nonxs_extensions=''
68 : We do not use find because it might not be available.
69 : We do not just use MANIFEST because the user may have dropped
70 : some additional extensions into the source tree and expect them
71 : to be built.
72
73 : Function to recursively find available extensions, ignoring DynaLoader
74 : NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
75 find_extensions='
76     for xxx in *; do
77         case "$xxx" in
78             DynaLoader|dynaload) ;;
79             *)
80             if $test -f $xxx/$xxx.xs; then
81                 known_extensions="$known_extensions $1$xxx";
82             elif $test -f $xxx/Makefile.PL; then
83                 nonxs_extensions="$nonxs_extensions $1$xxx";
84             else
85                 if $test -d $xxx -a $# -lt 10; then
86                     set $1$xxx/ $*;
87                     cd "$xxx";
88                     eval $find_extensions;
89                     cd ..;
90                     shift;
91                 fi;
92             fi
93             ;;
94         esac;
95     done'
96 tdir=`pwd`
97 cd "$rsrc/ext"
98 set X
99 shift
100 eval $find_extensions
101 # Special case:  Add in threads/shared since it is not picked up by the
102 # recursive find above (and adding in general recursive finding breaks
103 # SDBM_File/sdbm).  A.D.  10/25/2001.
104 known_extensions="$known_extensions threads/shared"
105 set X $known_extensions
106 shift
107 known_extensions="$*"
108 #  Ditto for IO/Compress/Base and IO/Compress/Zlib
109 nonxs_extensions="$nonxs_extensions IO/Compress/Base IO/Compress/Zlib"
110 set X $nonxs_extensions
111 shift
112 nonxs_extensions="$*"
113 cd "$tdir"
114
115 : Now see which are supported on this system.
116 ?X: avail_ext lists available XS extensions.
117 avail_ext=''
118 for xxx in $known_extensions ; do
119         case "$xxx" in
120 ?X: Handle possible DOS 8.3 filename and case alterations
121         DB_File|db_file)
122                 case "$i_db" in
123                 $define) avail_ext="$avail_ext $xxx" ;;
124                 esac
125                 ;;
126         GDBM_File|gdbm_fil)
127                 case "$i_gdbm" in
128                 $define) avail_ext="$avail_ext $xxx" ;;
129                 esac
130                 ;;
131         I18N/Langinfo|i18n_lan)
132                 case "$i_langinfo$d_nl_langinfo" in
133                 $define$define) avail_ext="$avail_ext $xxx" ;;
134                 esac
135                 ;;
136         NDBM_File|ndbm_fil)
137                 case "$i_ndbm" in
138                 $define)
139                     case "$osname-$use64bitint" in
140                     hpux-define)
141                         case "$libs" in
142                         *-lndbm*) avail_ext="$avail_ext $xxx" ;;
143                         esac
144                         ;;
145                     *) avail_ext="$avail_ext $xxx" ;;
146                     esac
147                     ;;
148                 esac
149                 ;;
150         ODBM_File|odbm_fil)
151                 case "${i_dbm}${i_rpcsvcdbm}" in
152                 *"${define}"*)
153                     case "$osname-$use64bitint" in
154                     hpux-define)
155                         case "$libs" in
156                         *-ldbm*) avail_ext="$avail_ext $xxx" ;;
157                         esac
158                         ;;
159                     *) avail_ext="$avail_ext $xxx" ;;
160                     esac
161                     ;;
162                 esac
163                 ;;
164         POSIX|posix)
165                 case "$useposix" in
166                 true|define|y) avail_ext="$avail_ext $xxx" ;;
167                 esac
168                 ;;
169         Opcode|opcode)
170                 case "$useopcode" in
171                 true|define|y) avail_ext="$avail_ext $xxx" ;;
172                 esac
173                 ;;
174         Socket|socket)
175                 case "$d_socket" in
176                 true|$define|y)
177                     case "$osname" in
178                     beos) ;; # not unless BONE
179                     *) avail_ext="$avail_ext $xxx" ;;
180                     esac
181                     ;;
182                 esac
183                 ;;
184         Sys/Syslog|sys/syslog)
185                 : XXX syslog requires socket
186                 case "$d_socket" in
187                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
188                 esac
189                 ;;
190         Thread|thread)
191                 case "$usethreads" in
192                 true|$define|y)
193                         case "$useithreads" in
194                         $undef|false|[nN]*) avail_ext="$avail_ext $xxx" ;;
195                         esac
196                 esac
197                 ;;
198         Win32)
199                 case "$osname" in
200                 cygwin) avail_ext="$avail_ext $xxx" ;;
201                 esac
202                 ;;
203         XS/APItest|xs/apitest)
204                 # This is just for testing.  Skip it unless we have dynamic loading.
205
206                 case "$usedl" in
207                 $define) avail_ext="$avail_ext $xxx" ;;
208                 esac
209                 ;;
210         XS/Typemap|xs/typemap)
211                 # This is just for testing.  Skip it unless we have dynamic loading.
212                 case "$usedl" in
213                 $define) avail_ext="$avail_ext $xxx" ;;
214                 esac
215                 ;;
216         threads|threads/shared)
217                 # threads and threads::shared are special cases.
218                 # To stop people from asking "Perl 5.8.0 was supposed
219                 # to have this new fancy threads implementation but my
220                 # perl doesn't have it" and from people trying to
221                 # (re)install the threads module using CPAN.pm and
222                 # CPAN.pm then offering to reinstall Perl 5.8.0,
223                 # the threads.pm and threads/shared.pm will always be
224                 # there, croaking informatively ("you need to rebuild
225                 # all of Perl with threads, sorry") when threads haven't
226                 # been compiled in.
227                 # --jhi
228                 avail_ext="$avail_ext $xxx"
229                 ;;
230         IPC/SysV|ipc/sysv)
231                 : XXX Do we need a useipcsysv variable here
232                 case "${d_msg}${d_sem}${d_shm}" in
233                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
234                 esac
235                 ;;
236         *)      avail_ext="$avail_ext $xxx"
237                 ;;
238         esac
239 done
240
241 set X $avail_ext
242 shift
243 avail_ext="$*"
244
245 case "$onlyextensions" in
246 '') ;;
247 *)  keepextensions=''
248     echo "You have requested that only certains extensions be included..." >&4
249     for i in $onlyextensions; do
250         case " $avail_ext " in
251         *" $i "*)
252             echo "Keeping extension $i."
253             keepextensions="$keepextensions $i"
254             ;;
255         *) echo "Ignoring extension $i." ;;
256         esac
257     done
258     avail_ext="$keepextensions"
259     ;;
260 esac
261
262 case "$noextensions" in
263 '') ;;
264 *)  keepextensions=''
265     echo "You have requested that certain extensions be ignored..." >&4
266     for i in $avail_ext; do
267         case " $noextensions " in
268         *" $i "*) echo "Ignoring extension $i." ;;
269         *) echo "Keeping extension $i.";
270            keepextensions="$keepextensions $i"
271            ;;
272         esac
273     done
274     avail_ext="$keepextensions"
275     ;;
276 esac
277
278 : Now see which nonxs extensions are supported on this system.
279 : For now assume all are.
280 nonxs_ext=''
281 for xxx in $nonxs_extensions ; do
282         case "$xxx" in
283         *)      nonxs_ext="$nonxs_ext $xxx"
284                 ;;
285         esac
286 done
287
288 set X $nonxs_ext
289 shift
290 nonxs_ext="$*"
291
292 case $usedl in
293 $define)
294         $cat <<EOM
295 A number of extensions are supplied with $package.  You may choose to
296 compile these extensions for dynamic loading (the default), compile
297 them into the $package executable (static loading), or not include
298 them at all.  Answer "none" to include no extensions.
299 Note that DynaLoader is always built and need not be mentioned here.
300
301 EOM
302         case "$dynamic_ext" in
303         '')
304                 : Exclude those listed in static_ext
305                 dflt=''
306                 for xxx in $avail_ext; do
307                         case " $static_ext " in
308                         *" $xxx "*) ;;
309                         *) dflt="$dflt $xxx" ;;
310                         esac
311                 done
312                 set X $dflt
313                 shift
314                 dflt="$*"
315                 ;;
316         *)      dflt="$dynamic_ext"
317                 # Perhaps we are reusing an old out-of-date config.sh.
318                 case "$hint" in
319                 previous)
320                         if test X"$dynamic_ext" != X"$avail_ext"; then
321                                 $cat <<EOM
322 NOTICE:  Your previous config.sh list may be incorrect.
323 The extensions now available to you are
324         ${avail_ext}
325 but the default list from your previous config.sh is
326         ${dynamic_ext}
327
328 EOM
329                         fi
330                         ;;
331                 esac
332                 ;;
333         esac
334         case "$dflt" in
335         '')     dflt=none;;
336         esac
337         rp="What extensions do you wish to load dynamically?"
338         . ./myread
339         case "$ans" in
340 ?X: Use ' ' so a subsequent Configure will preserve that value.
341         none) dynamic_ext=' ' ;;
342         *) dynamic_ext="$ans" ;;
343         esac
344
345         case "$static_ext" in
346         '')
347                 : Exclude those already listed in dynamic linking
348                 dflt=''
349                 for xxx in $avail_ext; do
350                         case " $dynamic_ext " in
351                         *" $xxx "*) ;;
352                         *) dflt="$dflt $xxx" ;;
353                         esac
354                 done
355                 set X $dflt
356                 shift
357                 dflt="$*"
358                 ;;
359         *)  dflt="$static_ext"
360                 ;;
361         esac
362
363         case "$dflt" in
364         '')     dflt=none;;
365         esac
366         rp="What extensions do you wish to load statically?"
367         . ./myread
368         case "$ans" in
369 ?X: Use ' ' so a subsequent Configure will preserve that value.
370         none) static_ext=' ' ;;
371         *) static_ext="$ans" ;;
372         esac
373         ;;
374 *)
375         $cat <<EOM
376 A number of extensions are supplied with $package.  Answer "none"
377 to include no extensions.
378 Note that DynaLoader is always built and need not be mentioned here.
379
380 EOM
381         case "$static_ext" in
382         '') dflt="$avail_ext" ;;
383         *)      dflt="$static_ext"
384                 # Perhaps we are reusing an old out-of-date config.sh.
385                 case "$hint" in
386                 previous)
387                         if test X"$static_ext" != X"$avail_ext"; then
388                                 $cat <<EOM
389 NOTICE:  Your previous config.sh list may be incorrect.
390 The extensions now available to you are
391         ${avail_ext}
392 but the default list from your previous config.sh is
393         ${static_ext}
394
395 EOM
396                         fi
397                         ;;
398                 esac
399                 ;;
400         esac
401         : Exclude those that are not xs extensions
402         case "$dflt" in
403         '')     dflt=none;;
404         esac
405         rp="What extensions do you wish to include?"
406         . ./myread
407         case "$ans" in
408 ?X: Use ' ' so a subsequent Configure will preserve that value.
409         none) static_ext=' ' ;;
410         *) static_ext="$ans" ;;
411         esac
412         ;;
413 esac
414 #
415 # Encode is a special case.  If we are building Encode as a static
416 # extension, we need to explicitly list its subextensions as well.
417 # For other nested extensions, this is handled automatically by
418 # the appropriate Makefile.PL.
419 case " $static_ext " in
420         *" Encode "*) # Add the subextensions of Encode
421         cd "$rsrc/ext"
422         for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do
423                 static_ext="$static_ext Encode/$xxx"
424         done
425         cd "$tdir"
426         ;;
427 esac
428
429 set X $dynamic_ext $static_ext $nonxs_ext
430 shift
431 extensions="$*"
432
433 # Sanity check:  We require an extension suitable for use with
434 # AnyDBM_File, as well as Fcntl and IO.  (Failure to have these
435 # should show up as failures in the test suite, but it's helpful to
436 # catch them now.) The 'extensions' list is normally sorted
437 # alphabetically, so we need to accept either
438 #    DB_File ... Fcntl ... IO  ....
439 # or something like
440 #    Fcntl ... NDBM_File ... IO  ....
441 case " $extensions"  in
442 *"_File "*" Fcntl "*" IO "*) ;; # DB_File
443 *" Fcntl "*"_File "*" IO "*) ;; # GDBM_File
444 *" Fcntl "*" IO "*"_File "*) ;; # NDBM_File
445 *) echo "WARNING: Extensions DB_File or *DBM_File, Fcntl, and IO not configured." >&4
446    echo "WARNING: The Perl you are building will be quite crippled." >& 4
447    ;;
448 esac
449