[ID 20001112.008] perlio.c's PerlIO_getpos ingores error return
[p5sagit/p5-mst-13.2.git] / hints / solaris_2.sh
1 # hints/solaris_2.sh
2 # Last modified:  Thu Nov  9 14:21:02 EST 2000
3 # Andy Dougherty  <doughera@lafayette.edu>
4 # Based on input from lots of folks, especially
5 # Dean Roehrich <roehrich@ironwood-fddi.cray.com>
6 #
7 # See README.solaris for additional information.
8 #
9 # If perl fails tests that involve dynamic loading of extensions, and
10 # you are using gcc, be sure that you are NOT using GNU as and ld.  One
11 # way to do that is to invoke Configure with
12
13 #     sh Configure -Dcc='gcc -B/usr/ccs/bin/'
14 #
15 #  (Note that the trailing slash is *required*.)
16 #  gcc will occasionally emit warnings about "unused prefix", but
17 #  these ought to be harmless.  See below for more details.
18  
19 # See man vfork.
20 usevfork=false
21
22 d_suidsafe=define
23
24 # Avoid all libraries in /usr/ucblib.
25 set `echo $glibpth | sed -e 's@/usr/ucblib@@'`
26 glibpth="$*"
27
28 # Remove bad libraries.  -lucb contains incompatible routines.
29 # -lld doesn't do anything useful.
30 # -lmalloc can cause a problem with GNU CC & Solaris.  Specifically,
31 # libmalloc.a may allocate memory that is only 4 byte aligned, but
32 # GNU CC on the Sparc assumes that doubles are 8 byte aligned.
33 # Thanks to  Hallvard B. Furuseth <h.b.furuseth@usit.uio.no>
34 set `echo " $libswanted " | sed -e 's@ ld @ @' -e 's@ malloc @ @' -e 's@ ucb @ @'`
35 libswanted="$*"
36
37 # Look for architecture name.  We want to suggest a useful default.
38 case "$archname" in
39 '')
40     if test -f /usr/bin/arch; then
41         archname=`/usr/bin/arch`
42         archname="${archname}-${osname}"
43     elif test -f /usr/ucb/arch; then
44         archname=`/usr/ucb/arch`
45         archname="${archname}-${osname}"
46     fi
47     ;;
48 esac
49
50 cc=${cc:-cc}
51
52 ccversion="`$cc -V 2>&1|head -1|sed 's/^cc: //'`"
53 case "$ccversion" in
54 *WorkShop*) ccname=workshop ;;
55 *) ccversion='' ;;
56 esac
57
58 cat >UU/workshoplibpth.cbu<<'EOCBU'
59 case "$workshoplibpth_done" in
60 '')     case "$use64bitall" in
61         "$define"|true|[yY]*)
62             loclibpth="$loclibpth /usr/lib/sparcv9"
63             if test -n "$workshoplibs"; then
64                 loclibpth=`echo $loclibpth | sed -e "s% $workshoplibs%%" `
65                 for lib in $workshoplibs; do
66                     # Logically, it should be sparcv9.
67                     # But the reality fights back, it's v9.
68                     loclibpth="$loclibpth $lib/sparcv9 $lib/v9"
69                 done
70             fi 
71             ;;
72         *)  loclibpth="$loclibpth $workshoplibs"  
73             ;;
74         esac
75         workshoplibpth_done="$define"
76         ;;
77 esac
78 EOCBU
79
80 case "$ccname" in
81 workshop)
82         cat >try.c <<EOF
83 #include <sunmath.h>
84 int main() { return(0); }
85 EOF
86         workshoplibs=`cc -### try.c -lsunmath -o try 2>&1|grep " -Y "|sed 's%.* -Y "P,\(.*\)".*%\1%'|tr ':' '\n'|grep '/SUNWspro/'`
87         . ./UU/workshoplibpth.cbu
88         ;;
89 esac
90
91 ######################################################
92 # General sanity testing.  See below for excerpts from the Solaris FAQ.
93 #
94 # From roehrich@ironwood-fddi.cray.com Wed Sep 27 12:51:46 1995
95 # Date: Thu, 7 Sep 1995 16:31:40 -0500
96 # From: Dean Roehrich <roehrich@ironwood-fddi.cray.com>
97 # To: perl5-porters@africa.nicoh.com
98 # Subject: Re: On perl5/solaris/gcc
99 #
100 # Here's another draft of the perl5/solaris/gcc sanity-checker. 
101
102 case `type ${cc:-cc}` in
103 */usr/ucb/cc*) cat <<END >&4
104
105 NOTE:  Some people have reported problems with /usr/ucb/cc.  
106 If you have difficulties, please make sure the directory
107 containing your C compiler is before /usr/ucb in your PATH.
108
109 END
110 ;;
111 esac
112
113
114 # Check that /dev/fd is mounted.  If it is not mounted, let the
115 # user know that suid scripts may not work.
116 /usr/bin/df /dev/fd 2>&1 > /dev/null
117 case $? in
118 0) ;;
119 *)
120         cat <<END >&4
121
122 NOTE: Your system does not have /dev/fd mounted.  If you want to
123 be able to use set-uid scripts you must ask your system administrator
124 to mount /dev/fd.
125
126 END
127         ;;
128 esac
129
130
131 # See if libucb can be found in /usr/lib.  If it is, warn the user
132 # that this may cause problems while building Perl extensions.
133 /usr/bin/ls /usr/lib/libucb* >/dev/null 2>&1
134 case $? in
135 0)
136         cat <<END >&4
137
138 NOTE: libucb has been found in /usr/lib.  libucb should reside in
139 /usr/ucblib.  You may have trouble while building Perl extensions.
140
141 END
142 ;;
143 esac
144
145 # Use shell built-in 'type' command instead of /usr/bin/which to
146 # avoid possible csh start-up problems and also to use the same shell
147 # we'll be using to Configure and make perl.
148 # The path name is the last field in the output, but the type command
149 # has an annoying array of possible outputs, e.g.:
150 #       make is hashed (/opt/gnu/bin/make)
151 #       cc is /usr/ucb/cc
152 #       foo not found
153 # use a command like type make | awk '{print $NF}' | sed 's/[()]//g'
154
155 # See if make(1) is GNU make(1).
156 # If it is, make sure the setgid bit is not set.
157 make -v > make.vers 2>&1
158 if grep GNU make.vers > /dev/null 2>&1; then
159     tmp=`type make | awk '{print $NF}' | sed 's/[()]//g'`
160     case "`/usr/bin/ls -lL $tmp`" in
161     ??????s*)
162             cat <<END >&2
163         
164 NOTE: Your PATH points to GNU make, and your GNU make has the set-group-id
165 bit set.  You must either rearrange your PATH to put /usr/ccs/bin before the
166 GNU utilities or you must ask your system administrator to disable the
167 set-group-id bit on GNU make.
168
169 END
170             ;;
171     esac
172 fi
173 rm -f make.vers
174
175 # XXX EXPERIMENTAL  A.D.  2/27/1998
176 # XXX This script UU/cc.cbu will get 'called-back' by Configure after it
177 # XXX has prompted the user for the C compiler to use.
178 cat > UU/cc.cbu <<'EOSH'
179 # If the C compiler is gcc:
180 #   - check the fixed-includes
181 #   - check as(1) and ld(1), they should not be GNU
182 #       (GNU as and ld 2.8.1 and later are reportedly ok, however.)
183 # If the C compiler is not gcc:
184 #   - check as(1) and ld(1), they should not be GNU
185 #       (GNU as and ld 2.8.1 and later are reportedly ok, however.)
186 #
187 # Watch out in case they have not set $cc.
188
189 # Perl compiled with some combinations of GNU as and ld may not 
190 # be able to perform dynamic loading of extensions.  If you have a
191 # problem with dynamic loading, be sure that you are using the Solaris
192 # /usr/ccs/bin/as and /usr/ccs/bin/ld.  You can do that with
193 #               sh Configure -Dcc='gcc -B/usr/ccs/bin/'
194 # (note the trailing slash is required). 
195 # Combinations that are known to work with the following hints:
196 #
197 #  gcc-2.7.2, GNU as 2.7, GNU ld 2.7
198 #  egcs-1.0.3, GNU as 2.9.1 and GNU ld 2.9.1
199 #       --Andy Dougherty  <doughera@lafayette.edu>  
200 #       Tue Apr 13 17:19:43 EDT 1999
201
202 # Get gcc to share its secrets.
203 echo 'main() { return 0; }' > try.c
204         # Indent to avoid propagation to config.sh
205         verbose=`${cc:-cc} -v -o try try.c 2>&1`
206
207 if echo "$verbose" | grep '^Reading specs from' >/dev/null 2>&1; then
208         #
209         # Using gcc.
210         #
211
212         tmp=`echo "$verbose" | grep '^Reading' |
213                 awk '{print $NF}'  | sed 's/specs$/include/'`
214
215         # Determine if the fixed-includes look like they'll work.
216         # Doesn't work anymore for gcc-2.7.2.
217
218         # See if as(1) is GNU as(1).  GNU as(1) might not work for this job.
219         if echo "$verbose" | grep ' /usr/ccs/bin/as ' >/dev/null 2>&1; then
220             :
221         else
222             cat <<END >&2
223
224 NOTE: You are using GNU as(1).  GNU as(1) might not build Perl.  If you
225 have trouble, you can use /usr/ccs/bin/as by including -B/usr/ccs/bin/
226 in your ${cc:-cc} command.  (Note that the trailing "/" is required.)
227
228 END
229             # Apparently not needed, at least for as 2.7 and later.
230             # cc="${cc:-cc} -B/usr/ccs/bin/"
231         fi
232
233         # See if ld(1) is GNU ld(1).  GNU ld(1) might not work for this job.
234         # Recompute $verbose since we may have just changed $cc.
235         verbose=`${cc:-cc} -v -o try try.c 2>&1 | grep ld 2>&1`
236
237         if echo "$verbose" | grep ' /usr/ccs/bin/ld ' >/dev/null 2>&1; then
238             # Ok, gcc directly calls the Solaris /usr/ccs/bin/ld.
239             :
240         elif echo "$verbose" | grep "ld: Software Generation Utilities" >/dev/null 2>&1; then
241             # Hmm.  gcc doesn't call /usr/ccs/bin/ld directly, but it
242             # does appear to be using it eventually.  egcs-1.0.3's ld
243             # wrapper does this.
244             # All Solaris versions of ld I've seen contain the magic
245             # string used in the grep.
246             :
247         else
248             # No evidence yet of /usr/ccs/bin/ld.  Some versions
249             # of egcs's ld wrapper call /usr/ccs/bin/ld in turn but
250             # apparently don't reveal that unless you pass in -V.
251             # (This may all depend on local configurations too.)
252
253             myld=`echo $verbose| grep ld | awk '/\/ld/ {print $1}'`
254             # This assumes that gcc's output will not change, and that
255             # /full/path/to/ld will be the first word of the output.
256             # Thus myld is something like opt/gnu/sparc-sun-solaris2.5/bin/ld
257
258             if $myld -V 2>&1 | grep "ld: Software Generation Utilities" >/dev/null 2>&1; then
259                 # Ok, /usr/ccs/bin/ld eventually does get called.
260                 :
261             else
262                 cat <<END >&2
263
264 NOTE: You are using GNU ld(1).  GNU ld(1) might not build Perl.  If you
265 have trouble, you can use /usr/ccs/bin/ld by including -B/usr/ccs/bin/
266 in your ${cc:-cc} command.  (Note that the trailing "/" is required.)
267
268 I will try to use GNU ld by passing in the -Wl,-E flag, but if that
269 doesn't work, you should use -B/usr/ccs/bin/ instead.
270
271 END
272                 ccdlflags="$ccdlflags -Wl,-E"
273                 lddlflags="$lddlflags -W,l-E -G"
274             fi
275         fi
276
277 else
278         #
279         # Not using gcc.
280         #
281
282         # See if as(1) is GNU as(1).  GNU might not work for this job.
283         case `as --version < /dev/null 2>&1` in
284         *GNU*)
285                 cat <<END >&2
286
287 NOTE: You are using GNU as(1).  GNU as(1) might not build Perl.
288 You must arrange to use /usr/ccs/bin/as, perhaps by adding /usr/ccs/bin
289 to the beginning of your PATH.
290
291 END
292                 ;;
293         esac
294
295         # See if ld(1) is GNU ld(1).  GNU ld(1) might not work for this job.
296         # ld --version doesn't properly report itself as a GNU tool,
297         # as of ld version 2.6, so we need to be more strict. TWP 9/5/96
298         gnu_ld=false
299         case `ld --version < /dev/null 2>&1` in
300         *GNU*|ld\ version\ 2*)
301                 gnu_ld=true ;;
302         *) ;;
303         esac
304         if $gnu_ld ; then :
305         else
306                 # Try to guess from path
307                 case `type ld | awk '{print $NF}'` in
308                 *gnu*|*GNU*|*FSF*)
309                         gnu_ld=true ;;
310                 esac
311         fi
312         if $gnu_ld ; then
313                 cat <<END >&2
314
315 NOTE: You are apparently using GNU ld(1).  GNU ld(1) might not build Perl.
316 You should arrange to use /usr/ccs/bin/ld, perhaps by adding /usr/ccs/bin
317 to the beginning of your PATH.
318
319 END
320         fi
321
322 fi
323
324 # as --version or ld --version might dump core.
325 rm -f try try.c
326 rm -f core
327
328 # XXX
329 EOSH
330
331 cat > UU/usethreads.cbu <<'EOCBU'
332 # This script UU/usethreads.cbu will get 'called-back' by Configure 
333 # after it has prompted the user for whether to use threads.
334 case "$usethreads" in
335 $define|true|[yY]*)
336         ccflags="-D_REENTRANT $ccflags"
337
338         # sched_yield is in -lposix4 up to Solaris 2.6, in -lrt starting with Solaris 7
339         case `uname -r` in
340         5.[0-6] | 5.5.1) sched_yield_lib="posix4" ;;
341         *) sched_yield_lib="rt";
342         esac
343         set `echo X "$libswanted "| sed -e "s/ c / $sched_yield_lib pthread c /"`
344         shift
345         libswanted="$*"
346
347         # On Solaris 2.6 x86 there is a bug with sigsetjmp() and siglongjmp()
348         # when linked with the threads library, such that whatever positive
349         # value you pass to siglongjmp(), sigsetjmp() returns 1.
350         # Thanks to Simon Parsons <S.Parsons@ftel.co.uk> for this report.
351         # Sun BugID is 4117946, "sigsetjmp always returns 1 when called by
352         # siglongjmp in a MT program". As of 19980622, there is no patch
353         # available.
354         cat >try.c <<'EOM'
355         /* Test for sig(set|long)jmp bug. */
356         #include <setjmp.h>
357          
358         main()
359         {
360             sigjmp_buf env;
361             int ret;
362         
363             ret = sigsetjmp(env, 1);
364             if (ret) { return ret == 2; }
365             siglongjmp(env, 2);
366         }
367 EOM
368         if test "`arch`" = i86pc -a `uname -r` = 5.6 && \
369            ${cc:-cc} try.c -lpthread >/dev/null 2>&1 && ./a.out; then
370             d_sigsetjmp=$undef
371             cat << 'EOM' >&2
372
373 You will see a *** WHOA THERE!!! ***  message from Configure for
374 d_sigsetjmp.  Keep the recommended value.  See hints/solaris_2.sh
375 for more information.
376
377 EOM
378         fi
379         ;;
380 esac
381 EOCBU
382
383 cat > UU/uselargefiles.cbu <<'EOCBU'
384 # This script UU/uselargefiles.cbu will get 'called-back' by Configure 
385 # after it has prompted the user for whether to use large files.
386 case "$uselargefiles" in
387 ''|$define|true|[yY]*)
388
389 # Keep these in the left margin.
390 ccflags_uselargefiles="`getconf LFS_CFLAGS 2>/dev/null`"
391 ldflags_uselargefiles="`getconf LFS_LDFLAGS 2>/dev/null`"
392 libswanted_uselargefiles="`getconf LFS_LIBS 2>/dev/null|sed -e 's@^-l@@' -e 's@ -l@ @g`"
393
394     ccflags="$ccflags $ccflags_uselargefiles"
395     ldflags="$ldflags $ldflags_uselargefiles"
396     libswanted="$libswanted $libswanted_uselargefiles"
397     ;;
398 esac
399 EOCBU
400
401 # This is truly a mess.
402 case "$usemorebits" in
403 "$define"|true|[yY]*)
404         use64bitint="$define"    
405         uselongdouble="$define"    
406         ;;
407 esac
408
409 cat > UU/use64bitall.cbu <<'EOCBU'
410 # This script UU/use64bitall.cbu will get 'called-back' by Configure 
411 # after it has prompted the user for whether to be maximally 64 bitty.
412 case "$use64bitall-$use64bitall_done" in
413 "$define-"|true-|[yY]*-)
414             case "`uname -r`" in
415             5.[1-6])
416                 cat >&4 <<EOM
417 Solaris `uname -r|sed -e 's/^5\.\([789]\)$/\1/'` does not support 64-bit pointers.
418 You should upgrade to at least Solaris 7.
419 EOM
420                 exit 1
421                 ;;
422             esac
423             libc='/usr/lib/sparcv9/libc.so'
424             if test ! -f $libc; then
425                 cat >&4 <<EOM
426
427 I do not see the 64-bit libc, $libc.
428 (You are either in an old sparc or in an x86.)
429 Cannot continue, aborting.
430
431 EOM
432                 exit 1
433             fi 
434             . ./UU/workshoplibpth.cbu
435             case "$cc -v 2>/dev/null" in
436             *gcc*)
437                 echo 'main() { return 0; }' > try.c
438                 case "`${cc:-cc} -mcpu=v9 -m64 -S try.c 2>&1 | grep 'm64 is not supported by this configuration'`" in
439                 *"m64 is not supported"*)
440                     cat >&4 <<EOM
441
442 Full 64-bit build not supported by this gcc configuration.
443 Cannot continue, aborting.
444
445 EOM
446                     exit 1
447                     ;;
448                 esac    
449                 ccflags="$ccflags -mcpu=v9 -m64"
450                 if test X`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null` != X; then
451                     ccflags="$ccflags -Wa,`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
452                 fi
453                 # no changes to ld flags, as (according to man ld):
454                 #
455                 # There is no specific option that tells ld to link 64-bit
456                 # objects; the class of the first object that gets processed
457                 # by ld determines whether it is to perform a 32-bit or a
458                 # 64-bit link edit.
459                 ;;
460             *)
461                 ccflags="$ccflags `getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
462                 ldflags="$ldflags `getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
463                 lddlflags="$lddlflags -G `getconf XBS5_LP64_OFF64_LDFLAGS 2>/dev/null`"
464                 ;;
465             esac        
466             libscheck='case "`/usr/bin/file $xxx`" in
467 *64-bit*|*SPARCV9*) ;;
468 *) xxx=/no/64-bit$xxx ;;
469 esac'
470             use64bitall_done=yes
471             ;;
472 esac
473 EOCBU
474  
475 # Actually, we want to run this already now, if so requested,
476 # because we need to fix up things right now.
477 case "$use64bitall" in
478 "$define"|true|[yY]*)
479         . ./UU/use64bitall.cbu
480         ;;
481 esac
482
483 cat > UU/uselongdouble.cbu <<'EOCBU'
484 # This script UU/uselongdouble.cbu will get 'called-back' by Configure 
485 # after it has prompted the user for whether to use long doubles.
486 case "$uselongdouble-$uselongdouble_done" in
487 "$define-"|true-|[yY]*-)
488         case "$ccname" in
489         workshop)
490                 libswanted="$libswanted sunmath"
491                 loclibpth="$loclibpth /opt/SUNWspro/lib"
492                 ;;
493         *)      cat >&4 <<EOM
494
495 The Sun Workshop compiler is not being used; therefore I do not see
496 the libsunmath; therefore I do not know how to do long doubles, sorry.
497 I'm disabling the use of long doubles.
498 EOM
499                 uselongdouble="$undef"
500                 ;;
501         esac
502         uselongdouble_done=yes
503         ;;
504 esac
505 EOCBU
506
507 # Actually, we want to run this already now, if so requested,
508 # because we need to fix up things right now.
509 case "$uselongdouble" in
510 "$define"|true|[yY]*)
511         . ./UU/uselongdouble.cbu
512         ;;
513 esac
514
515 rm -f try.c try.o try