This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport 232083c091a7dd8f390a1735f72256cf82491726
[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 \
ce87fced 11 ccdlflags installarchlib userelocatableinc
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
a3c22f16 65 svr4*|nonstopux|dgux|dynixptx|esix|powerux|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)
ce87fced
MB
113 case "$userelocatableinc" in
114 true|define)
115 echo "Cannot build with both -Duserelocatableinc and -Duseshrplib" >&4
116 echo "See INSTALL for an explanation why that won't work." >&4
117 exit 4
118 ;;
119 esac
959f3c4c
JH
120 case "$libperl" in
121 '')
122 # Figure out a good name for libperl.so. Since it gets stored in
123 # a version-specific architecture-dependent library, the version
124 # number isn't really that important, except for making cc/ld happy.
125 #
cfba7844 126 # A name such as libperl.so.10.1
959f3c4c 127 majmin="libperl.$so.$patchlevel.$subversion"
cfba7844 128 # A name such as libperl.so.100
959f3c4c
JH
129 majonly=`echo $patchlevel $subversion |
130 $awk '{printf "%d%02d", $1, $2}'`
131 majonly=libperl.$so.$majonly
132 # I'd prefer to keep the os-specific stuff here to a minimum, and
133 # rely on figuring it out from the naming of libc.
134 case "${osname}${osvers}" in
135 next4*)
136 dflt=libperl.5.$so
137 # XXX How handle the --version stuff for MAB?
138 ;;
76ba8ff9 139 linux*|gnu*) # ld won't link with a bare -lperl otherwise.
959f3c4c
JH
140 dflt=libperl.$so
141 ;;
cfba7844
RU
142 cygwin*) # ld links now against the dll directly
143 majmin="cygperl5_${patchlevel}_${subversion}.${so}"
144 majonly=`echo $patchlevel $subversion |
145 $awk '{printf "%03d%03d", $1, $2}'`
146 majonly=cygperl5.$majonly.$so
147 dflt=$majmin
edd6115f 148 ;;
959f3c4c
JH
149 *) # Try to guess based on whether libc has major.minor.
150 case "$libc" in
151 *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
152 *libc.$so.[0-9]*) dflt=$majonly ;;
153 *) dflt=libperl.$so ;;
154 esac
155 ;;
156 esac
157 ;;
158 *) dflt=$libperl
159 ;;
160 esac
161 cat << EOM
162
163I need to select a good name for the shared libperl. If your system uses
164library names with major and minor numbers, then you might want something
165like $majmin. Alternatively, if your system uses a single version
166number for shared libraries, then you might want to use $majonly.
167Or, your system might be quite happy with a simple libperl.$so.
168
169Since the shared libperl will get installed into a version-specific
170architecture-dependent directory, the version number of the shared perl
171library probably isn't important, so the default should be o.k.
172
173EOM
174 rp='What name do you want to give to the shared libperl?'
175 . ./myread
176 libperl=$ans
177 echo "Ok, I'll use $libperl"
178 ;;
179*)
180 libperl="libperl${_a}"
181 ;;
182esac
183
184# Detect old use of shrpdir via undocumented Configure -Dshrpdir
185case "$shrpdir" in
186'') ;;
187*) $cat >&4 <<EOM
188WARNING: Use of the shrpdir variable for the installation location of
189the shared $libperl is not supported. It was never documented and
190will not work in this version. Let me (<$maintloc>)
191know of any problems this may cause.
192
193EOM
194 case "$shrpdir" in
195 "$archlibexp/CORE")
196 $cat >&4 <<EOM
197But your current setting of $shrpdir is
198the default anyway, so it's harmless.
199EOM
200 ;;
201 *)
202 $cat >&4 <<EOM
203Further, your current attempted setting of $shrpdir
204conflicts with the value of $archlibexp/CORE
205that installperl will use.
206EOM
207 ;;
208 esac
209 ;;
210esac
211
212# How will the perl executable find the installed shared $libperl?
213# Add $xxx to ccdlflags.
214# If we can't figure out a command-line option, use $shrpenv to
215# set env LD_RUN_PATH. The main perl makefile uses this.
216shrpdir=$archlibexp/CORE
217xxx=''
218tmp_shrpenv=''
219if "$useshrplib"; then
2f125bce 220 case "$osname" in
959f3c4c
JH
221 aix)
222 # We'll set it in Makefile.SH...
223 ;;
4d5de5cd 224 solaris)
959f3c4c
JH
225 xxx="-R $shrpdir"
226 ;;
4641839d 227 freebsd|mirbsd|netbsd|openbsd|interix|dragonfly)
959f3c4c
JH
228 xxx="-Wl,-R$shrpdir"
229 ;;
76ba8ff9 230 bsdos|linux|irix*|dec_osf|gnu*)
959f3c4c
JH
231 xxx="-Wl,-rpath,$shrpdir"
232 ;;
233 next)
234 # next doesn't like the default...
235 ;;
b880f9b6
MB
236 haiku)
237 # Haiku doesn't like the default, either.
238 ;;
959f3c4c
JH
239 hpux*)
240 # hpux doesn't like the default, either.
241 tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
242 ;;
cfba7844
RU
243 cygwin)
244 # cygwin needs only ldlibpth
245 ;;
959f3c4c
JH
246 *)
247 tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
248 ;;
249 esac
250 case "$xxx" in
251 '') ;;
2f125bce 252 *)
959f3c4c
JH
253 # Only add $xxx if it isn't already in ccdlflags.
254 case " $ccdlflags " in
255 *" $xxx "*) ;;
256 *) ccdlflags="$ccdlflags $xxx"
257 cat <<EOM >&4
258
259Adding $xxx to the flags
2f125bce 260passed to $ld so that the perl executable will find the
959f3c4c
JH
261installed shared $libperl.
262
263EOM
264 ;;
265 esac
266 ;;
267 esac
268fi
269# Fix ccdlflags in AIX for building external extensions.
270# (For building Perl itself bare -bE:perl.exp is needed,
271# Makefile.SH takes care of this.)
272case "$osname" in
273aix) ccdlflags="$ccdlflags -bE:$installarchlib/CORE/perl.exp" ;;
274esac
275# Respect a hint or command-line value.
276case "$shrpenv" in
277'') shrpenv="$tmp_shrpenv" ;;
278esac
279case "$ldlibpthname" in
280'') ldlibpthname=LD_LIBRARY_PATH ;;
281none) ldlibpthname='' ;;
282esac
283