This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
QNX shell needs more semicolons.
[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 package test cat rsrc d_msg d_shm
14 ?MAKE:  -pick add $@ %<
15 ?Y:BOTTOM
16 ?S:known_extensions:
17 ?S:     This variable holds a list of all XS extensions included in 
18 ?S:     the package.
19 ?S:.
20 ?S:dynamic_ext:
21 ?S:     This variable holds a list of XS extension files we want to
22 ?S:     link dynamically into the package.  It is used by Makefile.
23 ?S:.
24 ?S:static_ext:
25 ?S:     This variable holds a list of XS extension files we want to
26 ?S:     link statically into the package.  It is used by Makefile.
27 ?S:.
28 ?S:nonxs_ext:
29 ?S:     This variable holds a list of all non-xs extensions included
30 ?S:     in the package.  All of them will be built.
31 ?S:.
32 ?S:extensions:
33 ?S:     This variable holds a list of all extension files (both XS and
34 ?S:     non-xs linked into the package.  It is propagated to Config.pm
35 ?S:     and is typically used to test whether a particular extesion 
36 ?S:     is available.
37 ?S:.
38 ?S:useposix:
39 ?S:     This variable holds either 'true' or 'false' to indicate
40 ?S:     whether the POSIX extension should be used.  The sole
41 ?S:     use for this currently is to allow an easy mechanism
42 ?S:     for hints files to indicate that POSIX will not compile
43 ?S:     on a particular system.
44 ?S:.
45 ?S:useopcode:
46 ?S:     This variable holds either 'true' or 'false' to indicate
47 ?S:     whether the Opcode extension should be used.  The sole
48 ?S:     use for this currently is to allow an easy mechanism
49 ?S:     for users to skip the Opcode extension from the Configure
50 ?S:     command line.
51 ?S:.
52 ?T:xxx avail_ext tdir nonxs_extensions find_extensions
53 ?INIT:: set useposix=false in your hint file to disable the POSIX extension.
54 ?INIT:useposix=true
55 ?INIT:: set useopcode=false in your hint file to disable the Opcode extension.
56 ?INIT:useopcode=true
57 echo " "
58 echo "Looking for extensions..." >&4
59 : If we are using the old config.sh, known_extensions may contain
60 : old or inaccurate or duplicate values.
61 known_extensions=''
62 nonxs_extensions=''
63 : We do not use find because it might not be available.
64 : We do not just use MANIFEST because the user may have dropped
65 : some additional extensions into the source tree and expect them
66 : to be built.
67
68 : Function to recursively find available extensions, ignoring DynaLoader
69 : NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
70 find_extensions='
71     for xxx in *; do
72        case "$xxx" in
73            DynaLoader|dynaload) ;;
74            *)
75            if $test -f $xxx/$xxx.xs; then
76                known_extensions="$known_extensions $1$xxx";
77            elif $test -f $xxx/Makefile.PL; then
78                nonxs_extensions="$nonxs_extensions $1$xxx";
79            else
80                if $test -d $xxx -a $# -lt 10; then
81                    set $1$xxx/ $*;
82                    cd $xxx;
83                    eval $find_extensions;
84                    cd ..;
85                    shift;
86                fi;
87            fi
88            ;;
89        esac;
90     done'
91 tdir=`pwd`
92 cd $rsrc/ext
93 set X
94 shift
95 eval $find_extensions
96 set X $nonxs_extensions
97 shift
98 nonxs_extensions="$*"
99 set X $known_extensions
100 shift
101 known_extensions="$*"
102 cd $tdir
103
104 : Now see which are supported on this system.
105 ?X: avail_ext lists available XS extensions.
106 avail_ext=''
107 for xxx in $known_extensions ; do
108         case "$xxx" in
109 ?X: Handle possible DOS 8.3 filename and case alterations
110         DB_File|db_file)
111                 case "$i_db" in
112                 $define) avail_ext="$avail_ext $xxx" ;;
113                 esac
114                 ;;
115         GDBM_File|gdbm_fil)
116                 case "$i_gdbm" in 
117                 $define) avail_ext="$avail_ext $xxx" ;;
118                 esac
119                 ;;
120         NDBM_File|ndbm_fil)
121                 case "$i_ndbm" in
122                 $define) avail_ext="$avail_ext $xxx" ;;
123                 esac
124                 ;;
125         ODBM_File|odbm_fil) 
126                 case "${i_dbm}${i_rpcsvcdbm}" in
127                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
128                 esac
129                 ;;
130         POSIX|posix)
131                 case "$useposix" in
132                 true|define|y) avail_ext="$avail_ext $xxx" ;;
133                 esac
134                 ;;
135         Opcode|opcode)
136                 case "$useopcode" in
137                 true|define|y) avail_ext="$avail_ext $xxx" ;;
138                 esac
139                 ;;
140         Socket|socket)
141                 case "$d_socket" in 
142                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
143                 esac
144                 ;;
145         Thread|thread)
146                 case "$usethreads" in 
147                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
148                 esac
149                 ;;
150         IPC/SysV|ipc/sysv)
151                 : XXX Do we need a useipcsysv variable here
152                 case "${d_msg}${d_sem}${d_shm}" in 
153                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
154                 esac
155                 ;;
156         *)      avail_ext="$avail_ext $xxx"
157                 ;;
158         esac
159 done
160
161 set X $avail_ext
162 shift
163 avail_ext="$*"
164
165 : Now see which nonxs extensions are supported on this system.
166 : For now assume all are.
167 nonxs_ext=''
168 for xxx in $nonxs_extensions ; do
169         case "$xxx" in
170         *)      nonxs_ext="$nonxs_ext $xxx"
171                 ;;
172         esac
173 done
174
175 set X $nonxs_ext
176 shift
177 nonxs_ext="$*"
178
179 case $usedl in
180 $define)
181         $cat <<EOM
182 A number of extensions are supplied with $package.  You may choose to
183 compile these extensions for dynamic loading (the default), compile
184 them into the $package executable (static loading), or not include
185 them at all.  Answer "none" to include no extensions.
186 Note that DynaLoader is always built and need not be mentioned here.
187
188 EOM
189         case "$dynamic_ext" in
190         '') dflt="$avail_ext" ;;
191         *)      dflt="$dynamic_ext"
192                 # Perhaps we are reusing an old out-of-date config.sh.
193                 case "$hint" in
194                 previous)
195                         if test X"$dynamic_ext" != X"$avail_ext"; then
196                                 $cat <<EOM
197 NOTICE:  Your previous config.sh list may be incorrect. 
198 The extensions now available to you are 
199         ${avail_ext}
200 but the default list from your previous config.sh is
201         ${dynamic_ext} 
202
203 EOM
204                         fi
205                         ;;
206                 esac
207                 ;;
208         esac
209         case "$dflt" in
210         '')     dflt=none;;
211         esac
212         rp="What extensions do you wish to load dynamically?"
213         . ./myread
214         case "$ans" in
215 ?X: Use ' ' so a subsequent Configure will preserve that value.
216         none) dynamic_ext=' ' ;;
217         *) dynamic_ext="$ans" ;;
218         esac
219
220         case "$static_ext" in
221         '')
222                 : Exclude those already listed in dynamic linking
223                 dflt=''
224                 for xxx in $avail_ext; do
225                         case " $dynamic_ext " in
226                         *" $xxx "*) ;;
227                         *) dflt="$dflt $xxx" ;;
228                         esac
229                 done
230                 set X $dflt
231                 shift
232                 dflt="$*"
233                 ;;
234         *)  dflt="$static_ext" 
235                 ;;
236         esac
237
238         case "$dflt" in
239         '')     dflt=none;;
240         esac
241         rp="What extensions do you wish to load statically?"
242         . ./myread
243         case "$ans" in
244 ?X: Use ' ' so a subsequent Configure will preserve that value.
245         none) static_ext=' ' ;;
246         *) static_ext="$ans" ;;
247         esac
248         ;;
249 *)
250         $cat <<EOM
251 A number of extensions are supplied with $package.  Answer "none" 
252 to include no extensions. 
253 Note that DynaLoader is always built and need not be mentioned here.
254
255 EOM
256         case "$static_ext" in
257         '') dflt="$avail_ext" ;;
258         *)      dflt="$static_ext"
259                 # Perhaps we are reusing an old out-of-date config.sh.
260                 case "$hint" in
261                 previous)
262                         if test X"$static_ext" != X"$avail_ext"; then
263                                 $cat <<EOM
264 NOTICE:  Your previous config.sh list may be incorrect. 
265 The extensions now available to you are 
266         ${avail_ext}
267 but the default list from your previous config.sh is
268         ${static_ext} 
269
270 EOM
271                         fi
272                         ;;
273                 esac
274                 ;;
275         esac
276         : Exclude those that are not xs extensions
277         case "$dflt" in
278         '')     dflt=none;;
279         esac
280         rp="What extensions do you wish to include?"
281         . ./myread
282         case "$ans" in
283 ?X: Use ' ' so a subsequent Configure will preserve that value.
284         none) static_ext=' ' ;;
285         *) static_ext="$ans" ;;
286         esac
287         ;;
288 esac
289
290 set X $dynamic_ext $static_ext $nonxs_ext
291 shift
292 extensions="$*"
293