fix 64-bit casting error in change 22741 (uninit var warnings)
[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
da0b61dd 42# malloc wrap works
43case "$usemallocwrap" in
44'') usemallocwrap='define' ;;
45esac
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
6b356c8e 146 ;;
2463cec9 147 esac
148
5f9d9a17 149# the required -bE:$installarchlib/CORE/perl.exp is added by
150# libperl.U (Configure) later.
a0d0e21e 151
411de0ab 152# The first 3 options would not be needed if dynamic libs. could be linked
153# with the compiler instead of ld.
154# -bI:$(PERL_INC)/perl.exp Read the exported symbols from the perl binary
155# -bE:$(BASEEXT).exp Export these symbols. This file contains only one
156# symbol: boot_$(EXP) can it be auto-generated?
1c00c3fe 157lddlflags="$lddlflags -bhalt:4 -bM:SRE -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc"
411de0ab 158
d002699e 159case "$use64bitall" in
160 $define|true|[yY]*) use64bitint="$define" ;;
161 esac
162
163case "$usemorebits" in
164 $define|true|[yY]*) use64bitint="$define"; uselongdouble="$define" ;;
165 esac
166
167case $cc_type in
168 vac|xlc)
169 case "$uselongdouble" in
170 $define|true|[yY]*)
171 ccflags="$ccflags -qlongdouble"
172 libswanted="c128 $libswanted"
411de0ab 173 lddlflags=`echo "$lddlflags " | sed -e 's/ -lc / -lc128 -lc /'`
d002699e 174 ;;
175 esac
2463cec9 176 ;;
d002699e 177 esac
178
444379fb 179case "$cc" in
2463cec9 180 *gcc*) ;;
181
182 cc*|xlc*) # cc should've been set by line 116 or so if empty.
444379fb 183 if test ! -x /usr/bin/$cc -a -x /usr/vac/bin/$cc; then
2463cec9 184 case ":$PATH:" in
444379fb 185 *:/usr/vac/bin:*) ;;
2463cec9 186 *) if test ! -x /QOpenSys/usr/bin/$cc; then
61074b56 187 # The /QOpenSys/usr/bin/$cc saves us if we are
188 # building natively in OS/400 PASE.
e6604a4d 189 cat >&4 <<EOF
444379fb 190
191***
192*** You either implicitly or explicitly specified an IBM C compiler,
193*** but you do not seem to have one in /usr/bin, but you seem to have
194*** the VAC installed in /usr/vac, but you do not have the /usr/vac/bin
195*** in your PATH. I suggest adding that and retrying Configure.
196***
197EOF
61074b56 198 exit 1
2463cec9 199 fi
200 ;;
444379fb 201 esac
2463cec9 202 fi
444379fb 203 ;;
2463cec9 204 esac
444379fb 205
5cf1d1f1 206case "$ldlibpthname" in
2463cec9 207 '') ldlibpthname=LIBPATH ;;
3427abbf 208 esac
52e1cb5e 209
2463cec9 210# This script UU/usethreads.cbu will get 'called-back' by Configure
104d25b7 211# after it has prompted the user for whether to use threads.
212cat > UU/usethreads.cbu <<'EOCBU'
213case "$usethreads" in
2463cec9 214 $define|true|[yY]*)
215 d_drand48_r='undef'
216 d_endgrent_r='undef'
217 d_endpwent_r='undef'
218 d_getgrent_r='undef'
219 d_getpwent_r='undef'
220 d_random_r='undef'
221 d_setgrent_r='undef'
222 d_setpwent_r='undef'
223 d_srand48_r='undef'
224 d_strerror_r='undef'
225
4e774c84 226 ccflags="$ccflags -DNEED_PTHREAD_INIT"
227 case "$cc" in
2463cec9 228 *gcc*) ccflags="-D_THREAD_SAFE $ccflags" ;;
229
230 cc_r) ;;
231 cc|xl[cC]|xl[cC]_r)
232 echo >&4 "Switching cc to cc_r because of POSIX threads."
233 # xlc_r has been known to produce buggy code in AIX 4.3.2.
234 # (e.g. pragma/overload core dumps) Let's suspect xlC_r, too.
235 # --jhi@iki.fi
236 cc=cc_r
237 ;;
238
239 '') cc=cc_r ;;
240
241 *)
242 cat >&4 <<EOM
6b356c8e 243*** For pthreads you should use the AIX C compiler cc_r.
244*** (now your compiler was set to '$cc')
245*** Cannot continue, aborting.
104d25b7 246EOM
2463cec9 247 exit 1
248 ;;
249 esac
c88be79f 250
251 # Insert pthreads to libswanted, before any libc or libC.
15173baf 252 set `echo X "$libswanted "| sed -e 's/ \([cC]\) / pthreads \1 /'`
c88be79f 253 shift
254 libswanted="$*"
255 # Insert pthreads to lddlflags, before any libc or libC.
15173baf 256 set `echo X "$lddlflags " | sed -e 's/ \(-l[cC]\) / -lpthreads \1 /'`
c88be79f 257 shift
258 lddlflags="$*"
104d25b7 259 ;;
260esac
261EOCBU
fa9667c9 262
2463cec9 263# This script UU/uselargefiles.cbu will get 'called-back' by Configure
bd9b35c9 264# after it has prompted the user for whether to use large files.
8a647129 265cat > UU/uselargefiles.cbu <<'EOCBU'
bd9b35c9 266case "$uselargefiles" in
2463cec9 267 ''|$define|true|[yY]*)
268 # Configure should take care of use64bitint and use64bitall being
269 # defined before uselargefiles.cbu is consulted.
270 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
21c7e20c 271# Keep these at the left margin.
272ccflags_uselargefiles="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
273ldflags_uselargefiles="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
2463cec9 274 else
9422c00b 275# Keep these at the left margin.
45c9e83b 276ccflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_CFLAGS 2>/dev/null`"
277ldflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LDFLAGS 2>/dev/null`"
2463cec9 278 fi
279 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
21c7e20c 280# Keep this at the left margin.
281libswanted_uselargefiles="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
2463cec9 282 else
9422c00b 283# Keep this at the left margin.
45c9e83b 284libswanted_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
2463cec9 285 fi
286
45c9e83b 287 case "$ccflags_uselargefiles$ldflags_uselargefiles$libs_uselargefiles" in
2463cec9 288 '') ;;
289 *) ccflags="$ccflags $ccflags_uselargefiles"
290 ldflags="$ldflags $ldflags_uselargefiles"
291 libswanted="$libswanted $libswanted_uselargefiles"
292 ;;
293 esac
6b8eaf93 294
2463cec9 295 case "$gccversion" in
296 '') ;;
297 *) # Remove xlc-specific -qflags.
298 ccflags="`echo $ccflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
299 ldflags="`echo $ldflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
300 # Move xlc-specific -bflags.
301 ccflags="`echo $ccflags | sed -e 's@ -b@ -Wl,-b@g'`"
302 ldflags="`echo ' '$ldflags | sed -e 's@ -b@ -Wl,-b@g'`"
303 lddlflags="`echo ' '$lddlflags | sed -e 's@ -b@ -Wl,-b@g'`"
304 ld='gcc'
305 echo >&4 "(using ccflags $ccflags)"
306 echo >&4 "(using ldflags $ldflags)"
307 echo >&4 "(using lddlflags $lddlflags)"
efeaa891 308 ;;
309 esac
2463cec9 310 ;;
311 esac
19e194ad 312EOCBU
313
19e194ad 314cat > UU/use64bitall.cbu <<'EOCBU'
2463cec9 315# This script UU/use64bitall.cbu will get 'called-back' by Configure
de6124c8 316# after it has prompted the user for whether to be maximally 64-bitty.
19e194ad 317case "$use64bitall" in
2463cec9 318 $define|true|[yY]*)
319 echo " "
320 echo "Checking the CPU width of your hardware..." >&4
321 $cat >size.c <<EOCP
19e194ad 322#include <stdio.h>
323#include <sys/systemcfg.h>
324int main (void)
325{
2463cec9 326 printf ("%d\n", _system_configuration.width);
327 return (0);
328 }
19e194ad 329EOCP
2463cec9 330 set size
331 if eval $compile_ok; then
332 qacpuwidth=`./size`
333 echo "You are running on $qacpuwidth bit hardware."
334 else
335 dflt="32"
336 echo " "
337 echo "(I can't seem to compile the test program. Guessing...)"
338 rp="What is the width of your CPU (in bits)?"
339 . ./myread
340 qacpuwidth="$ans"
19e194ad 341 fi
2463cec9 342 $rm -f size.c size
343
344 case "$qacpuwidth" in
19e194ad 345 32*)
346 cat >&4 <<EOM
347Bzzzt! At present, you can only perform a
348full 64-bit build on a 64-bit machine.
349EOM
350 exit 1
351 ;;
352 esac
2463cec9 353 qacflags="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
354 qaldflags="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
355 # See jhi's comments above regarding this re-eval. I've
356 # seen similar weirdness in the form of:
357 #
19e194ad 358# 1506-173 (W) Option lm is not valid. Enter xlc for list of valid options.
2463cec9 359 #
360 # error messages from 'cc -E' invocation. Again, the offending
361 # string is simply not detectable by any means. Since it doesn't
362 # do any harm, I didn't pursue it. -- sh
363 qaldflags="`echo $qaldflags`"
364 qalibs="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
365 # -q32 and -b32 may have been set by uselargefiles or user.
366 # Remove them.
367 ccflags="`echo $ccflags | sed -e 's@-q32@@'`"
368 ldflags="`echo $ldflags | sed -e 's@-b32@@'`"
369 # Tell archiver to use large format. Unless we remove 'ar'
370 # from 'trylist', the Configure script will just reset it to 'ar'
371 # immediately prior to writing config.sh. This took me hours
372 # to figure out.
373 trylist="`echo $trylist | sed -e 's@^ar @@' -e 's@ ar @ @g' -e 's@ ar$@@'`"
374 ar="ar -X64"
375 nm_opt="-X64 $nm_opt"
376 # Note: Placing the 'qacflags' variable into the 'ldflags' string
377 # is NOT a typo. ldflags is passed to the C compiler for final
378 # linking, and it wants -q64 (-b64 is for ld only!).
379 case "$qacflags$qaldflags$qalibs" in
380 '') ;;
381 *) ccflags="$ccflags $qacflags"
382 ldflags="$ldflags $qacflags"
383 lddlflags="$qaldflags $lddlflags"
384 libswanted="$libswanted $qalibs"
385 ;;
19e194ad 386 esac
2463cec9 387 case "$ccflags" in
19e194ad 388 *-DUSE_64_BIT_ALL*) ;;
2463cec9 389 *) ccflags="$ccflags -DUSE_64_BIT_ALL";;
19e194ad 390 esac
2463cec9 391 case "$archname64" in
19e194ad 392 ''|64*) archname64=64all ;;
393 esac
2463cec9 394 longsize="8"
395 qacflags=''
396 qaldflags=''
397 qalibs=''
398 qacpuwidth=''
399 ;;
400 esac
efeaa891 401EOCBU
5b877257 402
2463cec9 403if test $usenativedlopen = 'true' ; then
fd90a50d 404 ccflags="$ccflags -DUSE_NATIVE_DLOPEN"
405 case "$cc" in
2463cec9 406 *gcc*) ldflags="$ldflags -Wl,-brtl" ;;
407 *) ldflags="$ldflags -brtl" ;;
9d20a131 408 esac
2463cec9 409elif test -f /lib/libC.a -a X"`$cc -v 2>&1 | grep gcc`" = X; then
410 # If the C++ libraries, libC and libC_r, are available we will
411 # prefer them over the vanilla libc, because the libC contain
412 # loadAndInit() and terminateAndUnload() which work correctly
413 # with C++ statics while libc load() and unload() do not. See
414 # ext/DynaLoader/dl_aix.xs. The C-to-C_r switch is done by
415 # usethreads.cbu, if needed.
416
417 # Cify libswanted.
418 set `echo X "$libswanted "| sed -e 's/ c / C c /'`
419 shift
420 libswanted="$*"
421 # Cify lddlflags.
422 set `echo X "$lddlflags "| sed -e 's/ -lc / -lC -lc /'`
423 shift
424 lddlflags="$*"
425 fi
4e774c84 426
522b859a 427case "$PASE" in
2463cec9 428 define)
522b859a 429 case "$prefix" in
2463cec9 430 '') prefix=/QOpenSys/perl ;;
431 esac
522b859a 432 cat >&4 <<EOF
433
434***
435*** You seem to be compiling in AIX for the OS/400 PASE environment.
436*** I'm not going to use the AIX bind, nsl, and possible util libraries, then.
437*** I'm also not going to install perl as /usr/bin/perl.
438*** Perl will be installed under $prefix.
439*** For instructions how to install this build from AIX to PASE,
440*** see the file README.os400. Accept the "aix" for the question
441*** about "Operating system name".
442***
443EOF
444 set `echo " $libswanted " | sed -e 's@ bind @ @' -e 's@ nsl @ @' -e 's@ util @ @'`
445 shift
446 libswanted="$*"
447 installusrbinperl="$undef"
abeab9d3 448
449 # V5R1 doesn't have this (V5R2 does), without knowing
450 # which one we have it's safer to be pessimistic.
451 # Cwd will work fine even without fchdir(), but if
452 # V5R1 tries to use code compiled assuming fchdir(),
453 # lots of grief will issue forth from Cwd.
454 case "$d_fchdir" in
2463cec9 455 '') d_fchdir="$undef" ;;
456 esac
522b859a 457 ;;
2463cec9 458 esac
522b859a 459
5b877257 460# EOF