xref: /openbsd/gnu/usr.bin/perl/hints/aix_4.sh (revision 09467b48)
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
116
117# since change #28654, _XOPEN_SOURCE symbol needs to be defined on aix 4.2
118# to avoid the following build error in perlio.c :
119# 1506-294 (S) Syntax error in expression on #if directive.
120#
121case "$osvers" in
122    4.2.1.0)
123	ccflags="$ccflags -D_XOPEN_SOURCE"
124	# aix 4.2 does not have IPv6 support
125	d_inetpton='undef'
126	d_inetntop='undef'
127	;;
128    esac
129nm_opt='-B'
130
131# These functions don't work like Perl expects them to.
132d_setregid='undef'
133d_setreuid='undef'
134
135# Changes for dynamic linking by Wayne Scott <wscott@ichips.intel.com>
136#
137# Tell perl which symbols to export for dynamic linking.
138cccdlflags='none'	# All AIX code is position independent
139   cc_type=xlc		# do not export to config.sh
140case "$cc" in
141    *gcc*)
142	cc_type=gcc
143	ccdlflags='-Xlinker'
144	if [ "X$gccversion" = "X" ]; then
145	    # Done too late in Configure if hinted
146	    gccversion=`$cc -dumpversion`
147	    fi
148	;;
149
150    *)  ccversion=`lslpp -L | grep 'C for AIX Compiler$' | grep -v '\.msg\.[A-Za-z_]*\.' | head -1 | awk '{print $1,$2}'`
151	case "$ccversion" in
152	    '') ccversion=`lslpp -L | grep 'IBM C and C++ Compilers LUM$'`
153		;;
154
155	    *.*.*.*.*.*.*)		# Ahhrgg, more than one C compiler installed
156		first_cc_path=`which ${cc:-cc}`
157		case "$first_cc_path" in
158		    *vac*)
159			cc_type=vac ;;
160		    /usr/bin/cc)		# Check the symlink
161			if [ -h $first_cc_path ] ; then
162			    ls -l $first_cc_path > reflect
163			    if grep -i vac reflect >/dev/null 2>&1 ; then
164				cc_type=vac
165				fi
166			    rm -f reflect
167			    fi
168			;;
169		    esac
170		ccversion=`lslpp -L | grep 'C for AIX Compiler$' | grep -i $cc_type | head -1`
171		;;
172
173	    vac*.*.*.*)
174		cc_type=vac
175		;;
176	    esac
177	ccversion=`echo "$ccversion" | awk '{print $2}'`
178
179	case "$ccversion" in
180	    3.6.6.0)
181		optimize='none'
182		;;
183
184	    4.4.0.0|4.4.0.1|4.4.0.2)
185		cat >&4 <<EOF
186***
187*** This C compiler ($ccversion) is outdated.
188***
189*** Please upgrade to at least 4.4.0.3.
190***
191EOF
192		;;
193
194	    5.0.0.0)
195		cat >&4 <<EOF
196***
197*** This C compiler ($ccversion) is known to have too many optimizer
198*** bugs to compile a working Perl.
199***
200*** Consider upgrading your C compiler, or getting the GNU cc (gcc).
201***
202*** Cannot continue, aborting.
203EOF
204		exit 1
205		;;
206
207	    5.0.1.0)
208		cat >&4 <<EOF
209***
210*** This C compiler ($ccversion) is known to have optimizer problems
211*** when compiling regcomp.c.
212***
213*** Disabling optimization for that file but consider upgrading
214*** your C compiler.
215***
216EOF
217regcomp_cflags='optimize='
218		;;
219	    esac
220	case "$ccversion" in
221	    5*) usemallocwrap='n' ;; # causes panic in miniperl
222	    esac
223    esac
224# the required -bE:$installarchlib/CORE/perl.exp is added by
225# libperl.U (Configure) later.
226
227# The first 3 options would not be needed if dynamic libs. could be linked
228# with the compiler instead of ld.
229# -bI:$(PERL_INC)/perl.exp  Read the exported symbols from the perl binary
230# -bE:$(BASEEXT).exp	    Export these symbols.  This file contains only one
231#			    symbol: boot_$(EXP)	 can it be auto-generated?
232if test $usenativedlopen = 'true' ; then
233    lddlflags="$lddlflags -bhalt:4 -bexpall -G -bnoentry -lc"
234else
235    lddlflags="$lddlflags -bhalt:4 -bM:SRE -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc"
236    fi
237
238case "$use64bitall" in
239    $define|true|[yY]*) use64bitint="$define" ;;
240    esac
241
242case "$usemorebits" in
243    $define|true|[yY]*) use64bitint="$define"; uselongdouble="$define" ;;
244    esac
245
246case $cc_type in
247    vac|xlc)
248	case "$uselongdouble" in
249	    $define|true|[yY]*)
250		ccflags="$ccflags -qlongdouble"
251		libswanted="c128 $libswanted"
252		lddlflags=`echo "$lddlflags " | sed -e 's/ -lc / -lc128 -lc /'`
253		;;
254	    esac
255    esac
256
257case "$cc" in
258    *gcc*) ;;
259    cc*|xlc*) # cc should've been set by line 116 or so if empty.
260	if test ! -x /usr/bin/$cc -a -x /usr/vac/bin/$cc; then
261	    case ":$PATH:" in
262		*:/usr/vac/bin:*) ;;
263		*)  if test ! -x /QOpenSys/usr/bin/$cc; then
264			# The /QOpenSys/usr/bin/$cc saves us if we are
265			# building natively in OS/400 PASE.
266			cat >&4 <<EOF
267
268***
269*** You either implicitly or explicitly specified an IBM C compiler,
270*** but you do not seem to have one in /usr/bin, but you seem to have
271*** the VAC installed in /usr/vac, but you do not have the /usr/vac/bin
272*** in your PATH.  I suggest adding that and retrying Configure.
273***
274EOF
275			exit 1
276			fi
277			;;
278		esac
279	    fi
280	;;
281    esac
282
283case "$ldlibpthname" in
284    '') ldlibpthname=LIBPATH ;;
285    esac
286
287# AIX 4.2 (using latest patchlevels on 20001130) has a broken bind
288# library (getprotobyname and getprotobynumber are outversioned by
289# the same calls in libc, at least for xlc version 3...
290case "`oslevel`" in
291    4.2.1.*)
292        case "$ccversion" in    # Don't know if needed for gcc
293	    3.1.4.*|5.0.2.*)    # libswanted "bind ... c ..." => "... c bind ..."
294	        set `echo X "$libswanted "| sed -e 's/ bind\( .*\) \([cC]\) / \1 \2 bind /'`
295	        shift
296	        libswanted="$*"
297	        ;;
298	    esac
299        ;;
300    esac
301
302# This script UU/usethreads.cbu will get 'called-back' by Configure
303# after it has prompted the user for whether to use threads.
304cat > UU/usethreads.cbu <<'EOCBU'
305case "$usethreads" in
306    $define|true|[yY]*)
307	d_drand48_r='undef'
308	d_endgrent_r='undef'
309	d_endpwent_r='undef'
310	d_getgrent_r='undef'
311	d_getpwent_r='undef'
312	d_random_r='undef'
313	d_setgrent_r='undef'
314	d_setpwent_r='undef'
315	d_srand48_r='undef'
316	d_strerror_r='undef'
317
318	ccflags="$ccflags -DNEED_PTHREAD_INIT"
319	case "$cc" in
320	    *gcc*)
321		ccflags="-D_THREAD_SAFE $ccflags"
322		;;
323	    cc_r) ;;
324	    cc|xl[cC]|xl[cC]_r)
325		echo >&4 "Switching cc to cc_r because of POSIX threads."
326		# xlc_r has been known to produce buggy code in AIX 4.3.2.
327		# (e.g. pragma/overload core dumps)	 Let's suspect xlC_r, too.
328		# --jhi@iki.fi
329		cc=cc_r
330
331		case "`oslevel`" in
332		    4.2.1.*) i_crypt='undef' ;;
333		    esac
334		;;
335	    '')
336		cc=cc_r
337		;;
338	    *)
339		cat >&4 <<EOM
340*** For pthreads you should use the AIX C compiler cc_r.
341*** (now your compiler was set to '$cc')
342*** Cannot continue, aborting.
343EOM
344		exit 1
345		;;
346	    esac
347
348	# c_rify libswanted.
349	set `echo X "$libswanted "| sed -e 's/ \([cC]\) / \1_r /g'`
350	shift
351	libswanted="$*"
352	# c_rify lddlflags.
353	set `echo X "$lddlflags "| sed -e 's/ \(-l[cC]\) / \1_r /g'`
354	shift
355	lddlflags="$*"
356
357	# Insert pthreads to libswanted, before any libc or libC.
358	set `echo X "$libswanted "| sed -e 's/ \([cC]_r\) / pthreads \1 /'`
359	shift
360	libswanted="$*"
361	# Insert pthreads to lddlflags, before any libc or libC.
362	set `echo X "$lddlflags " | sed -e 's/ \(-l[cC]_r\) / -lpthreads \1 /'`
363	shift
364	lddlflags="$*"
365	;;
366    esac
367EOCBU
368
369# This script UU/uselargefiles.cbu will get 'called-back' by Configure
370# after it has prompted the user for whether to use large files.
371cat > UU/uselargefiles.cbu <<'EOCBU'
372case "$uselargefiles" in
373    ''|$define|true|[yY]*)
374	# Configure should take care of use64bitint and use64bitall being
375	# defined before uselargefiles.cbu is consulted.
376	if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
377# Keep these at the left margin.
378ccflags_uselargefiles="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
379ldflags_uselargefiles="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
380	else
381# Keep these at the left margin.
382ccflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_CFLAGS 2>/dev/null`"
383ldflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LDFLAGS 2>/dev/null`"
384	    fi
385
386	# _Somehow_ in AIX 4.3.1.0 the above getconf call manages to
387	# insert(?) *something* to $ldflags so that later (in Configure) evaluating
388	# $ldflags causes a newline after the '-b64' (the result of the getconf).
389	# (nothing strange shows up in $ldflags even in hexdump;
390	#  so it may be something (a bug) in the shell, instead?)
391	# Try it out: just uncomment the below line and rerun Configure:
392# echo >&4 "AIX 4.3.1.0 $ldflags_uselargefiles mystery" ; exit 1
393	# Just don't ask me how AIX does it, I spent hours wondering.
394	# Therefore the line re-evaluating ldflags_uselargefiles: it seems to fix
395	# the whatever it was that AIX managed to break. --jhi
396	ldflags_uselargefiles="`echo $ldflags_uselargefiles`"
397	if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
398# Keep this at the left margin.
399libswanted_uselargefiles="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
400	else
401# Keep this at the left margin.
402libswanted_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
403	    fi
404
405	case "$ccflags_uselargefiles$ldflags_uselargefiles$libs_uselargefiles" in
406	    '') ;;
407	    *)  ccflags="$ccflags $ccflags_uselargefiles"
408	        ldflags="$ldflags $ldflags_uselargefiles"
409	        libswanted="$libswanted $libswanted_uselargefiles"
410	        ;;
411	    esac
412
413	case "$gccversion" in
414	    '') ;;
415	    *)  # Remove xlc-specific -qflags.
416	        ccflags="`echo $ccflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
417	        ldflags="`echo $ldflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
418	        # Move xlc-specific -bflags.
419	        ccflags="`echo $ccflags | sed -e 's@ -b@ -Wl,-b@g'`"
420	        ldflags="`echo ' '$ldflags | sed -e 's@ -b@ -Wl,-b@g'`"
421	        lddlflags="`echo ' '$lddlflags | sed -e 's@ -b@ -Wl,-b@g'`"
422		lddlflags="`echo ' '$lddlflags | sed -e 's@ -G @ -Wl,-G @g'`"
423	        ld='gcc'
424	        echo >&4 "(using ccflags   $ccflags)"
425	        echo >&4 "(using ldflags   $ldflags)"
426	        echo >&4 "(using lddlflags $lddlflags)"
427	        ;;
428	    esac
429	;;
430    esac
431EOCBU
432
433# This script UU/use64bitint.cbu will get 'called-back' by Configure
434# after it has prompted the user for whether to use 64 bit integers.
435cat > UU/use64bitint.cbu <<'EOCBU'
436case "$use64bitint" 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	;;
448    esac
449EOCBU
450
451cat > UU/use64bitall.cbu <<'EOCBU'
452# This script UU/use64bitall.cbu will get 'called-back' by Configure
453# after it has prompted the user for whether to be maximally 64-bitty.
454case "$use64bitall" in
455    $define|true|[yY]*)
456	case "`oslevel`" in
457	    4.[012].*)
458		cat >&4 <<EOM
459AIX `oslevel` does not support 64-bit interfaces.
460You should upgrade to at least AIX 4.3.
461EOM
462		exit 1
463		;;
464	    esac
465	echo " "
466	echo "Checking the CPU width of your hardware..." >&4
467	$cat >size.c <<EOCP
468#include <stdio.h>
469#include <sys/systemcfg.h>
470int main (void)
471{
472    printf ("%d\n", _system_configuration.width);
473    return (0);
474    }
475EOCP
476	set size
477	if eval $compile_ok; then
478	    qacpuwidth=`./size`
479	    echo "You are running on $qacpuwidth bit hardware."
480	else
481	    dflt="32"
482	    echo " "
483	    echo "(I can't seem to compile the test program.  Guessing...)"
484	    rp="What is the width of your CPU (in bits)?"
485	    . ./myread
486	    qacpuwidth="$ans"
487	    fi
488	$rm -f size.c size
489	case "$qacpuwidth" in
490	    32*)
491		cat >&4 <<EOM
492Bzzzt! At present, you can only perform a
493full 64-bit build on a 64-bit machine.
494EOM
495		exit 1
496		;;
497	    esac
498
499	qacflags="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
500	qaldflags="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
501	# See jhi's comments above regarding this re-eval.  I've
502	# seen similar weirdness in the form of:
503	#
504	# 1506-173 (W) Option lm is not valid.  Enter xlc for list of valid options.
505	#
506	# error messages from 'cc -E' invocation. Again, the offending
507	# string is simply not detectable by any means.  Since it doesn't
508	# do any harm, I didn't pursue it. -- sh
509	qaldflags="`echo $qaldflags`"
510	qalibs="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
511	# -q32 and -b32 may have been set by uselargefiles or user.
512	# Remove them.
513	ccflags="`echo $ccflags | sed -e 's@-q32@@'`"
514	ldflags="`echo $ldflags | sed -e 's@-b32@@'`"
515	# Tell archiver to use large format.  Unless we remove 'ar'
516	# from 'trylist', the Configure script will just reset it to 'ar'
517	# immediately prior to writing config.sh.  This took me hours
518	# to figure out.
519	trylist="`echo $trylist | sed -e 's@^ar @@' -e 's@ ar @ @g' -e 's@ ar$@@'`"
520	ar="ar -X64"
521	nm_opt="-X64 $nm_opt"
522	# Note: Placing the 'qacflags' variable into the 'ldflags' string
523	# is NOT a typo.  ldflags is passed to the C compiler for final
524	# linking, and it wants -q64 (-b64 is for ld only!).
525	case "$qacflags$qaldflags$qalibs" in
526	    '') ;;
527	    *)  ccflags="$ccflags $qacflags"
528	        ldflags="$ldflags $qacflags"
529	        lddlflags="$qaldflags $lddlflags"
530	        libswanted="$libswanted $qalibs"
531	        ;;
532	    esac
533	case "$ccflags" in
534	    *-DUSE_64_BIT_ALL*) ;;
535	    *) ccflags="$ccflags -DUSE_64_BIT_ALL";;
536	    esac
537	case "$archname64" in
538	    ''|64*) archname64=64all ;;
539	    esac
540	longsize="8"
541	qacflags=''
542	qaldflags=''
543	qalibs=''
544	qacpuwidth=''
545	;;
546    esac
547EOCBU
548
549if test $usenativedlopen = 'true' ; then
550    ccflags="$ccflags -DUSE_NATIVE_DLOPEN"
551    case "$cc" in
552        *gcc*) ldflags="$ldflags -Wl,-brtl" ;;
553        *)     ldflags="$ldflags -brtl" ;;
554        esac
555else
556    case `oslevel` in
557	4.2.*)	;;	# libC_r has broke gettimeofday
558	*)  # If the C++ libraries, libC and libC_r, are available we will
559	    # prefer them over the vanilla libc, because the libC contain
560	    # loadAndInit() and terminateAndUnload() which work correctly
561	    # with C++ statics while libc load() and unload() do not. See
562	    # ext/DynaLoader/dl_aix.xs. The C-to-C_r switch is done by
563	    # usethreads.cbu, if needed.
564	    if test -f /lib/libC.a -a X"`$cc -v 2>&1 | grep gcc`" = X; then
565		# Cify libswanted.
566		set `echo X "$libswanted "| sed -e 's/ c / C c /'`
567		shift
568		libswanted="$*"
569		# Cify lddlflags.
570		set `echo X "$lddlflags "| sed -e 's/ -lc / -lC -lc /'`
571		shift
572		lddlflags="$*"
573		fi
574	esac
575    fi
576
577case "$PASE" in
578    define)
579	case "$prefix" in
580	    '') prefix=/QOpenSys/perl ;;
581	    esac
582	cat >&4 <<EOF
583
584***
585*** You seem to be compiling in AIX for the OS/400 PASE environment.
586*** I'm not going to use the AIX bind, nsl, and possible util libraries, then.
587*** I'm also not going to install perl as /usr/bin/perl.
588*** Perl will be installed under $prefix.
589*** For instructions how to install this build from AIX to PASE,
590*** see the file README.os400.  Accept the "aix" for the question
591*** about "Operating system name".
592***
593EOF
594	set `echo " $libswanted " | sed -e 's@ bind @ @' -e 's@ nsl @ @' -e 's@ util @ @'`
595	shift
596	libswanted="$*"
597	installusrbinperl="$undef"
598
599	# V5R1 doesn't have this (V5R2 does), without knowing
600	# which one we have it's safer to be pessimistic.
601	# Cwd will work fine even without fchdir(), but if
602	# V5R1 tries to use code compiled assuming fchdir(),
603	# lots of grief will issue forth from Cwd.
604	case "$d_fchdir" in
605	    '') d_fchdir="$undef" ;;
606	    esac
607	;;
608    esac
609
610# EOF
611