This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport #34126
[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 \
962b21ca 11 lib_ext 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
5bcf820f 65 svr4*|nonstopux|dgux|dynixptx|esix|powerux|beos|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 #
119 # A name such as libperl.so.3.1
120 majmin="libperl.$so.$patchlevel.$subversion"
121 # A name such as libperl.so.301
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 ;;
0ff30f53
JH
135 cygwin*) # ld links against an importlib
136 dflt=libperl$lib_ext
edd6115f 137 ;;
959f3c4c
JH
138 *) # Try to guess based on whether libc has major.minor.
139 case "$libc" in
140 *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
141 *libc.$so.[0-9]*) dflt=$majonly ;;
142 *) dflt=libperl.$so ;;
143 esac
144 ;;
145 esac
146 ;;
147 *) dflt=$libperl
148 ;;
149 esac
150 cat << EOM
151
152I need to select a good name for the shared libperl. If your system uses
153library names with major and minor numbers, then you might want something
154like $majmin. Alternatively, if your system uses a single version
155number for shared libraries, then you might want to use $majonly.
156Or, your system might be quite happy with a simple libperl.$so.
157
158Since the shared libperl will get installed into a version-specific
159architecture-dependent directory, the version number of the shared perl
160library probably isn't important, so the default should be o.k.
161
162EOM
163 rp='What name do you want to give to the shared libperl?'
164 . ./myread
165 libperl=$ans
166 echo "Ok, I'll use $libperl"
167 ;;
168*)
169 libperl="libperl${_a}"
170 ;;
171esac
172
173# Detect old use of shrpdir via undocumented Configure -Dshrpdir
174case "$shrpdir" in
175'') ;;
176*) $cat >&4 <<EOM
177WARNING: Use of the shrpdir variable for the installation location of
178the shared $libperl is not supported. It was never documented and
179will not work in this version. Let me (<$maintloc>)
180know of any problems this may cause.
181
182EOM
183 case "$shrpdir" in
184 "$archlibexp/CORE")
185 $cat >&4 <<EOM
186But your current setting of $shrpdir is
187the default anyway, so it's harmless.
188EOM
189 ;;
190 *)
191 $cat >&4 <<EOM
192Further, your current attempted setting of $shrpdir
193conflicts with the value of $archlibexp/CORE
194that installperl will use.
195EOM
196 ;;
197 esac
198 ;;
199esac
200
201# How will the perl executable find the installed shared $libperl?
202# Add $xxx to ccdlflags.
203# If we can't figure out a command-line option, use $shrpenv to
204# set env LD_RUN_PATH. The main perl makefile uses this.
205shrpdir=$archlibexp/CORE
206xxx=''
207tmp_shrpenv=''
208if "$useshrplib"; then
2f125bce 209 case "$osname" in
959f3c4c
JH
210 aix)
211 # We'll set it in Makefile.SH...
212 ;;
4d5de5cd 213 solaris)
959f3c4c
JH
214 xxx="-R $shrpdir"
215 ;;
d01e9330 216 freebsd|netbsd|openbsd|interix|dragonfly)
959f3c4c
JH
217 xxx="-Wl,-R$shrpdir"
218 ;;
76ba8ff9 219 bsdos|linux|irix*|dec_osf|gnu*)
959f3c4c
JH
220 xxx="-Wl,-rpath,$shrpdir"
221 ;;
222 next)
223 # next doesn't like the default...
224 ;;
225 beos)
226 # beos doesn't like the default, either.
227 ;;
228 hpux*)
229 # hpux doesn't like the default, either.
230 tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
231 ;;
232 *)
233 tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
234 ;;
235 esac
236 case "$xxx" in
237 '') ;;
2f125bce 238 *)
959f3c4c
JH
239 # Only add $xxx if it isn't already in ccdlflags.
240 case " $ccdlflags " in
241 *" $xxx "*) ;;
242 *) ccdlflags="$ccdlflags $xxx"
243 cat <<EOM >&4
244
245Adding $xxx to the flags
2f125bce 246passed to $ld so that the perl executable will find the
959f3c4c
JH
247installed shared $libperl.
248
249EOM
250 ;;
251 esac
252 ;;
253 esac
254fi
255# Fix ccdlflags in AIX for building external extensions.
256# (For building Perl itself bare -bE:perl.exp is needed,
257# Makefile.SH takes care of this.)
258case "$osname" in
259aix) ccdlflags="$ccdlflags -bE:$installarchlib/CORE/perl.exp" ;;
260esac
261# Respect a hint or command-line value.
262case "$shrpenv" in
263'') shrpenv="$tmp_shrpenv" ;;
264esac
265case "$ldlibpthname" in
266'') ldlibpthname=LD_LIBRARY_PATH ;;
267none) ldlibpthname='' ;;
268esac
269