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