This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
OS/2 support bits (from Ilya Zakharevich)
[perl5.git] / hints / aix.sh
1 # hints/aix.sh
2 # AIX 3.x.x hints thanks to Wayne Scott <wscott@ichips.intel.com>
3 # AIX 4.1 hints thanks to Christopher Chan-Nui <channui@austin.ibm.com>.
4 # AIX 4.1 pthreading by Christopher Chan-Nui <channui@austin.ibm.com> and
5 #         Jarkko Hietaniemi <jhi@iki.fi>.
6 # Merged on Mon Feb  6 10:22:35 EST 1995 by
7 #   Andy Dougherty  <doughera@lafcol.lafayette.edu>
8
9 #
10 # Contact dfavor@corridor.com for any of the following:
11 #
12 #    - AIX 43x and above support
13 #    - gcc + threads support
14 #    - socks support
15 #
16 # Apr 99 changes:
17 #
18 #    - use nm in AIX 43x and above
19 #    - gcc + threads now builds
20 #    [(added support for socks) Jul 99 SOCKS support rewritten]
21 #
22 # Notes:
23 #
24 #    - shared libperl support is tricky. if ever libperl.a ends up
25 #      in /usr/local/lib/* it can override any subsequent builds of
26 #      that same perl release. to make sure you know where the shared
27 #      libperl.a is coming from do a 'dump -Hv perl' and check all the
28 #      library search paths in the loader header.
29 #
30 #      it would be nice to warn the user if a libperl.a exists that is
31 #      going to override the current build, but that would be complex.
32 #
33 #      better yet, a solid fix for this situation should be developed.
34 #
35
36 # Configure finds setrgid and setruid, but they're useless.  The man
37 # pages state:
38 #    setrgid: The EPERM error code is always returned.
39 #    setruid: The EPERM error code is always returned. Processes cannot
40 #             reset only their real user IDs.
41 d_setrgid='undef'
42 d_setruid='undef'
43
44 alignbytes=8
45
46 case "$usemymalloc" in
47 '')  usemymalloc='n' ;;
48 esac
49
50 # Intuiting the existence of system calls under AIX is difficult,
51 # at best; the safest technique is to find them empirically.
52
53 # AIX 4.3.* and above default to using nm for symbol extraction
54 case "$osvers" in
55    3.*|4.1.*|4.2.*)
56       usenm='undef'
57       ;;
58    *)
59       usenm='true'
60       ;;
61 esac
62
63 so="a"
64 dlext="o"
65
66 # Trying to set this breaks the POSIX.c compilation
67
68 # Make setsockopt work correctly.  See man page.
69 # ccflags='-D_BSD=44'
70
71 # uname -m output is too specific and not appropriate here
72 case "$archname" in
73 '') archname="$osname" ;;
74 esac
75
76 case "$osvers" in
77 3*) d_fchmod=undef
78     ccflags="$ccflags -D_ALL_SOURCE"
79     ;;
80 *)  # These hints at least work for 4.x, possibly other systems too.
81     ccflags="$ccflags -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE"
82     case "$cc" in
83      *gcc*) ;;
84      *) ccflags="$ccflags -qmaxmem=16384" ;;
85     esac
86     nm_opt='-B'
87     ;;
88 esac
89
90 # These functions don't work like Perl expects them to.
91 d_setregid='undef'
92 d_setreuid='undef'
93
94 # Changes for dynamic linking by Wayne Scott <wscott@ichips.intel.com>
95 #
96 # Tell perl which symbols to export for dynamic linking.
97 case "$cc" in
98 *gcc*) ccdlflags='-Xlinker' ;;
99 esac
100 # the required -bE:$installarchlib/CORE/perl.exp is added by
101 # libperl.U (Configure) later.
102
103 case "$ldlibpthname" in
104 '') ldlibpthname=LIBPATH ;;
105 esac
106
107 # The first 3 options would not be needed if dynamic libs. could be linked
108 # with the compiler instead of ld.
109 # -bI:$(PERL_INC)/perl.exp  Read the exported symbols from the perl binary
110 # -bE:$(BASEEXT).exp        Export these symbols.  This file contains only one
111 #                           symbol: boot_$(EXP)  can it be auto-generated?
112 case "$osvers" in
113 3*) 
114     lddlflags="$lddlflags -H512 -T512 -bhalt:4 -bM:SRE -bI:$(PERL_INC)/perl.exp -bE:$(BASEEXT).exp -e _nostart -lc"
115     ;;
116 *) 
117     lddlflags="$lddlflags -bhalt:4 -bM:SRE -bI:$(PERL_INC)/perl.exp -bE:$(BASEEXT).exp -b noentry -lc"
118     ;;
119 esac
120
121 # This script UU/usethreads.cbu will get 'called-back' by Configure 
122 # after it has prompted the user for whether to use threads.
123 cat > UU/usethreads.cbu <<'EOCBU'
124 case "$usethreads" in
125 $define|true|[yY]*)
126         ccflags="$ccflags -DNEED_PTHREAD_INIT"
127         case "$cc" in
128         gcc) ;;
129         cc_r) ;;
130         cc|xl[cC]_r) 
131             echo >&4 "Switching cc to cc_r because of POSIX threads."
132             # xlc_r has been known to produce buggy code in AIX 4.3.2.
133             # (e.g. pragma/overload core dumps)  Let's suspect xlC_r, too.
134             # --jhi@iki.fi
135             cc=cc_r
136             if test ! -e /bin/cc_r; then
137                     cat >&4 <<EOM
138 For pthreads you should use the AIX C compiler cc_r.
139 But I cannot find it as /bin/cc_r.
140 Cannot continue, aborting.
141 EOM
142             fi
143             ;;
144         '') 
145             cc=cc_r
146             ;;
147         *)
148             cat >&4 <<EOM
149 For pthreads you should use the AIX C compiler cc_r.
150 (now your compiler was set to '$cc')
151 Cannot continue, aborting.
152 EOM
153             exit 1
154             ;;
155         esac
156
157         # c_rify libswanted.
158         set `echo X "$libswanted "| sed -e 's/ \([cC]\) / \1_r /g'`
159         shift
160         libswanted="$*"
161         # c_rify lddlflags.
162         set `echo X "$lddlflags "| sed -e 's/ \(-l[cC]\) / \1_r /g'`
163         shift
164         lddlflags="$*"
165
166         # Insert pthreads to libswanted, before any libc or libC.
167         set `echo X "$libswanted "| sed -e 's/ \([cC]\) / pthreads \1 /'`
168         shift
169         libswanted="$*"
170         # Insert pthreads to lddlflags, before any libc or libC.
171         set `echo X "$lddlflags " | sed -e 's/ \(-l[cC]\) / -lpthreads \1 /'`
172         shift
173         lddlflags="$*"
174
175         ;;
176 esac
177 EOCBU
178
179 # This script UU/use64bits.cbu will get 'called-back' by Configure 
180 # after it has prompted the user for whether to use 64 bits.
181 cat > UU/use64bits.cbu <<'EOCBU'
182 case "$use64bits" in
183 $define|true|[yY]*)
184             case "`oslevel`" in
185             3.*|4.[012].*)
186                 cat >&4 <<EOM
187 AIX `oslevel` does not support 64-bit interfaces.
188 You should upgrade to at least AIX 4.2.
189 EOM
190                 exit 1
191                 ;;
192             esac
193             ccflags="$ccflags -DUSE_LONG_LONG"
194             ccflags="$ccflags `getconf XBS5_ILP32_OFFBIG_CFLAGS 2>/dev/null`"
195
196             ldflags="$ldflags `getconf XBS5_ILP32_OFFBIG_LDFLAGS 2>/dev/null`"
197             # _Somehow_ in AIX 4.3.1.0 the above getconf call manages to
198             # insert(?) *something* to $ldflags so that later (in Configure) evaluating
199             # $ldflags causes a newline after the '-b64' (the result of the getconf).
200             # (nothing strange shows up in $ldflags even in hexdump;
201             #  so it may be something in the shell, instead?)
202             # Try it out: just uncomment the below line and rerun Configure:
203 #           echo >&4 "AIX 4.3.1.0 $ldflags mystery" ; exit 1
204             # Just don't ask me how AIX does it.
205             # Therefore the line re-evaluating ldflags: it seems to bypass
206             # the whatever it was that AIX managed to break. --jhi
207             ldflags="`echo $ldflags`"
208
209             libswanted="$libswanted `getconf XBS5_ILP32_OFFBIG_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
210             # When a 64-bit cc becomes available $archname64
211             # may need setting so that $archname gets it attached.
212             ;;
213 esac
214 EOCBU
215
216 # This script UU/uselongdouble.cbu will get 'called-back' by Configure 
217 # after it has prompted the user for whether to use long doubles.
218 cat > UU/uselongdouble.cbu <<'EOCBU'
219 case "$uselongdouble" in
220 $define|true|[yY]*)
221         ccflags="$ccflags -qlongdouble"
222         # The explicit cc128, xlc128, xlC128 are not needed,
223         # the -qlongdouble should do the trick. --jhi
224         ;;
225 esac
226 EOCBU
227
228 # If the C++ libraries, libC and libC_r, are available we will prefer them
229 # over the vanilla libc, because the libC contain loadAndInit() and
230 # terminateAndUnload() which work correctly with C++ statics while libc
231 # load() and unload() do not.  See ext/DynaLoader/dl_aix.xs.
232 # The C-to-C_r switch is done by usethreads.cbu, if needed.
233 if test -f /lib/libC.a -a X"$gccversion" = X; then
234     # Cify libswanted.
235     set `echo X "$libswanted "| sed -e 's/ c / C c /'`
236     shift
237     libswanted="$*"
238     # Cify lddlflags.
239     set `echo X "$lddlflags "| sed -e 's/ -lc / -lC -lc /'`
240     shift
241     lddlflags="$*"
242 fi
243
244 # EOF