xref: /openbsd-src/gnu/usr.bin/perl/hints/aix.sh (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1# hints/aix.sh
2
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
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#
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#
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
32#	      reset only their real user IDs.
33d_setrgid='undef'
34d_setruid='undef'
35
36alignbytes=8
37
38case "$usemymalloc" in
39    '')  usemymalloc='n' ;;
40    esac
41
42# malloc wrap works, but not in vac-5, see later
43case "$usemallocwrap" in
44    '') usemallocwrap='define' ;;
45    esac
46
47# Intuiting the existence of system calls under AIX is difficult,
48# at best; the safest technique is to find them empirically.
49
50case "$usenativedlopen" in
51    '') usenativedlopen='true' ;;
52    esac
53
54so="a"
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>
59dlext="so"
60
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.
64case "$OBJECT_MODE" in
65    32) cat >&4 <<EOF
66
67You have OBJECT_MODE=32 set in the environment.
68I take this as a hint you do not want to
69build for a 64-bit address space. You will be
70given the opportunity to change this later.
71EOF
72	;;
73    64) cat >&4 <<EOF
74
75You have OBJECT_MODE=64 set in the environment.
76This forces a full 64-bit build.  If that is
77not what you intended, please terminate this
78program, unset it and restart.
79EOF
80	;;
81    esac
82
83 s=`lslpp -lc bos.adt.libm >/dev/null`
84if [ $? != 0 ]; then
85    echo "You cannot build perl without the bos.adt.libm package installed" >&4
86    exit
87    fi
88
89# uname -m output is too specific and not appropriate here
90case "$archname" in
91    '') archname="$osname" ;;
92    esac
93
94cc=${cc:-cc}
95
96ccflags="$ccflags -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE"
97case "$cc" in
98    *gcc*) ;;
99    *) ccflags="$ccflags -qmaxmem=-1 -qnoansialias -qlanglvl=extc99" ;;
100    esac
101nm_opt='-B'
102
103# These functions don't work like Perl expects them to.
104d_setregid='undef'
105d_setreuid='undef'
106
107# Changes for dynamic linking by Wayne Scott <wscott@ichips.intel.com>
108#
109# Tell perl which symbols to export for dynamic linking.
110cccdlflags='none'	# All AIX code is position independent
111   cc_type=xlc		# do not export to config.sh
112case "$cc" in
113    *gcc*)
114	cc_type=gcc
115	ccdlflags='-Xlinker'
116	if [ "X$gccversion" = "X" ]; then
117	    # Done too late in Configure if hinted
118	    gccversion=`$cc -dumpversion`
119	    fi
120	;;
121
122    *)  ccversion=`lslpp -ql -Ou vac.C | grep -v '^Path' | head -1 | awk '{print $1,$2}'`
123	case "$ccversion" in
124	    '') ccversion=`lslpp -L | grep 'IBM C and C++ Compilers LUM$'` ;;
125
126	    *.*.*.*.*.*.*)	# Ahhrgg, more than one C compiler installed
127		first_cc_path=`which ${cc:-cc}`
128		case "$first_cc_path" in
129		    *vac*)
130			cc_type=vac ;;
131
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
136				cc_type=vac
137				fi
138			    rm -f reflect
139			    fi
140			;;
141		    esac
142		ccversion=`lslpp -L | grep 'C for AIX Compiler$' | grep -i $cc_type | head -1`
143		;;
144
145	    vac*.*.*.*)
146		cc_type=vac
147		;;
148	    esac
149
150	ccversion=`echo "$ccversion" | awk '{print $2}'`
151	# Redbooks state AIX-5 only supports vac-5.0.2.0 and up
152	case "$ccversion" in
153	    5*) usemallocwrap='n' ;; # panic in miniperl
154	    esac
155	;;
156    esac
157
158# the required -bE:$installarchlib/CORE/perl.exp is added by
159# libperl.U (Configure) later.
160
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?
166if test $usenativedlopen = 'true' ; then
167    lddlflags="$lddlflags -bhalt:4 -G -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc -lm"
168else
169    lddlflags="$lddlflags -bhalt:4 -bM:SRE -bI:\$(PERL_INC)/perl.exp -bE:\$(BASEEXT).exp -bnoentry -lc"
170    fi
171
172case "$use64bitall" in
173    $define|true|[yY]*) use64bitint="$define" ;;
174    esac
175
176case "$usemorebits" in
177    $define|true|[yY]*) use64bitint="$define"; uselongdouble="$define" ;;
178    esac
179
180case $cc_type in
181    vac|xlc)
182	case "$uselongdouble" in
183	    $define|true|[yY]*)
184		ccflags="$ccflags -qlongdouble"
185		libswanted="c128 $libswanted"
186		lddlflags=`echo "$lddlflags " | sed -e 's/ -lc / -lc128 -lc /'`
187		;;
188	    esac
189	;;
190    esac
191
192case "$cc" in
193    *gcc*) ;;
194
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
197	    case ":$PATH:" in
198		*:/usr/vac/bin:*) ;;
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.
202			cat >&4 <<EOF
203
204***
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.
209***
210EOF
211			exit 1
212			fi
213		    ;;
214		esac
215	    fi
216	;;
217    esac
218
219case "$ldlibpthname" in
220    '') ldlibpthname=LIBPATH ;;
221    esac
222
223# This script UU/usethreads.cbu will get 'called-back' by Configure
224# after it has prompted the user for whether to use threads.
225cat > UU/usethreads.cbu <<'EOCBU'
226case "$usethreads" in
227    $define|true|[yY]*)
228	d_drand48_r='undef'
229	d_endgrent_r='undef'
230	d_endpwent_r='undef'
231	d_getgrent_r='undef'
232	d_getpwent_r='undef'
233	d_random_r='undef'
234	d_setgrent_r='undef'
235	d_setpwent_r='undef'
236	d_srand48_r='undef'
237	d_srandom_r='undef'
238	d_strerror_r='undef'
239
240	ccflags="$ccflags -DNEED_PTHREAD_INIT"
241	case "$cc" in
242	    *gcc*)
243	      ccflags="-D_THREAD_SAFE $ccflags"
244	      ;;
245	    cc_r)
246	      ;;
247	    xlc_r)
248	      ;;
249	    # we do not need the C++ compiler
250	    xlC_r)
251	      cc=xlc_r
252	      ;;
253	    '')
254	      cc=cc_r
255	      ;;
256	    *)
257	esac
258
259	# Insert pthreads to libswanted, before any libc or libC.
260	set `echo X "$libswanted "| sed -e 's/ \([cC]\) / pthreads \1 /'`
261	shift
262	libswanted="$*"
263	# Insert pthreads to lddlflags, before any libc or libC.
264	set `echo X "$lddlflags " | sed -e 's/ \(-l[cC]\) / -lpthreads \1 /'`
265	shift
266	lddlflags="$*"
267	;;
268    *)
269	case "$cc" in
270	    xlc)
271	      ;;
272	    # we do not need the C++ compiler
273	    xlC)
274	      cc=xlc
275	      ;;
276	    *)
277	esac
278	;;
279esac
280EOCBU
281
282# This script UU/uselargefiles.cbu will get 'called-back' by Configure
283# after it has prompted the user for whether to use large files.
284cat > UU/uselargefiles.cbu <<'EOCBU'
285case "$uselargefiles" in
286    ''|$define|true|[yY]*)
287	# Configure should take care of use64bitint and use64bitall being
288	# defined before uselargefiles.cbu is consulted.
289	if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
290# Keep these at the left margin.
291ccflags_uselargefiles="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
292ldflags_uselargefiles="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
293	else
294# Keep these at the left margin.
295ccflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_CFLAGS 2>/dev/null`"
296ldflags_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LDFLAGS 2>/dev/null`"
297	    fi
298	if test X"$use64bitint:$quadtype" = X"$define:long" -o X"$use64bitall" = Xdefine; then
299# Keep this at the left margin.
300libswanted_uselargefiles="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
301	else
302# Keep this at the left margin.
303libswanted_uselargefiles="`getconf XBS5_ILP32_OFFBIG_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
304	    fi
305
306	case "$ccflags_uselargefiles$ldflags_uselargefiles$libs_uselargefiles" in
307	    '') ;;
308	    *)  ccflags="$ccflags $ccflags_uselargefiles"
309		ldflags="$ldflags $ldflags_uselargefiles"
310		libswanted="$libswanted $libswanted_uselargefiles"
311		;;
312	    esac
313
314	# -bmaxdata:0x80000000
315	# - This increases the size of heap memory available to perl.
316	#   Default is 256 MB, which sounds large but caused a software
317	#   vendor problems. So this sets heap to 2 GB maximum. Anything
318	#   higher and you'd want to consider 64 bit perl.
319	# - NOTE however, that setting this in 64bit mode will limit your
320	#   amount of available memory to 2GB, so we set this only in
321	#   32bit mode to avoid future problems a la "should be enough
322	#   for everyone" ...
323	#
324	case "$use64bitall" in
325	    $define|true|[yY]*)
326		:
327		;;
328	    *)
329	    	ldflags="$ldflags -bmaxdata:0x80000000"
330		;;
331	    esac
332
333	case "$gccversion" in
334	    '') # Not using gcc.
335	    	# Due to calling $cc without $cflags when linking some
336		# binaries we need to hardwire $cc to the right mode.
337		# The correct fix would be to have Makefile.SH not set
338		# CLDFLAGS from $ldflags ...
339		case "$use64bitall" in
340		    $define|true|[yY]*) cc="$cc -q64"	;;
341		    *)			cc="$cc -q32"	;;
342		    esac
343                # Some 32-bit getconfs will set ccflags to include -qlonglong
344                # but that's no longer needed with an explicit -qextc99.
345                ccflags="`echo $ccflags | sed -e 's@ -qlonglong@@'`"
346		;;
347	    *)  # Remove xlc-specific -qflags.
348		ccflags="`echo $ccflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
349		ldflags="`echo $ldflags | sed -e 's@ -q[^ ]*@ @g' -e 's@^-q[^ ]* @@g'`"
350		# Move xlc-specific -bflags.
351		ccflags="`echo $ccflags | sed -e 's@ -b@ -Wl,-b@g'`"
352		ldflags="`echo ' '$ldflags | sed -e 's@ -b@ -Wl,-b@g'`"
353		lddlflags="`echo ' '$lddlflags | sed -e 's@ -b@ -Wl,-b@g'`"
354		lddlflags="`echo ' '$lddlflags | sed -e 's@ -G @ -Wl,-G @g'`"
355
356	    	# Due to calling $cc without $cflags when linking some
357		# binaries we need to hardwire $cc to the right mode.
358		case "$use64bitall" in
359		    $define|true|[yY]*)
360			cc="$cc -maix64"
361			ld="$cc"
362			;;
363		    *)
364			cc="$cc -maix32"
365			ld="$cc"
366			;;
367		    esac
368		echo >&4 "(using ccflags   $ccflags)"
369		echo >&4 "(using ldflags   $ldflags)"
370		echo >&4 "(using lddlflags $lddlflags)"
371		;;
372	    esac
373	;;
374    esac
375EOCBU
376
377cat > UU/use64bitall.cbu <<'EOCBU'
378# This script UU/use64bitall.cbu will get 'called-back' by Configure
379# after it has prompted the user for whether to be maximally 64-bitty.
380case "$use64bitall" in
381    $define|true|[yY]*)
382	echo " "
383	echo "Checking the CPU width of your hardware..." >&4
384	$cat >size.c <<EOCP
385#include <stdio.h>
386#include <sys/systemcfg.h>
387int main (void)
388{
389    printf ("%d\n", _system_configuration.width);
390    return (0);
391    }
392EOCP
393	set size
394	if eval $compile_ok; then
395	    qacpuwidth=`./size`
396	    echo "You are running on $qacpuwidth bit hardware."
397	else
398	    dflt="32"
399	    echo " "
400	    echo "(I can't seem to compile the test program.  Guessing...)"
401	    rp="What is the width of your CPU (in bits)?"
402	    . ./myread
403	    qacpuwidth="$ans"
404	    fi
405	$rm -f size.c size
406
407	case "$qacpuwidth" in
408	    32*)
409		cat >&4 <<EOM
410Bzzzt! At present, you can only perform a
411full 64-bit build on a 64-bit machine.
412EOM
413		exit 1
414		;;
415	    esac
416	qacflags="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
417	qaldflags="`getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
418	# See jhi's comments above regarding this re-eval.  I've
419	# seen similar weirdness in the form of:
420	#
421# 1506-173 (W) Option lm is not valid.  Enter xlc for list of valid options.
422	#
423	# error messages from 'cc -E' invocation. Again, the offending
424	# string is simply not detectable by any means.  Since it doesn't
425	# do any harm, I didn't pursue it. -- sh
426	qaldflags="`echo $qaldflags`"
427	qalibs="`getconf XBS5_LP64_OFF64_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
428	# -q32 and -b32 may have been set by uselargefiles or user.
429	# Remove them.
430	ccflags="`echo $ccflags | sed -e 's@-q32@@'`"
431	ldflags="`echo $ldflags | sed -e 's@-b32@@'`"
432	case "$cc" in
433	    *gcc*)
434		ccflags="`echo $ccflags | sed -e 's@-q64@-maix64@'`"
435		ccflags_uselargefiles="`echo $ccflags_uselargefiles | sed -e 's@-q64@-maix64@'`"
436		qacflags="`echo $qacflags | sed -e 's@-q64@-maix64@'`"
437		;;
438	    esac
439	# Tell archiver to use large format.  Unless we remove 'ar'
440	# from 'trylist', the Configure script will just reset it to 'ar'
441	# immediately prior to writing config.sh.  This took me hours
442	# to figure out.
443	trylist="`echo $trylist | sed -e 's@^ar @@' -e 's@ ar @ @g' -e 's@ ar$@@'`"
444	ar="ar -X64"
445	nm_opt="-X64 $nm_opt"
446	case "$qacflags$qaldflags$qalibs" in
447	    '') ;;
448	    *)  ccflags="$ccflags $qacflags"
449		ldflags="$ldflags"
450		lddlflags="$qaldflags $lddlflags"
451		libswanted="$libswanted $qalibs"
452		;;
453	    esac
454	case "$ccflags" in
455	    *-DUSE_64_BIT_ALL*) ;;
456	    *) ccflags="$ccflags -DUSE_64_BIT_ALL";;
457	    esac
458	case "$archname64" in
459	    ''|64*) archname64=64all ;;
460	    esac
461	longsize="8"
462	qacflags=''
463	qaldflags=''
464	qalibs=''
465	qacpuwidth=''
466	;;
467    esac
468EOCBU
469
470if test $usenativedlopen = 'true' ; then
471    ccflags="$ccflags -DUSE_NATIVE_DLOPEN"
472    # -brtl		    Enables a binary to use run time linking
473    # -bdynamic		    When used with -brtl, tells linker to search for
474    #			    ".so"-suffix libraries as well as ".a" suffix
475    #			    libraries. AIX allows both .so and .a libraries to
476    #			    contain dynamic shared objects.
477    case "$cc" in
478	*gcc*) ldflags="$ldflags -Wl,-brtl -Wl,-bdynamic" ;;
479	*)     ldflags="$ldflags -brtl -bdynamic" ;;
480	esac
481elif test -f /lib/libC.a -a X"`$cc -v 2>&1 | grep gcc`" = X; then
482    # If the C++ libraries, libC and libC_r, are available we will
483    # prefer them over the vanilla libc, because the libC contain
484    # loadAndInit() and terminateAndUnload() which work correctly
485    # with C++ statics while libc load() and unload() do not. See
486    # ext/DynaLoader/dl_aix.xs. The C-to-C_r switch is done by
487    # usethreads.cbu, if needed.
488
489    # Cify libswanted.
490    set `echo X "$libswanted "| sed -e 's/ c / C c /'`
491    shift
492    libswanted="$*"
493    # Cify lddlflags.
494    set `echo X "$lddlflags "| sed -e 's/ -lc / -lC -lc /'`
495    shift
496    lddlflags="$*"
497    fi
498
499case "$PASE" in
500    define)
501	case "$prefix" in
502	    '') prefix=/QOpenSys/perl ;;
503	    esac
504	cat >&4 <<EOF
505
506***
507*** You seem to be compiling in AIX for the OS/400 PASE environment.
508*** I'm not going to use the AIX bind, nsl, and possible util libraries, then.
509*** I'm also not going to install perl as /usr/bin/perl.
510*** Perl will be installed under $prefix.
511*** For instructions how to install this build from AIX to PASE,
512*** see the file README.os400.  Accept the "aix" for the question
513*** about "Operating system name".
514***
515EOF
516	set `echo " $libswanted " | sed -e 's@ bind @ @' -e 's@ nsl @ @' -e 's@ util @ @'`
517	shift
518	libswanted="$*"
519	installusrbinperl="$undef"
520
521	# V5R1 doesn't have this (V5R2 does), without knowing
522	# which one we have it's safer to be pessimistic.
523	# Cwd will work fine even without fchdir(), but if
524	# V5R1 tries to use code compiled assuming fchdir(),
525	# lots of grief will issue forth from Cwd.
526	case "$d_fchdir" in
527	    '') d_fchdir="$undef" ;;
528	    esac
529	;;
530    esac
531
532# remove libbsd.a from wanted libraries
533libswanted=`echo " $libswanted " | sed -e 's/ bsd / /'`
534libswanted=`echo " $libswanted " | sed -e 's/ BSD / /'`
535d_flock='undef'
536
537# remove libgdbm from wanted libraries
538# The libgdbm < 1.8.3-5 from the AIX Toolbox is not working
539# because two wrong .h are present
540if [ -f "/opt/freeware/include/gdbm/dbm.h" ] ||
541   [ -f "/opt/freeware/include/gdbm/ndbm.h" ]; then
542    echo "GDBM support disabled because your GDBM package contains extraneous headers - see README.aix."
543    libswanted=`echo " $libswanted " | sed -e 's/ gdbm / /'`
544    i_gdbm='undef'
545    i_gdbmndbm='undef'
546fi
547# EOF
548