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
8 # Contact dfavor@corridor.com for any of the following:
10 # - AIX 43x and above support
11 # - gcc + threads support
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.
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.
25 # better yet, a solid fix for this situation should be developed.
28 # Configure finds setrgid and setruid, but they're useless. The man
30 # setrgid: The EPERM error code is always returned.
31 # setruid: The EPERM error code is always returned. Processes cannot
32 # reset only their real user IDs.
37 case "$usemymalloc" in
38 '') usemymalloc='n' ;;
41 # malloc wrap works, but not in vac-5, see later
42 case "$usemallocwrap" in
43 '') usemallocwrap='define' ;;
46 # Intuiting the existence of system calls under AIX is difficult,
47 # at best; the safest technique is to find them empirically.
49 case "$usenativedlopen" in
50 '') usenativedlopen='true' ;;
54 # AIX itself uses .o (libc.o) but we prefer compatibility
55 # with the rest of the world and with rest of the scripting
56 # languages (Tcl, Python) and related systems (SWIG).
57 # Stephanie Beals <bealzy@us.ibm.com>
60 # Take possible hint from the environment. If 32-bit is set in the
61 # environment, we can override it later. If set for 64, the
62 # 'sizeof' test sees a native 64-bit architecture and never looks back.
63 case "$OBJECT_MODE" in
66 You have OBJECT_MODE=32 set in the environment.
67 I take this as a hint you do not want to
68 build for a 64-bit address space. You will be
69 given the opportunity to change this later.
74 You have OBJECT_MODE=64 set in the environment.
75 This forces a full 64-bit build. If that is
76 not what you intended, please terminate this
77 program, unset it and restart.
82 s=`lslpp -lc bos.adt.libm >/dev/null`
84 echo "You cannot build perl without the bos.adt.libm package installed" >&4
88 # uname -m output is too specific and not appropriate here
90 '') archname="$osname" ;;
95 ccflags="$ccflags -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE"
98 *) ccflags="$ccflags -qmaxmem=-1 -qnoansialias -qlanglvl=extc99" ;;
102 # These functions don't work like Perl expects them to.
106 # Changes for dynamic linking by Wayne Scott <wscott@ichips.intel.com>
108 # Tell perl which symbols to export for dynamic linking.
109 cccdlflags='none' # All AIX code is position independent
110 cc_type=xlc # do not export to config.sh
115 if [ "X$gccversion" = "X" ]; then
116 # Done too late in Configure if hinted
117 gccversion=`$cc -dumpversion`
121 *) ccversion=`lslpp -ql -Ou vac.C | grep -v '^Path' | head -1 | awk '{print $1,$2}'`
123 '') ccversion=`lslpp -L | grep 'IBM C and C++ Compilers LUM$'` ;;
125 *.*.*.*.*.*.*) # Ahhrgg, more than one C compiler installed
126 first_cc_path=`which ${cc:-cc}`
127 case "$first_cc_path" in
131 /usr/bin/cc) # Check the symlink
132 if [ -h $first_cc_path ] ; then
133 ls -l $first_cc_path > reflect
134 if grep -i vac reflect >/dev/null 2>&1 ; then
141 ccversion=`lslpp -L | grep 'C for AIX Compiler$' | grep -i $cc_type | head -1`
149 ccversion=`echo "$ccversion" | awk '{print $2}'`
150 # Redbooks state AIX-5 only supports vac-5.0.2.0 and up
152 5*) usemallocwrap='n' ;; # panic in miniperl
157 # the required -bE:$installarchlib/CORE/perl.exp is added by
158 # libperl.U (Configure) later.
160 # The first 3 options would not be needed if dynamic libs. could be linked
161 # with the compiler instead of ld.
162 # -bI:$(PERL_INC)/perl.exp Read the exported symbols from the perl binary
163 # -bE:$(BASEEXT).exp Export these symbols. This file contains only one
164 # symbol: boot_$(EXP) can it be auto-generated?
165 if test $usenativedlopen = 'true' ; then
166 lddlflags="$lddlflags -bhalt:4 -G -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc -lm"
168 lddlflags="$lddlflags -bhalt:4 -bM:SRE -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc"
171 case "$use64bitall" in
172 $define|true|[yY]*) use64bitint="$define" ;;
175 case "$usemorebits" in
176 $define|true|[yY]*) use64bitint="$define"; uselongdouble="$define" ;;
181 case "$uselongdouble" in
183 ccflags="$ccflags -qlongdouble"
184 libswanted="c128 $libswanted"
185 lddlflags=`echo "$lddlflags " | sed -e 's/ -lc / -lc128 -lc /'`
194 cc*|xlc*) # cc should've been set by line 116 or so if empty.
195 if test ! -x /usr/bin/$cc -a -x /usr/vac/bin/$cc; then
198 *) if test ! -x /QOpenSys/usr/bin/$cc; then
199 # The /QOpenSys/usr/bin/$cc saves us if we are
200 # building natively in OS/400 PASE.
204 *** You either implicitly or explicitly specified an IBM C compiler,
205 *** but you do not seem to have one in /usr/bin, but you seem to have
206 *** the VAC installed in /usr/vac, but you do not have the /usr/vac/bin
207 *** in your PATH. I suggest adding that and retrying Configure.
218 case "$ldlibpthname" in
219 '') ldlibpthname=LIBPATH ;;
222 # This script UU/usethreads.cbu will get 'called-back' by Configure
223 # after it has prompted the user for whether to use threads.
224 cat > UU/usethreads.cbu <<'EOCBU'
225 case "$usethreads" in
239 ccflags="$ccflags -DNEED_PTHREAD_INIT"
242 ccflags="-D_THREAD_SAFE $ccflags"
248 # we do not need the C++ compiler
258 # Insert pthreads to libswanted, before any libc or libC.
259 set `echo X "$libswanted "| sed -e 's/ \([cC]\) / pthreads \1 /'`
262 # Insert pthreads to lddlflags, before any libc or libC.
263 set `echo X "$lddlflags " | sed -e 's/ \(-l[cC]\) / -lpthreads \1 /'`
271 # we do not need the C++ compiler
281 # This script UU/uselargefiles.cbu will get 'called-back' by Configure
282 # after it has prompted the user for whether to use large files.
283 cat > UU/uselargefiles.cbu <<'EOCBU'
284 case "$uselargefiles" in
285 ''|$define|true|[yY]*)
286 # Configure should take care of use64bitint and use64bitall being
287 # defined before uselargefiles.cbu is consulted.
288 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
289 # Keep these at the left margin.
290 ccflags_uselargefiles="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
291 ldflags_uselargefiles="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
293 # Keep these at the left margin.
294 ccflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_CFLAGS 2>/dev/null`"
295 ldflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LDFLAGS 2>/dev/null`"
297 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
298 # Keep this at the left margin.
299 libswanted_uselargefiles="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
301 # Keep this at the left margin.
302 libswanted_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
305 case "$ccflags_uselargefiles$ldflags_uselargefiles$libs_uselargefiles" in
307 *) ccflags="$ccflags $ccflags_uselargefiles"
308 ldflags="$ldflags $ldflags_uselargefiles"
309 libswanted="$libswanted $libswanted_uselargefiles"
313 # -bmaxdata:0x80000000
314 # - This increases the size of heap memory available to perl.
315 # Default is 256 MB, which sounds large but caused a software
316 # vendor problems. So this sets heap to 2 GB maximum. Anything
317 # higher and you'd want to consider 64 bit perl.
318 # - NOTE however, that setting this in 64bit mode will limit your
319 # amount of available memory to 2GB, so we set this only in
320 # 32bit mode to avoid future problems a la "should be enough
323 case "$use64bitall" in
328 ldflags="$ldflags -bmaxdata:0x80000000"
332 case "$gccversion" in
334 # Due to calling $cc without $cflags when linking some
335 # binaries we need to hardwire $cc to the right mode.
336 # The correct fix would be to have Makefile.SH not set
337 # CLDFLAGS from $ldflags ...
338 case "$use64bitall" in
339 $define|true|[yY]*) cc="$cc -q64" ;;
342 # Some 32-bit getconfs will set ccflags to include -qlonglong
343 # but that's no longer needed with an explicit -qextc99.
344 ccflags="`echo $ccflags | sed -e 's@ -qlonglong@@'`"
346 *) # Remove xlc-specific -qflags.
347 ccflags="`echo $ccflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
348 ldflags="`echo $ldflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
349 # Move xlc-specific -bflags.
350 ccflags="`echo $ccflags | sed -e 's@ -b@ -Wl,-b@g'`"
351 ldflags="`echo ' '$ldflags | sed -e 's@ -b@ -Wl,-b@g'`"
352 lddlflags="`echo ' '$lddlflags | sed -e 's@ -b@ -Wl,-b@g'`"
353 lddlflags="`echo ' '$lddlflags | sed -e 's@ -G @ -Wl,-G @g'`"
355 # Due to calling $cc without $cflags when linking some
356 # binaries we need to hardwire $cc to the right mode.
357 case "$use64bitall" in
367 echo >&4 "(using ccflags $ccflags)"
368 echo >&4 "(using ldflags $ldflags)"
369 echo >&4 "(using lddlflags $lddlflags)"
376 cat > UU/use64bitall.cbu <<'EOCBU'
377 # This script UU/use64bitall.cbu will get 'called-back' by Configure
378 # after it has prompted the user for whether to be maximally 64-bitty.
379 case "$use64bitall" in
382 echo "Checking the CPU width of your hardware..." >&4
385 #include <sys/systemcfg.h>
388 printf ("%d\n", _system_configuration.width);
393 if eval $compile_ok; then
395 echo "You are running on $qacpuwidth bit hardware."
399 echo "(I can't seem to compile the test program. Guessing...)"
400 rp="What is the width of your CPU (in bits)?"
406 case "$qacpuwidth" in
409 Bzzzt! At present, you can only perform a
410 full 64-bit build on a 64-bit machine.
415 qacflags="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
416 qaldflags="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
417 # See jhi's comments above regarding this re-eval. I've
418 # seen similar weirdness in the form of:
420 # 1506-173 (W) Option lm is not valid. Enter xlc for list of valid options.
422 # error messages from 'cc -E' invocation. Again, the offending
423 # string is simply not detectable by any means. Since it doesn't
424 # do any harm, I didn't pursue it. -- sh
425 qaldflags="`echo $qaldflags`"
426 qalibs="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
427 # -q32 and -b32 may have been set by uselargefiles or user.
429 ccflags="`echo $ccflags | sed -e 's@-q32@@'`"
430 ldflags="`echo $ldflags | sed -e 's@-b32@@'`"
433 ccflags="`echo $ccflags | sed -e 's@-q64@-maix64@'`"
434 ccflags_uselargefiles="`echo $ccflags_uselargefiles | sed -e 's@-q64@-maix64@'`"
435 qacflags="`echo $qacflags | sed -e 's@-q64@-maix64@'`"
438 # Tell archiver to use large format. Unless we remove 'ar'
439 # from 'trylist', the Configure script will just reset it to 'ar'
440 # immediately prior to writing config.sh. This took me hours
442 trylist="`echo $trylist | sed -e 's@^ar @@' -e 's@ ar @ @g' -e 's@ ar$@@'`"
444 nm_opt="-X64 $nm_opt"
445 case "$qacflags$qaldflags$qalibs" in
447 *) ccflags="$ccflags $qacflags"
449 lddlflags="$qaldflags $lddlflags"
450 libswanted="$libswanted $qalibs"
454 *-DUSE_64_BIT_ALL*) ;;
455 *) ccflags="$ccflags -DUSE_64_BIT_ALL";;
457 case "$archname64" in
458 ''|64*) archname64=64all ;;
469 if test $usenativedlopen = 'true' ; then
470 ccflags="$ccflags -DUSE_NATIVE_DLOPEN"
471 # -brtl Enables a binary to use run time linking
472 # -bdynamic When used with -brtl, tells linker to search for
473 # ".so"-suffix libraries as well as ".a" suffix
474 # libraries. AIX allows both .so and .a libraries to
475 # contain dynamic shared objects.
477 *gcc*) ldflags="$ldflags -Wl,-brtl -Wl,-bdynamic" ;;
478 *) ldflags="$ldflags -brtl -bdynamic" ;;
480 elif test -f /lib/libC.a -a X"`$cc -v 2>&1 | grep gcc`" = X; then
481 # If the C++ libraries, libC and libC_r, are available we will
482 # prefer them over the vanilla libc, because the libC contain
483 # loadAndInit() and terminateAndUnload() which work correctly
484 # with C++ statics while libc load() and unload() do not. See
485 # ext/DynaLoader/dl_aix.xs. The C-to-C_r switch is done by
486 # usethreads.cbu, if needed.
489 set `echo X "$libswanted "| sed -e 's/ c / C c /'`
493 set `echo X "$lddlflags "| sed -e 's/ -lc / -lC -lc /'`
501 '') prefix=/QOpenSys/perl ;;
506 *** You seem to be compiling in AIX for the OS/400 PASE environment.
507 *** I'm not going to use the AIX bind, nsl, and possible util libraries, then.
508 *** I'm also not going to install perl as /usr/bin/perl.
509 *** Perl will be installed under $prefix.
510 *** For instructions how to install this build from AIX to PASE,
511 *** see the file README.os400. Accept the "aix" for the question
512 *** about "Operating system name".
515 set `echo " $libswanted " | sed -e 's@ bind @ @' -e 's@ nsl @ @' -e 's@ util @ @'`
518 installusrbinperl="$undef"
520 # V5R1 doesn't have this (V5R2 does), without knowing
521 # which one we have it's safer to be pessimistic.
522 # Cwd will work fine even without fchdir(), but if
523 # V5R1 tries to use code compiled assuming fchdir(),
524 # lots of grief will issue forth from Cwd.
526 '') d_fchdir="$undef" ;;
531 # remove libbsd.a from wanted libraries
532 libswanted=`echo " $libswanted " | sed -e 's/ bsd / /'`
533 libswanted=`echo " $libswanted " | sed -e 's/ BSD / /'`
536 # remove libgdbm from wanted libraries
537 # The libgdbm < 1.8.3-5 from the AIX Toolbox is not working
538 # because two wrong .h are present
539 if [ -f "/opt/freeware/include/gdbm/dbm.h" ] ||
540 [ -f "/opt/freeware/include/gdbm/ndbm.h" ]; then
541 echo "GDBM support disabled because your GDBM package contains extraneous headers - see README.aix."
542 libswanted=`echo " $libswanted " | sed -e 's/ gdbm / /'`
547 # Some releases (and patch levels) of AIX cannot have both
548 # long doubles and infinity (infinity plus one equals ... NaNQ!)
550 # This deficiency, and others, is apparently a well-documented feature
551 # of AIX 128-bit long doubles:
553 # http://www-01.ibm.com/support/knowledgecenter/ssw_aix_61/com.ibm.aix.genprogc/128bit_long_double_floating-point_datatype.htm
555 # The URL seems to be fragile, it has moved around over the years,
556 # but searching AIX docs at ibm.com for "128-bit long double
557 # floating-point data type" should surface the latest info.
559 # Some salient points:
562 # * The 128-bit implementation differs from the IEEE standard for long double
563 # in the following ways:
564 # * Supports only round-to-nearest mode. If the application changes
565 # the rounding mode, results are undefined.
566 # * Does not fully support the IEEE special numbers NaN and INF.
567 # * Does not support IEEE status flags for overflow, underflow,
568 # and other conditions. These flags have no meaning for the 128-bit
569 # long double inplementation.
570 # * The 128-bit long double data type does not support the following math
571 # APIs: atanhl, cbrtl, copysignl, exp2l, expm1l, fdiml, fmal, fmaxl,
572 # fminl, hypotl, ilogbl, llrintl, llroundl, log1pl, log2l, logbl,
573 # lrintl, lroundl, nanl, nearbyintl, nextafterl, nexttoward,
574 # nexttowardf, nexttowardl, remainderl, remquol, rintl, roundl,
575 # scalblnl, scalbnl, tgammal, and truncl.
576 # * The representation of 128-bit long double numbers means that the
577 # following macros required by standard C in the values.h file do not
578 # have clear meaning:
579 # * Number of bits in the mantissa (LDBL_MANT_DIG)
580 # * Epsilon (LBDL_EPSILON)
581 # * Maximum representable finite value (LDBL_MAX)
584 # The missing math functions affect the POSIX extension math interfaces.
586 case "$uselongdouble" in
588 echo "Checking if your infinity is working with long doubles..." >&4
593 long double inf = INFINITY;
594 long double one = 1.0L;
595 printf("%Lg\n", inf + one);
598 $cc -qlongdouble -o inf$$ inf$$.c -lm
600 INF) echo "Your infinity is working correctly with long doubles." >&4 ;;
601 *) # NaNQ (or anything else than INF)
603 echo "Your infinity is broken, I suggest disabling long doubles." >&4
604 rp="Disable long doubles?"
609 echo "Okay, disabling long doubles." >&4
610 uselongdouble="$undef"
611 ccflags=`echo " $ccflags " | sed -e 's/ -qlongdouble / /'`
612 libswanted=`echo " $libswanted " | sed -e 's/ c128/ /'`
613 lddlflags=`echo " $lddlflags " | sed -e 's/ -lc128 / /'`
616 echo "Okay, keeping long doubles enabled." >&4
625 # Some releases (and patch levels) of AIX have a broken powl().
627 case "$uselongdouble" in
629 echo "Checking if your powl() is broken..." >&4
634 printf("%Lg\n", powl(-3.0L, 2.0L));
637 case "$gccversion" in
638 '') $cc -qlongdouble -o powl$$ powl$$.c -lm ;;
639 *) $cc -o powl$$ powl$$.c -lm ;;
642 9) echo "Your powl() is working correctly." >&4 ;;
644 echo "Your powl() is broken, will use a workaround." >&4
645 pp_cflags='ccflags="$ccflags -DHAS_AIX_POWL_NEG_BASE_BUG"'
648 rm -f powl$$.c powl$$
652 # Some releases of AIX cc/xlc a broken fmodl(), but -q64 seems to help.
653 case "$gccversion" in
654 '') case "$uselongdouble" in
658 *) echo "Checking if your fmodl() is broken..." >&4
659 cat > fmodl$$.c <<EOF
663 printf("%ld\n", (long)fmodl(powl(2, 31), (long double)4294967295));
666 $cc -qlongdouble -o fmodl$$ fmodl$$.c -lm
668 2147483648) echo "Your fmodl() is working correctly." >&4 ;;
669 *) echo "Your fmodl() is broken, will try with -q64..." >&4
670 $cc -q64 -qlongdouble -o fmodl$$ fmodl$$.c -lm
673 echo "The -q64 did the trick, will use it." >& 4
674 ccflags="`echo $ccflags | sed -e 's@-q32@@g'`"
675 ldflags="`echo $ldflags | sed -e 's@-q32@@g'`"
676 ccflags="$ccflags -q64"
677 ldflags="$ldflags -q64"
679 *) echo "Not even the -q64 worked. I'm disabling long doubles." >&4
680 echo "And you should have stern talk with your IBM rep." >&4
681 uselongdouble="$undef"
682 ccflags=`echo " $ccflags " | sed -e 's/ -qlongdouble / /'`
683 libswanted=`echo " $libswanted " | sed -e 's/ c128/ /'`
684 lddlflags=`echo " $lddlflags " | sed -e 's/ -lc128 / /'`
686 esac # second fmodl$$
690 esac # Checking if ...
693 rm -f fmodl$$.c fmodl$$