This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix some typos in perlsyn.pod
[perl5.git] / hints / irix_6.sh
CommitLineData
85f483a2 1# hints/irix_6.sh
e8c10df3
SH
2#
3# original from Krishna Sethuraman, krishna@sgi.com
4#
ba51d756 5# Modified Mon Jul 22 14:52:25 EDT 1996
1973dd96 6# Andy Dougherty <doughera@lafayette.edu>
e8c10df3
SH
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
f4cb4c40 10
ba51d756
CS
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):
b238e826
JH
16# 1184 - "=" is used where where "==" may have been intended
17# 1552 - variable "foo" set but never used
ba51d756
CS
18
19# Tweaked by Chip Salzenberg <chip@perl.com> on 5/13/97
20# - don't assume 'cc -n32' if the n32 libm.so is missing
85f483a2 21
eb1cfdd6
MB
22# Threaded by Jarkko Hietaniemi <jhi@iki.fi> on 11/18/97
23# - POSIX threads knowledge by IRIX version
24
37c4c505
KS
25# gcc-enabled by Kurt Starsinic <kstar@isinet.com> on 3/24/1998
26
5ff3f7a4
GS
27# 64-bitty by Jarkko Hietaniemi on 9/1998
28
2c549067
MP
29# Martin Pool added -shared for gcc on 2004-01-27
30
e8c10df3
SH
31# Use sh Configure -Dcc='cc -n32' to try compiling with -n32.
32# or -Dcc='cc -n32 -mips3' (or -mips4) to force (non)portability
33# Don't bother with -n32 unless you have the 7.1 or later compilers.
34# But there's no quick and light-weight way to check in 6.2.
f4cb4c40 35
1381c0fe
JH
36# NOTE: some IRIX cc versions, e.g. 7.3.1.1m (try cc -version) have
37# been known to have issues (coredumps) when compiling perl.c.
38# If you've used -OPT:fast_io=ON and this happens, try removing it.
39# If that fails, or you didn't use that, then try adjusting other
40# optimization options (-LNO, -INLINE, -O3 to -O2, etcetera).
41# The compiler bug has been reported to SGI.
20f6aaab 42# -- Allen Smith <allens@cpan.org>
44e4f4cc 43
49117913
AS
44# Modified (10/30/04) to turn off usemallocwrap (PERL_MALLOC_WRAP) in -n32
45# mode - Allen.
46
6d240721
JH
47case "$use64bitall" in
48$define|true|[yY]*)
49 case "`uname -s`" in
50 IRIX)
51 cat <<END >&2
52You have asked for use64bitall but you aren't running on 64-bit IRIX.
53I'll try changing it to use64bitint.
54END
55 use64bitall="$undef"
56
57 case "`uname -r`" in
58 [1-5]*|6.[01])
59 cat <<END >&2
60Sorry, can't do use64bitint either. Try upgrading to IRIX 6.2 or later.
61END
62 use64bitint="$undef"
63 ;;
64 *) use64bitint="$define"
65 ;;
66 esac
67 ;;
68 esac
69 ;;
70esac
71
72# Until we figure out what to be probed for in Configure (ditto for hpux.sh)
73case "$usemorebits" in # Need to expand this now, then.
74$define|true|[yY]*)
75 case "`uname -r`" in
76 [1-5]*|6.[01])
77 uselongdouble="$define"
78 ;;
79 *) use64bitint="$define" uselongdouble="$define" ;;
80 esac
81esac
82
ba51d756
CS
83# Let's assume we want to use 'cc -n32' by default, unless the
84# necessary libm is missing (which has happened at least twice)
85f483a2 85case "$cc" in
a3489f11
JH
86'') case "$use64bitall" in
87 "$define"|true|[yY]*) test -f /usr/lib64/libm.so && cc='cc -64' ;;
88 *) test -f /usr/lib32/libm.so && cc='cc -n32' ;;
89 esac
90esac
6b356c8e 91
6d240721
JH
92case "$use64bitint" in
93 "$define"|true|[yY]*) ;;
94 *) d_casti32="$undef" ;;
95esac
96
5e4c82f0 97cc=${cc:-cc}
20f6aaab 98cat=${cat:-cat}
a3489f11 99
20f6aaab 100$cat > UU/cc.cbu <<'EOCCBU'
6d240721
JH
101# This script UU/cc.cbu will get 'called-back' by Configure after it
102# has prompted the user for the C compiler to use.
103
6b356c8e
JH
104case "$cc" in
105*gcc*) ;;
220a9130 106*) ccversion=`cc -version 2>&1` ;;
6b356c8e
JH
107esac
108
85f483a2
SH
109# Check for which compiler we're using
110
e8c10df3
SH
111case "$cc" in
112*"cc -n32"*)
6d240721 113 test -z "$ldlibpthname" && ldlibpthname='LD_LIBRARYN32_PATH'
85f483a2 114
f1edc4d6
GS
115 # If a library is requested to link against, make sure the
116 # objects in the library are of the same ABI we are compiling
117 # against. Albert Chin-A-Young <china@thewrittenword.com>
6d240721
JH
118
119 # In other words, you no longer have to worry regarding having old
120 # library paths (/usr/lib) in the searchpath for -n32 or -64; thank
121 # you very much, Albert! Now if we could just get more module authors
122 # to use something like this... - Allen
123
f1edc4d6 124 libscheck='case "$xxx" in
eade9b71 125*.a) /bin/ar p $xxx `/bin/ar t $xxx | sed q` >$$.o;
f1edc4d6
GS
126 case "`/usr/bin/file $$.o`" in
127 *N32*) rm -f $$.o ;;
128 *) rm -f $$.o; xxx=/no/n32$xxx ;;
129 esac ;;
130*) case "`/usr/bin/file $xxx`" in
131 *N32*) ;;
132 *) xxx=/no/n32$xxx ;;
133 esac ;;
6e553f51
JH
134esac'
135
a3489f11 136 # NOTE: -L/usr/lib32 -L/lib32 are automatically selected by the linker
6d240721 137 test -z "$ldflags" && ldflags=' -L/usr/local/lib32 -L/usr/local/lib'
a3489f11
JH
138 cccdlflags=' '
139 # From: David Billinghurst <David.Billinghurst@riotinto.com.au>
140 # If you get complaints about so_locations then change the following
141 # line to something like:
142 # lddlflags="-n32 -shared -check_registry /usr/lib32/so_locations"
6d240721
JH
143 test -z "$lddlflags" && lddlflags="-n32 -shared"
144 test -z "$libc" && libc='/usr/lib32/libc.so'
145 test -z "$plibpth" && plibpth='/usr/lib32 /lib32 /usr/ccs/lib'
49117913
AS
146
147 # PERL_MALLOC_WRAP gives false alarms ("panic: memory wrap") in IRIX
148 # -n32 mode, resulting in perl compiles never getting further than
149 # miniperl. I am not sure whether it actually does any good in -32 or
150 # -64 mode, especially the latter, but it does not give false
151 # alarms (in testing). -Allen
152
153 usemallocwrap=${usemallocwrap:-false}
154 ;;
f737ff5c 155*"cc -64"*)
6d240721
JH
156 case "`uname -s`" in
157 IRIX)
20f6aaab 158 $cat >&4 <<EOM
6d240721
JH
159You cannot use cc -64 or -Duse64bitall in 32-bit IRIX, sorry.
160Cannot continue, aborting.
161EOM
162 exit 1
163 ;;
164 esac
165 test -z "$ldlibpthname" && ldlibpthname='LD_LIBRARY64_PATH'
166 test -z "$use64bitall" && use64bitall="$define"
167 test -z "$use64bitint" && use64bitint="$define"
a3489f11
JH
168 loclibpth="$loclibpth /usr/lib64"
169 libscheck='case "`/usr/bin/file $xxx`" in
170*64-bit*) ;;
171*) xxx=/no/64-bit$xxx ;;
172esac'
173 # NOTE: -L/usr/lib64 -L/lib64 are automatically selected by the linker
6d240721 174 test -z "$ldflags" && ldflags=' -L/usr/local/lib64 -L/usr/local/lib'
a3489f11 175 cccdlflags=' '
6d240721 176 test -z "$archname64" && archname64='64all'
a3489f11
JH
177 # From: David Billinghurst <David.Billinghurst@riotinto.com.au>
178 # If you get complaints about so_locations then change the following
179 # line to something like:
180 # lddlflags="-64 -shared -check_registry /usr/lib64/so_locations"
6d240721
JH
181 test -z lddlflags="-64 -shared"
182 test -z "$libc" && libc='/usr/lib64/libc.so'
183 test -z "$plibpth" && plibpth='/usr/lib64 /lib64 /usr/ccs/lib'
a3489f11
JH
184 ;;
185*gcc*)
3a2263fe 186 ccflags="$ccflags -D_BSD_TYPES -D_BSD_TIME"
6d240721 187 test -z "$optimize" && optimize="-O3"
a3489f11 188 usenm='undef'
2c549067
MP
189 # It seems gcc can build Irix shlibs, but of course it needs
190 # -shared. Otherwise you get link errors looking for main().
191 lddlflags="$lddlflags -shared"
a3489f11
JH
192 case "`uname -s`" in
193 # Without the -mabi=64 gcc in 64-bit IRIX has problems passing
194 # and returning small structures. This affects inet_*() and semctl().
46c3340e 195 # See http://groups.google.com/group/comp.sys.sgi.admin/msg/3ad8353bc4ce3cb0
a3489f11
JH
196 # for more information. Reported by Lionel Cons <lionel.cons@cern.ch>.
197 IRIX64) ccflags="$ccflags -mabi=64"
198 ldflags="$ldflags -mabi=64 -L/usr/lib64"
199 lddlflags="$lddlflags -mabi=64"
200 ;;
201 *) ccflags="$ccflags -DIRIX32_SEMUN_BROKEN_BY_GCC"
49117913
AS
202 # XXX Note: It is possible that turning off usemallocwrap is
203 # needed here; insufficient data! - Allen
a3489f11
JH
204 ;;
205 esac
206 ;;
207*)
208 # this is needed to force the old-32 paths
209 # since the system default can be changed.
210 ccflags="$ccflags -32 -D_BSD_TYPES -D_BSD_TIME -Olimit 3100"
211 optimize='-O'
212 ;;
213esac
214
215# Settings common to both native compiler modes.
216case "$cc" in
f737ff5c 217*"cc -n32"*|*"cc -64"*)
6d240721 218 test -z "$ld" && ld=$cc
a3489f11
JH
219
220 # perl's malloc can return improperly aligned buffer
5ec73030
JH
221 # which (under 5.6.0RC1) leads into really bizarre bus errors
222 # and freak test failures (lib/safe1 #18, for example),
223 # even more so with -Duse64bitall: for example lib/io_linenumtb.
224 # fails under the harness but succeeds when run separately,
225 # under make test pragma/warnings #98 fails, and lib/io_dir
226 # apparently coredumps (the last two don't happen under
227 # the harness. Helmut Jarausch is seeing bus errors from
228 # miniperl, as was Scott Henry with snapshots from just before
229 # the RC1. --jhi
230 usemymalloc='undef'
a3489f11 231
6d240721
JH
232 # Was at the first of the line - Allen
233 #malloc_cflags='ccflags="-DSTRICT_ALIGNMENT $ccflags"'
234
235 nm_opt="$nm_opt -p"
236 nm_so_opt="$nm_so_opt -p"
a3489f11 237
1f3e59ba
JH
238 # Warnings to turn off because the source code hasn't
239 # been cleaned up enough yet to satisfy the IRIX cc.
240 # 1184: "=" is used where where "==" may have been intended.
241 # 1552: The variable "foobar" is set but never used.
242 woff=1184,1552
243
29c7c2ae
SH
244 # Perl 5.004_57 introduced new qsort code into pp_ctl.c that
245 # makes IRIX cc prior to 7.2.1 to emit bad code.
246 # so some serious hackery follows to set pp_ctl flags correctly.
247
85f483a2
SH
248 # Check for which version of the compiler we're running
249 case "`$cc -version 2>&1`" in
250 *7.0*) # Mongoose 7.0
1f3e59ba 251 ccflags="$ccflags -D_BSD_TYPES -D_BSD_TIME -woff $woff -OPT:Olimit=0"
589615b8 252 optimize='none'
85f483a2 253 ;;
cd25c765 254 *7.1*|*7.2|*7.20) # Mongoose 7.1+
6d240721
JH
255 ccflags="$ccflags -D_BSD_TYPES -D_BSD_TIME -woff $woff"
256 case "$optimize" in
257 '') optimize='-O3 -OPT:Olimit=0' ;;
258 '-O') optimize='-O3 -OPT:Olimit=0' ;;
259 *) ;;
260 esac
261
262 # This is a temporary fix for 5.005+.
263 # See hints/README.hints, especially the section
264 # =head2 Propagating variables to config.sh
265
266 # Note the part about case statements not working without
267 # weirdness like the below echo statement... and, since
268 # we're in a callback unit, it's to config.sh, not UU/config.sh
269 # - Allen
270
271
272 pp_ctl_cflags="$pp_ctl_flags optimize=\"$optimize -O1\""
273 echo "pp_ctl_cflags=\"$pp_ctl_flags optimize=\\\"\$optimize -O1\\\"\"" >> config.sh
29c7c2ae 274 ;;
6d240721
JH
275
276
277
20f6aaab 278# XXX What is space=ON doing in here? Could someone ask Scott Henry? - Allen
6d240721 279
29c7c2ae 280 *7.*) # Mongoose 7.2.1+
6d240721
JH
281 ccflags="$ccflags -D_BSD_TYPES -D_BSD_TIME -woff $woff"
282 case "$optimize" in
283 '') optimize='-O3 -OPT:Olimit=0:space=ON' ;;
284 '-O') optimize='-O3 -OPT:Olimit=0:space=ON' ;;
285 *) ;;
286 esac
85f483a2
SH
287 ;;
288 *6.2*) # Ragnarok 6.2
1f3e59ba 289 ccflags="$ccflags -D_BSD_TYPES -D_BSD_TIME -woff $woff"
589615b8 290 optimize='none'
85f483a2
SH
291 ;;
292 *) # Be safe and not optimize
20f6aaab 293 ccflags="$ccflags -D_BSD_TYPES -D_BSD_TIME -woff $woff"
85f483a2
SH
294 optimize='none'
295 ;;
296 esac
297
9ea370a7
KS
298# this is to accommodate the 'modules' capability of the
299# 7.2 MIPSPro compilers, which allows for the compilers to be installed
300# in a nondefault location. Almost everything works as expected, but
301# /usr/include isn't caught properly. Hence see the /usr/include/pthread.h
302# change below to include TOOLROOT (a modules environment variable),
303# and the following code. Additional
304# code to accommodate the 'modules' environment should probably be added
305# here if possible, or be inserted as a ${TOOLROOT} reference before
306# absolute paths (again, see the pthread.h change below).
307# -- krishna@sgi.com, 8/23/98
308
a3489f11
JH
309 if [ "X${TOOLROOT}" != "X" ]; then
310 # we cant set cppflags because it gets overwritten
311 # we dont actually need $TOOLROOT/usr/include on the cc line cuz the
312 # modules functionality already includes it but
313 # XXX - how do I change cppflags in the hints file?
314 ccflags="$ccflags -I${TOOLROOT}/usr/include"
9ea370a7 315 usrinc="${TOOLROOT}/usr/include"
a3489f11 316 fi
9ea370a7 317
e8c10df3
SH
318 ;;
319esac
c43fed53 320
1381c0fe 321# workaround for an optimizer bug
6d240721
JH
322# Made to work via UU/config.sh thing (or, rather, config.sh, since we're in
323# a callback) from README.hints, plus further stuff; doesn't handle -g still,
324# unfortunately - Allen
ea437474 325case "`$cc -version 2>&1`" in
6d240721
JH
326*7.2.*)
327 test -z "$op_cflags" && echo "op_cflags=\"optimize=\\\"\$optimize -O1\\\"\"" >> config.sh
328 test -z "$op_cflags" && op_cflags="optimize=\"\$optimize -O1\""
329 test -z "$opmini_cflags" && echo "opmini_cflags=\"optimize=\\\"\$optimize -O1\\\"\"" >> config.sh
330 test -z "$opmini_cflags" && opmini_cflags="optimize=\"\$optimize -O1\""
331 ;;
332*7.3.1.*)
333 test -z "$op_cflags" && echo "op_cflags=\"optimize=\\\"\$optimize -O2\\\"\"" >> config.sh
334 test -z "$op_cflags" && op_cflags="$op_cflags optimize=\"\$optimize -O2\""
335 test -z "$opmini_cflags" && echo "opmini_cflags=\"optimize=\\\"\$optimize -O2\\\"\"" >> config.sh
336 test -z "$opmini_cflags" && opmini_cflags="optimize=\"\$optimize -O2\""
337 ;;
ea6ddde2
JH
338esac
339
c297d531
AD
340
341# Workaround [perl #33849]: perl 5.8.6 fails to build on IRIX 6.5 due to
342# bizarre preprocessor bug: cc -E - unfortunately goes into K&R mode, but
343# cc -E file.c doesn't. Force a wrapper to always get the ANSI mode.
344# (We only need to do this for cc, not for gcc. ccversion is computed above.)
345case "$ccversion" in
346'') ;; # gcc. Do nothing.
08c5d564
AD
347*) # Inside this call-back unit, we are down in the UU/ subdirectory,
348 # but Configure will look for cppstdin one level up.
349 cd ..; cppstdin=`pwd`/cppstdin; cd UU
c297d531
AD
350 cpprun="$cppstdin"
351 ;;
352esac
353
6d240721
JH
354EOCCBU
355
356# End of cc.cbu callback unit. - Allen
357
f5a8bab6
GS
358# We don't want these libraries.
359# Socket networking is in libc, these are not installed by default,
360# and just slow perl down. (scotth@sgi.com)
53df3d8c
JH
361# librt contains nothing we need (some places need it for Time::HiRes) --jhi
362set `echo X "$libswanted "|sed -e 's/ socket / /' -e 's/ nsl / /' -e 's/ dl / /' -e 's/ rt / /'`
f4cb4c40
AD
363shift
364libswanted="$*"
e8c10df3
SH
365
366# I have conflicting reports about the sun, crypt, bsd, and PW
367# libraries on Irix 6.2.
368#
20f6aaab 369# One user reports:
e8c10df3
SH
370# Don't need sun crypt bsd PW under 6.2. You *may* need to link
371# with these if you want to run perl built under 6.2 on a 5.3 machine
372# (I haven't checked)
ecfc5424 373#
e8c10df3
SH
374# Another user reported that if he included those libraries, a large number
375# of the tests failed (approx. 20-25) and he would get a core dump. To
376# make things worse, test results were inconsistent, i.e., some of the
377# tests would pass some times and fail at other times.
378# The safest thing to do seems to be to eliminate them.
379#
380# Actually, the only libs that you want are '-lm'. Everything else
381# you need is in libc. You do also need '-lbsd' if you choose not
382# to use the -D_BSD_* defines. Note that as of 6.2 the only
383# difference between '-lmalloc' and '-lc' malloc is the debugging
f5a8bab6 384# and control calls, which aren't used by perl. -- scotth@sgi.com
f4cb4c40 385
f5a8bab6 386set `echo X "$libswanted "|sed -e 's/ sun / /' -e 's/ crypt / /' -e 's/ bsd / /' -e 's/ PW / /' -e 's/ malloc / /'`
e8c10df3
SH
387shift
388libswanted="$*"
eb1cfdd6 389
6d240721
JH
390# libbind.{so|a} would be from a BIND/named installation - IRIX 6.5.* has
391# pretty much everything that would be useful in libbind in libc, including
392# accessing a local caching server (nsd) that will also look in /etc/hosts,
393# NIS (yuck!), etcetera. libbind also doesn't have the _r (thread-safe
394# reentrant) functions.
395# - Allen <easmith@beatrice.rutgers.edu>
396
397case "`uname -r`" in
3986.5)
399 set `echo X "$libswanted "|sed -e 's/ bind / /'`
400 shift
401 libswanted="$*"
402 ;;
403esac
404
405# Don't groan about unused libraries.
406case "$ldflags" in
407 *-Wl,-woff,84*) ;;
408 *) ldflags="$ldflags -Wl,-woff,84" ;;
409esac
410
411# Irix 6.5.6 seems to have a broken header <sys/mode.h>
412# don't include that (it doesn't contain S_IFMT, S_IFREG, et al)
413
414i_sysmode="$undef"
415
20f6aaab 416$cat > UU/usethreads.cbu <<'EOCBU'
104d25b7
JH
417# This script UU/usethreads.cbu will get 'called-back' by Configure
418# after it has prompted the user for whether to use threads.
104d25b7
JH
419case "$usethreads" in
420$define|true|[yY]*)
421 if test ! -f ${TOOLROOT}/usr/include/pthread.h -o ! -f /usr/lib/libpthread.so; then
422 case "`uname -r`" in
423 [1-5].*|6.[01])
424 cat >&4 <<EOM
425IRIX `uname -r` does not support POSIX threads.
426You should upgrade to at least IRIX 6.2 with pthread patches.
427EOM
428 ;;
429 6.2)
430 cat >&4 <<EOM
431IRIX 6.2 can have the POSIX threads.
7162771d 432However, the following IRIX patches (or their replacements) MUST be installed:
104d25b7
JH
433 1404 Irix 6.2 Posix 1003.1b man pages
434 1645 IRIX 6.2 & 6.3 POSIX header file updates
435 2000 Irix 6.2 Posix 1003.1b support modules
436 2254 Pthread library fixes
437 2401 6.2 all platform kernel rollup
438IMPORTANT:
439 Without patch 2401, a kernel bug in IRIX 6.2 will
440 cause your machine to panic and crash when running
441 threaded perl. IRIX 6.3 and up should be OK.
442EOM
443 ;;
444 [67].*)
445 cat >&4 <<EOM
446IRIX `uname -r` should have the POSIX threads.
447But, somehow, you do not seem to have them installed.
448EOM
449 ;;
450 esac
451 cat >&4 <<EOM
452Cannot continue, aborting.
453EOM
454 exit 1
455 fi
456 set `echo X "$libswanted "| sed -e 's/ c / pthread /'`
104d25b7
JH
457 shift
458 libswanted="$*"
459
460 usemymalloc='n'
5ad89fa3
JH
461
462 # These are hidden behind a _POSIX1C ifdef that would
463 # require including <pthread.h> for the Configure hasproto
464 # to see these.
6d240721
JH
465
466# d_asctime_r_proto="$define"
467# d_ctime_r_proto="$define"
468# d_gmtime_r_proto="$define"
469# d_localtime_r_proto="$define"
470
471 # Safer just to go ahead and include it, for other ifdefs like them
472 # (there are a lot, such as in netdb.h). - Allen
473 ccflags="$ccflags -DPTHREAD_H_FIRST"
474
475 pthread_h_first="$define"
476 echo "pthread_h_first='define'" >> config.sh
477
104d25b7 478 ;;
6d240721 479
104d25b7
JH
480esac
481EOCBU
482
6b8eaf93
JH
483# The -n32 makes off_t to be 8 bytes, so we should have largefileness.
484
20f6aaab 485$cat > UU/use64bitint.cbu <<'EOCBU'
6d240721
JH
486# This script UU/use64bitint.cbu will get 'called-back' by Configure
487# after it has prompted the user for whether to use 64 bit integers.
488
db3030c0 489case "$use64bitint" in
6d240721
JH
490$define|true|[yY]*)
491 case "`uname -r`" in
492 [1-5]*|6.[01])
493 cat >&4 <<EOM
494IRIX `uname -r` does not support 64-bit types.
495You should upgrade to at least IRIX 6.2.
496Cannot continue, aborting.
497EOM
498 exit 1
499 ;;
500 esac
501 usemymalloc="$undef"
502 ;;
503*) d_casti32="$undef" ;;
db3030c0 504esac
afd0dee8 505
6d240721
JH
506EOCBU
507
20f6aaab 508$cat > UU/use64bitall.cbu <<'EOCBU'
6d240721
JH
509# This script UU/use64bitall.cbu will get 'called-back' by Configure
510# after it has prompted the user for whether to be maximally 64 bitty.
511
512case "$use64bitall" in
513$define|true|[yY]*)
514 case "$cc" in
515 *-n32*|*-32*)
516 cat >&4 <<EOM
517You cannot use a non-64 bit cc for -Duse64bitall, sorry.
518Cannot continue, aborting.
519EOM
520 exit 1
521 ;;
522 esac
523 ;;
524esac
525
526EOCBU
527
20f6aaab
AS
528$cat > UU/uselongdouble.cbu <<'EOCBU'
529# This script UU/uselongdouble.cbu will get 'called-back' by Configure
530# after it has prompted the user for whether to use long doubles.
531
532# This script is designed to test IRIX (and other machines, once it's put into
533# Configure) for a bug in which they fail to round correctly when using
534# sprintf/printf/etcetera on a long double with precision specified (%.0Lf or
535# whatever). Sometimes, this only happens when the number in question is
536# between 1 and -1, weirdly enough. - Allen
537
538case "$uselongdouble" in
539$define|true|[yY]*)
540
541case "$d_PRIfldbl" in
542$define|true|[yY]*)
543
544 echo " " >try.c
545 $cat >>try.c <<EOP
546#include <stdio.h>
547
548#define sPRIfldbl $sPRIfldbl
549
550#define I_STDLIB $i_stdlib
551#ifdef I_STDLIB
552#include <stdlib.h>
553#endif
554
555int main()
556{
557 char buf1[64];
558 char buf2[64];
559 buf1[63] = '\0';
560 buf2[63] = '\0';
561
562 (void)sprintf(buf1,"%.0"sPRIfldbl,(long double)0.6L);
563 (void)sprintf(buf2,"%.0f",(double)0.6);
564 if (strcmp(buf1,buf2)) {
565 exit(1);
566 }
567 (void)sprintf(buf1,"%.0"sPRIfldbl,(long double)-0.6L);
568 (void)sprintf(buf2,"%.0f",(double)-0.6);
569 if (strcmp(buf1,buf2)) {
570 exit(1);
571 } else {
572 exit(0);
573 }
574}
575
576EOP
577
578 set try
579 if eval $compile && $run ./try; then
580 rm -f try try.* >/dev/null
581 else
582 rm -f try try.* core a.out >/dev/null
583 ccflags="$ccflags -DHAS_LDBL_SPRINTF_BUG"
584 cppflags="$cppflags -DHAS_LDBL_SPRINTF_BUG"
585
586 echo " " >try.c
587 $cat >>try.c <<EOP
588#include <stdio.h>
589
590#define sPRIfldbl $sPRIfldbl
591
592#define I_STDLIB $i_stdlib
593#ifdef I_STDLIB
594#include <stdlib.h>
595#endif
596
597int main()
598{
599 char buf1[64];
600 char buf2[64];
601 buf1[63] = '\0';
602 buf2[63] = '\0';
603
604 (void)sprintf(buf1,"%.0"sPRIfldbl,(long double)1.6L);
605 (void)sprintf(buf2,"%.0f",(double)1.6);
606 if (strcmp(buf1,buf2)) {
607 exit(1);
608 }
609 (void)sprintf(buf1,"%.0"sPRIfldbl,(long double)-1.6L);
610 (void)sprintf(buf2,"%.0f",(double)-1.6);
611 if (strcmp(buf1,buf2)) {
612 exit(1);
613 } else {
614 exit(0);
615 }
616}
617
618EOP
619
620 set try
621 if eval $compile && $run ./try; then
622 rm -f try try.c >/dev/null
623 ccflags="$ccflags -DHAS_LDBL_SPRINTF_BUG_LESS1"
624 cppflags="$cppflags -DHAS_LDBL_SPRINTF_BUG_LESS1"
625 else
626 rm -f try try.c core try.o a.out >/dev/null
627 fi
628 fi
629;;
630*) # Can't tell!
631 ccflags="$ccflags -DHAS_LDBL_SPRINTF_BUG"
632 cppflags="$cppflags -DHAS_LDBL_SPRINTF_BUG"
633 ;;
634esac
635
636# end of case statement for how to print ldbl with 'f'
637;;
638*) ;;
639esac
640
641# end of case statement for whether to do long doubles
642
643EOCBU
644
d1a954cb
JH
645# Helmut Jarausch reports that Perl's malloc is rather unusable
646# with IRIX, and SGI confirms the problem.
647usemymalloc=${usemymalloc:-false}