This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
debugger (step backwards)
[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*) ;;
88567e60 114 *) ccflags="$ccflags -qmaxmem=-1 -qnoansialias" ;;
b6d030a4
MB
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
88567e60
MB
207 case "$ccversion" in
208 5*) usemallocwrap='n' ;; # causes panic in miniperl
209 esac
b6d030a4
MB
210 esac
211# the required -bE:$installarchlib/CORE/perl.exp is added by
212# libperl.U (Configure) later.
213
214# The first 3 options would not be needed if dynamic libs. could be linked
215# with the compiler instead of ld.
216# -bI:$(PERL_INC)/perl.exp Read the exported symbols from the perl binary
217# -bE:$(BASEEXT).exp Export these symbols. This file contains only one
218# symbol: boot_$(EXP) can it be auto-generated?
219lddlflags="$lddlflags -bhalt:4 -bM:SRE -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc"
220
221case "$use64bitall" in
222 $define|true|[yY]*) use64bitint="$define" ;;
223 esac
224
225case "$usemorebits" in
226 $define|true|[yY]*) use64bitint="$define"; uselongdouble="$define" ;;
227 esac
228
229case $cc_type in
230 vac|xlc)
231 case "$uselongdouble" in
232 $define|true|[yY]*)
233 ccflags="$ccflags -qlongdouble"
234 libswanted="c128 $libswanted"
235 lddlflags=`echo "$lddlflags " | sed -e 's/ -lc / -lc128 -lc /'`
236 ;;
237 esac
238 esac
239
240case "$cc" in
241 *gcc*) ;;
242 cc*|xlc*) # cc should've been set by line 116 or so if empty.
243 if test ! -x /usr/bin/$cc -a -x /usr/vac/bin/$cc; then
244 case ":$PATH:" in
245 *:/usr/vac/bin:*) ;;
246 *) if test ! -x /QOpenSys/usr/bin/$cc; then
247 # The /QOpenSys/usr/bin/$cc saves us if we are
248 # building natively in OS/400 PASE.
249 cat >&4 <<EOF
250
251***
252*** You either implicitly or explicitly specified an IBM C compiler,
253*** but you do not seem to have one in /usr/bin, but you seem to have
254*** the VAC installed in /usr/vac, but you do not have the /usr/vac/bin
255*** in your PATH. I suggest adding that and retrying Configure.
256***
257EOF
258 exit 1
259 fi
260 ;;
261 esac
262 fi
263 ;;
264 esac
265
266case "$ldlibpthname" in
267 '') ldlibpthname=LIBPATH ;;
268 esac
269
270# AIX 4.2 (using latest patchlevels on 20001130) has a broken bind
271# library (getprotobyname and getprotobynumber are outversioned by
272# the same calls in libc, at least for xlc version 3...
273case "`oslevel`" in
274 4.2.1.*)
275 case "$ccversion" in # Don't know if needed for gcc
276 3.1.4.*|5.0.2.*) # libswanted "bind ... c ..." => "... c bind ..."
277 set `echo X "$libswanted "| sed -e 's/ bind\( .*\) \([cC]\) / \1 \2 bind /'`
278 shift
279 libswanted="$*"
280 ;;
281 esac
282 ;;
283 esac
284
285# This script UU/usethreads.cbu will get 'called-back' by Configure
286# after it has prompted the user for whether to use threads.
287cat > UU/usethreads.cbu <<'EOCBU'
288case "$usethreads" in
289 $define|true|[yY]*)
290 d_drand48_r='undef'
291 d_endgrent_r='undef'
292 d_endpwent_r='undef'
293 d_getgrent_r='undef'
294 d_getpwent_r='undef'
295 d_random_r='undef'
296 d_setgrent_r='undef'
297 d_setpwent_r='undef'
298 d_srand48_r='undef'
299 d_strerror_r='undef'
300
301 ccflags="$ccflags -DNEED_PTHREAD_INIT"
302 case "$cc" in
303 *gcc*)
304 ccflags="-D_THREAD_SAFE $ccflags"
305 ;;
306 cc_r) ;;
307 cc|xl[cC]|xl[cC]_r)
308 echo >&4 "Switching cc to cc_r because of POSIX threads."
309 # xlc_r has been known to produce buggy code in AIX 4.3.2.
310 # (e.g. pragma/overload core dumps) Let's suspect xlC_r, too.
311 # --jhi@iki.fi
312 cc=cc_r
313
314 case "`oslevel`" in
315 4.2.1.*) i_crypt='undef' ;;
316 esac
317 ;;
318 '')
319 cc=cc_r
320 ;;
321 *)
322 cat >&4 <<EOM
323*** For pthreads you should use the AIX C compiler cc_r.
324*** (now your compiler was set to '$cc')
325*** Cannot continue, aborting.
326EOM
327 exit 1
328 ;;
329 esac
330
331 # c_rify libswanted.
332 set `echo X "$libswanted "| sed -e 's/ \([cC]\) / \1_r /g'`
333 shift
334 libswanted="$*"
335 # c_rify lddlflags.
336 set `echo X "$lddlflags "| sed -e 's/ \(-l[cC]\) / \1_r /g'`
337 shift
338 lddlflags="$*"
339
340 # Insert pthreads to libswanted, before any libc or libC.
341 set `echo X "$libswanted "| sed -e 's/ \([cC]_r\) / pthreads \1 /'`
342 shift
343 libswanted="$*"
344 # Insert pthreads to lddlflags, before any libc or libC.
345 set `echo X "$lddlflags " | sed -e 's/ \(-l[cC]_r\) / -lpthreads \1 /'`
346 shift
347 lddlflags="$*"
348 ;;
349 esac
350EOCBU
351
352# This script UU/uselargefiles.cbu will get 'called-back' by Configure
353# after it has prompted the user for whether to use large files.
354cat > UU/uselargefiles.cbu <<'EOCBU'
355case "$uselargefiles" in
356 ''|$define|true|[yY]*)
357 # Configure should take care of use64bitint and use64bitall being
358 # defined before uselargefiles.cbu is consulted.
359 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
360# Keep these at the left margin.
361ccflags_uselargefiles="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
362ldflags_uselargefiles="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
363 else
364# Keep these at the left margin.
365ccflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_CFLAGS 2>/dev/null`"
366ldflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LDFLAGS 2>/dev/null`"
367 fi
368
369 # _Somehow_ in AIX 4.3.1.0 the above getconf call manages to
370 # insert(?) *something* to $ldflags so that later (in Configure) evaluating
371 # $ldflags causes a newline after the '-b64' (the result of the getconf).
372 # (nothing strange shows up in $ldflags even in hexdump;
373 # so it may be something (a bug) in the shell, instead?)
374 # Try it out: just uncomment the below line and rerun Configure:
375# echo >&4 "AIX 4.3.1.0 $ldflags_uselargefiles mystery" ; exit 1
376 # Just don't ask me how AIX does it, I spent hours wondering.
377 # Therefore the line re-evaluating ldflags_uselargefiles: it seems to fix
378 # the whatever it was that AIX managed to break. --jhi
379 ldflags_uselargefiles="`echo $ldflags_uselargefiles`"
380 if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
381# Keep this at the left margin.
382libswanted_uselargefiles="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
383 else
384# Keep this at the left margin.
385libswanted_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
386 fi
387
388 case "$ccflags_uselargefiles$ldflags_uselargefiles$libs_uselargefiles" in
389 '') ;;
390 *) ccflags="$ccflags $ccflags_uselargefiles"
391 ldflags="$ldflags $ldflags_uselargefiles"
392 libswanted="$libswanted $libswanted_uselargefiles"
393 ;;
394 esac
395
396 case "$gccversion" in
397 '') ;;
398 *) # Remove xlc-specific -qflags.
399 ccflags="`echo $ccflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
400 ldflags="`echo $ldflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
401 # Move xlc-specific -bflags.
402 ccflags="`echo $ccflags | sed -e 's@ -b@ -Wl,-b@g'`"
403 ldflags="`echo ' '$ldflags | sed -e 's@ -b@ -Wl,-b@g'`"
404 lddlflags="`echo ' '$lddlflags | sed -e 's@ -b@ -Wl,-b@g'`"
405 ld='gcc'
406 echo >&4 "(using ccflags $ccflags)"
407 echo >&4 "(using ldflags $ldflags)"
408 echo >&4 "(using lddlflags $lddlflags)"
409 ;;
410 esac
411 ;;
412 esac
413EOCBU
414
415# This script UU/use64bitint.cbu will get 'called-back' by Configure
416# after it has prompted the user for whether to use 64 bit integers.
417cat > UU/use64bitint.cbu <<'EOCBU'
418case "$use64bitint" in
419 $define|true|[yY]*)
420 case "`oslevel`" in
421 4.[012].*)
422 cat >&4 <<EOM
423AIX `oslevel` does not support 64-bit interfaces.
424You should upgrade to at least AIX 4.3.
425EOM
426 exit 1
427 ;;
428 esac
429 ;;
430 esac
431EOCBU
432
433cat > UU/use64bitall.cbu <<'EOCBU'
434# This script UU/use64bitall.cbu will get 'called-back' by Configure
435# after it has prompted the user for whether to be maximally 64-bitty.
436case "$use64bitall" in
437 $define|true|[yY]*)
438 case "`oslevel`" in
439 4.[012].*)
440 cat >&4 <<EOM
441AIX `oslevel` does not support 64-bit interfaces.
442You should upgrade to at least AIX 4.3.
443EOM
444 exit 1
445 ;;
446 esac
447 echo " "
448 echo "Checking the CPU width of your hardware..." >&4
449 $cat >size.c <<EOCP
450#include <stdio.h>
451#include <sys/systemcfg.h>
452int main (void)
453{
454 printf ("%d\n", _system_configuration.width);
455 return (0);
456 }
457EOCP
458 set size
459 if eval $compile_ok; then
460 qacpuwidth=`./size`
461 echo "You are running on $qacpuwidth bit hardware."
462 else
463 dflt="32"
464 echo " "
465 echo "(I can't seem to compile the test program. Guessing...)"
466 rp="What is the width of your CPU (in bits)?"
467 . ./myread
468 qacpuwidth="$ans"
469 fi
470 $rm -f size.c size
471 case "$qacpuwidth" in
472 32*)
473 cat >&4 <<EOM
474Bzzzt! At present, you can only perform a
475full 64-bit build on a 64-bit machine.
476EOM
477 exit 1
478 ;;
479 esac
480
481 qacflags="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
482 qaldflags="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
483 # See jhi's comments above regarding this re-eval. I've
484 # seen similar weirdness in the form of:
485 #
486 # 1506-173 (W) Option lm is not valid. Enter xlc for list of valid options.
487 #
488 # error messages from 'cc -E' invocation. Again, the offending
489 # string is simply not detectable by any means. Since it doesn't
490 # do any harm, I didn't pursue it. -- sh
491 qaldflags="`echo $qaldflags`"
492 qalibs="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
493 # -q32 and -b32 may have been set by uselargefiles or user.
494 # Remove them.
495 ccflags="`echo $ccflags | sed -e 's@-q32@@'`"
496 ldflags="`echo $ldflags | sed -e 's@-b32@@'`"
497 # Tell archiver to use large format. Unless we remove 'ar'
498 # from 'trylist', the Configure script will just reset it to 'ar'
499 # immediately prior to writing config.sh. This took me hours
500 # to figure out.
501 trylist="`echo $trylist | sed -e 's@^ar @@' -e 's@ ar @ @g' -e 's@ ar$@@'`"
502 ar="ar -X64"
503 nm_opt="-X64 $nm_opt"
504 # Note: Placing the 'qacflags' variable into the 'ldflags' string
505 # is NOT a typo. ldflags is passed to the C compiler for final
506 # linking, and it wants -q64 (-b64 is for ld only!).
507 case "$qacflags$qaldflags$qalibs" in
508 '') ;;
509 *) ccflags="$ccflags $qacflags"
510 ldflags="$ldflags $qacflags"
511 lddlflags="$qaldflags $lddlflags"
512 libswanted="$libswanted $qalibs"
513 ;;
514 esac
515 case "$ccflags" in
516 *-DUSE_64_BIT_ALL*) ;;
517 *) ccflags="$ccflags -DUSE_64_BIT_ALL";;
518 esac
519 case "$archname64" in
520 ''|64*) archname64=64all ;;
521 esac
522 longsize="8"
523 qacflags=''
524 qaldflags=''
525 qalibs=''
526 qacpuwidth=''
527 ;;
528 esac
529EOCBU
530
531if test $usenativedlopen = 'true' ; then
532 ccflags="$ccflags -DUSE_NATIVE_DLOPEN"
533 case "$cc" in
534 *gcc*) ldflags="$ldflags -Wl,-brtl" ;;
535 *) ldflags="$ldflags -brtl" ;;
536 esac
537else
538 case `oslevel` in
539 4.2.*) ;; # libC_r has broke gettimeofday
540 *) # If the C++ libraries, libC and libC_r, are available we will
541 # prefer them over the vanilla libc, because the libC contain
542 # loadAndInit() and terminateAndUnload() which work correctly
543 # with C++ statics while libc load() and unload() do not. See
544 # ext/DynaLoader/dl_aix.xs. The C-to-C_r switch is done by
545 # usethreads.cbu, if needed.
546 if test -f /lib/libC.a -a X"`$cc -v 2>&1 | grep gcc`" = X; then
547 # Cify libswanted.
548 set `echo X "$libswanted "| sed -e 's/ c / C c /'`
549 shift
550 libswanted="$*"
551 # Cify lddlflags.
552 set `echo X "$lddlflags "| sed -e 's/ -lc / -lC -lc /'`
553 shift
554 lddlflags="$*"
555 fi
556 esac
557 fi
558
559case "$PASE" in
560 define)
561 case "$prefix" in
562 '') prefix=/QOpenSys/perl ;;
563 esac
564 cat >&4 <<EOF
565
566***
567*** You seem to be compiling in AIX for the OS/400 PASE environment.
568*** I'm not going to use the AIX bind, nsl, and possible util libraries, then.
569*** I'm also not going to install perl as /usr/bin/perl.
570*** Perl will be installed under $prefix.
571*** For instructions how to install this build from AIX to PASE,
572*** see the file README.os400. Accept the "aix" for the question
573*** about "Operating system name".
574***
575EOF
576 set `echo " $libswanted " | sed -e 's@ bind @ @' -e 's@ nsl @ @' -e 's@ util @ @'`
577 shift
578 libswanted="$*"
579 installusrbinperl="$undef"
580
581 # V5R1 doesn't have this (V5R2 does), without knowing
582 # which one we have it's safer to be pessimistic.
583 # Cwd will work fine even without fchdir(), but if
584 # V5R1 tries to use code compiled assuming fchdir(),
585 # lots of grief will issue forth from Cwd.
586 case "$d_fchdir" in
587 '') d_fchdir="$undef" ;;
588 esac
589 ;;
590 esac
591
592# EOF