1#!/usr/bin/sh
2
3### SYSTEM ARCHITECTURE
4
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`;
8	xxOsRevMinor=`uname -r | sed -e 's/^[^0-9]*//' | cut -d. -f2`;
9	xxOsRev=`expr 100 \* $xxOsRevMajor + $xxOsRevMinor`
10if [ "$xxOsRevMajor" -ge 10 ]; then
11    # This system is running >= 10.x
12
13    # Tested on 10.01 PA1.x and 10.20 PA[12].x.
14    # Idea: Scan /usr/include/sys/unistd.h for matches with
15    # "#define CPU_* `getconf # CPU_VERSION`" to determine CPU type.
16    # Note the text following "CPU_" is used, *NOT* the comment.
17    #
18    # ASSUMPTIONS: Numbers will continue to be defined in hex -- and in
19    # /usr/include/sys/unistd.h -- and the CPU_* #defines will be kept
20    # up to date with new CPU/OS releases.
21    xxcpu=`getconf CPU_VERSION`; # Get the number.
22    xxcpu=`printf '0x%x' $xxcpu`; # convert to hex
23    archname=`sed -n -e "s/^#[[:space:]]*define[[:space:]]*CPU_//p" /usr/include/sys/unistd.h |
24	sed -n -e "s/[[:space:]]*$xxcpu[[:space:]].*//p" |
25	sed -e s/_RISC/-RISC/ -e s/HP_// -e s/_/./ -e "s/[[:space:]]*//g"`;
26else
27    # This system is running <= 9.x
28    # Tested on 9.0[57] PA and [78].0 MC680[23]0.  Idea: After removing
29    # MC6888[12] from context string, use first CPU identifier.
30    #
31    # ASSUMPTION: Only CPU identifiers contain no lowercase letters.
32    archname=`getcontext | tr ' ' '\012' | grep -v '[a-z]' | grep -v MC688 |
33	sed -e 's/HP-//' -e 1q`;
34    selecttype='int *'
35    fi
36
37# For some strange reason, the u32align test from Configure hangs in
38# HP-UX 10.20 since the December 2001 patches.  So hint it to avoid
39# the test.
40if [ "$xxOsRevMajor" -le 10 ]; then
41    d_u32align=$define
42    fi
43
44echo "Archname is $archname"
45
46# Fix XSlib (CPAN) confusion when re-using a prefix but changing from ILP32
47# to LP64 builds.  They're NOT binary compatible, so quit claiming they are.
48archname64=LP64
49
50
51### HP-UX OS specific behaviour
52
53# -ldbm is obsolete and should not be used
54# -lBSD contains BSD-style duplicates of SVR4 routines that cause confusion
55# -lPW is obsolete and should not be used
56# The libraries crypt, malloc, ndir, and net are empty.
57set `echo "X $libswanted " | sed -e 's/ ld / /' -e 's/ dbm / /' -e 's/ BSD / /' -e 's/ PW / /'`
58shift
59libswanted="$*"
60
61cc=${cc:-cc}
62ar=/usr/bin/ar	# Yes, truly override.  We do not want the GNU ar.
63full_ar=$ar	# I repeat, no GNU ar.  arrr.
64
65set `echo "X $ccflags " | sed -e 's/ -A[ea] / /' -e 's/ -D_HPUX_SOURCE / /'`
66shift
67	cc_cppflags="$* -D_HPUX_SOURCE"
68cppflags="-Aa -D__STDC_EXT__ $cc_cppflags"
69
70case "$prefix" in
71    "") prefix='/opt/perl5' ;;
72    esac
73
74    gnu_as=no
75    gnu_ld=no
76case `$cc -v 2>&1`"" in
77    *gcc*)  ccisgcc="$define"
78	    ccflags="$cc_cppflags"
79	    if [ "X$gccversion" = "X" ]; then
80		# Done too late in Configure if hinted
81		gccversion=`$cc -dumpversion`
82		fi
83	    case "$gccversion" in
84		[012]*) # HP-UX and gcc-2.* break UINT32_MAX :-(
85		    ccflags="$ccflags -DUINT32_MAX_BROKEN"
86		    ;;
87		[34]*) # GCC (both 32bit and 64bit) will define __STDC_EXT__
88                       # by default when using GCC 3.0 and newer versions of
89                       # the compiler.
90		   cppflags="$cc_cppflags"
91		   ;;
92		esac
93	    case "`getconf KERNEL_BITS 2>/dev/null`" in
94		*64*)
95		    echo "main(){}">try.c
96		    case "$gccversion" in
97			[34]*)
98			    case "$archname" in
99                               PA-RISC*)
100                                   case "$ccflags" in
101                                       *-mpa-risc*) ;;
102                                       *) ccflags="$ccflags -mpa-risc-2-0" ;;
103                                       esac
104                                   ;;
105				esac
106			    ;;
107			*)  # gcc with gas will not accept +DA2.0
108			    case "`$cc -c -Wa,+DA2.0 try.c 2>&1`" in
109				*"+DA2.0"*)		# gas
110				    gnu_as=yes
111				    ;;
112				*)			# HPas
113				    ccflags="$ccflags -Wa,+DA2.0"
114				    ;;
115				esac
116			    ;;
117			esac
118		    # gcc with gld will not accept +vnocompatwarnings
119		    case "`$cc -o try -Wl,+vnocompatwarnings try.c 2>&1`" in
120			*"+vnocompat"*)		# gld
121			    gnu_ld=yes
122			    ;;
123			*)			# HPld
124			   case "$gccversion" in
125			       [12]*)
126				   # Why not 3 as well here?
127				   # Since not relevant to IA64, not changed.
128				   ldflags="$ldflags -Wl,+vnocompatwarnings"
129				   ccflags="$ccflags -Wl,+vnocompatwarnings"
130				   ;;
131			       esac
132			    ;;
133			esac
134		    rm -f try.c
135		    ;;
136		esac
137	    ;;
138    *)      ccisgcc=''
139	    # What cannot be use in combination with ccache links :(
140	    cc_found=""
141	    for p in `echo $PATH | tr : ' ''` ; do
142		x="$p/cc"
143		if [ -f $x ] && [ -x $x ]; then
144		    if [ -h $x ]; then
145			l=`ls -l $x | sed 's,.*-> ,,'`
146			case $l in
147			    /*) x=$l		;;
148			    *)  x="$p/$l"	;;
149			    esac
150			fi
151		    x=`echo $x | sed 's,/\./,/,g'`
152		    case $x in
153			*ccache*) ;;
154			*) [ -z "$cc_found" ] && cc_found=$x ;;
155			esac
156		    fi
157		done
158	    [ -z "$cc_found" ] && cc_found=`which cc`
159	    what $cc_found >&4
160	    ccversion=`what $cc_found | awk '/Compiler/{print $2}/Itanium/{print $6,$7}/for Integrity/{print $6,$7}'`
161	    case "$ccflags" in
162               "-Ae "*) ;;
163		*)  ccflags="-Ae -Wp,-H150000 $cc_cppflags"
164		    # +vnocompatwarnings not known in 10.10 and older
165		    if [ $xxOsRev -ge 1020 ]; then
166			ccflags="$ccflags -Wl,+vnocompatwarnings"
167			fi
168		    ;;
169               esac
170	    # Needed because cpp does only support -Aa (not -Ae)
171	    cpplast='-'
172	    cppminus='-'
173	    cppstdin='cc -E -Aa -D__STDC_EXT__'
174	    cpprun=$cppstdin
175#	    case "$d_casti32" in
176#		"") d_casti32='undef' ;;
177#		esac
178	    ;;
179    esac
180
181# When HP-UX runs a script with "#!", it sets argv[0] to the script name.
182toke_cflags='ccflags="$ccflags -DARG_ZERO_IS_SCRIPT"'
183
184### 64 BITNESS
185
186# Some gcc versions do native 64 bit long (e.g. 2.9-hppa-000310 and gcc-3.0)
187# We have to force 64bitness to go search the right libraries
188    gcc_64native=no
189case "$ccisgcc" in
190    $define|true|[Yy])
191	echo '#include <stdio.h>\nint main(){long l;printf("%d\\n",sizeof(l));}'>try.c
192	$cc -o try $ccflags $ldflags try.c
193	if [ "`try`" = "8" ]; then
194	    case "$use64bitall" in
195		$define|true|[Yy]) ;;
196		*)  cat <<EOM >&4
197
198*** This version of gcc uses 64 bit longs. -Duse64bitall is
199*** implicitly set to enable continuation
200EOM
201		esac
202	    use64bitall=$define
203	    gcc_64native=yes
204	    fi
205	;;
206    esac
207
208case "$use64bitall" in
209    $define|true|[yY]*) use64bitint="$define" ;;
210    esac
211
212case "$usemorebits" in
213    $define|true|[yY]*) use64bitint="$define"; uselongdouble="$define" ;;
214    esac
215
216# There is a weird pre-C99 long double (a struct of four uin32_t)
217# in HP-UX 10.20 but beyond strtold() there's no support for them
218# for example in <math.h>.
219case "$uselongdouble" in
220    $define|true|[yY]*)
221	if [ "$xxOsRevMajor" -lt 11 ]; then
222	    cat <<EOM >&4
223
224*** uselongdouble (or usemorebits) is not supported on HP-UX $xxOsRevMajor.
225*** You need at least HP-UX 11.0.
226*** Cannot continue, aborting.
227EOM
228	    exit 1
229	fi
230	;;
231    esac
232
233# Configure long double scan will detect the HP-UX 10.20 "long double"
234# (a struct of four uin32_t) and think it is IEEE quad.  Make it not so.
235if [ "$xxOsRevMajor" -lt 11 ]; then
236    d_longdbl="$undef"
237    longdblsize=8 # Make it double.
238fi
239
240case "$archname" in
241    IA64*)
242	# While here, override so=sl auto-detection
243	so='so'
244	;;
245    esac
246
247case "$use64bitall" in
248    $define|true|[Yy])
249
250	if [ "$xxOsRevMajor" -lt 11 ]; then
251	    cat <<EOM >&4
252
253*** 64-bit compilation is not supported on HP-UX $xxOsRevMajor.
254*** You need at least HP-UX 11.0.
255*** Cannot continue, aborting.
256EOM
257	    exit 1
258	    fi
259
260	if [ $xxOsRev -eq 1100 ]; then
261	    # HP-UX 11.00 uses only 48 bits internally in 64bit mode, not 64
262	    # force min/max to 2**47-1
263	    sGMTIME_max=140737488355327
264	    sGMTIME_min=-62167219200
265	    sLOCALTIME_max=140737488355327
266	    sLOCALTIME_min=-62167219200
267	    fi
268
269	# Set libc and the library paths
270	case "$archname" in
271	    PA-RISC*)
272		loclibpth="$loclibpth /lib/pa20_64"
273		libc='/lib/pa20_64/libc.sl' ;;
274	    IA64*)
275		loclibpth="$loclibpth /usr/lib/hpux64"
276		libc='/usr/lib/hpux64/libc.so' ;;
277	    esac
278	if [ ! -f "$libc" ]; then
279	    cat <<EOM >&4
280
281*** You do not seem to have the 64-bit libc.
282*** I cannot find the file $libc.
283*** Cannot continue, aborting.
284EOM
285	    exit 1
286	    fi
287
288	case "$ccisgcc" in
289	    $define|true|[Yy])
290		# The fixed socket.h header file is wrong for gcc-4.x
291		# on PA-RISC2.0W, so Sock_type_t is size_t which is
292		# unsigned long which is 64bit which is too long
293		case "$gccversion" in
294		    4*) case "$archname" in
295			    PA-RISC*) socksizetype=int ;;
296			    esac
297			;;
298		    esac
299
300		# For the moment, don't care that it ain't supported (yet)
301		# by gcc (up to and including 2.95.3), cause it'll crash
302		# anyway. Expect auto-detection of 64-bit enabled gcc on
303		# HP-UX soon, including a user-friendly exit
304		case $gcc_64native in
305		    no) case "$gccversion" in
306			    [1234]*)
307				ccflags="$ccflags -mlp64"
308				case "$archname" in
309				    PA-RISC*)
310					ldflags="$ldflags -Wl,+DD64"
311					;;
312				    IA64*)
313					ldflags="$ldflags -mlp64"
314					;;
315				    esac
316				;;
317			    esac
318			;;
319		    esac
320		;;
321	    *)
322		case "$use64bitall" in
323		    $define|true|[yY]*)
324			ccflags="$ccflags +DD64"
325			ldflags="$ldflags +DD64"
326			;;
327		    esac
328		;;
329	    esac
330
331	# Reset the library checker to make sure libraries
332	# are the right type
333	# (NOTE: on IA64, this doesn't work with .a files.)
334	libscheck='case "`/usr/bin/file $xxx`" in
335		       *ELF-64*|*LP64*|*PA-RISC2.0*) ;;
336		       *) xxx=/no/64-bit$xxx ;;
337		       esac'
338
339	;;
340
341    *)	# Not in 64-bit mode
342
343	case "$archname" in
344	    PA-RISC*)
345		libc='/lib/libc.sl' ;;
346	    IA64*)
347		loclibpth="$loclibpth /usr/lib/hpux32"
348		libc='/usr/lib/hpux32/libc.so' ;;
349	    esac
350	;;
351    esac
352
353# By setting the deferred flag below, this means that if you run perl
354# on a system that does not have the required shared library that you
355# linked it with, it will die when you try to access a symbol in the
356# (missing) shared library.  If you would rather know at perl startup
357# time that you are missing an important shared library, switch the
358# comments so that immediate, rather than deferred loading is
359# performed.  Even with immediate loading, you can postpone errors for
360# undefined (or multiply defined) routines until actual access by
361# adding the "nonfatal" option.
362# ccdlflags="-Wl,-E -Wl,-B,immediate $ccdlflags"
363# ccdlflags="-Wl,-E -Wl,-B,immediate,-B,nonfatal $ccdlflags"
364if [ "$gnu_ld" = "yes" ]; then
365    ccdlflags="-Wl,-E $ccdlflags"
366else
367    ccdlflags="-Wl,-E -Wl,-B,deferred $ccdlflags"
368    fi
369
370
371### COMPILER SPECIFICS
372
373## Local restrictions (point to README.hpux to lift these)
374
375## Optimization limits
376cat >try.c <<EOF
377#include <stdio.h>
378#include <sys/resource.h>
379
380int main ()
381{
382    struct rlimit rl;
383    int i = getrlimit (RLIMIT_DATA, &rl);
384    printf ("%d\n", (int)(rl.rlim_cur / (1024 * 1024)));
385    } /* main */
386EOF
387$cc -o try $ccflags $ldflags try.c
388	maxdsiz=`try`
389rm -f try try.c core
390if [ $maxdsiz -le 64 ]; then
391    # 64 Mb is probably not enough to optimize toke.c
392    # and regexp.c with -O2
393    cat <<EOM >&4
394Your kernel limits the data section of your programs to $maxdsiz Mb,
395which is (sadly) not enough to fully optimize some parts of the
396perl binary. I'll try to use a lower optimization level for
397those parts. If you are a sysadmin, and you *do* want full
398optimization, raise the 'maxdsiz' kernel configuration parameter
399to at least 0x08000000 (128 Mb) and rebuild your kernel.
400EOM
401regexec_cflags=''
402doop_cflags=''
403op_cflags=''
404opmini_cflags=''
405perlmain_cflags=''
406pp_pack_cflags=''
407    fi
408
409case "$ccisgcc" in
410    $define|true|[Yy])
411
412	case "$optimize" in
413	    "")           optimize="-g -O" ;;
414	    *O[3456789]*) optimize=`echo "$optimize" | sed -e 's/O[3-9]/O2/'` ;;
415	    esac
416	#ld="$cc"
417	ld=/usr/bin/ld
418	cccdlflags='-fPIC'
419	#lddlflags='-shared'
420	lddlflags='-b'
421	case "$optimize" in
422	    *-g*-O*|*-O*-g*)
423		# gcc without gas will not accept -g
424		echo "main(){}">try.c
425		case "`$cc $optimize -c try.c 2>&1`" in
426		    *"-g option disabled"*)
427			set `echo "X $optimize " | sed -e 's/ -g / /'`
428			shift
429			optimize="$*"
430			;;
431		    esac
432		;;
433	    esac
434	if [ $maxdsiz -le 64 ]; then
435	    case "$optimize" in
436		*O2*)
437		    opt=`echo "$optimize" | sed -e 's/O2/O1/'`
438		    toke_cflags="$toke_cflags;optimize=\"$opt\""
439		    regexec_cflags="optimize=\"$opt\""
440		    ;;
441		esac
442	    fi
443	;;
444
445    *)
446	case "$optimize" in
447	    "")           optimize="+O2 +Onolimit" ;;
448	    *O[3456789]*) optimize=`echo "$optimize" | sed -e 's/O[3-9]/O2/'` ;;
449	    esac
450	case "$optimize" in
451	    *-O*|\
452	    *O2*)   opt=`echo "$optimize" | sed -e 's/-O/+O2/' -e 's/O2/O1/' -e 's/ *+Onolimit//'`
453		    ;;
454	    *)      opt="$optimize"
455		    ;;
456	    esac
457	case "$archname" in
458	    PA-RISC2.0)
459		case "$ccversion" in
460		    B.11.11.*)
461			# opmini.c and op.c with +O2 makes the compiler die
462			# of internal error, for perlmain.c only +O0 (no opt)
463                        # works. Disable +Ox for pp_pack, as the optimizer
464                        # causes this unit to fail (not a limit issue)
465			case "$optimize" in
466			*O[12]*)
467			    opt=`echo "$optimize" | sed -e 's/O2/O1/' -e 's/ *+Onolimit//'`
468			    opmini_cflags="optimize=\"$opt\""
469			    op_cflags="optimize=\"$opt\""
470			    perlmain_cflags="optimize=\"\""
471			    pp_pack_cflags="optimize=\"\""
472			    ;;
473			esac
474		    esac
475		;;
476	    IA64*)
477		case "$ccversion" in
478		    B3910B*A.06.0[12345])
479			# > cc --version
480			# cc: HP aC++/ANSI C B3910B A.06.05 [Jul 25 2005]
481			# Has optimizing problems with -O2 and up for both
482			# maint (5.8.8+) and blead (5.9.3+)
483			# -O1/+O1 passed all tests (m)'05 [ 10 Jan 2005 ]
484			optimize="$opt"			;;
485			B3910B*A.06.15)
486			# > cc --version
487			# cc: HP C/aC++ B3910B A.06.15 [May 16 2007]
488			# Has optimizing problems with +O2 for blead (5.17.4),
489			# see https://github.com/Perl/perl5/issues/11748.
490			#
491			# +O2 +Onolimit +Onoprocelim  +Ostore_ordering \
492			# +Onolibcalls=strcmp
493			# passes all tests (with/without -DDEBUGGING) [Nov 17 2011]
494			case "$optimize" in
495			    *O2*) optimize="$optimize +Onoprocelim +Ostore_ordering +Onolibcalls=strcmp" ;;
496			    esac
497			;;
498		    *)  doop_cflags="optimize=\"$opt\""
499			op_cflags="optimize=\"$opt\""
500			#opt=`echo "$optimize" | sed -e 's/O1/O0/'`
501			globals_cflags="optimize=\"$opt\""	;;
502		    esac
503		;;
504	    esac
505	if [ $maxdsiz -le 64 ]; then
506	    toke_cflags="$toke_cflags;optimize=\"$opt\""
507	    regexec_cflags="optimize=\"$opt\""
508	    fi
509	ld=/usr/bin/ld
510	cccdlflags='+Z'
511	lddlflags='-b +vnocompatwarnings'
512	;;
513    esac
514
515## LARGEFILES
516if [ $xxOsRev -lt 1020 ]; then
517    uselargefiles="$undef"
518    fi
519
520#case "$uselargefiles-$ccisgcc" in
521#    "$define-$define"|'-define')
522#	cat <<EOM >&4
523#
524#*** I'm ignoring large files for this build because
525#*** I don't know how to do use large files in HP-UX using gcc.
526#
527#EOM
528#	uselargefiles="$undef"
529#	;;
530#    esac
531
532# Once we have the compiler flags defined, Configure will
533# execute the following call-back script. See hints/README.hints
534# for details.
535cat > UU/cc.cbu <<'EOCBU'
536# This script UU/cc.cbu will get 'called-back' by Configure after it
537# has prompted the user for the C compiler to use.
538
539# Compile and run the a test case to see if a certain gcc bug is
540# present. If so, lower the optimization level when compiling
541# pp_pack.c.  This works around a bug in unpack.
542
543if test -z "$ccisgcc" -a -z "$gccversion"; then
544    : no tests needed for HPc
545else
546    echo " "
547    echo "Testing for a certain gcc bug is fixed in your compiler..."
548
549    # Try compiling the test case.
550    if $cc -o t001 -O $ccflags $ldflags -lm ../hints/t001.c; then
551       gccbug=`$run ./t001`
552       case "$gccbug" in
553           *fails*)
554               cat >&4 <<EOF
555This C compiler ($gccversion) is known to have optimizer
556problems when compiling pp_pack.c.
557
558Disabling optimization for pp_pack.c.
559EOF
560               case "$pp_pack_cflags" in
561                   '') pp_pack_cflags='optimize='
562                       echo "pp_pack_cflags='optimize=\"\"'" >> config.sh ;;
563                   *)  echo "You specified pp_pack_cflags yourself, so we'll go with your value." >&4 ;;
564                   esac
565               ;;
566           *)  echo "Your compiler is ok." >&4
567               ;;
568           esac
569    else
570       echo " "
571       echo "*** WHOA THERE!!! ***" >&4
572       echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
573       case "$knowitall" in
574           '') echo "    You'd better start hunting for one and let me know about it." >&4
575               exit 1
576               ;;
577           esac
578       fi
579
580    rm -f t001$_o t001$_exe
581    fi
582EOCBU
583
584cat >config.arch <<'EOCBU'
585# This script UU/config.arch will get 'called-back' by Configure after
586# all other configurations are done just before config.h is generated
587case "$archname:$optimize" in
588  PA*:*-g*[-+]O*|PA*:*[-+]O*-g*)
589    case "$ccflags" in
590      *DD64*) ;;
591      *) case "$ccversion" in
592	  # Only on PA-RISC. B3910B (aCC) is not faulty
593	  # B.11.* and A.10.* are
594	  [AB].1*)
595	      # cc: error 1414: Can't handle preprocessed file foo.i if -g and -O specified.
596	      echo "HP-UX C-ANSI-C on PA-RISC does not accept both -g and -O on preprocessed files" >&4
597	      echo "when compiling in 32bit mode. The optimizer will be disabled." >&4
598	      optimize=`echo "$optimize" | sed -e 's/[-+]O[0-9]*//' -e 's/+Onolimit//' -e 's/^ *//'`
599	      ;;
600	  esac
601      esac
602  esac
603EOCBU
604
605cat >UU/uselargefiles.cbu <<'EOCBU'
606# This script UU/uselargefiles.cbu will get 'called-back' by Configure
607# after it has prompted the user for whether to use large files.
608
609case "$archname:$use64bitall:$use64bitint" in
610    *-LP64*:undef:define)
611	archname=`echo "$archname" | sed 's/-LP64/-64int/'`
612	echo "Archname changed to $archname"
613	;;
614    esac
615
616case "$uselargefiles" in
617    ""|$define|true|[yY]*)
618	# there are largefile flags available via getconf(1)
619	# but we cheat for now.  (Keep that in the left margin.)
620ccflags_uselargefiles="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
621
622	case " $ccflags " in
623	*" $ccflags_uselargefiles "*) ;;
624	*) ccflags="$ccflags $ccflags_uselargefiles" ;;
625	esac
626
627	if test -z "$ccisgcc" -a -z "$gccversion"; then
628	    # The strict ANSI mode (-Aa) doesn't like large files.
629	    ccflags=`echo " $ccflags "|sed 's@ -Aa @ @g'`
630	    case "$ccflags" in
631		*-Ae*) ;;
632		*)     ccflags="$ccflags -Ae" ;;
633		esac
634	    fi
635	;;
636    esac
637EOCBU
638
639# THREADING
640
641# This script UU/usethreads.cbu will get 'called-back' by Configure
642# after it has prompted the user for whether to use threads.
643cat >UU/usethreads.cbu <<'EOCBU'
644case "$usethreads" in
645    $define|true|[yY]*)
646	if [ "$xxOsRevMajor" -lt 10 ]; then
647	    cat <<EOM >&4
648
649HP-UX $xxOsRevMajor cannot support POSIX threads.
650Consider upgrading to at least HP-UX 11.
651Cannot continue, aborting.
652EOM
653	    exit 1
654	    fi
655
656	if [ "$xxOsRevMajor" -eq 10 ]; then
657	    # Under 10.X, a threaded perl can be built
658	    if [ -f /usr/include/pthread.h ]; then
659		if [ -f /usr/lib/libcma.sl ]; then
660		    # DCE (from Core OS CD) is installed
661
662		   # Check if it is pristine, or patched
663		   cmavsn=`what /usr/lib/libcma.sl 2>&1 | grep 1996`
664		   if [ ! -z "$cmavsn" ]; then
665		       cat <<EOM >&4
666
667***************************************************************************
668
669Perl will support threading through /usr/lib/libcma.sl from
670the HP DCE package, but the version found is too old to be
671reliable.
672
673If you are not depending on this specific version of the library,
674consider to upgrade using patch PHSS_23672 (read README.hpux)
675
676***************************************************************************
677
678(sleeping for 10 seconds...)
679EOM
680		       sleep 10
681		       fi
682
683		    # It needs # libcma and OLD_PTHREADS_API. Also
684		    # <pthread.h> needs to be #included before any
685		    # other includes (in perl.h)
686
687		    # HP-UX 10.X uses the old pthreads API
688		    d_oldpthreads="$define"
689
690		    # include libcma before all the others
691		    libswanted="cma $libswanted"
692
693		    # tell perl.h to include <pthread.h> before other
694		    # include files
695		    ccflags="$ccflags -DPTHREAD_H_FIRST"
696# First column on purpose:
697# this is not a standard Configure variable
698# but we need to get this noticed.
699pthread_h_first="$define"
700
701		    # HP-UX 10.X seems to have no easy
702		    # way of detecting these *time_r protos.
703		    d_gmtime_r_proto='define'
704		    gmtime_r_proto='REENTRANT_PROTO_I_TS'
705		    d_localtime_r_proto='define'
706		    localtime_r_proto='REENTRANT_PROTO_I_TS'
707
708		    # Avoid the poisonous conflicting (and irrelevant)
709		    # prototypes of setkey ().
710		    i_crypt="$undef"
711
712		    # CMA redefines select to cma_select, and cma_select
713		    # expects int * instead of fd_set * (just like 9.X)
714		    selecttype='int *'
715
716		elif [ -f /usr/lib/libpthread.sl ]; then
717		    # PTH package is installed
718		    libswanted="pthread $libswanted"
719		else
720		    libswanted="no_threads_available"
721		    fi
722	    else
723		libswanted="no_threads_available"
724		fi
725
726	    if [ $libswanted = "no_threads_available" ]; then
727		cat <<EOM >&4
728
729In HP-UX 10.X for POSIX threads you need both of the files
730/usr/include/pthread.h and either /usr/lib/libcma.sl or /usr/lib/libpthread.sl.
731Either you must upgrade to HP-UX 11 or install a posix thread library:
732
733    DCE-CoreTools from HP-UX 10.20 Hardware Extensions 3.0 CD (B3920-13941)
734
735or
736
737    PTH package from e.g. http://hpux.connect.org.uk/hppd/hpux/Gnu/pth-2.0.7/
738
739Cannot continue, aborting.
740EOM
741		exit 1
742		fi
743	else
744	    # 12 may want upping the _POSIX_C_SOURCE datestamp...
745	    ccflags=" -D_POSIX_C_SOURCE=199506L -D_REENTRANT $ccflags"
746	    set `echo X "$libswanted "| sed -e 's/ c / pthread c /'`
747	    shift
748	    libswanted="$*"
749
750	    # HP-UX 11.X seems to have no easy
751	    # way of detecting these *time_r protos.
752	    d_gmtime_r_proto='define'
753	    gmtime_r_proto='REENTRANT_PROTO_S_TS'
754	    d_localtime_r_proto='define'
755	    localtime_r_proto='REENTRANT_PROTO_S_TS'
756	    fi
757	;;
758    esac
759EOCBU
760
761# There used to be:
762#  The mysterious io_xs memory corruption in 11.00 32bit seems to get
763#  fixed by not using Perl's malloc.  Flip side is performance loss.
764#  So we want mymalloc for all situations possible
765# That set usemymalloc to 'n' for threaded builds and non-gcc 32bit
766#  non-debugging builds and 'y' for all others
767
768usemymalloc='n'
769case "$useperlio" in
770    $undef|false|[nN]*) usemymalloc='y' ;;
771    esac
772
773# malloc wrap works
774case "$usemallocwrap" in
775    '') usemallocwrap='define' ;;
776    esac
777
778# ctime_r () and asctime_r () seem to have issues for versions before
779# HP-UX 11
780if [ $xxOsRevMajor -lt 11 ]; then
781    d_ctime_r="$undef"
782    d_asctime_r="$undef"
783    fi
784
785# fpclassify () is a macro, the library call is Fpclassify
786# Similarly with the others below.
787d_fpclassify='define'
788d_isnan='define'
789d_isinf='define'
790d_isfinite='define'
791d_unordered='define'
792# Next one(s) need the leading tab.  These are special 'hint' symbols that
793# are not to be propagated to config.sh, all related to pthreads draft 4
794# interfaces.
795case "$d_oldpthreads" in
796    ''|$undef)
797	d_crypt_r_proto='undef'
798	d_getgrent_r_proto='undef'
799	d_getpwent_r_proto='undef'
800	d_strerror_r_proto='undef'
801	;;
802    esac
803
804# H.Merijn says it's not 1998 anymore: ODBM is not needed,
805# and it seems to be buggy in HP-UX anyway.
806i_dbm=undef
807
808if [ "$xxOsRevMajor" -lt 11 ] || [ "$xxOsRevMajor" -eq 11 ] && [ "$xxOsRevMinor" -lt 23 ]; then
809    # In HP-UXes prior to 11.23 strtold() returned a HP-UX
810    # specific union called long_double, not a C99 long double.
811    case "`grep 'double strtold.const' /usr/include/stdlib.h`" in
812        *"long double strtold"*) ;; # strtold should be safe.
813        *) echo "Looks like your strtold() is non-standard..." >&4
814        d_strtold=undef ;;
815    esac
816fi
817
818# In pre-11 HP-UXes there really isn't isfinite(), despite what
819# Configure might think. (There is finite(), though.)
820case "`grep 'isfinite' /usr/include/math.h`" in
821*"isfinite"*) ;;
822*) d_isfinite=undef ;;
823esac
824
825# 11.23 says it has mbrlen and mbrtowc, but compiling them fails as it can't
826# find the type definition for mbstate_t which one of the parameters is.  It's
827# not in the hdr the man page says it is.  Perhaps a better Configure probe is
828# needed, but for now simply undefine them
829d_mbrlen='undef'
830d_mbrtowc='undef'
831# And this one is not know on 11.11 (with HP C-ANSI-C)
832if [ "$xxOsRevMajor" -lt 11 ] || [ "$xxOsRevMinor" -lt 12 ]; then
833d_wcrtomb='undef'
834fi
835