Commit | Line | Data |
---|---|---|
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 |
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 | |
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 |
78 | find_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' |
132 | tdir=`pwd` | |
473e3a1b MB |
133 | cd "$rsrc/cpan" |
134 | set X | |
135 | shift | |
136 | eval $find_extensions | |
2e336f39 MB |
137 | cd "$rsrc/dist" |
138 | set X | |
139 | shift | |
140 | eval $find_extensions | |
3720fc47 | 141 | cd "$rsrc/ext" |
86a2f2c4 | 142 | set X |
959f3c4c JH |
143 | shift |
144 | eval $find_extensions | |
cac33f20 MB |
145 | if $test -d File-Glob; then |
146 | : All ext/ flattened | |
147 | else | |
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" | |
154 | fi | |
959f3c4c JH |
155 | set X $known_extensions |
156 | shift | |
aa1bc9e8 | 157 | known_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '` |
4823dbc4 MB |
158 | set X $nonxs_extensions |
159 | shift | |
aa1bc9e8 | 160 | nonxs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '` |
3720fc47 | 161 | cd "$tdir" |
959f3c4c JH |
162 | |
163 | : Now see which are supported on this system. | |
164 | ?X: avail_ext lists available XS extensions. | |
165 | avail_ext='' | |
166 | for 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 |
a3c22f16 | 234 | true|$define|y) avail_ext="$avail_ext $xxx" ;; |
959f3c4c JH |
235 | esac |
236 | ;; | |
fa92de3e YST |
237 | Sys/Syslog|sys/syslog) |
238 | : XXX syslog requires socket | |
3c64a580 | 239 | case "$d_socket" in |
fa92de3e YST |
240 | true|$define|y) avail_ext="$avail_ext $xxx" ;; |
241 | esac | |
242 | ;; | |
959f3c4c | 243 | Thread|thread) |
4a2f2b60 JH |
244 | case "$usethreads" in |
245 | true|$define|y) | |
50dd2a3c MB |
246 | case "$use5005threads" in |
247 | $define|true|[yY]*) avail_ext="$avail_ext $xxx" ;; | |
4a2f2b60 | 248 | esac |
80f8756f JH |
249 | esac |
250 | ;; | |
a0e4e5e9 JH |
251 | threads|threads/shared) |
252 | # threads and threads::shared are special cases. | |
253 | # To stop people from asking "Perl 5.8.0 was supposed | |
254 | # to have this new fancy threads implementation but my | |
255 | # perl doesn't have it" and from people trying to | |
256 | # (re)install the threads module using CPAN.pm and | |
257 | # CPAN.pm then offering to reinstall Perl 5.8.0, | |
258 | # the threads.pm and threads/shared.pm will always be | |
259 | # there, croaking informatively ("you need to rebuild | |
260 | # all of Perl with threads, sorry") when threads haven't | |
261 | # been compiled in. | |
262 | # --jhi | |
263 | avail_ext="$avail_ext $xxx" | |
264 | ;; | |
cac33f20 MB |
265 | VMS*) |
266 | ;; | |
1d5a8f63 | 267 | Win32*) |
2ed3374f JD |
268 | case "$osname" in |
269 | cygwin) avail_ext="$avail_ext $xxx" ;; | |
270 | esac | |
271 | ;; | |
6e939e10 AD |
272 | XS/APItest|xs/apitest) |
273 | # This is just for testing. Skip it unless we have dynamic loading. | |
274 | ||
275 | case "$usedl" in | |
276 | $define) avail_ext="$avail_ext $xxx" ;; | |
277 | esac | |
278 | ;; | |
279 | XS/Typemap|xs/typemap) | |
280 | # This is just for testing. Skip it unless we have dynamic loading. | |
281 | case "$usedl" in | |
282 | $define) avail_ext="$avail_ext $xxx" ;; | |
283 | esac | |
284 | ;; | |
959f3c4c JH |
285 | *) avail_ext="$avail_ext $xxx" |
286 | ;; | |
287 | esac | |
288 | done | |
289 | ||
290 | set X $avail_ext | |
291 | shift | |
292 | avail_ext="$*" | |
293 | ||
3eb2ab03 JH |
294 | case "$onlyextensions" in |
295 | '') ;; | |
296 | *) keepextensions='' | |
04c34a22 | 297 | echo "You have requested that only certain extensions be included..." >&4 |
3eb2ab03 JH |
298 | for i in $onlyextensions; do |
299 | case " $avail_ext " in | |
300 | *" $i "*) | |
301 | echo "Keeping extension $i." | |
302 | keepextensions="$keepextensions $i" | |
303 | ;; | |
304 | *) echo "Ignoring extension $i." ;; | |
305 | esac | |
306 | done | |
307 | avail_ext="$keepextensions" | |
308 | ;; | |
309 | esac | |
310 | ||
311 | case "$noextensions" in | |
312 | '') ;; | |
313 | *) keepextensions='' | |
314 | echo "You have requested that certain extensions be ignored..." >&4 | |
315 | for i in $avail_ext; do | |
0ec877d1 JH |
316 | case " $noextensions " in |
317 | *" $i "*) echo "Ignoring extension $i." ;; | |
3eb2ab03 JH |
318 | *) echo "Keeping extension $i."; |
319 | keepextensions="$keepextensions $i" | |
320 | ;; | |
321 | esac | |
322 | done | |
323 | avail_ext="$keepextensions" | |
324 | ;; | |
325 | esac | |
326 | ||
959f3c4c JH |
327 | : Now see which nonxs extensions are supported on this system. |
328 | : For now assume all are. | |
329 | nonxs_ext='' | |
330 | for xxx in $nonxs_extensions ; do | |
331 | case "$xxx" in | |
332 | *) nonxs_ext="$nonxs_ext $xxx" | |
333 | ;; | |
334 | esac | |
335 | done | |
336 | ||
337 | set X $nonxs_ext | |
338 | shift | |
339 | nonxs_ext="$*" | |
340 | ||
341 | case $usedl in | |
342 | $define) | |
343 | $cat <<EOM | |
344 | A number of extensions are supplied with $package. You may choose to | |
345 | compile these extensions for dynamic loading (the default), compile | |
346 | them into the $package executable (static loading), or not include | |
347 | them at all. Answer "none" to include no extensions. | |
348 | Note that DynaLoader is always built and need not be mentioned here. | |
349 | ||
350 | EOM | |
351 | case "$dynamic_ext" in | |
a7eb1db8 MB |
352 | '') |
353 | : Exclude those listed in static_ext | |
354 | dflt='' | |
355 | for xxx in $avail_ext; do | |
356 | case " $static_ext " in | |
357 | *" $xxx "*) ;; | |
358 | *) dflt="$dflt $xxx" ;; | |
359 | esac | |
360 | done | |
361 | set X $dflt | |
362 | shift | |
363 | dflt="$*" | |
364 | ;; | |
959f3c4c JH |
365 | *) dflt="$dynamic_ext" |
366 | # Perhaps we are reusing an old out-of-date config.sh. | |
367 | case "$hint" in | |
368 | previous) | |
369 | if test X"$dynamic_ext" != X"$avail_ext"; then | |
370 | $cat <<EOM | |
3c64a580 RGS |
371 | NOTICE: Your previous config.sh list may be incorrect. |
372 | The extensions now available to you are | |
959f3c4c JH |
373 | ${avail_ext} |
374 | but the default list from your previous config.sh is | |
3c64a580 | 375 | ${dynamic_ext} |
959f3c4c JH |
376 | |
377 | EOM | |
378 | fi | |
379 | ;; | |
380 | esac | |
381 | ;; | |
382 | esac | |
383 | case "$dflt" in | |
384 | '') dflt=none;; | |
385 | esac | |
386 | rp="What extensions do you wish to load dynamically?" | |
387 | . ./myread | |
388 | case "$ans" in | |
389 | ?X: Use ' ' so a subsequent Configure will preserve that value. | |
390 | none) dynamic_ext=' ' ;; | |
391 | *) dynamic_ext="$ans" ;; | |
392 | esac | |
393 | ||
394 | case "$static_ext" in | |
395 | '') | |
396 | : Exclude those already listed in dynamic linking | |
397 | dflt='' | |
398 | for xxx in $avail_ext; do | |
399 | case " $dynamic_ext " in | |
400 | *" $xxx "*) ;; | |
401 | *) dflt="$dflt $xxx" ;; | |
402 | esac | |
403 | done | |
404 | set X $dflt | |
405 | shift | |
406 | dflt="$*" | |
407 | ;; | |
3c64a580 | 408 | *) dflt="$static_ext" |
959f3c4c JH |
409 | ;; |
410 | esac | |
411 | ||
412 | case "$dflt" in | |
413 | '') dflt=none;; | |
414 | esac | |
415 | rp="What extensions do you wish to load statically?" | |
416 | . ./myread | |
417 | case "$ans" in | |
418 | ?X: Use ' ' so a subsequent Configure will preserve that value. | |
419 | none) static_ext=' ' ;; | |
420 | *) static_ext="$ans" ;; | |
421 | esac | |
422 | ;; | |
423 | *) | |
424 | $cat <<EOM | |
3c64a580 RGS |
425 | A number of extensions are supplied with $package. Answer "none" |
426 | to include no extensions. | |
959f3c4c JH |
427 | Note that DynaLoader is always built and need not be mentioned here. |
428 | ||
429 | EOM | |
430 | case "$static_ext" in | |
431 | '') dflt="$avail_ext" ;; | |
432 | *) dflt="$static_ext" | |
433 | # Perhaps we are reusing an old out-of-date config.sh. | |
434 | case "$hint" in | |
435 | previous) | |
436 | if test X"$static_ext" != X"$avail_ext"; then | |
437 | $cat <<EOM | |
3c64a580 RGS |
438 | NOTICE: Your previous config.sh list may be incorrect. |
439 | The extensions now available to you are | |
959f3c4c JH |
440 | ${avail_ext} |
441 | but the default list from your previous config.sh is | |
3c64a580 | 442 | ${static_ext} |
959f3c4c JH |
443 | |
444 | EOM | |
445 | fi | |
446 | ;; | |
447 | esac | |
448 | ;; | |
449 | esac | |
450 | : Exclude those that are not xs extensions | |
451 | case "$dflt" in | |
452 | '') dflt=none;; | |
453 | esac | |
454 | rp="What extensions do you wish to include?" | |
455 | . ./myread | |
456 | case "$ans" in | |
457 | ?X: Use ' ' so a subsequent Configure will preserve that value. | |
458 | none) static_ext=' ' ;; | |
459 | *) static_ext="$ans" ;; | |
460 | esac | |
461 | ;; | |
462 | esac | |
3c64a580 | 463 | # |
75423307 JH |
464 | # Encode is a special case. If we are building Encode as a static |
465 | # extension, we need to explicitly list its subextensions as well. | |
466 | # For other nested extensions, this is handled automatically by | |
467 | # the appropriate Makefile.PL. | |
468 | case " $static_ext " in | |
469 | *" Encode "*) # Add the subextensions of Encode | |
d23c2a3f | 470 | cd "$rsrc/cpan" |
75423307 JH |
471 | for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do |
472 | static_ext="$static_ext Encode/$xxx" | |
473 | done | |
474 | cd "$tdir" | |
475 | ;; | |
476 | esac | |
959f3c4c JH |
477 | |
478 | set X $dynamic_ext $static_ext $nonxs_ext | |
479 | shift | |
480 | extensions="$*" | |
481 | ||
9d9aa0de JH |
482 | # Sanity check: We require an extension suitable for use with |
483 | # AnyDBM_File, as well as Fcntl and IO. (Failure to have these | |
484 | # should show up as failures in the test suite, but it's helpful to | |
485 | # catch them now.) The 'extensions' list is normally sorted | |
486 | # alphabetically, so we need to accept either | |
487 | # DB_File ... Fcntl ... IO .... | |
488 | # or something like | |
489 | # Fcntl ... NDBM_File ... IO .... | |
1af58dcc JH |
490 | case " $extensions" in |
491 | *"_File "*" Fcntl "*" IO "*) ;; # DB_File | |
492 | *" Fcntl "*"_File "*" IO "*) ;; # GDBM_File | |
493 | *" Fcntl "*" IO "*"_File "*) ;; # NDBM_File | |
3ae30915 JH |
494 | *) echo "WARNING: Extensions DB_File or *DBM_File, Fcntl, and IO not configured." >&4 |
495 | echo "WARNING: The Perl you are building will be quite crippled." >& 4 | |
496 | ;; | |
497 | esac | |
498 |