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.
38 case "$usemymalloc" in
39 '') usemymalloc='n' ;;
42 # malloc wrap works, but not in vac-5, see later
43 case "$usemallocwrap" in
44 '') usemallocwrap='define' ;;
47 # Intuiting the existence of system calls under AIX is difficult,
48 # at best; the safest technique is to find them empirically.
50 case "$usenativedlopen" in
51 '') usenativedlopen='true' ;;
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>
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.
64 case "$OBJECT_MODE" in
67 You have OBJECT_MODE=32 set in the environment.
68 I take this as a hint you do not want to
69 build for a 64-bit address space. You will be
70 given the opportunity to change this later.
75 You have OBJECT_MODE=64 set in the environment.
76 This forces a full 64-bit build. If that is
77 not what you intended, please terminate this
78 program, unset it and restart.
83 s=`lslpp -lc bos.adt.libm >/dev/null`
85 echo "You cannot build perl without the bos.adt.libm package installed" >&4
89 # uname -m output is too specific and not appropriate here
91 '') archname="$osname" ;;
96 ccflags="$ccflags -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE"
99 *) ccflags="$ccflags -qmaxmem=-1 -qnoansialias" ;;
103 # These functions don't work like Perl expects them to.
107 # Changes for dynamic linking by Wayne Scott <wscott@ichips.intel.com>
109 # Tell perl which symbols to export for dynamic linking.
110 cccdlflags='none' # All AIX code is position independent
111 cc_type=xlc # do not export to config.sh
116 if [ "X$gccversion" = "X" ]; then
117 # Done too late in Configure if hinted
118 gccversion=`$cc -dumpversion`
122 *) ccversion=`lslpp -ql -Ou vac.C | grep -v '^Path' | head -1 | awk '{print $1,$2}'`
124 '') ccversion=`lslpp -L | grep 'IBM C and C++ Compilers LUM$'` ;;
126 *.*.*.*.*.*.*) # Ahhrgg, more than one C compiler installed
127 first_cc_path=`which ${cc:-cc}`
128 case "$first_cc_path" in
132 /usr/bin/cc) # Check the symlink
133 if [ -h $first_cc_path ] ; then
134 ls -l $first_cc_path > reflect
135 if grep -i vac reflect >/dev/null 2>&1 ; then
142 ccversion=`lslpp -L | grep 'C for AIX Compiler$' | grep -i $cc_type | head -1`
150 ccversion=`echo "$ccversion" | awk '{print $2}'`
151 # Redbooks state AIX-5 only supports vac-5.0.2.0 and up
153 5*) usemallocwrap='n' ;; # panic in miniperl
158 # the required -bE:$installarchlib/CORE/perl.exp is added by
159 # libperl.U (Configure) later.
161 # The first 3 options would not be needed if dynamic libs. could be linked
162 # with the compiler instead of ld.
163 # -bI:$(PERL_INC)/perl.exp Read the exported symbols from the perl binary
164 # -bE:$(BASEEXT).exp Export these symbols. This file contains only one
165 # symbol: boot_$(EXP) can it be auto-generated?
166 if test $usenativedlopen = 'true' ; then
167 lddlflags="$lddlflags -bhalt:4 -G -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc -lm"
169 lddlflags="$lddlflags -bhalt:4 -bM:SRE -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc"
172 case "$use64bitall" in
173 $define|true|[yY]*) use64bitint="$define" ;;
176 case "$usemorebits" in
177 $define|true|[yY]*) use64bitint="$define"; uselongdouble="$define" ;;
182 case "$uselongdouble" in
184 ccflags="$ccflags -qlongdouble"
185 libswanted="c128 $libswanted"
186 lddlflags=`echo "$lddlflags " | sed -e 's/ -lc / -lc128 -lc /'`
195 cc*|xlc*) # cc should've been set by line 116 or so if empty.
196 if test ! -x /usr/bin/$cc -a -x /usr/vac/bin/$cc; then
199 *) if test ! -x /QOpenSys/usr/bin/$cc; then
200 # The /QOpenSys/usr/bin/$cc saves us if we are
201 # building natively in OS/400 PASE.
205 *** You either implicitly or explicitly specified an IBM C compiler,
206 *** but you do not seem to have one in /usr/bin, but you seem to have
207 *** the VAC installed in /usr/vac, but you do not have the /usr/vac/bin
208 *** in your PATH. I suggest adding that and retrying Configure.
219 case "$ldlibpthname" in
220 '') ldlibpthname=LIBPATH ;;
223 # This script UU/usethreads.cbu will get 'called-back' by Configure
224 # after it has prompted the user for whether to use threads.
225 cat > UU/usethreads.cbu <<'EOCBU'
226 case "$usethreads" in
239 ccflags="$ccflags -DNEED_PTHREAD_INIT"
241 *gcc*) ccflags="-D_THREAD_SAFE $ccflags" ;;
249 # No | alternation in aix sed. :-(
250 newcc=`echo $cc | sed -e 's/cc$/cc_r/' -e 's/xl[cC]$/cc_r/' -e 's/xl[cC]_r$/cc_r/'`
256 echo >&4 "Switching cc to cc_r because of POSIX threads."
257 # xlc_r has been known to produce buggy code in AIX 4.3.2.
258 # (e.g. pragma/overload core dumps) Let's suspect xlC_r, too.
265 *** For pthreads you should use the AIX C compiler cc_r.
266 *** (now your compiler was set to '$cc')
267 *** Cannot continue, aborting.
274 # Insert pthreads to libswanted, before any libc or libC.
275 set `echo X "$libswanted "| sed -e 's/ \([cC]\) / pthreads \1 /'`
278 # Insert pthreads to lddlflags, before any libc or libC.
279 set `echo X "$lddlflags " | sed -e 's/ \(-l[cC]\) / -lpthreads \1 /'`
286 # This script UU/uselargefiles.cbu will get 'called-back' by Configure
287 # after it has prompted the user for whether to use large files.
288 cat > UU/uselargefiles.cbu <<'EOCBU'
289 case "$uselargefiles" in
290 ''|$define|true|[yY]*)
291 # Configure should take care of use64bitint and use64bitall being
292 # defined before uselargefiles.cbu is consulted.
293 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
294 # Keep these at the left margin.
295 ccflags_uselargefiles="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
296 ldflags_uselargefiles="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
298 # Keep these at the left margin.
299 ccflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_CFLAGS 2>/dev/null`"
300 ldflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LDFLAGS 2>/dev/null`"
302 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
303 # Keep this at the left margin.
304 libswanted_uselargefiles="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
306 # Keep this at the left margin.
307 libswanted_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
310 case "$ccflags_uselargefiles$ldflags_uselargefiles$libs_uselargefiles" in
312 *) ccflags="$ccflags $ccflags_uselargefiles"
313 ldflags="$ldflags $ldflags_uselargefiles"
314 libswanted="$libswanted $libswanted_uselargefiles"
318 # -bmaxdata:0x80000000
319 # - This increases the size of heap memory available to perl.
320 # Default is 256 MB, which sounds large but caused a software
321 # vendor problems. So this sets heap to 2 GB maximum. Anything
322 # higher and you'd want to consider 64 bit perl.
323 # - NOTE however, that setting this in 64bit mode will limit your
324 # amount of available memory to 2GB, so we set this only in
325 # 32bit mode to avoid future problems a la "should be enough
328 case "$use64bitall" in
333 ldflags="$ldflags -bmaxdata:0x80000000"
337 case "$gccversion" in
339 # Due to calling $cc without $cflags when linking some
340 # binaries we need to hardwire $cc to the right mode.
341 # The correct fix would be to have Makefile.SH not set
342 # CLDFLAGS from $ldflags ...
343 case "$use64bitall" in
344 $define|true|[yY]*) cc="$cc -q64" ;;
348 *) # Remove xlc-specific -qflags.
349 ccflags="`echo $ccflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
350 ldflags="`echo $ldflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
351 # Move xlc-specific -bflags.
352 ccflags="`echo $ccflags | sed -e 's@ -b@ -Wl,-b@g'`"
353 ldflags="`echo ' '$ldflags | sed -e 's@ -b@ -Wl,-b@g'`"
354 lddlflags="`echo ' '$lddlflags | sed -e 's@ -b@ -Wl,-b@g'`"
355 lddlflags="`echo ' '$lddlflags | sed -e 's@ -G @ -Wl,-G @g'`"
357 # Due to calling $cc without $cflags when linking some
358 # binaries we need to hardwire $cc to the right mode.
359 case "$use64bitall" in
369 echo >&4 "(using ccflags $ccflags)"
370 echo >&4 "(using ldflags $ldflags)"
371 echo >&4 "(using lddlflags $lddlflags)"
378 cat > UU/use64bitall.cbu <<'EOCBU'
379 # This script UU/use64bitall.cbu will get 'called-back' by Configure
380 # after it has prompted the user for whether to be maximally 64-bitty.
381 case "$use64bitall" in
384 echo "Checking the CPU width of your hardware..." >&4
387 #include <sys/systemcfg.h>
390 printf ("%d\n", _system_configuration.width);
395 if eval $compile_ok; then
397 echo "You are running on $qacpuwidth bit hardware."
401 echo "(I can't seem to compile the test program. Guessing...)"
402 rp="What is the width of your CPU (in bits)?"
408 case "$qacpuwidth" in
411 Bzzzt! At present, you can only perform a
412 full 64-bit build on a 64-bit machine.
417 qacflags="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
418 qaldflags="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
419 # See jhi's comments above regarding this re-eval. I've
420 # seen similar weirdness in the form of:
422 # 1506-173 (W) Option lm is not valid. Enter xlc for list of valid options.
424 # error messages from 'cc -E' invocation. Again, the offending
425 # string is simply not detectable by any means. Since it doesn't
426 # do any harm, I didn't pursue it. -- sh
427 qaldflags="`echo $qaldflags`"
428 qalibs="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
429 # -q32 and -b32 may have been set by uselargefiles or user.
431 ccflags="`echo $ccflags | sed -e 's@-q32@@'`"
432 ldflags="`echo $ldflags | sed -e 's@-b32@@'`"
435 ccflags="`echo $ccflags | sed -e 's@-q64@-maix64@'`"
436 ccflags_uselargefiles="`echo $ccflags_uselargefiles | sed -e 's@-q64@-maix64@'`"
437 qacflags="`echo $qacflags | sed -e 's@-q64@-maix64@'`"
440 # Tell archiver to use large format. Unless we remove 'ar'
441 # from 'trylist', the Configure script will just reset it to 'ar'
442 # immediately prior to writing config.sh. This took me hours
444 trylist="`echo $trylist | sed -e 's@^ar @@' -e 's@ ar @ @g' -e 's@ ar$@@'`"
446 nm_opt="-X64 $nm_opt"
447 case "$qacflags$qaldflags$qalibs" in
449 *) ccflags="$ccflags $qacflags"
451 lddlflags="$qaldflags $lddlflags"
452 libswanted="$libswanted $qalibs"
456 *-DUSE_64_BIT_ALL*) ;;
457 *) ccflags="$ccflags -DUSE_64_BIT_ALL";;
459 case "$archname64" in
460 ''|64*) archname64=64all ;;
471 if test $usenativedlopen = 'true' ; then
472 ccflags="$ccflags -DUSE_NATIVE_DLOPEN"
473 # -brtl Enables a binary to use run time linking
474 # -bdynamic When used with -brtl, tells linker to search for
475 # ".so"-suffix libraries as well as ".a" suffix
476 # libraries. AIX allows both .so and .a libraries to
477 # contain dynamic shared objects.
479 *gcc*) ldflags="$ldflags -Wl,-brtl -Wl,-bdynamic" ;;
480 *) ldflags="$ldflags -brtl -bdynamic" ;;
482 elif test -f /lib/libC.a -a X"`$cc -v 2>&1 | grep gcc`" = X; then
483 # If the C++ libraries, libC and libC_r, are available we will
484 # prefer them over the vanilla libc, because the libC contain
485 # loadAndInit() and terminateAndUnload() which work correctly
486 # with C++ statics while libc load() and unload() do not. See
487 # ext/DynaLoader/dl_aix.xs. The C-to-C_r switch is done by
488 # usethreads.cbu, if needed.
491 set `echo X "$libswanted "| sed -e 's/ c / C c /'`
495 set `echo X "$lddlflags "| sed -e 's/ -lc / -lC -lc /'`
503 '') prefix=/QOpenSys/perl ;;
508 *** You seem to be compiling in AIX for the OS/400 PASE environment.
509 *** I'm not going to use the AIX bind, nsl, and possible util libraries, then.
510 *** I'm also not going to install perl as /usr/bin/perl.
511 *** Perl will be installed under $prefix.
512 *** For instructions how to install this build from AIX to PASE,
513 *** see the file README.os400. Accept the "aix" for the question
514 *** about "Operating system name".
517 set `echo " $libswanted " | sed -e 's@ bind @ @' -e 's@ nsl @ @' -e 's@ util @ @'`
520 installusrbinperl="$undef"
522 # V5R1 doesn't have this (V5R2 does), without knowing
523 # which one we have it's safer to be pessimistic.
524 # Cwd will work fine even without fchdir(), but if
525 # V5R1 tries to use code compiled assuming fchdir(),
526 # lots of grief will issue forth from Cwd.
528 '') d_fchdir="$undef" ;;