This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Configure now aborts with a diagnostic if it detects a duplicate extension.
[metaconfig.git] / U / perl / Extensions.U
CommitLineData
959f3c4c
JH
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 : \
3c64a580 12 Myread hint usedl d_sem d_socket i_db i_dbm i_rpcsvcdbm i_gdbm \
4b46a0b2 13 d_ndbm usethreads use5005threads package test cat rsrc \
d0abe53c 14 d_msg d_shm osname use64bitint i_langinfo d_nl_langinfo \
aa1bc9e8 15 libs d_cplusplus sed ls rm contains trnl sort
959f3c4c
JH
16?MAKE: -pick add $@ %<
17?Y:BOTTOM
18?S:known_extensions:
3c64a580 19?S: This variable holds a list of all XS extensions included in
959f3c4c
JH
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
4dd7201d 37?S: and is typically used to test whether a particular extension
959f3c4c
JH
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:.
cac33f20 54?T:xxx avail_ext this_ext leaf tdir nonxs_extensions find_extensions
959f3c4c
JH
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
3ae30915
JH
59?LINT:extern noextensions
60?LINT:extern onlyextensions
946dea48 61?T:keepextensions i
d7a2632b 62: Check extensions
959f3c4c
JH
63echo " "
64echo "Looking for extensions..." >&4
65: If we are using the old config.sh, known_extensions may contain
66: old or inaccurate or duplicate values.
67known_extensions=''
68nonxs_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
8747f5ce 76: In 5.10.1 and later, extensions are stored in directories
407204de 77: like File-Glob instead of the older File/Glob/.
959f3c4c
JH
78find_extensions='
79 for xxx in *; do
ba5f32a3
MB
80 case "$xxx" in
81 DynaLoader|dynaload) ;;
82 *)
cac33f20
MB
83 this_ext=`echo $xxx | $sed -e s/-/\\\//g`;
84 leaf=`echo $xxx | $sed -e s/.*-//`;
473e3a1b 85 if $test -d File; then
cac33f20
MB
86 if $test -f $xxx/$leaf.xs -o -f $xxx/$leaf.c; then
87 known_extensions="$known_extensions $1$this_ext";
88 elif $test -f $xxx/Makefile.PL; then
89 nonxs_extensions="$nonxs_extensions $1$this_ext";
90 else
91 if $test -d $xxx -a $# -lt 10; then
92 set $1$xxx/ $*;
93 cd "$xxx";
94 eval $find_extensions;
95 cd ..;
96 shift;
97 fi;
ba5f32a3 98 fi;
473e3a1b 99 else
6edba00b
MB
100 echo " $known_extensions $nonxs_extensions" > $$.tmp;
101 if $contains " $this_ext " $$.tmp; then
102 echo >&4;
103 echo "Duplicate directories detected for extension $xxx" >&4;
104 echo "Configure cannot correctly recover from this - shall I abort?" >&4;
105 case "$knowitall" in
106 "") dflt=y;;
107 *) dflt=n;;
108 esac;
109 . ../UU/myread;
110 case "$ans" in
111 n*|N*) ;;
112 *) echo >&4;
113 echo "Ok. Stopping Configure." >&4;
114 echo "Please remove the duplicate directory (eg using git clean) and then re-run Configure" >&4;
115 exit 1;;
116 esac;
117 echo "Ok. You will need to correct config.sh before running make." >&4;
118 fi;
473e3a1b
MB
119 $ls -1 $xxx > $$.tmp;
120 if $contains "\.xs$" $$.tmp > /dev/null 2>&1; then
121 known_extensions="$known_extensions $this_ext";
122 elif $contains "\.c$" $$.tmp > /dev/null 2>&1; then
123 known_extensions="$known_extensions $this_ext";
473e3a1b
MB
124 elif $test -d $xxx; then
125 nonxs_extensions="$nonxs_extensions $this_ext";
126 fi;
127 $rm -f $$.tmp;
ba5f32a3
MB
128 fi
129 ;;
130 esac;
959f3c4c
JH
131 done'
132tdir=`pwd`
473e3a1b
MB
133cd "$rsrc/cpan"
134set X
135shift
136eval $find_extensions
2e336f39
MB
137cd "$rsrc/dist"
138set X
139shift
140eval $find_extensions
3720fc47 141cd "$rsrc/ext"
86a2f2c4 142set X
959f3c4c
JH
143shift
144eval $find_extensions
cac33f20
MB
145if $test -d File-Glob; then
146 : All ext/ flattened
147else
148 # Special case: Add in modules that nest beyond the first level.
149 # Currently threads/shared and Hash/Util/FieldHash, since they are
150 # not picked up by the recursive find above (and adding in general
151 # recursive finding breaks SDBM_File/sdbm).
152 # A.D. 20011025 (SDBM), ajgough 20071008 (FieldHash)
153 known_extensions="$known_extensions threads/shared Hash/Util/FieldHash"
154fi
959f3c4c
JH
155set X $known_extensions
156shift
aa1bc9e8 157known_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
4823dbc4
MB
158set X $nonxs_extensions
159shift
aa1bc9e8 160nonxs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
3720fc47 161cd "$tdir"
959f3c4c
JH
162
163: Now see which are supported on this system.
164?X: avail_ext lists available XS extensions.
165avail_ext=''
166for xxx in $known_extensions ; do
167 case "$xxx" in
168?X: Handle possible DOS 8.3 filename and case alterations
169 DB_File|db_file)
170 case "$i_db" in
171 $define) avail_ext="$avail_ext $xxx" ;;
172 esac
173 ;;
174 GDBM_File|gdbm_fil)
3c64a580 175 case "$i_gdbm" in
959f3c4c
JH
176 $define) avail_ext="$avail_ext $xxx" ;;
177 esac
178 ;;
dfd712ee 179 I18N/Langinfo|i18n_lan)
3c64a580 180 case "$i_langinfo$d_nl_langinfo" in
0e5a028f
JH
181 $define$define) avail_ext="$avail_ext $xxx" ;;
182 esac
183 ;;
a0e4e5e9
JH
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 ;;
959f3c4c 190 NDBM_File|ndbm_fil)
4b46a0b2 191 case "$d_ndbm" in
4ee071c7 192 $define)
33b2427b 193 case "$osname-$use64bitint" in
2862815c 194 hpux-define)
4ee071c7
JH
195 case "$libs" in
196 *-lndbm*) avail_ext="$avail_ext $xxx" ;;
197 esac
198 ;;
199 *) avail_ext="$avail_ext $xxx" ;;
200 esac
201 ;;
959f3c4c
JH
202 esac
203 ;;
3c64a580 204 ODBM_File|odbm_fil)
959f3c4c 205 case "${i_dbm}${i_rpcsvcdbm}" in
4ee071c7 206 *"${define}"*)
a0e4e5e9
JH
207 case "$d_cplusplus" in
208 define) ;; # delete as a function name will not work
209 *) case "$osname-$use64bitint" in
210 hpux-define)
211 case "$libs" in
212 *-ldbm*) avail_ext="$avail_ext $xxx" ;;
213 esac
214 ;;
215 *) avail_ext="$avail_ext $xxx" ;;
4ee071c7
JH
216 esac
217 ;;
4ee071c7
JH
218 esac
219 ;;
959f3c4c
JH
220 esac
221 ;;
a0e4e5e9
JH
222 Opcode|opcode)
223 case "$useopcode" in
959f3c4c
JH
224 true|define|y) avail_ext="$avail_ext $xxx" ;;
225 esac
226 ;;
a0e4e5e9
JH
227 POSIX|posix)
228 case "$useposix" in
959f3c4c
JH
229 true|define|y) avail_ext="$avail_ext $xxx" ;;
230 esac
231 ;;
232 Socket|socket)
3c64a580 233 case "$d_socket" in
625b7e7f
JH
234 true|$define|y)
235 case "$osname" in
236 beos) ;; # not unless BONE
237 *) avail_ext="$avail_ext $xxx" ;;
238 esac
239 ;;
959f3c4c
JH
240 esac
241 ;;
fa92de3e
YST
242 Sys/Syslog|sys/syslog)
243 : XXX syslog requires socket
3c64a580 244 case "$d_socket" in
fa92de3e
YST
245 true|$define|y) avail_ext="$avail_ext $xxx" ;;
246 esac
247 ;;
959f3c4c 248 Thread|thread)
4a2f2b60
JH
249 case "$usethreads" in
250 true|$define|y)
50dd2a3c
MB
251 case "$use5005threads" in
252 $define|true|[yY]*) avail_ext="$avail_ext $xxx" ;;
4a2f2b60 253 esac
80f8756f
JH
254 esac
255 ;;
a0e4e5e9
JH
256 threads|threads/shared)
257 # threads and threads::shared are special cases.
258 # To stop people from asking "Perl 5.8.0 was supposed
259 # to have this new fancy threads implementation but my
260 # perl doesn't have it" and from people trying to
261 # (re)install the threads module using CPAN.pm and
262 # CPAN.pm then offering to reinstall Perl 5.8.0,
263 # the threads.pm and threads/shared.pm will always be
264 # there, croaking informatively ("you need to rebuild
265 # all of Perl with threads, sorry") when threads haven't
266 # been compiled in.
267 # --jhi
268 avail_ext="$avail_ext $xxx"
269 ;;
cac33f20
MB
270 VMS*)
271 ;;
1d5a8f63 272 Win32*)
2ed3374f
JD
273 case "$osname" in
274 cygwin) avail_ext="$avail_ext $xxx" ;;
275 esac
276 ;;
6e939e10
AD
277 XS/APItest|xs/apitest)
278 # This is just for testing. Skip it unless we have dynamic loading.
279
280 case "$usedl" in
281 $define) avail_ext="$avail_ext $xxx" ;;
282 esac
283 ;;
284 XS/Typemap|xs/typemap)
285 # This is just for testing. Skip it unless we have dynamic loading.
286 case "$usedl" in
287 $define) avail_ext="$avail_ext $xxx" ;;
288 esac
289 ;;
959f3c4c
JH
290 *) avail_ext="$avail_ext $xxx"
291 ;;
292 esac
293done
294
295set X $avail_ext
296shift
297avail_ext="$*"
298
3eb2ab03
JH
299case "$onlyextensions" in
300'') ;;
301*) keepextensions=''
04c34a22 302 echo "You have requested that only certain extensions be included..." >&4
3eb2ab03
JH
303 for i in $onlyextensions; do
304 case " $avail_ext " in
305 *" $i "*)
306 echo "Keeping extension $i."
307 keepextensions="$keepextensions $i"
308 ;;
309 *) echo "Ignoring extension $i." ;;
310 esac
311 done
312 avail_ext="$keepextensions"
313 ;;
314esac
315
316case "$noextensions" in
317'') ;;
318*) keepextensions=''
319 echo "You have requested that certain extensions be ignored..." >&4
320 for i in $avail_ext; do
0ec877d1
JH
321 case " $noextensions " in
322 *" $i "*) echo "Ignoring extension $i." ;;
3eb2ab03
JH
323 *) echo "Keeping extension $i.";
324 keepextensions="$keepextensions $i"
325 ;;
326 esac
327 done
328 avail_ext="$keepextensions"
329 ;;
330esac
331
959f3c4c
JH
332: Now see which nonxs extensions are supported on this system.
333: For now assume all are.
334nonxs_ext=''
335for xxx in $nonxs_extensions ; do
336 case "$xxx" in
337 *) nonxs_ext="$nonxs_ext $xxx"
338 ;;
339 esac
340done
341
342set X $nonxs_ext
343shift
344nonxs_ext="$*"
345
346case $usedl in
347$define)
348 $cat <<EOM
349A number of extensions are supplied with $package. You may choose to
350compile these extensions for dynamic loading (the default), compile
351them into the $package executable (static loading), or not include
352them at all. Answer "none" to include no extensions.
353Note that DynaLoader is always built and need not be mentioned here.
354
355EOM
356 case "$dynamic_ext" in
a7eb1db8
MB
357 '')
358 : Exclude those listed in static_ext
359 dflt=''
360 for xxx in $avail_ext; do
361 case " $static_ext " in
362 *" $xxx "*) ;;
363 *) dflt="$dflt $xxx" ;;
364 esac
365 done
366 set X $dflt
367 shift
368 dflt="$*"
369 ;;
959f3c4c
JH
370 *) dflt="$dynamic_ext"
371 # Perhaps we are reusing an old out-of-date config.sh.
372 case "$hint" in
373 previous)
374 if test X"$dynamic_ext" != X"$avail_ext"; then
375 $cat <<EOM
3c64a580
RGS
376NOTICE: Your previous config.sh list may be incorrect.
377The extensions now available to you are
959f3c4c
JH
378 ${avail_ext}
379but the default list from your previous config.sh is
3c64a580 380 ${dynamic_ext}
959f3c4c
JH
381
382EOM
383 fi
384 ;;
385 esac
386 ;;
387 esac
388 case "$dflt" in
389 '') dflt=none;;
390 esac
391 rp="What extensions do you wish to load dynamically?"
392 . ./myread
393 case "$ans" in
394?X: Use ' ' so a subsequent Configure will preserve that value.
395 none) dynamic_ext=' ' ;;
396 *) dynamic_ext="$ans" ;;
397 esac
398
399 case "$static_ext" in
400 '')
401 : Exclude those already listed in dynamic linking
402 dflt=''
403 for xxx in $avail_ext; do
404 case " $dynamic_ext " in
405 *" $xxx "*) ;;
406 *) dflt="$dflt $xxx" ;;
407 esac
408 done
409 set X $dflt
410 shift
411 dflt="$*"
412 ;;
3c64a580 413 *) dflt="$static_ext"
959f3c4c
JH
414 ;;
415 esac
416
417 case "$dflt" in
418 '') dflt=none;;
419 esac
420 rp="What extensions do you wish to load statically?"
421 . ./myread
422 case "$ans" in
423?X: Use ' ' so a subsequent Configure will preserve that value.
424 none) static_ext=' ' ;;
425 *) static_ext="$ans" ;;
426 esac
427 ;;
428*)
429 $cat <<EOM
3c64a580
RGS
430A number of extensions are supplied with $package. Answer "none"
431to include no extensions.
959f3c4c
JH
432Note that DynaLoader is always built and need not be mentioned here.
433
434EOM
435 case "$static_ext" in
436 '') dflt="$avail_ext" ;;
437 *) dflt="$static_ext"
438 # Perhaps we are reusing an old out-of-date config.sh.
439 case "$hint" in
440 previous)
441 if test X"$static_ext" != X"$avail_ext"; then
442 $cat <<EOM
3c64a580
RGS
443NOTICE: Your previous config.sh list may be incorrect.
444The extensions now available to you are
959f3c4c
JH
445 ${avail_ext}
446but the default list from your previous config.sh is
3c64a580 447 ${static_ext}
959f3c4c
JH
448
449EOM
450 fi
451 ;;
452 esac
453 ;;
454 esac
455 : Exclude those that are not xs extensions
456 case "$dflt" in
457 '') dflt=none;;
458 esac
459 rp="What extensions do you wish to include?"
460 . ./myread
461 case "$ans" in
462?X: Use ' ' so a subsequent Configure will preserve that value.
463 none) static_ext=' ' ;;
464 *) static_ext="$ans" ;;
465 esac
466 ;;
467esac
3c64a580 468#
75423307
JH
469# Encode is a special case. If we are building Encode as a static
470# extension, we need to explicitly list its subextensions as well.
471# For other nested extensions, this is handled automatically by
472# the appropriate Makefile.PL.
473case " $static_ext " in
474 *" Encode "*) # Add the subextensions of Encode
d23c2a3f 475 cd "$rsrc/cpan"
75423307
JH
476 for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do
477 static_ext="$static_ext Encode/$xxx"
478 done
479 cd "$tdir"
480 ;;
481esac
959f3c4c
JH
482
483set X $dynamic_ext $static_ext $nonxs_ext
484shift
485extensions="$*"
486
9d9aa0de
JH
487# Sanity check: We require an extension suitable for use with
488# AnyDBM_File, as well as Fcntl and IO. (Failure to have these
489# should show up as failures in the test suite, but it's helpful to
490# catch them now.) The 'extensions' list is normally sorted
491# alphabetically, so we need to accept either
492# DB_File ... Fcntl ... IO ....
493# or something like
494# Fcntl ... NDBM_File ... IO ....
1af58dcc
JH
495case " $extensions" in
496*"_File "*" Fcntl "*" IO "*) ;; # DB_File
497*" Fcntl "*"_File "*" IO "*) ;; # GDBM_File
498*" Fcntl "*" IO "*"_File "*) ;; # NDBM_File
3ae30915
JH
499*) echo "WARNING: Extensions DB_File or *DBM_File, Fcntl, and IO not configured." >&4
500 echo "WARNING: The Perl you are building will be quite crippled." >& 4
501 ;;
502esac
503