Miscellaneus AIX fixes + SOCKS support.
[p5sagit/p5-mst-13.2.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, when Dccflags=-DSOCKS specified
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="so"
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 -bE:perl.exp' ;;
99 *) ccdlflags='-bE:perl.exp' ;;
100 esac
101
102 # The first 3 options would not be needed if dynamic libs. could be linked
103 # with the compiler instead of ld.
104 # -bI:$(PERL_INC)/perl.exp  Read the exported symbols from the perl binary
105 # -bE:$(BASEEXT).exp        Export these symbols.  This file contains only one
106 #                           symbol: boot_$(EXP)  can it be auto-generated?
107 case "$osvers" in
108 3*) 
109     lddlflags="$lddlflags -H512 -T512 -bhalt:4 -bM:SRE -bI:$(PERL_INC)/perl.exp -bE:$(BASEEXT).exp -e _nostart"
110     ;;
111 *) 
112     lddlflags="$lddlflags -bhalt:4 -bM:SRE -bI:$(PERL_INC)/perl.exp -bE:$(BASEEXT).exp -b noentry"
113     ;;
114 esac
115
116 # Save this for backward compatibility for now.
117 # Configure already (5.005_58) knows how to probe for
118 # <socks.h> and libsocks.  What sucks is that the name
119 # of the socks library seems to be version dependent
120 # (e.g. libsocks5), bleagh.
121 #
122 # if $ccflags contains -DSOCKS, then add socks library support.
123 #
124 # It is expected that libsocks.a resides in /usr/local/lib and that
125 # socks.h resides in /usr/local/include. If these files live some
126 # different place then modify 
127 #
128
129 for arg in $ccflags ; do
130
131    if [ "$arg" = "-DSOCKS" ] ; then
132
133       sockslib=socks5
134       incpath=/usr/local/include
135       libpath=/usr/local/lib
136
137       lddlflags="$lddlflags -l$sockslib"
138
139       # setting $libs here breaks the optional libraries search
140       # for some reason, so use $libswanted instead
141       #libs="$libs -lsocks5"
142
143       libswanted="$libswanted $sockslib"
144
145       #
146       # path for include file
147       #
148
149       locincpth="$locincpath /usr/local/include"
150
151       #
152       # path for library not needed, if in /usr/local/lib as that
153       # directory is already searched.
154       #
155
156       #loclibpth="$loclibpath /usr/local/lib"
157
158       break
159
160    fi
161
162 done
163
164 lddllibc="-lc"
165
166 # This script UU/usethreads.cbu will get 'called-back' by Configure 
167 # after it has prompted the user for whether to use threads.
168 cat > UU/usethreads.cbu <<'EOCBU'
169 case "$usethreads" in
170 $define|true|[yY]*)
171         ccflags="$ccflags -DNEED_PTHREAD_INIT"
172         case "$cc" in
173         gcc) ;;
174         cc_r) ;;
175         cc|xlc_r) 
176             echo >&4 "Switching cc to cc_r because of POSIX threads."
177             # xlc_r has been known to produce buggy code in AIX 4.3.2.
178             # (e.g. pragma/overload core dumps)
179             # --jhi@iki.fi
180             cc=cc_r
181             ;;
182         '') 
183             cc=cc_r
184             ;;
185         *)
186             cat >&4 <<EOM
187 For pthreads you should use the AIX C compiler cc_r.
188 (now your compiler was '$cc')
189 Cannot continue, aborting.
190 EOM
191             exit 1
192             ;;
193         esac
194
195         # Add the POSIX threads library and the re-entrant libc.
196
197         lddllibc="-lpthreads -lc_r"
198
199         # Add the c_r library to the list of wanted libraries.
200         # Make sure the c_r library is before the c library or
201         # make will fail.
202         set `echo X "$libswanted "| sed -e 's/ c / pthreads c_r /'`
203         shift
204         libswanted="$*"
205         ;;
206 esac
207
208 EOCBU
209
210 lddlflags="$lddlflags $lddllibc"
211
212 # This script UU/use64bits.cbu will get 'called-back' by Configure 
213 # after it has prompted the user for whether to use 64 bits.
214 cat > UU/use64bits.cbu <<'EOCBU'
215 case "$use64bits" in
216 $define|true|[yY]*)
217             case "`uname -r`" in
218             3.*|4.[012].*)
219                 cat >&4 <<EOM
220 AIX `uname -r` does not support 64-bit interfaces.
221 You should upgrade to at least AIX 4.3.
222 EOM
223                 exit 1
224                 ;;
225             esac
226             ccflags="$ccflags `getconf XBS5_LPBIG_OFFBIG_CFLAGS`"
227             ccflags="$ccflags -DUSE_LONG_LONG"
228             ldflags="$ldflags `getconf XBS5_LPBIG_OFFBIG_LDFLAGS`"
229             libswanted="$libswanted `getconf XBS5_LPBIG_OFFBIG_LIBS`"
230             # When a 64-bit cc becomes available $archname64
231             # may need setting so that $archname gets it attached.
232             ;;
233 esac
234 EOCBU