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