This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Detection of IPv6 clueful functions by Configure
[metaconfig.git] / U / perl / libperl.U
CommitLineData
959f3c4c
JH
1?RCS: $Id: libperl.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?MAKE:libperl useshrplib shrpenv ldlibpthname: \
9 Myread Oldconfig archlibexp awk cat libc \
10 _a osname osvers so patchlevel subversion usedl ld \
cfba7844 11 ccdlflags installarchlib
959f3c4c
JH
12?MAKE: -pick wipe $@ %<
13?S:libperl:
14?S: The perl executable is obtained by linking perlmain.c with
15?S: libperl, any static extensions (usually just DynaLoader),
16?S: and any other libraries needed on this system. libperl
17?S: is usually libperl.a, but can also be libperl.so.xxx if
18?S: the user wishes to build a perl executable with a shared
19?S: library.
20?S:.
21?S:useshrplib:
472f992b
MB
22?S: This variable is set to 'true' if the user wishes
23?S: to build a shared libperl, and 'false' otherwise.
959f3c4c
JH
24?S:.
25?S:shrpenv:
26?S: If the user builds a shared libperl.so, then we need to tell the
2f125bce 27?S: 'perl' executable where it will be able to find the installed libperl.so.
959f3c4c
JH
28?S: One way to do this on some systems is to set the environment variable
29?S: LD_RUN_PATH to the directory that will be the final location of the
30?S: shared libperl.so. The makefile can use this with something like
31?S: $shrpenv $(CC) -o perl perlmain.o $libperl $libs
32?S: Typical values are
33?S: shrpenv="env LD_RUN_PATH=$archlibexp/CORE"
34?S: or
35?S: shrpenv=''
36?S: See the main perl Makefile.SH for actual working usage.
37?S: Alternatively, we might be able to use a command line option such
4d5de5cd 38?S: as -R $archlibexp/CORE (Solaris) or -Wl,-rpath
959f3c4c
JH
39?S: $archlibexp/CORE (Linux).
40?S:.
41?S:ldlibpthname:
42?S: This variable holds the name of the shared library
43?S: search path, often LD_LIBRARY_PATH. To get an empty
44?S: string, the hints file must set this to 'none'.
45?S:.
46?T:shrpdir majonly majmin also xxx tmp_shrpenv
47?X: metalint gets confused and thinks we're actually setting LDOPTS
48?X: and LD_RUN_PATH.
49?LINT:extern LDOPTS
50?LINT:change LDOPTS
51?LINT:extern LD_RUN_PATH
52?LINT:change LD_RUN_PATH
53?LINT:change ccdlflags
54?LINT:extern maintloc maintname
55?Y:top
d9c563cf 56: Do we want a shared libperl?
959f3c4c
JH
57also=''
58case "$usedl" in
59$undef)
60 # No dynamic loading being used, so don't bother even to prompt.
61 useshrplib='false'
62 ;;
63*) case "$useshrplib" in
64 '') case "$osname" in
b880f9b6 65 svr4*|nonstopux|dgux|dynixptx|esix|powerux|beos|haiku|cygwin*)
959f3c4c
JH
66 dflt=y
67 also='Building a shared libperl is required for dynamic loading to work on your system.'
68 ;;
69 next*)
70 case "$osvers" in
71 4*) dflt=y
72 also='Building a shared libperl is needed for MAB support.'
73 ;;
74 *) dflt=n
75 ;;
76 esac
77 ;;
78 *) dflt=n
79 ;;
80 esac
81 ;;
82 $define|true|[Yy]*)
83 dflt=y
84 ;;
85 *) dflt=n
86 ;;
87 esac
88 $cat << EOM
89
90The perl executable is normally obtained by linking perlmain.c with
91libperl${_a}, any static extensions (usually just DynaLoader), and
92any other libraries needed on this system (such as -lm, etc.). Since
93your system supports dynamic loading, it is probably possible to build
94a shared libperl.$so. If you will have more than one executable linked
95to libperl.$so, this will significantly reduce the size of each
fc0fa78a 96executable, but it may have a noticeable effect on performance. The
959f3c4c
JH
97default is probably sensible for your system.
98$also
99
100EOM
101 rp="Build a shared libperl.$so (y/n)"
102 . ./myread
103 case "$ans" in
104 true|$define|[Yy]*)
105 useshrplib='true' ;;
106 *) useshrplib='false' ;;
107 esac
108 ;;
109esac
110
111case "$useshrplib" in
112true)
113 case "$libperl" in
114 '')
115 # Figure out a good name for libperl.so. Since it gets stored in
116 # a version-specific architecture-dependent library, the version
117 # number isn't really that important, except for making cc/ld happy.
118 #
cfba7844 119 # A name such as libperl.so.10.1
959f3c4c 120 majmin="libperl.$so.$patchlevel.$subversion"
cfba7844 121 # A name such as libperl.so.100
959f3c4c
JH
122 majonly=`echo $patchlevel $subversion |
123 $awk '{printf "%d%02d", $1, $2}'`
124 majonly=libperl.$so.$majonly
125 # I'd prefer to keep the os-specific stuff here to a minimum, and
126 # rely on figuring it out from the naming of libc.
127 case "${osname}${osvers}" in
128 next4*)
129 dflt=libperl.5.$so
130 # XXX How handle the --version stuff for MAB?
131 ;;
76ba8ff9 132 linux*|gnu*) # ld won't link with a bare -lperl otherwise.
959f3c4c
JH
133 dflt=libperl.$so
134 ;;
cfba7844
RU
135 cygwin*) # ld links now against the dll directly
136 majmin="cygperl5_${patchlevel}_${subversion}.${so}"
137 majonly=`echo $patchlevel $subversion |
138 $awk '{printf "%03d%03d", $1, $2}'`
139 majonly=cygperl5.$majonly.$so
140 dflt=$majmin
edd6115f 141 ;;
959f3c4c
JH
142 *) # Try to guess based on whether libc has major.minor.
143 case "$libc" in
144 *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
145 *libc.$so.[0-9]*) dflt=$majonly ;;
146 *) dflt=libperl.$so ;;
147 esac
148 ;;
149 esac
150 ;;
151 *) dflt=$libperl
152 ;;
153 esac
154 cat << EOM
155
156I need to select a good name for the shared libperl. If your system uses
157library names with major and minor numbers, then you might want something
158like $majmin. Alternatively, if your system uses a single version
159number for shared libraries, then you might want to use $majonly.
160Or, your system might be quite happy with a simple libperl.$so.
161
162Since the shared libperl will get installed into a version-specific
163architecture-dependent directory, the version number of the shared perl
164library probably isn't important, so the default should be o.k.
165
166EOM
167 rp='What name do you want to give to the shared libperl?'
168 . ./myread
169 libperl=$ans
170 echo "Ok, I'll use $libperl"
171 ;;
172*)
173 libperl="libperl${_a}"
174 ;;
175esac
176
177# Detect old use of shrpdir via undocumented Configure -Dshrpdir
178case "$shrpdir" in
179'') ;;
180*) $cat >&4 <<EOM
181WARNING: Use of the shrpdir variable for the installation location of
182the shared $libperl is not supported. It was never documented and
183will not work in this version. Let me (<$maintloc>)
184know of any problems this may cause.
185
186EOM
187 case "$shrpdir" in
188 "$archlibexp/CORE")
189 $cat >&4 <<EOM
190But your current setting of $shrpdir is
191the default anyway, so it's harmless.
192EOM
193 ;;
194 *)
195 $cat >&4 <<EOM
196Further, your current attempted setting of $shrpdir
197conflicts with the value of $archlibexp/CORE
198that installperl will use.
199EOM
200 ;;
201 esac
202 ;;
203esac
204
205# How will the perl executable find the installed shared $libperl?
206# Add $xxx to ccdlflags.
207# If we can't figure out a command-line option, use $shrpenv to
208# set env LD_RUN_PATH. The main perl makefile uses this.
209shrpdir=$archlibexp/CORE
210xxx=''
211tmp_shrpenv=''
212if "$useshrplib"; then
2f125bce 213 case "$osname" in
959f3c4c
JH
214 aix)
215 # We'll set it in Makefile.SH...
216 ;;
4d5de5cd 217 solaris)
959f3c4c
JH
218 xxx="-R $shrpdir"
219 ;;
d01e9330 220 freebsd|netbsd|openbsd|interix|dragonfly)
959f3c4c
JH
221 xxx="-Wl,-R$shrpdir"
222 ;;
76ba8ff9 223 bsdos|linux|irix*|dec_osf|gnu*)
959f3c4c
JH
224 xxx="-Wl,-rpath,$shrpdir"
225 ;;
226 next)
227 # next doesn't like the default...
228 ;;
229 beos)
230 # beos doesn't like the default, either.
231 ;;
b880f9b6
MB
232 haiku)
233 # Haiku doesn't like the default, either.
234 ;;
959f3c4c
JH
235 hpux*)
236 # hpux doesn't like the default, either.
237 tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
238 ;;
cfba7844
RU
239 cygwin)
240 # cygwin needs only ldlibpth
241 ;;
959f3c4c
JH
242 *)
243 tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
244 ;;
245 esac
246 case "$xxx" in
247 '') ;;
2f125bce 248 *)
959f3c4c
JH
249 # Only add $xxx if it isn't already in ccdlflags.
250 case " $ccdlflags " in
251 *" $xxx "*) ;;
252 *) ccdlflags="$ccdlflags $xxx"
253 cat <<EOM >&4
254
255Adding $xxx to the flags
2f125bce 256passed to $ld so that the perl executable will find the
959f3c4c
JH
257installed shared $libperl.
258
259EOM
260 ;;
261 esac
262 ;;
263 esac
264fi
265# Fix ccdlflags in AIX for building external extensions.
266# (For building Perl itself bare -bE:perl.exp is needed,
267# Makefile.SH takes care of this.)
268case "$osname" in
269aix) ccdlflags="$ccdlflags -bE:$installarchlib/CORE/perl.exp" ;;
270esac
271# Respect a hint or command-line value.
272case "$shrpenv" in
273'') shrpenv="$tmp_shrpenv" ;;
274esac
275case "$ldlibpthname" in
276'') ldlibpthname=LD_LIBRARY_PATH ;;
277none) ldlibpthname='' ;;
278esac
279