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