This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: Change 33598: [PATCH] Re: Smoke [5.11.0] 33456 PASS darwin 9.2.0 (macppcG5/1...
[metaconfig.git] / U / perl / dlsrc.U
CommitLineData
959f3c4c
JH
1?RCS: $Id: dlsrc.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: dlsrc.U,v $
9?RCS:
10?X: hpux support thanks to Jeff Okamoto <okamoto@hpcc101.corp.hp.com>
11?X:
12?X: To create a shared library, you must compile ALL source files in the
13?X: library with +z (or possibly +Z if the library is whopping huge),
14?X: then link the library with -b. Example:
15?X: cc -c +z module_a.c
16?X: cc -c +z module_b.c
17?X: ld -b module_a.o module_b.o -o module.sl
18?X:
2cb64bf6 19?MAKE:usedl ld dlsrc cccdlflags lddlflags ccdlflags: rm_try \
3c617870
TC
20 Getfile Myread test osname sed i_dld d_dlopen Findhdr Setvar src run \
21 cc ccflags ldflags optimize ls gccversion cat rsrc i_stdlib i_unistd
959f3c4c
JH
22?MAKE: -pick add $@ %<
23?Y:BOTTOM
24?S:usedl:
edd6115f 25?S: This variable indicates if the system supports dynamic
959f3c4c
JH
26?S: loading of some sort. See also dlsrc and dlobj.
27?S:.
28?S:ld:
29?S: This variable indicates the program to be used to link
30?S: libraries for dynamic loading. On some systems, it is 'ld'.
31?S: On ELF systems, it should be $cc. Mostly, we'll try to respect
32?S: the hint file setting.
33?S:.
34?S:dlsrc:
35?S: This variable contains the name of the dynamic loading file that
36?S: will be used with the package.
37?S:.
38?S:cccdlflags:
39?S: This variable contains any special flags that might need to be
40?S: passed with 'cc -c' to compile modules to be used to create a shared
41?S: library that will be used for dynamic loading. For hpux, this
42?S: should be +z. It is up to the makefile to use it.
43?S:.
44?S:lddlflags:
45?S: This variable contains any special flags that might need to be
46?S: passed to $ld to create a shared library suitable for dynamic
47?S: loading. It is up to the makefile to use it. For hpux, it
48?S: should be '-b'. For sunos 4.1, it is empty.
49?S:.
50?S:ccdlflags:
51?S: This variable contains any special flags that might need to be
52?S: passed to cc to link with a shared library for dynamic loading.
53?S: It is up to the makefile to use it. For sunos 4.1, it should
54?S: be empty.
55?S:.
56?C:USE_DYNAMIC_LOADING ~ %<:
57?C: This symbol, if defined, indicates that dynamic loading of
58?C: some sort is available.
59?C:.
60?H:?%<:#$usedl USE_DYNAMIC_LOADING /**/
61?H:.
62?W:%<:dlopen
63?T:dldir thisflag tdir
41322e17 64?F:!a.out
959f3c4c
JH
65: determine which dynamic loading, if any, to compile in
66echo " "
67dldir="ext/DynaLoader"
68case "$usedl" in
69$define|y|true)
70 dflt='y'
71 usedl="$define"
72 ;;
73$undef|n|false)
74 dflt='n'
75 usedl="$undef"
76 ;;
2cb64bf6 77*)
959f3c4c
JH
78 dflt='n'
79 case "$d_dlopen" in
80 $define) dflt='y' ;;
81 esac
82 case "$i_dld" in
83 $define) dflt='y' ;;
84 esac
85 : Does a dl_xxx.xs file exist for this operating system
86 $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
87 ;;
88esac
89rp="Do you wish to use dynamic loading?"
90. ./myread
91usedl="$ans"
92case "$ans" in
93y*) usedl="$define"
94 case "$dlsrc" in
95 '')
96 if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
97 dflt="$dldir/dl_${osname}.xs"
98 elif $test "$d_dlopen" = "$define" ; then
99 dflt="$dldir/dl_dlopen.xs"
100 elif $test "$i_dld" = "$define" ; then
101 dflt="$dldir/dl_dld.xs"
102 else
103 dflt=''
104 fi
105 ;;
106 *) dflt="$dldir/$dlsrc"
107 ;;
108 esac
109 echo "The following dynamic loading files are available:"
110 : Can not go over to $dldir because getfile has path hard-coded in.
3720fc47 111 tdir=`pwd`; cd "$rsrc"; $ls -C $dldir/dl*.xs; cd "$tdir"
959f3c4c
JH
112 rp="Source file to use for dynamic loading"
113 fn="fne"
114 gfpth="$src"
115 . ./getfile
116 usedl="$define"
117 : emulate basename
70ffff07 118 dlsrc=`echo $ans | $sed -e 's%.*/\([^/]*\)$%\1%'`
959f3c4c
JH
119
120 $cat << EOM
121
122Some systems may require passing special flags to $cc -c to
123compile modules that will be used to create a shared library.
124To use no flags, say "none".
125
126EOM
127 case "$cccdlflags" in
128 '') case "$gccversion" in
129 '') case "$osname" in
130 hpux) dflt='+z' ;;
131 next) dflt='none' ;;
132 irix*) dflt='-KPIC' ;;
5bcf820f 133 svr4*|esix*|solaris|nonstopux) dflt='-KPIC' ;;
959f3c4c
JH
134 sunos) dflt='-pic' ;;
135 *) dflt='none' ;;
136 esac
137 ;;
138 *) case "$osname" in
5e191ef7 139 darwin) dflt='none' ;;
4b3d7136 140 linux*|svr4*|esix*|solaris|nonstopux) dflt='-fPIC' ;;
959f3c4c
JH
141 *) dflt='-fpic' ;;
142 esac ;;
143 esac ;;
144 ' ') dflt='none' ;;
145 *) dflt="$cccdlflags" ;;
146 esac
147 rp="Any special flags to pass to $cc -c to compile shared library modules?"
148 . ./myread
149 case "$ans" in
150?X: Use ' ' so that a subsequent Configure run preserves the old state.
151 none) cccdlflags=' ' ;;
152 *) cccdlflags="$ans" ;;
153 esac
154
155 cat << EOM
156
157Some systems use ld to create libraries that can be dynamically loaded,
158while other systems (such as those using ELF) use $cc.
159
160EOM
161 case "$ld" in
1273bb5e 162 '') $cat >try.c <<EOM
959f3c4c
JH
163/* Test for whether ELF binaries are produced */
164#include <fcntl.h>
1273bb5e
JH
165#$i_stdlib I_STDLIB
166#ifdef I_STDLIB
959f3c4c 167#include <stdlib.h>
1273bb5e 168#endif
20376335
JH
169#$i_unistd I_UNISTD
170#ifdef I_UNISTD
171#include <unistd.h>
172#endif
959f3c4c
JH
173int main() {
174 char b[4];
175 int i = open("a.out",O_RDONLY);
2cb64bf6 176 if(i == -1)
959f3c4c
JH
177 exit(1); /* fail */
178 if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
179 exit(0); /* succeed (yes, it's ELF) */
180 else
181 exit(1); /* fail */
182}
183EOM
0f00356b 184 if $cc $ccflags $ldflags try.c >/dev/null 2>&1 && $run ./a.out; then
959f3c4c
JH
185 cat <<EOM
186You appear to have ELF support. I'll use $cc to build dynamic libraries.
187EOM
188 dflt="$cc"
189 else
190 echo "I'll use ld to build dynamic libraries."
191 dflt='ld'
192 fi
2cb64bf6 193 $rm_try
959f3c4c
JH
194 ;;
195 *) dflt="$ld"
196 ;;
197 esac
198
199 rp="What command should be used to create dynamic libraries?"
200 . ./myread
201 ld="$ans"
202
203 cat << EOM
204
205Some systems may require passing special flags to $ld to create a
206library that can be dynamically loaded. If your ld flags include
207-L/other/path options to locate libraries outside your loader's normal
208search path, you may need to specify those -L options here as well. To
209use no flags, say "none".
210
211EOM
212 case "$lddlflags" in
213 '') case "$osname" in
214 beos) dflt='-nostart' ;;
8b424337
JH
215 hpux) dflt='-b';
216 case "$gccversion" in
217 '') dflt="$dflt +vnocompatwarnings" ;;
f27d6ab9 218 esac
2cb64bf6 219 ;;
3c617870 220 linux|irix*|gnu*) dflt="-shared $optimize" ;;
959f3c4c
JH
221 next) dflt='none' ;;
222 solaris) dflt='-G' ;;
223 sunos) dflt='-assert nodefinitions' ;;
5bcf820f 224 svr4*|esix*|nonstopux) dflt="-G $ldflags" ;;
959f3c4c
JH
225 *) dflt='none' ;;
226 esac
227 ;;
228 *) dflt="$lddlflags" ;;
229 esac
230
231 : Try to guess additional flags to pick up local libraries.
232 : Be careful not to append to a plain 'none'
233 case "$dflt" in
234 none) dflt='' ;;
235 esac
236 for thisflag in $ldflags; do
237 case "$thisflag" in
4d5de5cd 238 -L*|-R*|-Wl,-R*)
959f3c4c
JH
239 case " $dflt " in
240 *" $thisflag "*) ;;
241 *) dflt="$dflt $thisflag" ;;
242 esac
243 ;;
244 esac
245 done
246
247 case "$dflt" in
248 ''|' ') dflt='none' ;;
249 esac
250
251 rp="Any special flags to pass to $ld to create a dynamically loaded library?"
252 . ./myread
253 case "$ans" in
254?X: Use ' ' so that a subsequent Configure run preserves the old state.
255 none) lddlflags=' ' ;;
256 *) lddlflags="$ans" ;;
257 esac
258
259 cat <<EOM
260
261Some systems may require passing special flags to $cc to indicate that
262the resulting executable will use dynamic linking. To use no flags,
263say "none".
264
265EOM
266 case "$ccdlflags" in
267 '') case "$osname" in
76ba8ff9 268 linux|hpux|gnu*) dflt='-Wl,-E' ;;
2c3385d3
AH
269 next|sunos) dflt='none' ;;
270 *) dflt='none' ;;
959f3c4c
JH
271 esac ;;
272 ' ') dflt='none' ;;
273 *) dflt="$ccdlflags" ;;
274 esac
ec0d834e 275 rp="Any special flags to pass to $cc to use dynamic linking?"
959f3c4c
JH
276 . ./myread
277 case "$ans" in
278?X: Use ' ' so that a subsequent Configure run preserves the old state.
279 none) ccdlflags=' ' ;;
280 *) ccdlflags="$ans" ;;
281 esac
282 ;;
283?X: End of usedl=y section
284*) usedl="$undef"
285 ld='ld'
286 dlsrc='dl_none.xs'
287 lddlflags=''
288 ccdlflags=''
289 ;;
290esac
291