This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
inline.h: Fix comment
[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
86959918 37case "$usemymalloc" in
2463cec9
MB
38 '') usemymalloc='n' ;;
39 esac
bbc711f9 40
88567e60 41# malloc wrap works, but not in vac-5, see later
da0b61dd 42case "$usemallocwrap" in
88567e60
MB
43 '') usemallocwrap='define' ;;
44 esac
da0b61dd 45
bbc711f9
DF
46# Intuiting the existence of system calls under AIX is difficult,
47# at best; the safest technique is to find them empirically.
48
2463cec9
MB
49case "$usenativedlopen" in
50 '') usenativedlopen='true' ;;
51 esac
cc628cc3 52
3c321fdc 53so="a"
0d9ec2f4
JH
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>
58dlext="so"
3c321fdc 59
19e194ad
JH
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.
63case "$OBJECT_MODE" in
2463cec9 64 32) cat >&4 <<EOF
19e194ad 65
2463cec9 66You have OBJECT_MODE=32 set in the environment.
19e194ad
JH
67I take this as a hint you do not want to
68build for a 64-bit address space. You will be
69given the opportunity to change this later.
70EOF
2463cec9
MB
71 ;;
72 64) cat >&4 <<EOF
19e194ad 73
2463cec9 74You have OBJECT_MODE=64 set in the environment.
19e194ad
JH
75This forces a full 64-bit build. If that is
76not what you intended, please terminate this
77program, unset it and restart.
78EOF
2463cec9
MB
79 ;;
80 esac
1aef975c 81
d909c5cb
MB
82 s=`lslpp -lc bos.adt.libm >/dev/null`
83if [ $? != 0 ]; then
84 echo "You cannot build perl without the bos.adt.libm package installed" >&4
85 exit
86 fi
87
1aef975c
AD
88# uname -m output is too specific and not appropriate here
89case "$archname" in
2463cec9
MB
90 '') archname="$osname" ;;
91 esac
1aef975c 92
bd9b35c9
JH
93cc=${cc:-cc}
94
1c00c3fe
MB
95ccflags="$ccflags -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE"
96case "$cc" in
97 *gcc*) ;;
9d7bf48e 98 *) ccflags="$ccflags -qmaxmem=-1 -qnoansialias -qlanglvl=extc99" ;;
80589958 99 esac
1c00c3fe 100nm_opt='-B'
1aef975c 101
bbc711f9
DF
102# These functions don't work like Perl expects them to.
103d_setregid='undef'
104d_setreuid='undef'
105
1aef975c 106# Changes for dynamic linking by Wayne Scott <wscott@ichips.intel.com>
a0d0e21e
LW
107#
108# Tell perl which symbols to export for dynamic linking.
411de0ab
MB
109cccdlflags='none' # All AIX code is position independent
110 cc_type=xlc # do not export to config.sh
4633a7c4 111case "$cc" in
2463cec9
MB
112 *gcc*)
113 cc_type=gcc
114 ccdlflags='-Xlinker'
115 if [ "X$gccversion" = "X" ]; then
116 # Done too late in Configure if hinted
0baa0948 117 gccversion=`$cc -dumpversion`
2463cec9 118 fi
2973cfbe 119 ;;
2463cec9 120
3c2f5eaa 121 *) ccversion=`lslpp -ql -Ou vac.C | grep -v '^Path' | head -1 | awk '{print $1,$2}'`
2463cec9
MB
122 case "$ccversion" in
123 '') ccversion=`lslpp -L | grep 'IBM C and C++ Compilers LUM$'` ;;
124
125 *.*.*.*.*.*.*) # Ahhrgg, more than one C compiler installed
126 first_cc_path=`which ${cc:-cc}`
127 case "$first_cc_path" in
128 *vac*)
129 cc_type=vac ;;
130
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
135 cc_type=vac
136 fi
137 rm -f reflect
138 fi
139 ;;
140 esac
141 ccversion=`lslpp -L | grep 'C for AIX Compiler$' | grep -i $cc_type | head -1`
142 ;;
143
144 vac*.*.*.*)
145 cc_type=vac
146 ;;
147 esac
148
149 ccversion=`echo "$ccversion" | awk '{print $2}'`
150 # Redbooks state AIX-5 only supports vac-5.0.2.0 and up
88567e60
MB
151 case "$ccversion" in
152 5*) usemallocwrap='n' ;; # panic in miniperl
153 esac
6b356c8e 154 ;;
2463cec9
MB
155 esac
156
5f9d9a17
ME
157# the required -bE:$installarchlib/CORE/perl.exp is added by
158# libperl.U (Configure) later.
a0d0e21e 159
411de0ab
MB
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?
142c1590 165if test $usenativedlopen = 'true' ; then
79c530cb 166 lddlflags="$lddlflags -bhalt:4 -G -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc -lm"
142c1590
MB
167else
168 lddlflags="$lddlflags -bhalt:4 -bM:SRE -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc"
169 fi
411de0ab 170
d002699e
MB
171case "$use64bitall" in
172 $define|true|[yY]*) use64bitint="$define" ;;
173 esac
174
175case "$usemorebits" in
176 $define|true|[yY]*) use64bitint="$define"; uselongdouble="$define" ;;
177 esac
178
179case $cc_type in
180 vac|xlc)
181 case "$uselongdouble" in
182 $define|true|[yY]*)
183 ccflags="$ccflags -qlongdouble"
184 libswanted="c128 $libswanted"
411de0ab 185 lddlflags=`echo "$lddlflags " | sed -e 's/ -lc / -lc128 -lc /'`
d002699e
MB
186 ;;
187 esac
2463cec9 188 ;;
d002699e
MB
189 esac
190
444379fb 191case "$cc" in
2463cec9
MB
192 *gcc*) ;;
193
194 cc*|xlc*) # cc should've been set by line 116 or so if empty.
444379fb 195 if test ! -x /usr/bin/$cc -a -x /usr/vac/bin/$cc; then
2463cec9 196 case ":$PATH:" in
444379fb 197 *:/usr/vac/bin:*) ;;
2463cec9 198 *) if test ! -x /QOpenSys/usr/bin/$cc; then
61074b56
JH
199 # The /QOpenSys/usr/bin/$cc saves us if we are
200 # building natively in OS/400 PASE.
e6604a4d 201 cat >&4 <<EOF
444379fb
JH
202
203***
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.
208***
209EOF
61074b56 210 exit 1
2463cec9
MB
211 fi
212 ;;
444379fb 213 esac
2463cec9 214 fi
444379fb 215 ;;
2463cec9 216 esac
444379fb 217
5cf1d1f1 218case "$ldlibpthname" in
2463cec9 219 '') ldlibpthname=LIBPATH ;;
3427abbf 220 esac
52e1cb5e 221
2463cec9 222# This script UU/usethreads.cbu will get 'called-back' by Configure
104d25b7
JH
223# after it has prompted the user for whether to use threads.
224cat > UU/usethreads.cbu <<'EOCBU'
225case "$usethreads" in
2463cec9
MB
226 $define|true|[yY]*)
227 d_drand48_r='undef'
228 d_endgrent_r='undef'
229 d_endpwent_r='undef'
230 d_getgrent_r='undef'
231 d_getpwent_r='undef'
232 d_random_r='undef'
233 d_setgrent_r='undef'
234 d_setpwent_r='undef'
235 d_srand48_r='undef'
4538cc61 236 d_srandom_r='undef'
2463cec9
MB
237 d_strerror_r='undef'
238
4e774c84
SB
239 ccflags="$ccflags -DNEED_PTHREAD_INIT"
240 case "$cc" in
68224244
RT
241 *gcc*)
242 ccflags="-D_THREAD_SAFE $ccflags"
243 ;;
244 cc_r)
245 ;;
246 xlc_r)
68224244
RT
247 ;;
248 # we do not need the C++ compiler
249 xlC_r)
68224244
RT
250 cc=xlc_r
251 ;;
252 '')
253 cc=cc_r
254 ;;
3e50adc2 255 *)
3e50adc2 256 esac
c88be79f
JH
257
258 # Insert pthreads to libswanted, before any libc or libC.
15173baf 259 set `echo X "$libswanted "| sed -e 's/ \([cC]\) / pthreads \1 /'`
c88be79f
JH
260 shift
261 libswanted="$*"
262 # Insert pthreads to lddlflags, before any libc or libC.
15173baf 263 set `echo X "$lddlflags " | sed -e 's/ \(-l[cC]\) / -lpthreads \1 /'`
c88be79f
JH
264 shift
265 lddlflags="$*"
104d25b7 266 ;;
68224244
RT
267 *)
268 case "$cc" in
269 xlc)
68224244
RT
270 ;;
271 # we do not need the C++ compiler
272 xlC)
68224244
RT
273 cc=xlc
274 ;;
275 *)
276 esac
277 ;;
104d25b7
JH
278esac
279EOCBU
fa9667c9 280
2463cec9 281# This script UU/uselargefiles.cbu will get 'called-back' by Configure
bd9b35c9 282# after it has prompted the user for whether to use large files.
8a647129 283cat > UU/uselargefiles.cbu <<'EOCBU'
bd9b35c9 284case "$uselargefiles" in
2463cec9
MB
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
21c7e20c
JH
289# Keep these at the left margin.
290ccflags_uselargefiles="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
291ldflags_uselargefiles="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
2463cec9 292 else
9422c00b 293# Keep these at the left margin.
45c9e83b
JH
294ccflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_CFLAGS 2>/dev/null`"
295ldflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LDFLAGS 2>/dev/null`"
2463cec9
MB
296 fi
297 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
21c7e20c 298# Keep this at the left margin.
af638b87 299libswanted_uselargefiles="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
2463cec9 300 else
9422c00b 301# Keep this at the left margin.
af638b87 302libswanted_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
2463cec9
MB
303 fi
304
45c9e83b 305 case "$ccflags_uselargefiles$ldflags_uselargefiles$libs_uselargefiles" in
2463cec9
MB
306 '') ;;
307 *) ccflags="$ccflags $ccflags_uselargefiles"
308 ldflags="$ldflags $ldflags_uselargefiles"
309 libswanted="$libswanted $libswanted_uselargefiles"
310 ;;
311 esac
6b8eaf93 312
be7cbdf3
NE
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
321 # for everyone" ...
322 #
323 case "$use64bitall" in
324 $define|true|[yY]*)
325 :
326 ;;
327 *)
328 ldflags="$ldflags -bmaxdata:0x80000000"
329 ;;
330 esac
331
2463cec9 332 case "$gccversion" in
be7cbdf3
NE
333 '') # Not using gcc.
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" ;;
340 *) cc="$cc -q32" ;;
341 esac
9d7bf48e
DM
342 # Some 32-bit getconfs will set ccflags to include -qlonglong
343 # but that's no longer needed with an explicit -qextc99.
da46ab37 344 ccflags="`echo $ccflags | sed -e 's@ -qlonglong@@'`"
be7cbdf3 345 ;;
2463cec9
MB
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'`"
ad5c63c6 353 lddlflags="`echo ' '$lddlflags | sed -e 's@ -G @ -Wl,-G @g'`"
be7cbdf3
NE
354
355 # Due to calling $cc without $cflags when linking some
356 # binaries we need to hardwire $cc to the right mode.
0c0f8223 357 case "$use64bitall" in
be7cbdf3
NE
358 $define|true|[yY]*)
359 cc="$cc -maix64"
360 ld="$cc"
361 ;;
362 *)
363 cc="$cc -maix32"
364 ld="$cc"
365 ;;
0c0f8223 366 esac
2463cec9
MB
367 echo >&4 "(using ccflags $ccflags)"
368 echo >&4 "(using ldflags $ldflags)"
369 echo >&4 "(using lddlflags $lddlflags)"
efeaa891
JH
370 ;;
371 esac
2463cec9
MB
372 ;;
373 esac
19e194ad
JH
374EOCBU
375
19e194ad 376cat > UU/use64bitall.cbu <<'EOCBU'
2463cec9 377# This script UU/use64bitall.cbu will get 'called-back' by Configure
de6124c8 378# after it has prompted the user for whether to be maximally 64-bitty.
19e194ad 379case "$use64bitall" in
2463cec9
MB
380 $define|true|[yY]*)
381 echo " "
382 echo "Checking the CPU width of your hardware..." >&4
383 $cat >size.c <<EOCP
19e194ad
JH
384#include <stdio.h>
385#include <sys/systemcfg.h>
386int main (void)
387{
2463cec9
MB
388 printf ("%d\n", _system_configuration.width);
389 return (0);
390 }
19e194ad 391EOCP
2463cec9
MB
392 set size
393 if eval $compile_ok; then
394 qacpuwidth=`./size`
395 echo "You are running on $qacpuwidth bit hardware."
396 else
397 dflt="32"
398 echo " "
399 echo "(I can't seem to compile the test program. Guessing...)"
400 rp="What is the width of your CPU (in bits)?"
401 . ./myread
402 qacpuwidth="$ans"
19e194ad 403 fi
2463cec9
MB
404 $rm -f size.c size
405
406 case "$qacpuwidth" in
19e194ad
JH
407 32*)
408 cat >&4 <<EOM
409Bzzzt! At present, you can only perform a
410full 64-bit build on a 64-bit machine.
411EOM
412 exit 1
413 ;;
414 esac
2463cec9
MB
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:
419 #
19e194ad 420# 1506-173 (W) Option lm is not valid. Enter xlc for list of valid options.
2463cec9
MB
421 #
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`"
af638b87 426 qalibs="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
2463cec9
MB
427 # -q32 and -b32 may have been set by uselargefiles or user.
428 # Remove them.
429 ccflags="`echo $ccflags | sed -e 's@-q32@@'`"
430 ldflags="`echo $ldflags | sed -e 's@-b32@@'`"
0c0f8223
MB
431 case "$cc" in
432 *gcc*)
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@'`"
436 ;;
437 esac
2463cec9
MB
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
441 # to figure out.
442 trylist="`echo $trylist | sed -e 's@^ar @@' -e 's@ ar @ @g' -e 's@ ar$@@'`"
443 ar="ar -X64"
444 nm_opt="-X64 $nm_opt"
2463cec9
MB
445 case "$qacflags$qaldflags$qalibs" in
446 '') ;;
447 *) ccflags="$ccflags $qacflags"
be7cbdf3 448 ldflags="$ldflags"
2463cec9
MB
449 lddlflags="$qaldflags $lddlflags"
450 libswanted="$libswanted $qalibs"
451 ;;
19e194ad 452 esac
2463cec9 453 case "$ccflags" in
19e194ad 454 *-DUSE_64_BIT_ALL*) ;;
2463cec9 455 *) ccflags="$ccflags -DUSE_64_BIT_ALL";;
19e194ad 456 esac
2463cec9 457 case "$archname64" in
19e194ad
JH
458 ''|64*) archname64=64all ;;
459 esac
2463cec9
MB
460 longsize="8"
461 qacflags=''
462 qaldflags=''
463 qalibs=''
464 qacpuwidth=''
465 ;;
466 esac
efeaa891 467EOCBU
5b877257 468
2463cec9 469if test $usenativedlopen = 'true' ; then
fd90a50d 470 ccflags="$ccflags -DUSE_NATIVE_DLOPEN"
142c1590
MB
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.
fd90a50d 476 case "$cc" in
be7cbdf3
NE
477 *gcc*) ldflags="$ldflags -Wl,-brtl -Wl,-bdynamic" ;;
478 *) ldflags="$ldflags -brtl -bdynamic" ;;
9d20a131 479 esac
2463cec9
MB
480elif 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.
487
488 # Cify libswanted.
489 set `echo X "$libswanted "| sed -e 's/ c / C c /'`
490 shift
491 libswanted="$*"
492 # Cify lddlflags.
493 set `echo X "$lddlflags "| sed -e 's/ -lc / -lC -lc /'`
494 shift
495 lddlflags="$*"
496 fi
4e774c84 497
522b859a 498case "$PASE" in
2463cec9 499 define)
522b859a 500 case "$prefix" in
2463cec9
MB
501 '') prefix=/QOpenSys/perl ;;
502 esac
522b859a
JH
503 cat >&4 <<EOF
504
505***
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".
513***
514EOF
515 set `echo " $libswanted " | sed -e 's@ bind @ @' -e 's@ nsl @ @' -e 's@ util @ @'`
516 shift
517 libswanted="$*"
518 installusrbinperl="$undef"
abeab9d3
RGS
519
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.
525 case "$d_fchdir" in
2463cec9
MB
526 '') d_fchdir="$undef" ;;
527 esac
522b859a 528 ;;
2463cec9 529 esac
522b859a 530
f67e8e0b
MB
531# remove libbsd.a from wanted libraries
532libswanted=`echo " $libswanted " | sed -e 's/ bsd / /'`
533libswanted=`echo " $libswanted " | sed -e 's/ BSD / /'`
534d_flock='undef'
535
c533d96e 536# remove libgdbm from wanted libraries
d549c43d
RT
537# The libgdbm < 1.8.3-5 from the AIX Toolbox is not working
538# because two wrong .h are present
539if [ -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 / /'`
543 i_gdbm='undef'
544 i_gdbmndbm='undef'
545fi
e014a478 546
8bbccb27
JH
547# Some releases (and patch levels) of AIX cannot have both
548# long doubles and infinity (infinity plus one equals ... NaNQ!)
78c93c95
JH
549#
550# This deficiency, and others, is apparently a well-documented feature
551# of AIX 128-bit long doubles:
552#
553# http://www-01.ibm.com/support/knowledgecenter/ssw_aix_61/com.ibm.aix.genprogc/128bit_long_double_floating-point_datatype.htm
554#
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.
558#
559# Some salient points:
560#
561# <quote>
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)
582# </quote>
583#
584# The missing math functions affect the POSIX extension math interfaces.
585
8bbccb27 586case "$uselongdouble" in
1a78f2f4 587'')
8bbccb27
JH
588 echo "Checking if your infinity is working with long doubles..." >&4
589 cat > inf$$.c <<EOF
590#include <math.h>
591#include <stdio.h>
592int main() {
593 long double inf = INFINITY;
594 long double one = 1.0L;
595 printf("%Lg\n", inf + one);
596}
597EOF
598 $cc -qlongdouble -o inf$$ inf$$.c -lm
599 case `./inf$$` in
600 INF) echo "Your infinity is working correctly with long doubles." >&4 ;;
1a78f2f4 601 *) # NaNQ (or anything else than INF)
5df8ece2
JH
602 echo " "
603 echo "Your infinity is broken, I suggest disabling long doubles." >&4
5df8ece2
JH
604 rp="Disable long doubles?"
605 dflt="y"
606 . UU/myread
607 case "$ans" in
608 [Yy]*)
609 echo "Okay, disabling long doubles." >&4
1a78f2f4 610 uselongdouble="$undef"
7928175e
JH
611 ccflags=`echo " $ccflags " | sed -e 's/ -qlongdouble / /'`
612 libswanted=`echo " $libswanted " | sed -e 's/ c128/ /'`
613 lddlflags=`echo " $lddlflags " | sed -e 's/ -lc128 / /'`
5df8ece2
JH
614 ;;
615 *)
616 echo "Okay, keeping long doubles enabled." >&4
5df8ece2
JH
617 ;;
618 esac
8bbccb27
JH
619 ;;
620 esac
621 rm -f inf$$.c inf$$
622 ;;
623esac
624
e014a478 625# Some releases (and patch levels) of AIX have a broken powl().
8bbccb27 626pp_cflags=''
e014a478
JH
627case "$uselongdouble" in
628define)
629 echo "Checking if your powl() is broken..." >&4
630 cat > powl$$.c <<EOF
631#include <math.h>
632#include <stdio.h>
633int main() {
634 printf("%Lg\n", powl(-3.0L, 2.0L));
635}
636EOF
e219c9bd
JH
637 case "$gccversion" in
638 '') $cc -qlongdouble -o powl$$ powl$$.c -lm ;;
639 *) $cc -o powl$$ powl$$.c -lm ;;
640 esac
e014a478
JH
641 case `./powl$$` in
642 9) echo "Your powl() is working correctly." >&4 ;;
643 *)
8bbccb27
JH
644 echo "Your powl() is broken, will use a workaround." >&4
645 pp_cflags='ccflags="$ccflags -DHAS_AIX_POWL_NEG_BASE_BUG"'
e014a478
JH
646 ;;
647 esac
648 rm -f powl$$.c powl$$
649 ;;
650esac
651
bc75599f
JH
652# Some releases of AIX cc/xlc a broken fmodl(), but -q64 seems to help.
653case "$gccversion" in
654'') case "$uselongdouble" in
655 define)
656 case "$ccflags" in
657 *-q64*) ;;
658 *) echo "Checking if your fmodl() is broken..." >&4
659 cat > fmodl$$.c <<EOF
660#include <math.h>
661#include <stdio.h>
662int main() {
663 printf("%ld\n", (long)fmodl(powl(2, 31), (long double)4294967295));
664}
665EOF
666 $cc -qlongdouble -o fmodl$$ fmodl$$.c -lm
667 case `./fmodl$$` in
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
671 case `./fmodl$$` in
672 2147483648)
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"
678 ;;
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 / /'`
685 ;;
686 esac # second fmodl$$
687 ;;
688 esac # first fmodl$$
689 ;;
690 esac # Checking if ...
691 ;;
692 esac # uselongdouble
693 rm -f fmodl$$.c fmodl$$
694 ;;
695esac # not gcc
696
697
5b877257 698# EOF