Make the test more portable.
[p5sagit/p5-mst-13.2.git] / hints / irix_6.sh
1 # hints/irix_6.sh
2 #
3 # original from Krishna Sethuraman, krishna@sgi.com
4 #
5 # Modified Mon Jul 22 14:52:25 EDT 1996
6 #       Andy Dougherty <doughera@lafcol.lafayette.edu>
7 #       with help from Dean Roehrich <roehrich@cray.com>.
8 #   cc -n32 update info from Krishna Sethuraman, krishna@sgi.com.
9 #       additional update from Scott Henry, scotth@sgi.com
10
11 # Futzed with by John Stoffel <jfs@fluent.com> on 4/24/1997
12 #    - assumes 'cc -n32' by default
13 #    - tries to check for various compiler versions and do the right 
14 #      thing when it can
15 #    - warnings turned off (-n32 messages):
16 #       1116 - non-void function should return a value
17 #       1048 - cast between pointer-to-object and pointer-to-function
18 #       1042 - operand types are incompatible
19
20 # Tweaked by Chip Salzenberg <chip@perl.com> on 5/13/97
21 #    - don't assume 'cc -n32' if the n32 libm.so is missing
22
23 # Threaded by Jarkko Hietaniemi <jhi@iki.fi> on 11/18/97
24 #    - POSIX threads knowledge by IRIX version
25
26 # gcc-enabled by Kurt Starsinic <kstar@isinet.com> on 3/24/1998
27
28 # 64-bitty by Jarkko Hietaniemi on 9/1998
29
30 # Use   sh Configure -Dcc='cc -n32' to try compiling with -n32.
31 #     or -Dcc='cc -n32 -mips3' (or -mips4) to force (non)portability
32 # Don't bother with -n32 unless you have the 7.1 or later compilers.
33 #     But there's no quick and light-weight way to check in 6.2.
34
35 # Let's assume we want to use 'cc -n32' by default, unless the
36 # necessary libm is missing (which has happened at least twice)
37 case "$cc" in
38 '') case "$use64bitall" in
39     "$define"|true|[yY]*) test -f /usr/lib64/libm.so && cc='cc -64' ;;
40     *) test -f /usr/lib32/libm.so && cc='cc -n32' ;;
41     esac        
42 esac
43 test -z "$cc" && cc=cc
44
45 case "$use64bitint" in
46 $define|true|[yY]*)
47             case "`uname -r`" in
48             [1-5]*|6.[01])
49                 cat >&4 <<EOM
50 IRIX `uname -r` does not support 64-bit types.
51 You should upgrade to at least IRIX 6.2.
52 Cannot continue, aborting.
53 EOM
54                 exit 1
55                 ;;
56             esac
57             ;;
58 esac
59
60 case "$use64bitall" in
61 "$define"|true|[yY]*)
62   case "`uname -s`" in
63   IRIX)
64             cat >&4 <<EOM
65 You cannot use -Duse64bitall in 32-bit IRIX, sorry.
66
67 Cannot continue, aborting.
68 EOM
69             exit 1
70         ;;
71   esac
72   ;;
73 esac
74
75 # Check for which compiler we're using
76
77 case "$cc" in
78 *"cc -n32"*)
79
80         # If a library is requested to link against, make sure the
81         # objects in the library are of the same ABI we are compiling
82         # against. Albert Chin-A-Young <china@thewrittenword.com>
83         libscheck='case "$xxx" in
84 *.a) /bin/ar p $xxx `/bin/ar t $xxx | /usr/bsd/head -1` >$$.o;
85   case "`/usr/bin/file $$.o`" in
86   *N32*) rm -f $$.o ;;
87   *) rm -f $$.o; xxx=/no/n32$xxx ;;
88   esac ;;
89 *) case "`/usr/bin/file $xxx`" in
90   *N32*) ;;
91   *) xxx=/no/n32$xxx ;;
92   esac ;;
93 esac'
94
95         # NOTE: -L/usr/lib32 -L/lib32 are automatically selected by the linker
96         ldflags=' -L/usr/local/lib32 -L/usr/local/lib'
97         cccdlflags=' '
98     # From: David Billinghurst <David.Billinghurst@riotinto.com.au>
99     # If you get complaints about so_locations then change the following
100     # line to something like:
101     #   lddlflags="-n32 -shared -check_registry /usr/lib32/so_locations"
102         lddlflags="-n32 -shared"
103         libc='/usr/lib32/libc.so'
104         plibpth='/usr/lib32 /lib32 /usr/ccs/lib'
105         ;;
106 *"cc -64")
107
108         loclibpth="$loclibpth /usr/lib64"
109         libscheck='case "`/usr/bin/file $xxx`" in
110 *64-bit*) ;;
111 *) xxx=/no/64-bit$xxx ;;
112 esac'
113         # NOTE: -L/usr/lib64 -L/lib64 are automatically selected by the linker
114         ldflags=' -L/usr/local/lib64 -L/usr/local/lib'
115         cccdlflags=' '
116     # From: David Billinghurst <David.Billinghurst@riotinto.com.au>
117     # If you get complaints about so_locations then change the following
118     # line to something like:
119     #   lddlflags="-64 -shared -check_registry /usr/lib64/so_locations"
120         lddlflags="-64 -shared"
121         libc='/usr/lib64/libc.so'
122         plibpth='/usr/lib64 /lib64 /usr/ccs/lib'
123         ;;
124 *gcc*)
125         ccflags="$ccflags -D_BSD_TYPES -D_BSD_TIME -D_POSIX_C_SOURCE"
126         optimize="-O3"
127         usenm='undef'
128         case "`uname -s`" in
129         # Without the -mabi=64 gcc in 64-bit IRIX has problems passing
130         # and returning small structures.  This affects inet_*() and semctl().
131         # See http://reality.sgi.com/ariel/freeware/gcc-2.8.1-notes.html
132         # for more information.  Reported by Lionel Cons <lionel.cons@cern.ch>.
133         IRIX64) ccflags="$ccflags -mabi=64"
134                 ldflags="$ldflags -mabi=64 -L/usr/lib64"
135                 lddlflags="$lddlflags -mabi=64"
136                 ;;
137         *)      ccflags="$ccflags -DIRIX32_SEMUN_BROKEN_BY_GCC"
138                 ;;
139         esac
140         ;;
141 *)
142         # this is needed to force the old-32 paths
143         #  since the system default can be changed.
144         ccflags="$ccflags -32 -D_BSD_TYPES -D_BSD_TIME -Olimit 3100"
145         optimize='-O'     
146         ;;
147 esac
148
149 # Settings common to both native compiler modes.
150 case "$cc" in
151 *"cc -n32"|*"cc -64")
152         ld=$cc
153
154         # perl's malloc can return improperly aligned buffer
155         # which (under 5.6.0RC1) leads into really bizarre bus errors
156         # and freak test failures (lib/safe1 #18, for example),
157         # even more so with -Duse64bitall: for example lib/io_linenumtb.
158         # fails under the harness but succeeds when run separately,
159         # under make test pragma/warnings #98 fails, and lib/io_dir
160         # apparently coredumps (the last two don't happen under
161         # the harness.  Helmut Jarausch is seeing bus errors from
162         # miniperl, as was Scott Henry with snapshots from just before
163         # the RC1. --jhi
164         usemymalloc='undef'
165 #malloc_cflags='ccflags="-DSTRICT_ALIGNMENT $ccflags"'
166
167         nm_opt='-p'
168         nm_so_opt='-p'
169
170         # Perl 5.004_57 introduced new qsort code into pp_ctl.c that
171         # makes IRIX  cc prior to 7.2.1 to emit bad code.
172         # so some serious hackery follows to set pp_ctl flags correctly.
173
174         # Check for which version of the compiler we're running
175         case "`$cc -version 2>&1`" in
176         *7.0*)                        # Mongoose 7.0
177              ccflags="$ccflags -D_BSD_TYPES -D_BSD_TIME -woff 1009,1042,1048,1110,1116,1174,1184,1552 -OPT:Olimit=0"
178              optimize='none'
179              ;;
180         *7.1*|*7.2|*7.20)             # Mongoose 7.1+
181              ccflags="$ccflags -D_BSD_TYPES -D_BSD_TIME -woff 1009,1110,1174,1184,1552 -OPT:Olimit=0"
182              optimize='-O3'
183 # This is a temporary fix for 5.005.
184 # Leave pp_ctl_cflags  line at left margin for Configure.  See 
185 # hints/README.hints, especially the section 
186 # =head2 Propagating variables to config.sh
187 pp_ctl_cflags='optimize=-O'
188              ;;
189         *7.*)                         # Mongoose 7.2.1+
190              ccflags="$ccflags -D_BSD_TYPES -D_BSD_TIME -woff 1009,1110,1174,1184,1552 -OPT:Olimit=0:space=ON"
191              optimize='-O3'
192              ;;
193         *6.2*)                        # Ragnarok 6.2
194              ccflags="$ccflags -D_BSD_TYPES -D_BSD_TIME -woff 1009,1110,1174,1184,1552"
195              optimize='none'
196              ;;
197         *)                            # Be safe and not optimize
198              ccflags="$ccflags -D_BSD_TYPES -D_BSD_TIME -woff 1009,1110,1174,1184,1552 -OPT:Olimit=0"
199              optimize='none'
200              ;;
201         esac
202
203 # this is to accommodate the 'modules' capability of the 
204 # 7.2 MIPSPro compilers, which allows for the compilers to be installed
205 # in a nondefault location.  Almost everything works as expected, but
206 # /usr/include isn't caught properly.  Hence see the /usr/include/pthread.h
207 # change below to include TOOLROOT (a modules environment variable),
208 # and the following code.  Additional
209 # code to accommodate the 'modules' environment should probably be added
210 # here if possible, or be inserted as a ${TOOLROOT} reference before
211 # absolute paths (again, see the pthread.h change below). 
212 # -- krishna@sgi.com, 8/23/98
213
214         if [ "X${TOOLROOT}" != "X" ]; then
215         # we cant set cppflags because it gets overwritten
216         # we dont actually need $TOOLROOT/usr/include on the cc line cuz the 
217         # modules functionality already includes it but
218         # XXX - how do I change cppflags in the hints file?
219                 ccflags="$ccflags -I${TOOLROOT}/usr/include"
220         usrinc="${TOOLROOT}/usr/include"
221         fi
222
223         ;;
224 esac
225
226 # Don't groan about unused libraries.
227 ldflags="$ldflags -Wl,-woff,84"
228
229 case "`$cc -version 2>&1`" in
230 *7.2.*) op_cflags='optimize=-O1' ;; # workaround for an optimizer bug
231 esac
232
233 # We don't want these libraries.
234 # Socket networking is in libc, these are not installed by default,
235 # and just slow perl down. (scotth@sgi.com)
236 set `echo X "$libswanted "|sed -e 's/ socket / /' -e 's/ nsl / /' -e 's/ dl / /'`
237 shift
238 libswanted="$*"
239
240 # Irix 6.5.6 seems to have a broken header <sys/mode.h>
241 # don't include that (it doesn't contain S_IFMT, S_IFREG, et al)
242
243 i_sysmode="$undef"
244
245 # I have conflicting reports about the sun, crypt, bsd, and PW
246 # libraries on Irix 6.2.
247 #
248 # One user rerports:
249 # Don't need sun crypt bsd PW under 6.2.  You *may* need to link
250 # with these if you want to run perl built under 6.2 on a 5.3 machine
251 # (I haven't checked)
252 #
253 # Another user reported that if he included those libraries, a large number
254 # of the tests failed (approx. 20-25) and he would get a core dump. To
255 # make things worse, test results were inconsistent, i.e., some of the
256 # tests would pass some times and fail at other times.
257 # The safest thing to do seems to be to eliminate them.
258 #
259 #  Actually, the only libs that you want are '-lm'.  Everything else
260 # you need is in libc.  You do also need '-lbsd' if you choose not
261 # to use the -D_BSD_* defines.  Note that as of 6.2 the only
262 # difference between '-lmalloc' and '-lc' malloc is the debugging
263 # and control calls, which aren't used by perl. -- scotth@sgi.com
264
265 set `echo X "$libswanted "|sed -e 's/ sun / /' -e 's/ crypt / /' -e 's/ bsd / /' -e 's/ PW / /' -e 's/ malloc / /'`
266 shift
267 libswanted="$*"
268
269 cat > UU/usethreads.cbu <<'EOCBU'
270 # This script UU/usethreads.cbu will get 'called-back' by Configure 
271 # after it has prompted the user for whether to use threads.
272 case "$usethreads" in
273 $define|true|[yY]*)
274         if test ! -f ${TOOLROOT}/usr/include/pthread.h -o ! -f /usr/lib/libpthread.so; then
275             case "`uname -r`" in
276             [1-5].*|6.[01])
277                 cat >&4 <<EOM
278 IRIX `uname -r` does not support POSIX threads.
279 You should upgrade to at least IRIX 6.2 with pthread patches.
280 EOM
281                 ;;
282             6.2)
283                 cat >&4 <<EOM
284 IRIX 6.2 can have the POSIX threads.
285 However, the following IRIX patches (or their replacements) MUST be installed:
286         1404 Irix 6.2 Posix 1003.1b man pages
287         1645 IRIX 6.2 & 6.3 POSIX header file updates
288         2000 Irix 6.2 Posix 1003.1b support modules
289         2254 Pthread library fixes
290         2401 6.2 all platform kernel rollup
291 IMPORTANT:
292         Without patch 2401, a kernel bug in IRIX 6.2 will
293         cause your machine to panic and crash when running
294         threaded perl. IRIX 6.3 and up should be OK.
295 EOM
296                 ;;
297             [67].*)
298                 cat >&4 <<EOM
299 IRIX `uname -r` should have the POSIX threads.
300 But, somehow, you do not seem to have them installed.
301 EOM
302                 ;;
303             esac
304             cat >&4 <<EOM
305 Cannot continue, aborting.
306 EOM
307             exit 1
308         fi
309         set `echo X "$libswanted "| sed -e 's/ c / pthread /'`
310         ld="${cc:-cc}"
311         shift
312         libswanted="$*"
313
314         usemymalloc='n'
315         ;;
316 esac
317 EOCBU
318
319 # The -n32 makes off_t to be 8 bytes, so we should have largefileness.
320