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