This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Added hints_4.sh for specific AIX 4 support
[perl5.git] / hints / aix_4.sh
CommitLineData
b6d030a4
MB
1# hints/aix.sh
2#
3# Split off from aix.sh on 04 Feb 2004 by H.Merijn Brand
4#
5# AIX 4.1 hints thanks to Christopher Chan-Nui <channui@austin.ibm.com>.
6# AIX 4.1 pthreading by Christopher Chan-Nui <channui@austin.ibm.com> and
7# Jarkko Hietaniemi <jhi@iki.fi>.
8# AIX 4.3.x LP64 build by Steven Hirsch <hirschs@btv.ibm.com>
9# Merged on Mon Feb 6 10:22:35 EST 1995 by
10# Andy Dougherty <doughera@lafayette.edu>
11
12# Contact dfavor@corridor.com for any of the following:
13#
14# - AIX 43x and above support
15# - gcc + threads support
16# - socks support
17#
18# Apr 99 changes:
19#
20# - use nm in AIX 43x and above
21# - gcc + threads now builds
22# [(added support for socks) Jul 99 SOCKS support rewritten]
23#
24# Notes:
25#
26# - shared libperl support is tricky. if ever libperl.a ends up
27# in /usr/local/lib/* it can override any subsequent builds of
28# that same perl release. to make sure you know where the shared
29# libperl.a is coming from do a 'dump -Hv perl' and check all the
30# library search paths in the loader header.
31#
32# it would be nice to warn the user if a libperl.a exists that is
33# going to override the current build, but that would be complex.
34#
35# better yet, a solid fix for this situation should be developed.
36#
37
38# Configure finds setrgid and setruid, but they're useless. The man
39# pages state:
40# setrgid: The EPERM error code is always returned.
41# setruid: The EPERM error code is always returned. Processes cannot
42# reset only their real user IDs.
43d_setrgid='undef'
44d_setruid='undef'
45
46alignbytes=8
47
48case "$usemymalloc" in
49 '') usemymalloc='n' ;;
50 esac
51
52# Intuiting the existence of system calls under AIX is difficult,
53# at best; the safest technique is to find them empirically.
54
55# AIX 4.3.* and above default to letting Configure test if nm
56# extraction will work.
57case "$osvers" in
58 4.1.*|4.2.*)
59 case "$usenm" in
60 '') usenm='undef' ;;
61 esac
62 case "$usenativedlopen" in
63 '') usenativedlopen='false' ;;
64 esac
65 ;;
66 *)
67 case "$usenativedlopen" in
68 '') usenativedlopen='true' ;;
69 esac
70 ;;
71 esac
72
73so="a"
74# AIX itself uses .o (libc.o) but we prefer compatibility
75# with the rest of the world and with rest of the scripting
76# languages (Tcl, Python) and related systems (SWIG).
77# Stephanie Beals <bealzy@us.ibm.com>
78dlext="so"
79
80# Take possible hint from the environment. If 32-bit is set in the
81# environment, we can override it later. If set for 64, the
82# 'sizeof' test sees a native 64-bit architecture and never looks back.
83case "$OBJECT_MODE" in
84 32)
85 cat >&4 <<EOF
86
87You have OBJECT_MODE=32 set in the environment.
88I take this as a hint you do not want to
89build for a 64-bit address space. You will be
90given the opportunity to change this later.
91EOF
92 ;;
93 64)
94 cat >&4 <<EOF
95
96You have OBJECT_MODE=64 set in the environment.
97This forces a full 64-bit build. If that is
98not what you intended, please terminate this
99program, unset it and restart.
100EOF
101 ;;
102 *) ;;
103 esac
104
105# uname -m output is too specific and not appropriate here
106case "$archname" in
107 '') archname="$osname" ;;
108 esac
109
110cc=${cc:-cc}
111ccflags="$ccflags -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE"
112case "$cc" in
113 *gcc*) ;;
114 *) ccflags="$ccflags -qmaxmem=-1 -qnoansialias" ;;
115 esac
116nm_opt='-B'
117
118# These functions don't work like Perl expects them to.
119d_setregid='undef'
120d_setreuid='undef'
121
122# Changes for dynamic linking by Wayne Scott <wscott@ichips.intel.com>
123#
124# Tell perl which symbols to export for dynamic linking.
125cccdlflags='none' # All AIX code is position independent
126 cc_type=xlc # do not export to config.sh
127case "$cc" in
128 *gcc*)
129 cc_type=gcc
130 ccdlflags='-Xlinker'
131 if [ "X$gccversion" = "X" ]; then
132 # Done too late in Configure if hinted
133 gccversion=`$cc --version | sed 's/.*(GCC) *//'`
134 fi
135 ;;
136
137 *) ccversion=`lslpp -L | grep 'C for AIX Compiler$' | grep -v '\.msg\.[A-Za-z_]*\.' | head -1 | awk '{print $1,$2}'`
138 case "$ccversion" in
139 '') ccversion=`lslpp -L | grep 'IBM C and C++ Compilers LUM$'`
140 ;;
141
142 *.*.*.*.*.*.*) # Ahhrgg, more than one C compiler installed
143 first_cc_path=`which ${cc:-cc}`
144 case "$first_cc_path" in
145 *vac*)
146 cc_type=vac ;;
147 /usr/bin/cc) # Check the symlink
148 if [ -h $first_cc_path ] ; then
149 ls -l $first_cc_path > reflect
150 if grep -i vac reflect >/dev/null 2>&1 ; then
151 cc_type=vac
152 fi
153 rm -f reflect
154 fi
155 ;;
156 esac
157 ccversion=`lslpp -L | grep 'C for AIX Compiler$' | grep -i $cc_type | head -1`
158 ;;
159
160 vac*.*.*.*)
161 cc_type=vac
162 ;;
163 esac
164 ccversion=`echo "$ccversion" | awk '{print $2}'`
165
166 case "$ccversion" in
167 3.6.6.0)
168 optimize='none'
169 ;;
170
171 4.4.0.0|4.4.0.1|4.4.0.2)
172 cat >&4 <<EOF
173***
174*** This C compiler ($ccversion) is outdated.
175***
176*** Please upgrade to at least 4.4.0.3.
177***
178EOF
179 ;;
180
181 5.0.0.0)
182 cat >&4 <<EOF
183***
184*** This C compiler ($ccversion) is known to have too many optimizer
185*** bugs to compile a working Perl.
186***
187*** Consider upgrading your C compiler, or getting the GNU cc (gcc).
188***
189*** Cannot continue, aborting.
190EOF
191 exit 1
192 ;;
193
194 5.0.1.0)
195 cat >&4 <<EOF
196***
197*** This C compiler ($ccversion) is known to have optimizer problems
198*** when compiling regcomp.c.
199***
200*** Disabling optimization for that file but consider upgrading
201*** your C compiler.
202***
203EOF
204regcomp_cflags='optimize='
205 ;;
206 esac
207 esac
208# the required -bE:$installarchlib/CORE/perl.exp is added by
209# libperl.U (Configure) later.
210
211# The first 3 options would not be needed if dynamic libs. could be linked
212# with the compiler instead of ld.
213# -bI:$(PERL_INC)/perl.exp Read the exported symbols from the perl binary
214# -bE:$(BASEEXT).exp Export these symbols. This file contains only one
215# symbol: boot_$(EXP) can it be auto-generated?
216lddlflags="$lddlflags -bhalt:4 -bM:SRE -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc"
217
218case "$use64bitall" in
219 $define|true|[yY]*) use64bitint="$define" ;;
220 esac
221
222case "$usemorebits" in
223 $define|true|[yY]*) use64bitint="$define"; uselongdouble="$define" ;;
224 esac
225
226case $cc_type in
227 vac|xlc)
228 case "$uselongdouble" in
229 $define|true|[yY]*)
230 ccflags="$ccflags -qlongdouble"
231 libswanted="c128 $libswanted"
232 lddlflags=`echo "$lddlflags " | sed -e 's/ -lc / -lc128 -lc /'`
233 ;;
234 esac
235 esac
236
237case "$cc" in
238 *gcc*) ;;
239 cc*|xlc*) # cc should've been set by line 116 or so if empty.
240 if test ! -x /usr/bin/$cc -a -x /usr/vac/bin/$cc; then
241 case ":$PATH:" in
242 *:/usr/vac/bin:*) ;;
243 *) if test ! -x /QOpenSys/usr/bin/$cc; then
244 # The /QOpenSys/usr/bin/$cc saves us if we are
245 # building natively in OS/400 PASE.
246 cat >&4 <<EOF
247
248***
249*** You either implicitly or explicitly specified an IBM C compiler,
250*** but you do not seem to have one in /usr/bin, but you seem to have
251*** the VAC installed in /usr/vac, but you do not have the /usr/vac/bin
252*** in your PATH. I suggest adding that and retrying Configure.
253***
254EOF
255 exit 1
256 fi
257 ;;
258 esac
259 fi
260 ;;
261 esac
262
263case "$ldlibpthname" in
264 '') ldlibpthname=LIBPATH ;;
265 esac
266
267# AIX 4.2 (using latest patchlevels on 20001130) has a broken bind
268# library (getprotobyname and getprotobynumber are outversioned by
269# the same calls in libc, at least for xlc version 3...
270case "`oslevel`" in
271 4.2.1.*)
272 case "$ccversion" in # Don't know if needed for gcc
273 3.1.4.*|5.0.2.*) # libswanted "bind ... c ..." => "... c bind ..."
274 set `echo X "$libswanted "| sed -e 's/ bind\( .*\) \([cC]\) / \1 \2 bind /'`
275 shift
276 libswanted="$*"
277 ;;
278 esac
279 ;;
280 esac
281
282# This script UU/usethreads.cbu will get 'called-back' by Configure
283# after it has prompted the user for whether to use threads.
284cat > UU/usethreads.cbu <<'EOCBU'
285case "$usethreads" in
286 $define|true|[yY]*)
287 d_drand48_r='undef'
288 d_endgrent_r='undef'
289 d_endpwent_r='undef'
290 d_getgrent_r='undef'
291 d_getpwent_r='undef'
292 d_random_r='undef'
293 d_setgrent_r='undef'
294 d_setpwent_r='undef'
295 d_srand48_r='undef'
296 d_strerror_r='undef'
297
298 ccflags="$ccflags -DNEED_PTHREAD_INIT"
299 case "$cc" in
300 *gcc*)
301 ccflags="-D_THREAD_SAFE $ccflags"
302 ;;
303 cc_r) ;;
304 cc|xl[cC]|xl[cC]_r)
305 echo >&4 "Switching cc to cc_r because of POSIX threads."
306 # xlc_r has been known to produce buggy code in AIX 4.3.2.
307 # (e.g. pragma/overload core dumps) Let's suspect xlC_r, too.
308 # --jhi@iki.fi
309 cc=cc_r
310
311 case "`oslevel`" in
312 4.2.1.*) i_crypt='undef' ;;
313 esac
314 ;;
315 '')
316 cc=cc_r
317 ;;
318 *)
319 cat >&4 <<EOM
320*** For pthreads you should use the AIX C compiler cc_r.
321*** (now your compiler was set to '$cc')
322*** Cannot continue, aborting.
323EOM
324 exit 1
325 ;;
326 esac
327
328 # c_rify libswanted.
329 set `echo X "$libswanted "| sed -e 's/ \([cC]\) / \1_r /g'`
330 shift
331 libswanted="$*"
332 # c_rify lddlflags.
333 set `echo X "$lddlflags "| sed -e 's/ \(-l[cC]\) / \1_r /g'`
334 shift
335 lddlflags="$*"
336
337 # Insert pthreads to libswanted, before any libc or libC.
338 set `echo X "$libswanted "| sed -e 's/ \([cC]_r\) / pthreads \1 /'`
339 shift
340 libswanted="$*"
341 # Insert pthreads to lddlflags, before any libc or libC.
342 set `echo X "$lddlflags " | sed -e 's/ \(-l[cC]_r\) / -lpthreads \1 /'`
343 shift
344 lddlflags="$*"
345 ;;
346 esac
347EOCBU
348
349# This script UU/uselargefiles.cbu will get 'called-back' by Configure
350# after it has prompted the user for whether to use large files.
351cat > UU/uselargefiles.cbu <<'EOCBU'
352case "$uselargefiles" in
353 ''|$define|true|[yY]*)
354 # Configure should take care of use64bitint and use64bitall being
355 # defined before uselargefiles.cbu is consulted.
356 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
357# Keep these at the left margin.
358ccflags_uselargefiles="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
359ldflags_uselargefiles="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
360 else
361# Keep these at the left margin.
362ccflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_CFLAGS 2>/dev/null`"
363ldflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LDFLAGS 2>/dev/null`"
364 fi
365
366 # _Somehow_ in AIX 4.3.1.0 the above getconf call manages to
367 # insert(?) *something* to $ldflags so that later (in Configure) evaluating
368 # $ldflags causes a newline after the '-b64' (the result of the getconf).
369 # (nothing strange shows up in $ldflags even in hexdump;
370 # so it may be something (a bug) in the shell, instead?)
371 # Try it out: just uncomment the below line and rerun Configure:
372# echo >&4 "AIX 4.3.1.0 $ldflags_uselargefiles mystery" ; exit 1
373 # Just don't ask me how AIX does it, I spent hours wondering.
374 # Therefore the line re-evaluating ldflags_uselargefiles: it seems to fix
375 # the whatever it was that AIX managed to break. --jhi
376 ldflags_uselargefiles="`echo $ldflags_uselargefiles`"
377 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
378# Keep this at the left margin.
379libswanted_uselargefiles="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
380 else
381# Keep this at the left margin.
382libswanted_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
383 fi
384
385 case "$ccflags_uselargefiles$ldflags_uselargefiles$libs_uselargefiles" in
386 '') ;;
387 *) ccflags="$ccflags $ccflags_uselargefiles"
388 ldflags="$ldflags $ldflags_uselargefiles"
389 libswanted="$libswanted $libswanted_uselargefiles"
390 ;;
391 esac
392
393 case "$gccversion" in
394 '') ;;
395 *) # Remove xlc-specific -qflags.
396 ccflags="`echo $ccflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
397 ldflags="`echo $ldflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
398 # Move xlc-specific -bflags.
399 ccflags="`echo $ccflags | sed -e 's@ -b@ -Wl,-b@g'`"
400 ldflags="`echo ' '$ldflags | sed -e 's@ -b@ -Wl,-b@g'`"
401 lddlflags="`echo ' '$lddlflags | sed -e 's@ -b@ -Wl,-b@g'`"
402 ld='gcc'
403 echo >&4 "(using ccflags $ccflags)"
404 echo >&4 "(using ldflags $ldflags)"
405 echo >&4 "(using lddlflags $lddlflags)"
406 ;;
407 esac
408 ;;
409 esac
410EOCBU
411
412# This script UU/use64bitint.cbu will get 'called-back' by Configure
413# after it has prompted the user for whether to use 64 bit integers.
414cat > UU/use64bitint.cbu <<'EOCBU'
415case "$use64bitint" in
416 $define|true|[yY]*)
417 case "`oslevel`" in
418 4.[012].*)
419 cat >&4 <<EOM
420AIX `oslevel` does not support 64-bit interfaces.
421You should upgrade to at least AIX 4.3.
422EOM
423 exit 1
424 ;;
425 esac
426 ;;
427 esac
428EOCBU
429
430cat > UU/use64bitall.cbu <<'EOCBU'
431# This script UU/use64bitall.cbu will get 'called-back' by Configure
432# after it has prompted the user for whether to be maximally 64-bitty.
433case "$use64bitall" in
434 $define|true|[yY]*)
435 case "`oslevel`" in
436 4.[012].*)
437 cat >&4 <<EOM
438AIX `oslevel` does not support 64-bit interfaces.
439You should upgrade to at least AIX 4.3.
440EOM
441 exit 1
442 ;;
443 esac
444 echo " "
445 echo "Checking the CPU width of your hardware..." >&4
446 $cat >size.c <<EOCP
447#include <stdio.h>
448#include <sys/systemcfg.h>
449int main (void)
450{
451 printf ("%d\n", _system_configuration.width);
452 return (0);
453 }
454EOCP
455 set size
456 if eval $compile_ok; then
457 qacpuwidth=`./size`
458 echo "You are running on $qacpuwidth bit hardware."
459 else
460 dflt="32"
461 echo " "
462 echo "(I can't seem to compile the test program. Guessing...)"
463 rp="What is the width of your CPU (in bits)?"
464 . ./myread
465 qacpuwidth="$ans"
466 fi
467 $rm -f size.c size
468 case "$qacpuwidth" in
469 32*)
470 cat >&4 <<EOM
471Bzzzt! At present, you can only perform a
472full 64-bit build on a 64-bit machine.
473EOM
474 exit 1
475 ;;
476 esac
477
478 qacflags="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
479 qaldflags="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
480 # See jhi's comments above regarding this re-eval. I've
481 # seen similar weirdness in the form of:
482 #
483 # 1506-173 (W) Option lm is not valid. Enter xlc for list of valid options.
484 #
485 # error messages from 'cc -E' invocation. Again, the offending
486 # string is simply not detectable by any means. Since it doesn't
487 # do any harm, I didn't pursue it. -- sh
488 qaldflags="`echo $qaldflags`"
489 qalibs="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
490 # -q32 and -b32 may have been set by uselargefiles or user.
491 # Remove them.
492 ccflags="`echo $ccflags | sed -e 's@-q32@@'`"
493 ldflags="`echo $ldflags | sed -e 's@-b32@@'`"
494 # Tell archiver to use large format. Unless we remove 'ar'
495 # from 'trylist', the Configure script will just reset it to 'ar'
496 # immediately prior to writing config.sh. This took me hours
497 # to figure out.
498 trylist="`echo $trylist | sed -e 's@^ar @@' -e 's@ ar @ @g' -e 's@ ar$@@'`"
499 ar="ar -X64"
500 nm_opt="-X64 $nm_opt"
501 # Note: Placing the 'qacflags' variable into the 'ldflags' string
502 # is NOT a typo. ldflags is passed to the C compiler for final
503 # linking, and it wants -q64 (-b64 is for ld only!).
504 case "$qacflags$qaldflags$qalibs" in
505 '') ;;
506 *) ccflags="$ccflags $qacflags"
507 ldflags="$ldflags $qacflags"
508 lddlflags="$qaldflags $lddlflags"
509 libswanted="$libswanted $qalibs"
510 ;;
511 esac
512 case "$ccflags" in
513 *-DUSE_64_BIT_ALL*) ;;
514 *) ccflags="$ccflags -DUSE_64_BIT_ALL";;
515 esac
516 case "$archname64" in
517 ''|64*) archname64=64all ;;
518 esac
519 longsize="8"
520 qacflags=''
521 qaldflags=''
522 qalibs=''
523 qacpuwidth=''
524 ;;
525 esac
526EOCBU
527
528if test $usenativedlopen = 'true' ; then
529 ccflags="$ccflags -DUSE_NATIVE_DLOPEN"
530 case "$cc" in
531 *gcc*) ldflags="$ldflags -Wl,-brtl" ;;
532 *) ldflags="$ldflags -brtl" ;;
533 esac
534else
535 case `oslevel` in
536 4.2.*) ;; # libC_r has broke gettimeofday
537 *) # If the C++ libraries, libC and libC_r, are available we will
538 # prefer them over the vanilla libc, because the libC contain
539 # loadAndInit() and terminateAndUnload() which work correctly
540 # with C++ statics while libc load() and unload() do not. See
541 # ext/DynaLoader/dl_aix.xs. The C-to-C_r switch is done by
542 # usethreads.cbu, if needed.
543 if test -f /lib/libC.a -a X"`$cc -v 2>&1 | grep gcc`" = X; then
544 # Cify libswanted.
545 set `echo X "$libswanted "| sed -e 's/ c / C c /'`
546 shift
547 libswanted="$*"
548 # Cify lddlflags.
549 set `echo X "$lddlflags "| sed -e 's/ -lc / -lC -lc /'`
550 shift
551 lddlflags="$*"
552 fi
553 esac
554 fi
555
556case "$PASE" in
557 define)
558 case "$prefix" in
559 '') prefix=/QOpenSys/perl ;;
560 esac
561 cat >&4 <<EOF
562
563***
564*** You seem to be compiling in AIX for the OS/400 PASE environment.
565*** I'm not going to use the AIX bind, nsl, and possible util libraries, then.
566*** I'm also not going to install perl as /usr/bin/perl.
567*** Perl will be installed under $prefix.
568*** For instructions how to install this build from AIX to PASE,
569*** see the file README.os400. Accept the "aix" for the question
570*** about "Operating system name".
571***
572EOF
573 set `echo " $libswanted " | sed -e 's@ bind @ @' -e 's@ nsl @ @' -e 's@ util @ @'`
574 shift
575 libswanted="$*"
576 installusrbinperl="$undef"
577
578 # V5R1 doesn't have this (V5R2 does), without knowing
579 # which one we have it's safer to be pessimistic.
580 # Cwd will work fine even without fchdir(), but if
581 # V5R1 tries to use code compiled assuming fchdir(),
582 # lots of grief will issue forth from Cwd.
583 case "$d_fchdir" in
584 '') d_fchdir="$undef" ;;
585 esac
586 ;;
587 esac
588
589# EOF