This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
When threads are active we need -lpthread, but previous `fix' of
[perl5.git] / hints / aix.sh
CommitLineData
1aef975c 1# hints/aix.sh
1aef975c 2
2463cec9
MB
3# AIX 3 and AIX 4 are split off to aix_3.sh and aix_4.sh
4# early Feb 2004 by H.Merijn Brand
5# please read comments in there for historic questions.
6# many now stripped here
7
bbc711f9
DF
8# Contact dfavor@corridor.com for any of the following:
9#
10# - AIX 43x and above support
11# - gcc + threads support
12# - socks support
13#
bbc711f9
DF
14# Notes:
15#
16# - shared libperl support is tricky. if ever libperl.a ends up
17# in /usr/local/lib/* it can override any subsequent builds of
18# that same perl release. to make sure you know where the shared
19# libperl.a is coming from do a 'dump -Hv perl' and check all the
20# library search paths in the loader header.
21#
22# it would be nice to warn the user if a libperl.a exists that is
23# going to override the current build, but that would be complex.
24#
25# better yet, a solid fix for this situation should be developed.
26#
1aef975c
AD
27
28# Configure finds setrgid and setruid, but they're useless. The man
29# pages state:
30# setrgid: The EPERM error code is always returned.
31# setruid: The EPERM error code is always returned. Processes cannot
4e774c84 32# reset only their real user IDs.
a0d0e21e
LW
33d_setrgid='undef'
34d_setruid='undef'
1aef975c 35
5f3774a9 36alignbytes=8
a5f75d66 37
86959918 38case "$usemymalloc" in
2463cec9
MB
39 '') usemymalloc='n' ;;
40 esac
bbc711f9
DF
41
42# Intuiting the existence of system calls under AIX is difficult,
43# at best; the safest technique is to find them empirically.
44
2463cec9
MB
45case "$usenativedlopen" in
46 '') usenativedlopen='true' ;;
47 esac
cc628cc3 48
3c321fdc 49so="a"
0d9ec2f4
JH
50# AIX itself uses .o (libc.o) but we prefer compatibility
51# with the rest of the world and with rest of the scripting
52# languages (Tcl, Python) and related systems (SWIG).
53# Stephanie Beals <bealzy@us.ibm.com>
54dlext="so"
3c321fdc 55
19e194ad
JH
56# Take possible hint from the environment. If 32-bit is set in the
57# environment, we can override it later. If set for 64, the
58# 'sizeof' test sees a native 64-bit architecture and never looks back.
59case "$OBJECT_MODE" in
2463cec9 60 32) cat >&4 <<EOF
19e194ad 61
2463cec9 62You have OBJECT_MODE=32 set in the environment.
19e194ad
JH
63I take this as a hint you do not want to
64build for a 64-bit address space. You will be
65given the opportunity to change this later.
66EOF
2463cec9
MB
67 ;;
68 64) cat >&4 <<EOF
19e194ad 69
2463cec9 70You have OBJECT_MODE=64 set in the environment.
19e194ad
JH
71This forces a full 64-bit build. If that is
72not what you intended, please terminate this
73program, unset it and restart.
74EOF
2463cec9
MB
75 ;;
76 esac
1aef975c
AD
77
78# uname -m output is too specific and not appropriate here
79case "$archname" in
2463cec9
MB
80 '') archname="$osname" ;;
81 esac
1aef975c 82
bd9b35c9
JH
83cc=${cc:-cc}
84
1c00c3fe
MB
85ccflags="$ccflags -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE"
86case "$cc" in
87 *gcc*) ;;
88 *) ccflags="$ccflags -qmaxmem=-1 -qnoansialias" ;;
80589958 89 esac
1c00c3fe 90nm_opt='-B'
1aef975c 91
bbc711f9
DF
92# These functions don't work like Perl expects them to.
93d_setregid='undef'
94d_setreuid='undef'
95
1aef975c 96# Changes for dynamic linking by Wayne Scott <wscott@ichips.intel.com>
a0d0e21e
LW
97#
98# Tell perl which symbols to export for dynamic linking.
411de0ab
MB
99cccdlflags='none' # All AIX code is position independent
100 cc_type=xlc # do not export to config.sh
4633a7c4 101case "$cc" in
2463cec9
MB
102 *gcc*)
103 cc_type=gcc
104 ccdlflags='-Xlinker'
105 if [ "X$gccversion" = "X" ]; then
106 # Done too late in Configure if hinted
107 gccversion=`$cc --version | sed 's/.*(GCC) *//'`
108 fi
2973cfbe 109 ;;
2463cec9
MB
110
111 *) ccversion=`lslpp -L | grep 'C for AIX Compiler$' | grep -v '\.msg\.[A-Za-z_]*\.' | head -1 | awk '{print $1,$2}'`
112 case "$ccversion" in
113 '') ccversion=`lslpp -L | grep 'IBM C and C++ Compilers LUM$'` ;;
114
115 *.*.*.*.*.*.*) # Ahhrgg, more than one C compiler installed
116 first_cc_path=`which ${cc:-cc}`
117 case "$first_cc_path" in
118 *vac*)
119 cc_type=vac ;;
120
121 /usr/bin/cc) # Check the symlink
122 if [ -h $first_cc_path ] ; then
123 ls -l $first_cc_path > reflect
124 if grep -i vac reflect >/dev/null 2>&1 ; then
125 cc_type=vac
126 fi
127 rm -f reflect
128 fi
129 ;;
130 esac
131 ccversion=`lslpp -L | grep 'C for AIX Compiler$' | grep -i $cc_type | head -1`
132 ;;
133
134 vac*.*.*.*)
135 cc_type=vac
136 ;;
137 esac
138
139 ccversion=`echo "$ccversion" | awk '{print $2}'`
140 # Redbooks state AIX-5 only supports vac-5.0.2.0 and up
6b356c8e 141 ;;
2463cec9
MB
142 esac
143
5f9d9a17
ME
144# the required -bE:$installarchlib/CORE/perl.exp is added by
145# libperl.U (Configure) later.
a0d0e21e 146
411de0ab
MB
147# The first 3 options would not be needed if dynamic libs. could be linked
148# with the compiler instead of ld.
149# -bI:$(PERL_INC)/perl.exp Read the exported symbols from the perl binary
150# -bE:$(BASEEXT).exp Export these symbols. This file contains only one
151# symbol: boot_$(EXP) can it be auto-generated?
1c00c3fe 152lddlflags="$lddlflags -bhalt:4 -bM:SRE -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc"
411de0ab 153
d002699e
MB
154case "$use64bitall" in
155 $define|true|[yY]*) use64bitint="$define" ;;
156 esac
157
158case "$usemorebits" in
159 $define|true|[yY]*) use64bitint="$define"; uselongdouble="$define" ;;
160 esac
161
162case $cc_type in
163 vac|xlc)
164 case "$uselongdouble" in
165 $define|true|[yY]*)
166 ccflags="$ccflags -qlongdouble"
167 libswanted="c128 $libswanted"
411de0ab 168 lddlflags=`echo "$lddlflags " | sed -e 's/ -lc / -lc128 -lc /'`
d002699e
MB
169 ;;
170 esac
2463cec9 171 ;;
d002699e
MB
172 esac
173
444379fb 174case "$cc" in
2463cec9
MB
175 *gcc*) ;;
176
177 cc*|xlc*) # cc should've been set by line 116 or so if empty.
444379fb 178 if test ! -x /usr/bin/$cc -a -x /usr/vac/bin/$cc; then
2463cec9 179 case ":$PATH:" in
444379fb 180 *:/usr/vac/bin:*) ;;
2463cec9 181 *) if test ! -x /QOpenSys/usr/bin/$cc; then
61074b56
JH
182 # The /QOpenSys/usr/bin/$cc saves us if we are
183 # building natively in OS/400 PASE.
e6604a4d 184 cat >&4 <<EOF
444379fb
JH
185
186***
187*** You either implicitly or explicitly specified an IBM C compiler,
188*** but you do not seem to have one in /usr/bin, but you seem to have
189*** the VAC installed in /usr/vac, but you do not have the /usr/vac/bin
190*** in your PATH. I suggest adding that and retrying Configure.
191***
192EOF
61074b56 193 exit 1
2463cec9
MB
194 fi
195 ;;
444379fb 196 esac
2463cec9 197 fi
444379fb 198 ;;
2463cec9 199 esac
444379fb 200
5cf1d1f1 201case "$ldlibpthname" in
2463cec9 202 '') ldlibpthname=LIBPATH ;;
3427abbf 203 esac
52e1cb5e 204
2463cec9 205# This script UU/usethreads.cbu will get 'called-back' by Configure
104d25b7
JH
206# after it has prompted the user for whether to use threads.
207cat > UU/usethreads.cbu <<'EOCBU'
208case "$usethreads" in
2463cec9
MB
209 $define|true|[yY]*)
210 d_drand48_r='undef'
211 d_endgrent_r='undef'
212 d_endpwent_r='undef'
213 d_getgrent_r='undef'
214 d_getpwent_r='undef'
215 d_random_r='undef'
216 d_setgrent_r='undef'
217 d_setpwent_r='undef'
218 d_srand48_r='undef'
219 d_strerror_r='undef'
220
4e774c84
SB
221 ccflags="$ccflags -DNEED_PTHREAD_INIT"
222 case "$cc" in
2463cec9
MB
223 *gcc*) ccflags="-D_THREAD_SAFE $ccflags" ;;
224
225 cc_r) ;;
226 cc|xl[cC]|xl[cC]_r)
227 echo >&4 "Switching cc to cc_r because of POSIX threads."
228 # xlc_r has been known to produce buggy code in AIX 4.3.2.
229 # (e.g. pragma/overload core dumps) Let's suspect xlC_r, too.
230 # --jhi@iki.fi
231 cc=cc_r
232 ;;
233
234 '') cc=cc_r ;;
235
236 *)
237 cat >&4 <<EOM
6b356c8e
JH
238*** For pthreads you should use the AIX C compiler cc_r.
239*** (now your compiler was set to '$cc')
240*** Cannot continue, aborting.
104d25b7 241EOM
2463cec9
MB
242 exit 1
243 ;;
244 esac
c88be79f
JH
245
246 # Insert pthreads to libswanted, before any libc or libC.
15173baf 247 set `echo X "$libswanted "| sed -e 's/ \([cC]\) / pthreads \1 /'`
c88be79f
JH
248 shift
249 libswanted="$*"
250 # Insert pthreads to lddlflags, before any libc or libC.
15173baf 251 set `echo X "$lddlflags " | sed -e 's/ \(-l[cC]\) / -lpthreads \1 /'`
c88be79f
JH
252 shift
253 lddlflags="$*"
104d25b7
JH
254 ;;
255esac
256EOCBU
fa9667c9 257
2463cec9 258# This script UU/uselargefiles.cbu will get 'called-back' by Configure
bd9b35c9 259# after it has prompted the user for whether to use large files.
8a647129 260cat > UU/uselargefiles.cbu <<'EOCBU'
bd9b35c9 261case "$uselargefiles" in
2463cec9
MB
262 ''|$define|true|[yY]*)
263 # Configure should take care of use64bitint and use64bitall being
264 # defined before uselargefiles.cbu is consulted.
265 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
21c7e20c
JH
266# Keep these at the left margin.
267ccflags_uselargefiles="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
268ldflags_uselargefiles="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
2463cec9 269 else
9422c00b 270# Keep these at the left margin.
45c9e83b
JH
271ccflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_CFLAGS 2>/dev/null`"
272ldflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LDFLAGS 2>/dev/null`"
2463cec9
MB
273 fi
274 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
21c7e20c
JH
275# Keep this at the left margin.
276libswanted_uselargefiles="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
2463cec9 277 else
9422c00b 278# Keep this at the left margin.
45c9e83b 279libswanted_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
2463cec9
MB
280 fi
281
45c9e83b 282 case "$ccflags_uselargefiles$ldflags_uselargefiles$libs_uselargefiles" in
2463cec9
MB
283 '') ;;
284 *) ccflags="$ccflags $ccflags_uselargefiles"
285 ldflags="$ldflags $ldflags_uselargefiles"
286 libswanted="$libswanted $libswanted_uselargefiles"
287 ;;
288 esac
6b8eaf93 289
2463cec9
MB
290 case "$gccversion" in
291 '') ;;
292 *) # Remove xlc-specific -qflags.
293 ccflags="`echo $ccflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
294 ldflags="`echo $ldflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
295 # Move xlc-specific -bflags.
296 ccflags="`echo $ccflags | sed -e 's@ -b@ -Wl,-b@g'`"
297 ldflags="`echo ' '$ldflags | sed -e 's@ -b@ -Wl,-b@g'`"
298 lddlflags="`echo ' '$lddlflags | sed -e 's@ -b@ -Wl,-b@g'`"
299 ld='gcc'
300 echo >&4 "(using ccflags $ccflags)"
301 echo >&4 "(using ldflags $ldflags)"
302 echo >&4 "(using lddlflags $lddlflags)"
efeaa891
JH
303 ;;
304 esac
2463cec9
MB
305 ;;
306 esac
19e194ad
JH
307EOCBU
308
19e194ad 309cat > UU/use64bitall.cbu <<'EOCBU'
2463cec9 310# This script UU/use64bitall.cbu will get 'called-back' by Configure
de6124c8 311# after it has prompted the user for whether to be maximally 64-bitty.
19e194ad 312case "$use64bitall" in
2463cec9
MB
313 $define|true|[yY]*)
314 echo " "
315 echo "Checking the CPU width of your hardware..." >&4
316 $cat >size.c <<EOCP
19e194ad
JH
317#include <stdio.h>
318#include <sys/systemcfg.h>
319int main (void)
320{
2463cec9
MB
321 printf ("%d\n", _system_configuration.width);
322 return (0);
323 }
19e194ad 324EOCP
2463cec9
MB
325 set size
326 if eval $compile_ok; then
327 qacpuwidth=`./size`
328 echo "You are running on $qacpuwidth bit hardware."
329 else
330 dflt="32"
331 echo " "
332 echo "(I can't seem to compile the test program. Guessing...)"
333 rp="What is the width of your CPU (in bits)?"
334 . ./myread
335 qacpuwidth="$ans"
19e194ad 336 fi
2463cec9
MB
337 $rm -f size.c size
338
339 case "$qacpuwidth" in
19e194ad
JH
340 32*)
341 cat >&4 <<EOM
342Bzzzt! At present, you can only perform a
343full 64-bit build on a 64-bit machine.
344EOM
345 exit 1
346 ;;
347 esac
2463cec9
MB
348 qacflags="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
349 qaldflags="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
350 # See jhi's comments above regarding this re-eval. I've
351 # seen similar weirdness in the form of:
352 #
19e194ad 353# 1506-173 (W) Option lm is not valid. Enter xlc for list of valid options.
2463cec9
MB
354 #
355 # error messages from 'cc -E' invocation. Again, the offending
356 # string is simply not detectable by any means. Since it doesn't
357 # do any harm, I didn't pursue it. -- sh
358 qaldflags="`echo $qaldflags`"
359 qalibs="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
360 # -q32 and -b32 may have been set by uselargefiles or user.
361 # Remove them.
362 ccflags="`echo $ccflags | sed -e 's@-q32@@'`"
363 ldflags="`echo $ldflags | sed -e 's@-b32@@'`"
364 # Tell archiver to use large format. Unless we remove 'ar'
365 # from 'trylist', the Configure script will just reset it to 'ar'
366 # immediately prior to writing config.sh. This took me hours
367 # to figure out.
368 trylist="`echo $trylist | sed -e 's@^ar @@' -e 's@ ar @ @g' -e 's@ ar$@@'`"
369 ar="ar -X64"
370 nm_opt="-X64 $nm_opt"
371 # Note: Placing the 'qacflags' variable into the 'ldflags' string
372 # is NOT a typo. ldflags is passed to the C compiler for final
373 # linking, and it wants -q64 (-b64 is for ld only!).
374 case "$qacflags$qaldflags$qalibs" in
375 '') ;;
376 *) ccflags="$ccflags $qacflags"
377 ldflags="$ldflags $qacflags"
378 lddlflags="$qaldflags $lddlflags"
379 libswanted="$libswanted $qalibs"
380 ;;
19e194ad 381 esac
2463cec9 382 case "$ccflags" in
19e194ad 383 *-DUSE_64_BIT_ALL*) ;;
2463cec9 384 *) ccflags="$ccflags -DUSE_64_BIT_ALL";;
19e194ad 385 esac
2463cec9 386 case "$archname64" in
19e194ad
JH
387 ''|64*) archname64=64all ;;
388 esac
2463cec9
MB
389 longsize="8"
390 qacflags=''
391 qaldflags=''
392 qalibs=''
393 qacpuwidth=''
394 ;;
395 esac
efeaa891 396EOCBU
5b877257 397
2463cec9 398if test $usenativedlopen = 'true' ; then
fd90a50d
MB
399 ccflags="$ccflags -DUSE_NATIVE_DLOPEN"
400 case "$cc" in
2463cec9
MB
401 *gcc*) ldflags="$ldflags -Wl,-brtl" ;;
402 *) ldflags="$ldflags -brtl" ;;
9d20a131 403 esac
2463cec9
MB
404elif test -f /lib/libC.a -a X"`$cc -v 2>&1 | grep gcc`" = X; then
405 # If the C++ libraries, libC and libC_r, are available we will
406 # prefer them over the vanilla libc, because the libC contain
407 # loadAndInit() and terminateAndUnload() which work correctly
408 # with C++ statics while libc load() and unload() do not. See
409 # ext/DynaLoader/dl_aix.xs. The C-to-C_r switch is done by
410 # usethreads.cbu, if needed.
411
412 # Cify libswanted.
413 set `echo X "$libswanted "| sed -e 's/ c / C c /'`
414 shift
415 libswanted="$*"
416 # Cify lddlflags.
417 set `echo X "$lddlflags "| sed -e 's/ -lc / -lC -lc /'`
418 shift
419 lddlflags="$*"
420 fi
4e774c84 421
522b859a 422case "$PASE" in
2463cec9 423 define)
522b859a 424 case "$prefix" in
2463cec9
MB
425 '') prefix=/QOpenSys/perl ;;
426 esac
522b859a
JH
427 cat >&4 <<EOF
428
429***
430*** You seem to be compiling in AIX for the OS/400 PASE environment.
431*** I'm not going to use the AIX bind, nsl, and possible util libraries, then.
432*** I'm also not going to install perl as /usr/bin/perl.
433*** Perl will be installed under $prefix.
434*** For instructions how to install this build from AIX to PASE,
435*** see the file README.os400. Accept the "aix" for the question
436*** about "Operating system name".
437***
438EOF
439 set `echo " $libswanted " | sed -e 's@ bind @ @' -e 's@ nsl @ @' -e 's@ util @ @'`
440 shift
441 libswanted="$*"
442 installusrbinperl="$undef"
abeab9d3
RGS
443
444 # V5R1 doesn't have this (V5R2 does), without knowing
445 # which one we have it's safer to be pessimistic.
446 # Cwd will work fine even without fchdir(), but if
447 # V5R1 tries to use code compiled assuming fchdir(),
448 # lots of grief will issue forth from Cwd.
449 case "$d_fchdir" in
2463cec9
MB
450 '') d_fchdir="$undef" ;;
451 esac
522b859a 452 ;;
2463cec9 453 esac
522b859a 454
5b877257 455# EOF