xref: /openbsd/gnu/usr.bin/perl/hints/solaris_2.sh (revision e0680481)
1# hints/solaris_2.sh
2# Contributions by (in alphabetical order) Alan Burlison, Andy Dougherty,
3# Dean Roehrich, Jarkko Hietaniemi, Lupe Christoph, Richard Soderberg and
4# many others.
5#
6# See README.solaris for additional information.
7#
8# For consistency with gcc, we do not adopt Sun Marketing's
9# removal of the '2.' prefix from the Solaris version number.
10# (Configure tries to detect an old fixincludes and needs
11# this information.)
12
13# If perl fails tests that involve dynamic loading of extensions, and
14# you are using gcc, be sure that you are NOT using GNU as and ld.  One
15# way to do that is to invoke Configure with
16#
17#     sh Configure -Dcc='gcc -B/usr/ccs/bin/'
18#
19#  (Note that the trailing slash is *required*.)
20#  gcc will occasionally emit warnings about "unused prefix", but
21#  these ought to be harmless.  See below for more details.
22
23# Solaris has secure SUID scripts
24d_suidsafe=${d_suidsafe:-define}
25
26# Be paranoid about nm failing to find symbols
27mistrustnm=${mistrustnm:-run}
28
29# Several people reported problems with perl's malloc, especially
30# when use64bitall is defined or when using gcc.
31#     http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-01/msg01318.html
32#     http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-01/msg00465.html
33usemymalloc=${usemymalloc:-false}
34
35# malloc wrap works
36case "$usemallocwrap" in
37'') usemallocwrap='define' ;;
38esac
39
40# Avoid all libraries in /usr/ucblib.
41# /lib is just a symlink to /usr/lib
42set `echo $glibpth | sed -e 's@/usr/ucblib@@' -e 's@ /lib @ @'`
43glibpth="$*"
44
45# Starting with Solaris 10, we don't want versioned shared libraries because
46# those often indicate a private use only library.  Especially badly that would
47# break things with SUNWbdb (Berkeley DB) being installed, which brings in
48# /usr/lib/libdb.so.1, but that is not really meant for public consumption.
49#  XXX Revisit after perl 5.10 -- should we apply this to older Solaris
50# versions too?  (A.D. 11/2007).
51case "`$run uname -r`" in
525.[0-9]) ;;
53*) ignore_versioned_solibs=y ;;
54esac
55
56# Remove unwanted libraries.  -lucb contains incompatible routines.
57# -lld and -lsec don't do anything useful. -lcrypt does not
58# really provide anything we need over -lc, so we drop it, too.
59# -lmalloc can cause a problem with GNU CC & Solaris.  Specifically,
60# libmalloc.a may allocate memory that is only 4 byte aligned, but
61# GNU CC on the Sparc assumes that doubles are 8 byte aligned.
62# Thanks to  Hallvard B. Furuseth <h.b.furuseth@usit.uio.no>
63set `echo " $libswanted " | sed -e 's@ ld @ @' -e 's@ malloc @ @' -e 's@ ucb @ @' -e 's@ sec @ @' -e 's@ crypt @ @'`
64libswanted="$*"
65
66# Add libnsl for networking support
67set `echo " $libswanted " | sed -e 's@ inet @ inet nsl @'`
68libswanted="$*"
69
70# Look for architecture name.  We want to suggest a useful default.
71case "$archname" in
72'')
73    if test -f /usr/bin/arch; then
74	archname=`/usr/bin/arch`
75	archname="${archname}-${osname}"
76    elif test -f /usr/ucb/arch; then
77	archname=`/usr/ucb/arch`
78	archname="${archname}-${osname}"
79    fi
80    ;;
81esac
82
83#
84# This extracts the library directories that will be searched by the Sun
85# Workshop compiler, given the command-line supplied in $tryworkshopcc.
86# Use thusly: loclibpth="`$getworkshoplibs` $loclibpth"
87#
88	getworkshoplibs=`cat <<'END'
89eval $tryworkshopcc -### 2>&1 | \
90sed -n '/ -Y /s!.* -Y "P,\([^"]*\)".*!\1!p' | tr ':' ' ' | \
91sed -e 's!/usr/lib/sparcv9!!' -e 's!/usr/ccs/lib/sparcv9!!' \
92    -e 's!/usr/lib!!g' -e 's!/usr/ccs/lib!!g'
93END
94`
95
96case "$cc" in
97'')    for i in `ls -r /opt/*studio*/bin/cc` /opt/SUNWspro/bin/cc \
98		`which gcc`
99       do
100	       if test -f "$i"; then
101		       cc=$i
102		       cat <<EOF >&4
103
104You specified no cc but you seem to have the Workshop compiler
105($cc) installed, using that.
106If you want something else, specify that in the command line,
107e.g. Configure -Dcc=gcc
108
109EOF
110			break
111		fi
112	done
113	;;
114esac
115
116######################################################
117# General sanity testing.  See below for excerpts from the Solaris FAQ.
118#
119# From roehrich@ironwood-fddi.cray.com Wed Sep 27 12:51:46 1995
120# Date: Thu, 7 Sep 1995 16:31:40 -0500
121# From: Dean Roehrich <roehrich@ironwood-fddi.cray.com>
122# To: perl5-porters@africa.nicoh.com
123# Subject: Re: On perl5/solaris/gcc
124#
125# Here's another draft of the perl5/solaris/gcc sanity-checker.
126
127case `type ${cc:-cc}` in
128*/usr/ucb/cc*) cat <<END >&4
129
130NOTE:  Some people have reported problems with /usr/ucb/cc.
131If you have difficulties, please make sure the directory
132containing your C compiler is before /usr/ucb in your PATH.
133
134END
135;;
136esac
137
138
139# Check that /dev/fd is mounted.  If it is not mounted, let the
140# user know that suid scripts may not work.
141$run mount | grep '^/dev/fd ' 2>&1 > /dev/null
142case $? in
1430) ;;
144*)
145	cat <<END >&4
146
147NOTE: Your system does not have /dev/fd mounted.  If you want to
148be able to use set-uid scripts you must ask your system administrator
149to mount /dev/fd.
150
151END
152	;;
153esac
154
155
156# See if libucb can be found in /usr/lib.  If it is, warn the user
157# that this may cause problems while building Perl extensions.
158found_libucb=''
159case "$run" in
160'') /usr/bin/ls /usr/lib/libucb* >/dev/null 2>&1
161    found_libucb=$?
162    ;;
163*)  $run /usr/bin/ls '/usr/lib/libucb*' >/dev/null 2>&1
164    found_libucb=$?
165    ;;
166esac
167
168case $found_libucb in
1690)
170	cat <<END >&4
171
172NOTE: libucb has been found in /usr/lib.  libucb should reside in
173/usr/ucblib.  You may have trouble while building Perl extensions.
174
175END
176;;
177esac
178
179# Use shell built-in 'type' command instead of /usr/bin/which to
180# avoid possible csh start-up problems and also to use the same shell
181# we'll be using to Configure and make perl.
182# The path name is the last field in the output, but the type command
183# has an annoying array of possible outputs, e.g.:
184#	make is hashed (/opt/gnu/bin/make)
185#	cc is /usr/ucb/cc
186#	foo not found
187# use a command like type make | awk '{print $NF}' | sed 's/[()]//g'
188
189# See if make(1) is GNU make(1).
190# If it is, make sure the setgid bit is not set.
191make -v > make.vers 2>&1
192if grep GNU make.vers > /dev/null 2>&1; then
193    tmp=`type make | awk '{print $NF}' | sed 's/[()]//g'`
194    case "`${ls:-'/usr/bin/ls'} -lL $tmp`" in
195    ??????s*)
196	    cat <<END >&2
197
198NOTE: Your PATH points to GNU make, and your GNU make has the set-group-id
199bit set.  You must either rearrange your PATH to put /usr/ccs/bin before the
200GNU utilities or you must ask your system administrator to disable the
201set-group-id bit on GNU make.
202
203END
204	    ;;
205    esac
206fi
207rm -f make.vers
208
209cat > UU/cc.cbu <<'EOCBU'
210# This script UU/cc.cbu will get 'called-back' by Configure after it
211# has prompted the user for the C compiler to use.
212
213# If the C compiler is gcc:
214#   - check the fixed-includes
215#   - check as(1) and ld(1), they should not be GNU
216#	(GNU as and ld 2.8.1 and later are reportedly ok, however.)
217# If the C compiler is not gcc:
218#   - Check if it is the Workshop/Forte compiler.
219#     If it is, prepare for 64 bit and long doubles.
220#   - check as(1) and ld(1), they should not be GNU
221#	(GNU as and ld 2.8.1 and later are reportedly ok, however.)
222#
223# Watch out in case they have not set $cc.
224
225# Perl compiled with some combinations of GNU as and ld may not
226# be able to perform dynamic loading of extensions.  If you have a
227# problem with dynamic loading, be sure that you are using the Solaris
228# /usr/ccs/bin/as and /usr/ccs/bin/ld.  You can do that with
229#	sh Configure -Dcc='gcc -B/usr/ccs/bin/'
230# (note the trailing slash is required).
231# Combinations that are known to work with the following hints:
232#
233#  gcc-2.7.2, GNU as 2.7, GNU ld 2.7
234#  egcs-1.0.3, GNU as 2.9.1 and GNU ld 2.9.1
235#	--Andy Dougherty  <doughera@lafayette.edu>
236#	Tue Apr 13 17:19:43 EDT 1999
237
238# Get gcc to share its secrets.
239echo 'int main() { return 0; }' > try.c
240	# Indent to avoid propagation to config.sh
241	verbose=`${cc:-cc} $ccflags -v -o try try.c 2>&1`
242
243# XXX TODO:  'specs' output changed from 'Reading specs from' in gcc-[23] to 'Using
244# built-in specs' in gcc-4.  Perhaps we should just use the same gcc test as
245# in Configure to see if we're using gcc.
246if echo "$verbose" | egrep '(Reading specs from)|(Using built-in specs)' >/dev/null 2>&1; then
247	#
248	# Using gcc.
249	#
250	cc_name='gcc'
251
252	# See if as(1) is GNU as(1).  GNU as(1) might not work for this job.
253	if echo "$verbose" | grep ' /usr/ccs/bin/as ' >/dev/null 2>&1; then
254	    :
255	else
256	    cat <<END >&2
257
258NOTE: You are using GNU as(1).  GNU as(1) might not build Perl.  If you
259have trouble, you can use /usr/ccs/bin/as by including -B/usr/ccs/bin/
260in your ${cc:-cc} command.  (Note that the trailing "/" is required.)
261
262END
263	    # Apparently not needed, at least for as 2.7 and later.
264	    # cc="${cc:-cc} $ccflags -B/usr/ccs/bin/"
265	fi
266
267	# See if ld(1) is GNU ld(1).  GNU ld(1) might not work for this job.
268	# Recompute $verbose since we may have just changed $cc.
269	verbose=`${cc:-cc} $ccflags -v -o try try.c 2>&1 | grep ld 2>&1`
270
271	if echo "$verbose" | grep ' /usr/ccs/bin/ld ' >/dev/null 2>&1; then
272	    # Ok, gcc directly calls the Solaris /usr/ccs/bin/ld.
273	    :
274	elif echo "$verbose" | grep "ld: Software Generation Utilities" >/dev/null 2>&1; then
275	    # Hmm.  gcc doesn't call /usr/ccs/bin/ld directly, but it
276	    # does appear to be using it eventually.  egcs-1.0.3's ld
277	    # wrapper does this.
278	    # Most Solaris versions of ld I've seen contain the magic
279	    # string used in the grep.
280	    :
281	elif echo "$verbose" | grep "Solaris Link Editors" >/dev/null 2>&1; then
282	    # However some Solaris 8 versions prior to ld 5.8-1.286 contain
283	    # this string instead.
284	    :
285	else
286	    # No evidence yet of /usr/ccs/bin/ld.  Some versions
287	    # of egcs's ld wrapper call /usr/ccs/bin/ld in turn but
288	    # apparently don't reveal that unless you pass in -V.
289	    # (This may all depend on local configurations too.)
290
291	    # Recompute verbose with -Wl,-v to find GNU ld if present
292	    verbose=`${cc:-cc} $ccflags -Wl,-v -o try try.c 2>&1 | grep /ld 2>&1`
293
294	    myld=`echo $verbose | awk '/\/ld/ {print $1}'`
295	    # This assumes that gcc's output will not change, and that
296	    # /full/path/to/ld will be the first word of the output.
297	    # Thus myld is something like /opt/gnu/sparc-sun-solaris2.5/bin/ld
298
299	    # Allow that $myld may be '', due to changes in gcc's output
300	    if ${myld:-ld} -V 2>&1 |
301		grep "ld: Software Generation Utilities" >/dev/null 2>&1; then
302		# Ok, /usr/ccs/bin/ld eventually does get called.
303		:
304	    elif ${myld:-ld} -V 2>&1 |
305		grep "Solaris Link Editors" >/dev/null 2>&1; then
306		# Ok, /usr/ccs/bin/ld eventually does get called.
307		:
308	    else
309		echo "Found GNU ld='$myld'" >&4
310		cat <<END >&2
311
312NOTE: You are using GNU ld(1).  GNU ld(1) might not build Perl.  If you
313have trouble, you can use /usr/ccs/bin/ld by including -B/usr/ccs/bin/
314in your ${cc:-cc} command.  (Note that the trailing "/" is required.)
315
316I will try to use GNU ld by passing in the -Wl,-E flag, but if that
317doesn't work, you should use -B/usr/ccs/bin/ instead.
318
319END
320		ccdlflags="$ccdlflags -Wl,-E"
321		lddlflags="$lddlflags -Wl,-E -shared"
322	    fi
323	fi
324
325else
326	#
327	# Not using gcc.
328	#
329	cat > try.c << 'EOM'
330#include <stdio.h>
331int main() {
332#if defined(__SUNPRO_C)
333	printf("workshop\n");
334#else
335#if defined(__SUNPRO_CC)
336	printf("workshop CC\n");
337#else
338	printf("\n");
339#endif
340#endif
341return(0);
342}
343EOM
344	tryworkshopcc="${cc:-cc} $ccflags try.c -o try"
345	if $tryworkshopcc >/dev/null 2>&1; then
346		cc_name=`$run ./try`
347		if test "$cc_name" = "workshop"; then
348			ccversion="`${cc:-cc} -V 2>&1|sed -n -e '1s/^[Cc][Cc9]9*: //p'`"
349		fi
350		if test "$cc_name" = "workshop CC"; then
351			ccversion="`${cc:-CC} -V 2>&1|sed -n -e '1s/^[Cc][C]: //p'`"
352		fi
353		case "$cc_name" in
354		workshop*)
355			# Settings for either cc or CC
356			if test ! "$use64bitall_done"; then
357				loclibpth="/usr/lib /usr/ccs/lib `$getworkshoplibs` $loclibpth"
358			fi
359			# Sun CC/cc don't support gcc attributes
360			d_attribute_format='undef'
361			d_attribute_malloc='undef'
362			d_attribute_nonnull='undef'
363			d_attribute_noreturn='undef'
364			d_attribute_pure='undef'
365			d_attribute_unused='undef'
366			d_attribute_warn_unused_result='undef'
367			case "$cc" in
368			*c99)	# c99 rejects bare '-O'.
369				case "$optimize" in
370				''|-O) optimize=-O3 ;;
371				esac
372				# Without -Xa c99 doesn't see
373				# many OS interfaces.
374				case "$ccflags" in
375				*-Xa*)	;;
376				*) ccflags="$ccflags -Xa" ;;
377				esac
378				;;
379			esac
380			;;
381		esac
382	fi
383
384	# See if as(1) is GNU as(1).  GNU might not work for this job.
385	case `as --version < /dev/null 2>&1` in
386	*GNU*)
387		cat <<END >&2
388
389NOTE: You are using GNU as(1).  GNU as(1) might not build Perl.
390You must arrange to use /usr/ccs/bin/as, perhaps by adding /usr/ccs/bin
391to the beginning of your PATH.
392
393END
394		;;
395	esac
396
397	# See if ld(1) is GNU ld(1).  GNU ld(1) might not work for this job.
398	# ld --version doesn't properly report itself as a GNU tool,
399	# as of ld version 2.6, so we need to be more strict. TWP 9/5/96
400	# Sun's ld always emits the "Software Generation Utilities" string.
401	if ld -V 2>&1 | grep "ld: Software Generation Utilities" >/dev/null 2>&1; then
402	    # Ok, ld is /usr/ccs/bin/ld.
403	    :
404	else
405	    cat <<END >&2
406
407NOTE: You are apparently using GNU ld(1).  GNU ld(1) might not build Perl.
408You should arrange to use /usr/ccs/bin/ld, perhaps by adding /usr/ccs/bin
409to the beginning of your PATH.
410
411END
412	fi
413fi
414
415# as --version or ld --version might dump core.
416rm -f try try.c core
417EOCBU
418
419cat > UU/usethreads.cbu <<'EOCBU'
420# This script UU/usethreads.cbu will get 'called-back' by Configure
421# after it has prompted the user for whether to use threads.
422case "$usethreads" in
423$define|true|[yY]*)
424	ccflags="-D_REENTRANT $ccflags"
425
426	# -lpthread overrides some lib C functions, so put it before c.
427	set `echo X "$libswanted "| sed -e "s/ c / pthread c /"`
428	shift
429	libswanted="$*"
430
431	# sched_yield is available in the -lrt library.  However,
432	# we can also pick up the equivalent yield() function in the
433	# normal C library.  To avoid pulling in unnecessary
434	# libraries, we'll normally avoid sched_yield()/-lrt and
435	# just use yield().  However, we'll honor a command-line
436	# override : "-Dsched_yield=sched_yield".
437	# If we end up using sched_yield, we're going to need -lrt.
438	sched_yield=${sched_yield:-yield}
439	if test "$sched_yield" = "sched_yield"; then
440	    set `echo X "$libswanted "| sed -e "s/ pthread / rt pthread /"`
441	    shift
442	    libswanted="$*"
443	fi
444
445	# On Solaris 2.6 x86 there is a bug with sigsetjmp() and siglongjmp()
446	# when linked with the threads library, such that whatever positive
447	# value you pass to siglongjmp(), sigsetjmp() returns 1.
448	# Thanks to Simon Parsons <S.Parsons@ftel.co.uk> for this report.
449	# Sun BugID is 4117946, "sigsetjmp always returns 1 when called by
450	# siglongjmp in a MT program". As of 19980622, there is no patch
451	# available.
452	cat >try.c <<'EOM'
453	/* Test for sig(set|long)jmp bug. */
454	#include <setjmp.h>
455
456	int main()
457	{
458	    sigjmp_buf env;
459	    int ret;
460
461	    ret = sigsetjmp(env, 1);
462	    if (ret) { return ret == 2; }
463	    siglongjmp(env, 2);
464	}
465EOM
466	if test "`arch`" = i86pc -a `uname -r` = 5.6 && \
467	   ${cc:-cc} try.c -lpthread >/dev/null 2>&1 && ./a.out; then
468	    d_sigsetjmp=$undef
469	fi
470
471	# These prototypes should be visible since we using
472	# -D_REENTRANT, but that does not seem to work.
473	# It does seem to work for getnetbyaddr_r, weirdly enough,
474	# and other _r functions. (Solaris 8)
475
476	d_ctermid_r_proto="$define"
477	d_gethostbyaddr_r_proto="$define"
478	d_gethostbyname_r_proto="$define"
479	d_getnetbyname_r_proto="$define"
480	d_getprotobyname_r_proto="$define"
481	d_getprotobynumber_r_proto="$define"
482	d_getservbyname_r_proto="$define"
483	d_getservbyport_r_proto="$define"
484
485	# Ditto. (Solaris 7)
486	d_readdir_r_proto="$define"
487	d_readdir64_r_proto="$define"
488	d_tmpnam_r_proto="$define"
489	d_ttyname_r_proto="$define"
490
491	;;
492esac
493EOCBU
494
495cat > UU/uselargefiles.cbu <<'EOCBU'
496# This script UU/uselargefiles.cbu will get 'called-back' by Configure
497# after it has prompted the user for whether to use large files.
498case "$uselargefiles" in
499''|$define|true|[yY]*)
500
501# Keep these in the left margin.
502ccflags_uselargefiles="`$run getconf LFS_CFLAGS 2>/dev/null`"
503ldflags_uselargefiles="`$run getconf LFS_LDFLAGS 2>/dev/null`"
504libswanted_uselargefiles="`$run getconf LFS_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g'`"
505
506    ccflags="$ccflags $ccflags_uselargefiles"
507    ldflags="$ldflags $ldflags_uselargefiles"
508    libswanted="$libswanted $libswanted_uselargefiles"
509    ;;
510esac
511EOCBU
512
513# This is truly a mess.
514case "$usemorebits" in
515"$define"|true|[yY]*)
516	use64bitint="$define"
517	uselongdouble="$define"
518	;;
519esac
520
521if test `$run uname -p` = i386; then
522    case "$use64bitint" in
523    "$define"|true|[yY]*)
524            ccflags="$ccflags -DPTR_IS_LONG"
525            ;;
526    esac
527fi
528
529if test `$run uname -p` = sparc -o `$run uname -p` = i386; then
530    cat > UU/use64bitint.cbu <<'EOCBU'
531# This script UU/use64bitint.cbu will get 'called-back' by Configure
532# after it has prompted the user for whether to use 64 bit integers.
533case "$use64bitint" in
534"$define"|true|[yY]*)
535	    case "`$run uname -r`" in
536	    5.[0-4])
537		cat >&4 <<EOM
538Solaris `uname -r|sed -e 's/^5\./2./'` does not support 64-bit integers.
539You should upgrade to at least Solaris 2.5.
540EOM
541		exit 1
542		;;
543	    esac
544
545# gcc-2.8.1 on Solaris 8 with -Duse64bitint fails op/pat.t test 822
546# if we compile regexec.c with -O.  Turn off optimization for that one
547# file.  See hints/README.hints , especially
548# =head2 Propagating variables to config.sh, method 3.
549#  A. Dougherty  May 24, 2002
550    case "${gccversion}-${optimize}" in
551    2.8*-O*)
552	# Honor a command-line override (rather unlikely)
553	case "$regexec_cflags" in
554	'') echo "Disabling optimization on regexec.c for gcc $gccversion" >&4
555	    regexec_cflags='optimize='
556	    echo "regexec_cflags='optimize=\"\"'" >> config.sh
557	    ;;
558	esac
559	;;
560    esac
561    ;;
562esac
563EOCBU
564
565    cat > UU/use64bitall.cbu <<'EOCBU'
566# This script UU/use64bitall.cbu will get 'called-back' by Configure
567# after it has prompted the user for whether to be maximally 64 bitty.
568case "$use64bitall-$use64bitall_done" in
569"$define-"|true-|[yY]*-)
570	    case "`$run uname -r`" in
571	    5.[0-6])
572		cat >&4 <<EOM
573Solaris `uname -r|sed -e 's/^5\./2./'` does not support 64-bit pointers.
574You should upgrade to at least Solaris 2.7.
575EOM
576		exit 1
577		;;
578	    esac
579	    processor=`$run uname -p`;
580	    if test "$processor" = sparc; then
581		libc='/usr/lib/sparcv9/libc.so'
582		if test ! -f $libc; then
583		    cat >&4 <<EOM
584
585I do not see the 64-bit libc, $libc.
586Cannot continue, aborting.
587
588EOM
589		    exit 1
590		fi
591	    fi
592	    case "${cc:-cc} -v 2>/dev/null" in
593	    *gcc*|*g++*)
594		echo 'int main() { return 0; }' > try.c
595		case "`${cc:-cc} $ccflags -mcpu=v9 -m64 -S try.c 2>&1 | grep 'm64 is not supported by this configuration'`" in
596		*"m64 is not supported"*)
597		    cat >&4 <<EOM
598
599Full 64-bit build is not supported by this gcc configuration.
600Check http://gcc.gnu.org/ for the latest news of availability
601of gcc for 64-bit Sparc.
602
603Cannot continue, aborting.
604
605EOM
606		    exit 1
607		    ;;
608		esac
609		if test "$processor" = sparc; then
610		    loclibpth="/usr/lib/sparcv9 $loclibpth"
611		    ccflags="$ccflags -mcpu=v9"
612		fi
613		ccflags="$ccflags -m64"
614
615		# This adds in -Wa,-xarch=v9.  I suspect that's superfluous,
616		# since the -m64 above should do that already.  Someone
617		# with gcc-3.x.x, please test with gcc -v.   A.D. 20-Nov-2003
618#		if test $processor = sparc -a X`$run getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null` != X; then
619#		    ccflags="$ccflags -Wa,`$run getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
620#		fi
621		ldflags="$ldflags -m64"
622
623		# See [perl #66604]:  On Solaris 11, gcc -m64 on amd64
624		# appears not to understand -G.  (gcc -G has not caused
625		# problems on other platforms in the past.)  gcc versions
626		# at least as old as 3.4.3 support -shared, so just
627		# use that with Solaris 11 and later, but keep
628		# the old behavior for older Solaris versions.
629		case "$osvers" in
630			2.?|2.10) lddlflags="$lddlflags -G -m64" ;;
631			*) lddlflags="$lddlflags -shared -m64" ;;
632		esac
633		;;
634	    *)
635		getconfccflags="`$run getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
636		getconfldflags="`$run getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
637		getconflddlflags="`$run getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
638		echo "int main() { return(0); } " > try.c
639		case "`${cc:-cc} $getconfccflags try.c 2>&1 | grep 'deprecated'`" in
640		*" -xarch=generic64 is deprecated, use -m64 "*)
641		    getconfccflags=`echo $getconfccflags | sed -e 's/xarch=generic64/m64/'`
642		    getconfldflags=`echo $getconfldflags | sed -e 's/xarch=generic64/m64/'`
643		    getconflddlflags=`echo $getconflddlflags | sed -e 's/xarch=generic64/m64/'`
644		    ;;
645		esac
646		ccflags="$ccflags $getconfccflags"
647		ldflags="$ldflags $getconfldflags"
648		lddlflags="$lddlflags -G $getconflddlflags"
649
650		echo "int main() { return(0); } " > try.c
651		tryworkshopcc="${cc:-cc} try.c -o try $ccflags"
652		if test "$processor" = sparc; then
653		    loclibpth="/usr/lib/sparcv9 /usr/ccs/lib/sparcv9 $loclibpth"
654		fi
655		loclibpth="`$getworkshoplibs` $loclibpth"
656		;;
657	    esac
658	    unset processor
659	    use64bitall_done=yes
660	    archname64=64
661	    ;;
662esac
663EOCBU
664
665    # Actually, we want to run this already now, if so requested,
666    # because we need to fix up things right now.
667    case "$use64bitall" in
668    "$define"|true|[yY]*)
669	# CBUs expect to be run in UU
670	cd UU; . ./use64bitall.cbu; cd ..
671	;;
672    esac
673fi
674
675cat > UU/uselongdouble.cbu <<'EOCBU'
676# This script UU/uselongdouble.cbu will get 'called-back' by Configure
677# after it has prompted the user for whether to use long doubles.
678case "$uselongdouble" in
679"$define"|true|[yY]*)
680	if test "$cc_name" = "workshop"; then
681		cat > try.c << 'EOM'
682#include <sunmath.h>
683int main() { (void) powl(2, 256); return(0); }
684EOM
685		if ${cc:-cc} try.c -lsunmath -o try > /dev/null 2>&1 && ./try; then
686			libswanted="$libswanted sunmath"
687		fi
688	else
689		cat >&4 <<EOM
690
691The Sun Workshop math library is either not available or not working,
692so I do not know how to do long doubles, sorry.
693I'm therefore disabling the use of long doubles.
694EOM
695		uselongdouble="$undef"
696	fi
697	;;
698esac
699EOCBU
700
701rm -f try.c try.o try a.out
702
703# If using C++, the Configure scan for dlopen() will fail in Solaris
704# because one of the two (1) an extern "C" linkage definition is needed
705# (2) #include <dlfcn.h> is needed, *and* a cast to (void*(*)())
706# is needed for the &dlopen.  Adding any of these would require changing
707# a delicate spot in Configure, so easier just to force our guess here
708# for Solaris.  Much the same goes for dlerror().
709case "$cc" in
710*g++*|*CC*)
711  d_dlopen='define'
712  d_dlerror='define'
713  ;;
714esac
715
716# Oracle/Sun builds their Perl shared since 5.6.1, and they also
717# strongly recommend using shared libraries in general.
718#
719# Furthermore, OpenIndiana seems to effectively require building perl
720# shared, or otherwise perl scripts won't even find the Perl library.
721useshrplib='true'
722