Re-establish the fp overflow detection for VAX VMS; there
[p5sagit/p5-mst-13.2.git] / hints / hpux.sh
CommitLineData
1dc48e02 1#!/usr/bin/sh
8e07c86e 2
1dc48e02 3### SYSTEM ARCHITECTURE
8e07c86e 4
1dc48e02 5# Determine the architecture type of this system.
6# Keep leading tab below -- Configure Black Magic -- RAM, 03/02/97
7 xxOsRevMajor=`uname -r | sed -e 's/^[^0-9]*//' | cut -d. -f1`;
8if [ "$xxOsRevMajor" -ge 10 ]; then
9 # This system is running >= 10.x
10
11 # Tested on 10.01 PA1.x and 10.20 PA[12].x.
12 # Idea: Scan /usr/include/sys/unistd.h for matches with
13 # "#define CPU_* `getconf # CPU_VERSION`" to determine CPU type.
14 # Note the text following "CPU_" is used, *NOT* the comment.
15 #
16 # ASSUMPTIONS: Numbers will continue to be defined in hex -- and in
17 # /usr/include/sys/unistd.h -- and the CPU_* #defines will be kept
18 # up to date with new CPU/OS releases.
19 xxcpu=`getconf CPU_VERSION`; # Get the number.
20 xxcpu=`printf '0x%x' $xxcpu`; # convert to hex
21 archname=`sed -n -e "s/^#[ \t]*define[ \t]*CPU_//p" /usr/include/sys/unistd.h |
22 sed -n -e "s/[ \t]*$xxcpu[ \t].*//p" |
23 sed -e s/_RISC/-RISC/ -e s/HP_// -e s/_/./`;
24else
25 # This system is running <= 9.x
26 # Tested on 9.0[57] PA and [78].0 MC680[23]0. Idea: After removing
27 # MC6888[12] from context string, use first CPU identifier.
28 #
29 # ASSUMPTION: Only CPU identifiers contain no lowercase letters.
30 archname=`getcontext | tr ' ' '\012' | grep -v '[a-z]' | grep -v MC688 |
31 sed -e 's/HP-//' -e 1q`;
32 selecttype='int *'
8e07c86e 33 fi
8e07c86e 34
1dc48e02 35echo "Archname is $archname"
36
37
38### HP-UX OS specific behaviour
5e4c82f0 39
e08bfeb2 40# -ldbm is obsolete and should not be used
41# -lBSD contains BSD-style duplicates of SVR4 routines that cause confusion
42# -lPW is obsolete and should not be used
43# The libraries crypt, malloc, ndir, and net are empty.
c723583c 44set `echo "X $libswanted " | sed -e 's/ ld / /' -e 's/ dbm / /' -e 's/ BSD / /' -e 's/ PW / /'`
45shift
e08bfeb2 46libswanted="$*"
47
1dc48e02 48cc=${cc:-cc}
c723583c 49ar=/usr/bin/ar # Yes, truly override. We do not want the GNU ar.
50full_ar=$ar # I repeat, no GNU ar. arrr.
167d2fcb 51
c723583c 52set `echo "X $ccflags " | sed -e 's/ -A[ea] / /' -e 's/ -D_HPUX_SOURCE / /'`
53shift
54 cc_cppflags="$* -D_HPUX_SOURCE"
55cppflags="-Aa -D__STDC_EXT__ $cc_cppflags"
56
57case "$prefix" in
58 "") prefix='/opt/perl5' ;;
59 esac
0f3ba31f 60
dcd01700 61 gnu_as=no
62 gnu_ld=no
b36fec95 63case `$cc -v 2>&1`"" in
c723583c 64 *gcc*) ccisgcc="$define"
dcd01700 65 ccflags="$cc_cppflags"
16c1da12 66 if [ "X$gccversion" = "X" ]; then
67 # Done too late in Configure if hinted
68 gccversion=`$cc --version`
69 fi
0f3ba31f 70 case "`getconf KERNEL_BITS 2>/dev/null`" in
dcd01700 71 *64*)
16c1da12 72 case "$gccversion" in
73 3*) ccflags="$ccflags -mpa-risc-2-0"
dcd01700 74 ;;
16c1da12 75 *) echo "main(){}">try.c
76 # gcc with gas will not accept +DA2.0
77 case "`$cc -c -Wa,+DA2.0 try.c 2>&1`" in
78 *"+DA2.0"*) # gas
79 gnu_as=yes
80 ;;
81 *) # HPas
82 ccflags="$ccflags -Wa,+DA2.0"
83 ;;
84 esac
dcd01700 85 ;;
86 esac
87 # gcc with gld will not accept +vnocompatwarnings
88 case "`$cc -o try -Wl,+vnocompatwarnings try.c 2>&1`" in
89 *"+vnocompat"*) # gld
90 gnu_ld=yes
91 ;;
92 *) # HPld
9fecddab 93 case "$gccversion" in
94 [12]*)
95 ldflags="$ldflags -Wl,+vnocompatwarnings"
96 ccflags="$ccflags -Wl,+vnocompatwarnings"
97 ;;
98 esac
dcd01700 99 ;;
100 esac
101 ;;
0f3ba31f 102 esac
c723583c 103 ;;
104 *) ccisgcc=''
105 ccversion=`which cc | xargs what | awk '/Compiler/{print $2}'`
5e2807cc 106 ccflags="-Ae $cc_cppflags -Wl,+vnocompatwarnings"
107 # Needed because cpp does only support -Aa (not -Ae)
108 cpplast='-'
109 cppminus='-'
110 cppstdin='cc -E -Aa -D__STDC_EXT__'
111 cpprun=$cppstdin
0f3ba31f 112 case "$d_casti32" in
113 "") d_casti32='undef' ;;
114 esac
115 ;;
1dc48e02 116 esac
117
e08bfeb2 118# When HP-UX runs a script with "#!", it sets argv[0] to the script name.
119toke_cflags='ccflags="$ccflags -DARG_ZERO_IS_SCRIPT"'
1dc48e02 120
1dc48e02 121### 64 BITNESS
b36fec95 122
8cb447e0 123# Some gcc versions do native 64 bit long (e.g. 2.9-hppa-000310 and gcc-3.0)
dcd01700 124# We have to force 64bitness to go search the right libraries
125 gcc_64native=no
126case "$ccisgcc" in
127 $define|true|[Yy])
8cb447e0 128 echo 'int main(){long l;printf("%d\\n",sizeof(l));}'>try.c
dcd01700 129 $cc -o try $ccflags $ldflags try.c
130 if [ "`try`" = "8" ]; then
131 cat <<EOM >&4
132
133*** This version of gcc uses 64 bit longs. -Duse64bitall is
134*** implicitly set to enable continuation
135EOM
136 use64bitall=$define
137 gcc_64native=yes
138 fi
139 ;;
140 esac
141
ec7b9793 142case "$use64bitall" in
1dc48e02 143 $define|true|[yY]*) use64bitint="$define" ;;
144 esac
145
6d5d7abf 146case "$usemorebits" in
1dc48e02 147 $define|true|[yY]*) use64bitint="$define"; uselongdouble="$define" ;;
148 esac
bf0c440f 149
1dc48e02 150case "$uselongdouble" in
151 $define|true|[yY]*)
152 cat <<EOM >&4
153
154*** long doubles are not (yet) supported on HP-UX (any version)
155*** Until it does, we cannot continue, aborting.
bf0c440f 156EOM
1dc48e02 157 exit 1 ;;
158 esac
bf0c440f 159
1dc48e02 160case "$use64bitint" in
161 $define|true|[Yy])
bf0c440f 162
1dc48e02 163 if [ "$xxOsRevMajor" -lt 11 ]; then
164 cat <<EOM >&4
165
166*** 64-bit compilation is not supported on HP-UX $xxOsRevMajor.
167*** You need at least HP-UX 11.0.
ec7b9793 168*** Cannot continue, aborting.
bf0c440f 169EOM
1dc48e02 170 exit 1
171 fi
bf0c440f 172
1dc48e02 173 # Set libc and the library paths
174 case "$archname" in
175 PA-RISC*)
176 loclibpth="$loclibpth /lib/pa20_64"
177 libc='/lib/pa20_64/libc.sl' ;;
178 IA64*)
179 loclibpth="$loclibpth /usr/lib/hpux64"
180 libc='/usr/lib/hpux64/libc.so' ;;
181 esac
182 if [ ! -f "$libc" ]; then
183 cat <<EOM >&4
184
185*** You do not seem to have the 64-bit libc.
186*** I cannot find the file $libc.
187*** Cannot continue, aborting.
188EOM
189 exit 1
190 fi
bf0c440f 191
dcd01700 192 case "$ccisgcc" in
193 $define|true|[Yy])
194 # For the moment, don't care that it ain't supported (yet)
195 # by gcc (up to and including 2.95.3), cause it'll crash
196 # anyway. Expect auto-detection of 64-bit enabled gcc on
197 # HP-UX soon, including a user-friendly exit
198 case $gcc_64native in
16c1da12 199 no) case "$gccversion" in
200 [12]*) ccflags="$ccflags -mlp64"
201 ldflags="$ldflags -Wl,+DD64"
202 ;;
203 esac
dcd01700 204 ;;
205 esac
206 ;;
207 *)
208 ccflags="$ccflags +DD64"
209 ldflags="$ldflags +DD64"
210 ;;
211 esac
bf0c440f 212
1dc48e02 213 # Reset the library checker to make sure libraries
214 # are the right type
215 libscheck='case "`/usr/bin/file $xxx`" in
216 *ELF-64*|*LP64*|*PA-RISC2.0*) ;;
217 *) xxx=/no/64-bit$xxx ;;
218 esac'
219
220 ;;
221
222 *) # Not in 64-bit mode
223
224 case "$archname" in
225 PA-RISC*)
226 libc='/lib/libc.sl' ;;
227 IA64*)
228 loclibpth="$loclibpth /usr/lib/hpux32"
229 libc='/usr/lib/hpux32/libc.so' ;;
230 esac
231 ;;
232 esac
233
dcd01700 234# By setting the deferred flag below, this means that if you run perl
235# on a system that does not have the required shared library that you
236# linked it with, it will die when you try to access a symbol in the
237# (missing) shared library. If you would rather know at perl startup
238# time that you are missing an important shared library, switch the
239# comments so that immediate, rather than deferred loading is
240# performed. Even with immediate loading, you can postpone errors for
241# undefined (or multiply defined) routines until actual access by
242# adding the "nonfatal" option.
243# ccdlflags="-Wl,-E -Wl,-B,immediate $ccdlflags"
244# ccdlflags="-Wl,-E -Wl,-B,immediate,-B,nonfatal $ccdlflags"
245if [ "$gnu_ld" = "yes" ]; then
246 ccdlflags="-Wl,-E $ccdlflags"
247else
248 ccdlflags="-Wl,-E -Wl,-B,deferred $ccdlflags"
249 fi
250
1dc48e02 251
252### COMPILER SPECIFICS
bf0c440f 253
7f128676 254## Local restrictions (point to README.hpux to lift these)
255
256## Optimization limits
257cat >try.c <<EOF
258#include <sys/resource.h>
259
260int main ()
261{
262 struct rlimit rl;
263 int i = getrlimit (RLIMIT_DATA, &rl);
264 printf ("%d\n", rl.rlim_cur / (1024 * 1024));
265 } /* main */
266EOF
267$cc -o try $ccflags $ldflags try.c
268 maxdsiz=`try`
269if [ $maxdsiz -le 64 ]; then
270 # 64 Mb is probably not enough to optimize toke.c
271 # and regexp.c with -O2
272 cat <<EOM >&4
273Your kernel limits the data section of your programs to $maxdsiz Mb,
274which is (sadly) not enough to fully optimize some parts of the
275perl binary. I'll try to use a lower optimization level for
276those parts. If you are a sysadmin, and you *do* want full
277optimization, raise the 'maxdsiz' kernel configuration parameter
278to at least 0x08000000 (128 Mb) and rebuild your kernel.
279EOM
a6bab54c 280regexec_cflags=''
7f128676 281 fi
282
b36fec95 283case "$ccisgcc" in
1dc48e02 284 $define|true|[Yy])
285
286 case "$optimize" in
c723583c 287 "") optimize="-g -O" ;;
288 *O[3456789]*) optimize=`echo "$optimize" | sed -e 's/O[3-9]/O2/'` ;;
1dc48e02 289 esac
c723583c 290 #ld="$cc"
5e2807cc 291 ld=/usr/bin/ld
1dc48e02 292 cccdlflags='-fPIC'
c723583c 293 #lddlflags='-shared'
5e2807cc 294 lddlflags='-b'
c723583c 295 case "$optimize" in
296 *-g*-O*|*-O*-g*)
297 # gcc without gas will not accept -g
298 echo "main(){}">try.c
299 case "`$cc $optimize -c try.c 2>&1`" in
300 *"-g option disabled"*)
301 set `echo "X $optimize " | sed -e 's/ -g / /'`
302 shift
303 optimize="$*"
304 ;;
305 esac
306 ;;
307 esac
7f128676 308 if [ $maxdsiz -le 64 ]; then
7f128676 309 case "$optimize" in
310 *O2*) opt=`echo "$optimize" | sed -e 's/O2/O1/'`
a6bab54c 311 toke_cflags="$toke_cflags;optimize=\"$opt\""
312 regexec_cflags="optimize=\"$opt\""
7f128676 313 ;;
314 esac
315 fi
1dc48e02 316 ;;
317
318 *) # HP's compiler cannot combine -g and -O
319 case "$optimize" in
5e2807cc 320 "") optimize="+O2 +Onolimit" ;;
c723583c 321 *O[3456789]*) optimize=`echo "$optimize" | sed -e 's/O[3-9]/O2/'` ;;
1dc48e02 322 esac
7f128676 323 if [ $maxdsiz -le 64 ]; then
7f128676 324 case "$optimize" in
325 *-O*|\
326 *O2*) opt=`echo "$optimize" | sed -e 's/-O/+O2/' -e 's/O2/O1/' -e 's/ *+Onolimit//'`
a6bab54c 327 toke_cflags="$toke_cflags;optimize=\"$opt\""
328 regexec_cflags="optimize=\"$opt\""
7f128676 329 ;;
330 esac
331 fi
1dc48e02 332 ld=/usr/bin/ld
333 cccdlflags='+Z'
c723583c 334 lddlflags='-b +vnocompatwarnings'
1dc48e02 335 ;;
b36fec95 336 esac
8e07c86e 337
1dc48e02 338## LARGEFILES
774d564b 339
c723583c 340#case "$uselargefiles-$ccisgcc" in
341# "$define-$define"|'-define')
342# cat <<EOM >&4
343#
344#*** I'm ignoring large files for this build because
345#*** I don't know how to do use large files in HP-UX using gcc.
346#
347#EOM
348# uselargefiles="$undef"
349# ;;
350# esac
dc45a647 351
1dc48e02 352cat >UU/uselargefiles.cbu <<'EOCBU'
353# This script UU/uselargefiles.cbu will get 'called-back' by Configure
354# after it has prompted the user for whether to use large files.
355case "$uselargefiles" in
356 ""|$define|true|[yY]*)
357 # there are largefile flags available via getconf(1)
358 # but we cheat for now. (Keep that in the left margin.)
359ccflags_uselargefiles="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
5cf1d1f1 360
1dc48e02 361 ccflags="$ccflags $ccflags_uselargefiles"
362
363 if test -z "$ccisgcc" -a -z "$gccversion"; then
364 # The strict ANSI mode (-Aa) doesn't like large files.
365 ccflags=`echo " $ccflags "|sed 's@ -Aa @ @g'`
366 case "$ccflags" in
367 *-Ae*) ;;
368 *) ccflags="$ccflags -Ae" ;;
369 esac
fa2879fb 370 fi
371 ;;
372 esac
1dc48e02 373EOCBU
fa2879fb 374
1dc48e02 375# THREADING
104d25b7 376
377# This script UU/usethreads.cbu will get 'called-back' by Configure
378# after it has prompted the user for whether to use threads.
1dc48e02 379cat >UU/usethreads.cbu <<'EOCBU'
104d25b7 380case "$usethreads" in
1dc48e02 381 $define|true|[yY]*)
382 if [ "$xxOsRevMajor" -lt 10 ]; then
383 cat <<EOM >&4
f1ee07ac 384
104d25b7 385HP-UX $xxOsRevMajor cannot support POSIX threads.
386Consider upgrading to at least HP-UX 11.
387Cannot continue, aborting.
388EOM
1dc48e02 389 exit 1
390 fi
391
392 if [ "$xxOsRevMajor" -eq 10 ]; then
393 # Under 10.X, a threaded perl can be built
394 if [ -f /usr/include/pthread.h ]; then
c7d9b096 395 if [ -f /usr/lib/libcma.sl ]; then
396 # DCE (from Core OS CD) is installed
397
1dc48e02 398 # It needs # libcma and OLD_PTHREADS_API. Also
399 # <pthread.h> needs to be #included before any
400 # other includes (in perl.h)
c7d9b096 401
402 # HP-UX 10.X uses the old pthreads API
403 d_oldpthreads="$define"
404
405 # include libcma before all the others
406 libswanted="cma $libswanted"
407
1dc48e02 408 # tell perl.h to include <pthread.h> before other
409 # include files
c7d9b096 410 ccflags="$ccflags -DPTHREAD_H_FIRST"
411
1dc48e02 412 # CMA redefines select to cma_select, and cma_select
413 # expects int * instead of fd_set * (just like 9.X)
c7d9b096 414 selecttype='int *'
415
416 elif [ -f /usr/lib/libpthread.sl ]; then
417 # PTH package is installed
418 libswanted="pthread $libswanted"
419 else
420 libswanted="no_threads_available"
421 fi
422 else
423 libswanted="no_threads_available"
424 fi
425
1dc48e02 426 if [ $libswanted = "no_threads_available" ]; then
427 cat <<EOM >&4
f1ee07ac 428
104d25b7 429In HP-UX 10.X for POSIX threads you need both of the files
c7d9b096 430/usr/include/pthread.h and either /usr/lib/libcma.sl or /usr/lib/libpthread.sl.
431Either you must upgrade to HP-UX 11 or install a posix thread library:
f1ee07ac 432
433 DCE-CoreTools from HP-UX 10.20 Hardware Extensions 3.0 CD (B3920-13941)
434
435or
436
1dc48e02 437 PTH package from e.g. http://hpux.tn.tudelft.nl/hppd/hpux/alpha.html
f1ee07ac 438
104d25b7 439Cannot continue, aborting.
440EOM
1dc48e02 441 exit 1
c7d9b096 442 fi
1dc48e02 443 else
444 # 12 may want upping the _POSIX_C_SOURCE datestamp...
445 ccflags=" -D_POSIX_C_SOURCE=199506L $ccflags"
446 set `echo X "$libswanted "| sed -e 's/ c / pthread c /'`
447 shift
448 libswanted="$*"
449 fi
104d25b7 450
227c31c3 451 usemymalloc='n'
104d25b7 452 ;;
1dc48e02 453 esac
bd9b35c9 454EOCBU
758a5d79 455
456# fpclassify() is a macro, the library call is Fpclassify
457d_fpclassify='define'
458