This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.0 alpha 9
[perl5.git] / Configure
CommitLineData
2304df62
AD
1#! /bin/sh
2#
3# If these # comments don't work, trim them. Don't worry about any other
4# shell scripts, Configure will trim # comments from them for you.
5#
6# (If you are trying to port this package to a machine without sh,
7# I would suggest you have a look at the prototypical config_h.SH file
8# and edit it to reflect your system. Some packages may include samples
9# of config.h for certain machines, so you might look for one of those.)
10#
11# Yes, you may rip this off to use in other distribution packages. This
12# script belongs to the public domain and cannot be copyrighted.
13#
14# (Note: this Configure script was generated automatically. Rather than
15# working with this copy of Configure, you may wish to get metaconfig.
16# The dist-3.0 package (which contains metaconfig) was posted in
17# comp.sources.misc so you may fetch it yourself from your nearest
18# archive site. Check with Archie if you don't know where that can be.)
19#
20
21# $Id: Head.U,v 3.0.1.3 1993/12/15 08:15:07 ram Exp $
22#
85e6fe83 23# Generated on Wed May 4 14:59:36 EDT 1994 [metaconfig 3.0 PL22]
2304df62
AD
24
25cat >/tmp/c1$$ <<EOF
26ARGGGHHHH!!!!!
27
28SCO csh still thinks true is false. Write to SCO today and tell them that next
29year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
30
31(Actually, Configure ought to just patch csh in place. Hmm. Hmmmmm. All
32we'd have to do is go in and swap the && and || tokens, wherever they are.)
33
34[End of diatribe. We now return you to your regularly scheduled programming...]
35EOF
36cat >/tmp/c2$$ <<EOF
37
38OOPS! You naughty creature! You didn't run Configure with sh!
39I will attempt to remedy the situation by running sh for you...
40EOF
41
42true || cat /tmp/c1$$ /tmp/c2$$
43true || exec sh $0 $argv:q
44
45(exit $?0) || cat /tmp/c2$$
46(exit $?0) || exec sh $0 $argv:q
47rm -f /tmp/c1$$ /tmp/c2$$
48
49: Sanity checks
50PATH=".:$PATH:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin"
51PATH=$PATH:'/usr/5bin:/etc:/usr/gnu/bin:/usr/new:/usr/new/bin:/usr/nbin'
52PATH=$PATH:'/sys5.3/bin:/sys5.3/usr/bin:/bsd4.3/bin:/bsd4.3/usr/ucb'
53PATH=$PATH:'/bsd4.3/usr/bin:/usr/bsd:/bsd43/bin:/usr/ccs/bin'
54PATH=$PATH:'/etc:/usr/lib:/usr/ucblib:/lib:/usr/ccs/lib'
55PATH=$PATH:'/sbin:/usr/sbin:/usr/libexec'
56export PATH
57
58if test ! -t 0; then
59 echo "Say 'sh Configure', not 'sh <Configure'"
60 exit 1
61fi
62
63: On HP-UX, large Configure scripts may exercise a bug in /bin/sh
64if test -f /hp-ux -a -f /bin/ksh; then
65 if (PATH=.; alias -x) >/dev/null 2>&1; then
66 : already under /bin/ksh
67 else
68 cat <<'EOM'
69(Feeding myself to ksh to avoid nasty sh bug in "here document" expansion.)
70EOM
71 exec /bin/ksh $0 "$@"
72 fi
73else
74 : Warn them if they use ksh on other systems
75 (PATH=.; alias -x) >/dev/null 2>&1 && \
76 cat <<'EOM'
77(I see you are using the Korn shell. Some ksh's blow up on Configure,
78especially on exotic machines. If yours does, try the Bourne shell instead.)
79EOM
80fi
81
82: Configure runs within the UU subdirectory
83test -d UU || mkdir UU
84cd UU && rm -f *
85
86extensions=''
2304df62
AD
87d_eunice=''
88d_xenix=''
89eunicefix=''
90Mcc=''
91awk=''
92bash=''
93bison=''
94byacc=''
95cat=''
96chgrp=''
97chmod=''
98chown=''
99compress=''
100cp=''
101cpio=''
102cpp=''
103csh=''
104date=''
105echo=''
106egrep=''
107emacs=''
108expr=''
109find=''
110flex=''
111gcc=''
112grep=''
113inews=''
114ksh=''
115less=''
116line=''
117lint=''
118ln=''
119lp=''
120lpr=''
121ls=''
122mail=''
123mailx=''
124make=''
125mkdir=''
126more=''
127mv=''
128nroff=''
129perl=''
130pg=''
131pmake=''
132pr=''
133rm=''
134rmail=''
135sed=''
136sendmail=''
137sh=''
138shar=''
139sleep=''
140smail=''
141sort=''
142submit=''
143tail=''
144tar=''
145tbl=''
146test=''
147touch=''
148tr=''
149troff=''
150uname=''
151uniq=''
152uuname=''
153vi=''
154zcat=''
155hint=''
156myuname=''
85e6fe83
LW
157osname=''
158osvers=''
2304df62
AD
159Author=''
160Date=''
161Header=''
162Id=''
163Locker=''
164Log=''
165RCSfile=''
166Revision=''
167Source=''
168State=''
169afs=''
85e6fe83 170memalignbytes=''
2304df62
AD
171bin=''
172binexp=''
173installbin=''
174byteorder=''
175cc=''
176gccversion=''
177ccflags=''
178cppflags=''
179ldflags=''
180lkflags=''
181optimize=''
182cf_by=''
183cf_time=''
184contains=''
185cpplast=''
186cppminus=''
187cpprun=''
188cppstdin=''
189d_access=''
190d_bcmp=''
191d_bcopy=''
192d_bzero=''
193d_casti32=''
194castflags=''
195d_castneg=''
196d_charsprf=''
197d_chsize=''
198d_const=''
199cryptlib=''
200d_crypt=''
201d_csh=''
202d_dosuid=''
203d_dup2=''
204d_fchmod=''
205d_fchown=''
206d_fcntl=''
207d_flexfnam=''
208d_flock=''
209d_getgrps=''
210d_gethent=''
211aphostname=''
212d_gethname=''
213d_phostname=''
214d_uname=''
215d_getpgrp2=''
216d_getpgrp=''
217d_getprior=''
218d_htonl=''
219d_isascii=''
220d_killpg=''
221d_link=''
222d_lstat=''
223d_memcmp=''
224d_memcpy=''
225d_memmove=''
226d_memset=''
227d_mkdir=''
228d_msg=''
229d_msgctl=''
230d_msgget=''
231d_msgrcv=''
232d_msgsnd=''
233d_open3=''
234d_portable=''
235d_readdir=''
85e6fe83
LW
236d_rewinddir=''
237d_seekdir=''
238d_telldir=''
2304df62
AD
239d_rename=''
240d_rmdir=''
241d_safebcpy=''
242d_safemcpy=''
243d_select=''
244d_sem=''
245d_semctl=''
246d_semget=''
247d_semop=''
248d_setegid=''
249d_seteuid=''
250d_setlocale=''
251d_setpgid=''
252d_setpgrp2=''
253d_bsdpgrp=''
254d_setpgrp=''
255d_setprior=''
256d_setregid=''
257d_setresgid=''
258d_setresuid=''
259d_setreuid=''
260d_setrgid=''
261d_setruid=''
262d_setsid=''
263d_shm=''
264d_shmat=''
85e6fe83 265d_voidshmat=''
2304df62
AD
266d_shmctl=''
267d_shmdt=''
268d_shmget=''
269d_oldsock=''
270d_socket=''
271d_sockpair=''
272sockethdr=''
273socketlib=''
274d_statblks=''
275d_stdstdio=''
276d_index=''
277d_strchr=''
278d_strctcpy=''
279d_strerrm=''
280d_strerror=''
281d_sysernlst=''
282d_syserrlst=''
283d_symlink=''
284d_syscall=''
285d_system=''
85e6fe83
LW
286d_time=''
287timetype=''
2304df62
AD
288clocktype=''
289d_times=''
290d_truncate=''
291d_usendir=''
292i_ndir=''
293ndirc=''
294ndirlib=''
295ndiro=''
296d_vfork=''
297d_voidsig=''
298signal_t=''
299d_volatile=''
300d_charvspr=''
301d_vprintf=''
302d_wait4=''
303d_waitpid=''
85e6fe83
LW
304cccdlflags=''
305ccdlflags=''
306dldir=''
2304df62
AD
307dlobj=''
308dlsrc=''
85e6fe83
LW
309lddlflags=''
310shlibsuffix=''
2304df62
AD
311usedl=''
312gidtype=''
313groupstype=''
314h_fcntl=''
315h_sysfile=''
316i_dbm=''
317d_dirnamlen=''
318i_dirent=''
319i_dlfcn=''
320i_fcntl=''
321i_gdbm=''
322i_grp=''
85e6fe83 323i_memory=''
2304df62 324i_ndbm=''
85e6fe83 325i_neterrno=''
2304df62
AD
326i_niin=''
327i_sysin=''
328d_pwage=''
329d_pwchange=''
330d_pwclass=''
331d_pwcomment=''
332d_pwexpire=''
333d_pwquota=''
334i_pwd=''
85e6fe83 335i_sdbm=''
2304df62
AD
336i_stdarg=''
337i_stddef=''
338i_string=''
339strings=''
340i_sysdir=''
341i_sysfile=''
342d_voidtty=''
343i_bsdioctl=''
344i_sysioctl=''
345i_syssockio=''
346i_sysndir=''
347i_sysselct=''
348i_sgtty=''
349i_termio=''
350i_termios=''
351i_systime=''
352i_systimek=''
353i_time=''
354timeincl=''
85e6fe83 355i_unistd=''
2304df62
AD
356i_utime=''
357i_varargs=''
358i_varhdr=''
359i_vfork=''
360intsize=''
361lib=''
362libexp=''
363libc=''
364libpth=''
365plibpth=''
366xlibpth=''
367libs=''
85e6fe83
LW
368lns=''
369lseektype=''
370d_mymalloc=''
2304df62
AD
371mallocobj=''
372mallocsrc=''
373malloctype=''
374usemymalloc=''
375installmansrc=''
376manext=''
377mansrc=''
378mansrcexp=''
379huge=''
380large=''
381medium=''
382models=''
383small=''
384split=''
385mydomain=''
386myhostname=''
387phostname=''
388c=''
389n=''
390groupcat=''
391hostcat=''
392passcat=''
85e6fe83
LW
393orderlib=''
394ranlib=''
2304df62
AD
395package=''
396spackage=''
397installprivlib=''
398privlib=''
399privlibexp=''
400prototype=''
85e6fe83 401ptrsize=''
2304df62
AD
402randbits=''
403installscript=''
404scriptdir=''
405scriptdirexp=''
406sig_name=''
407sharpbang=''
408shsharp=''
409spitshell=''
410startsh=''
411stdchar=''
412sysman=''
413uidtype=''
414nm_opt=''
415runnm=''
416usenm=''
417incpath=''
418mips=''
419mips_type=''
420usrinc=''
421defvoidused=''
422voidflags=''
423yacc=''
424yaccflags=''
425CONFIG=''
426
427: script used to extract .SH files with variable substitutions
428cat >extract <<'EOS'
429CONFIG=true
430echo "Doing variable substitutions on .SH files..."
431if test -f MANIFEST; then
432 set x `awk '{print $1}' <MANIFEST | grep '\.SH'`
433else
434 echo "(Looking for .SH files under the current directory.)"
435 set x `find . -name "*.SH" -print`
436fi
437shift
438case $# in
4390) set x *.SH; shift;;
440esac
441if test ! -f $1; then
442 shift
443fi
444for file in $*; do
445 case "$file" in
446 */*)
447 dir=`expr X$file : 'X\(.*\)/'`
448 file=`expr X$file : 'X.*/\(.*\)'`
449 (cd $dir && . ./$file)
450 ;;
451 *)
452 . ./$file
453 ;;
454 esac
455done
456if test -f config_h.SH; then
457 if test ! -f config.h; then
458 : oops, they left it out of MANIFEST, probably, so do it anyway.
459 . ./config_h.SH
460 fi
461fi
462EOS
463
464: produce awk script to parse command line options
465cat >options.awk <<'EOF'
466BEGIN {
467 optstr = "deEf:hrsSV"; # getopt-style specification
468
469 len = length(optstr);
470 for (i = 1; i <= len; i++) {
471 c = substr(optstr, i, 1);
472 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
473 if (a == ":") {
474 arg[c] = 1;
475 i++;
476 }
477 opt[c] = 1;
478 }
479}
480{
481 expect = 0;
482 str = $0;
483 if (substr(str, 1, 1) != "-") {
484 printf("'%s'\n", str);
485 next;
486 }
487 len = length($0);
488 for (i = 2; i <= len; i++) {
489 c = substr(str, i, 1);
490 if (!opt[c]) {
491 printf("-%s\n", substr(str, i));
492 next;
493 }
494 printf("-%s\n", c);
495 if (arg[c]) {
496 if (i < len)
497 printf("'%s'\n", substr(str, i + 1));
498 else
499 expect = 1;
500 next;
501 }
502 }
503}
504END {
505 if (expect)
506 print "?";
507}
508EOF
509
510: process the command line options
511set X `for arg in "$@"; do echo $arg; done | awk -f options.awk`
512eval "set $*"
513shift
514rm -f options.awk
515
516: set up default values
517fastread=''
518reuseval=false
519config_sh=''
520alldone=''
521error=''
522silent=''
523extractsh=''
524
525: option parsing
526while test $# -gt 0; do
527 case "$1" in
528 -d) shift; fastread=yes;;
529 -e) shift; alldone=cont;;
530 -f)
531 shift
532 cd ..
533 if test -r "$1"; then
534 config_sh="$1"
535 else
536 echo "Configure: cannot read config file $1." >&2
537 error=true
538 fi
539 cd UU
540 shift;;
541 -h) shift; error=true;;
542 -r) shift; reuseval=true;;
543 -s) shift; silent=true;;
544 -E) shift; alldone=exit;;
545 -S) shift; extractsh=true;;
546 -V) echo "Configure generated by metaconfig 3.0 PL22." >&2
547 exit 0;;
548 --) break;;
549 -*) echo "Configure: unknown option $1" >&2; shift; error=true;;
550 *) break;;
551 esac
552done
553
554case "$error" in
555true)
556 cat >&2 <<EOM
557Usage: Configure [-dehrESV] [-f config.sh]
558 -d : use defaults for all answers.
559 -e : go on without questioning past the production of config.sh.
560 -f : specify an alternate default configuration file.
561 -h : print this help message and exit (with an error status).
562 -r : reuse C symbols value if possible (skips costly nm extraction).
563 -s : silent mode, only echoes questions and essential information.
564 -E : stop at the end of questions, after having produced config.sh.
565 -S : perform variable substitutions on all .SH files (can mix with -f)
566 -V : print version number and exit (with a zero status).
567EOM
568 exit 1
569 ;;
570esac
571
572exec 4>&1
573case "$silent" in
574true) exec 1>/dev/null;;
575esac
576
577case "$extractsh" in
578true)
579 case "$config_sh" in
580 '') config_sh='config.sh'; config='./config.sh';;
581 /*) config="$config_sh";;
582 *) config="./$config_sh";;
583 esac
584 echo " "
585 echo "Fetching answers from $config_sh..."
586 cd ..
587 . $config
588 echo " "
589 . ./UU/extract
590 rm -rf UU
591 echo "Done."
592 exit 0
593 ;;
594esac
595
596: set package name
85e6fe83 597package=perl5
2304df62
AD
598
599: Eunice requires " " instead of "", can you believe it
600echo " "
601: Here we go...
602echo "Beginning of configuration questions for $package."
603
604define='define'
605undef='undef'
606smallmach='pdp11 i8086 z8000 i80286 iAPX286'
607rmlist=''
608
609trap 'echo " "; rm -rf $rmlist; exit 1' 1 2 3 15
610
611: We must find out about Eunice early
612eunicefix=':'
613if test -f /etc/unixtovms; then
614 eunicefix=/etc/unixtovms
615fi
616if test -f /etc/unixtovms.exe; then
617 eunicefix=/etc/unixtovms.exe
618fi
619
620: list of known cpp symbols
621attrlist="__alpha __bsdi__ BSD_NET2 DGUX M_I186 M_I286 M_I386"
622attrlist="$attrlist M_I8086 M_XENIX UTS __DGUX__"
623attrlist="$attrlist _AIX __STDC__ __m88k__ ansi bsd4_2 gcos gimpel"
624attrlist="$attrlist hp9000s300 hp9000s400 hp9000s500 hp9000s700"
625attrlist="$attrlist hp9000s800 hpux"
626attrlist="$attrlist i186 i386 i486 i8086 iAPX286 ibm interdata"
627attrlist="$attrlist m88k mc300 mc500 mc68000 mc68k mc700 mert"
628attrlist="$attrlist mips NeXT ns16000 ns32000 nsc32000 os"
629attrlist="$attrlist __osf__ pdp11 posix"
630attrlist="$attrlist pyr sinix sony sparc sun tower tower32 tower32_600"
631attrlist="$attrlist tower32_800 tss u3b2 u3b20 u3b200 u3b5 ultrix unix"
632attrlist="$attrlist __unix__ vax venix xenix z8000"
633
634i_whoami=''
635: List of extensions we want:
636extensions=''
637gccversion=''
638: no include file wanted by default
639inclwanted=''
640
85e6fe83
LW
641: File to use for dynamic loading
642usedl=''
643gidtype=''
2304df62
AD
644groupstype=''
645: change the next line if compiling for Xenix/286 on Xenix/386
646xlibpth='/usr/lib/386 /lib/386'
647
648: general looking path for locating libraries
649libpth="/usr/lib/large /lib /usr/lib $xlibpth /lib/large"
650libpth="$libpth /usr/lib/small /lib/small"
651libpth="$libpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
652
653: Private path used by Configure to find libraries. Its value
654: is prepend to libpth. This variable takes care of special
655: machines, like the mips. Usually, it should be empty.
656plibpth=''
657
85e6fe83 658libswanted=" net socket inet nsl nm sdbm gdbm ndbm dbm malloc dl dld sun m c_s posix cposix ndir dir ucb bsd BSD PW x "
2304df62
AD
659
660: full support for void wanted by default
661defvoidused=15
662
663
664: Some greps do not return status, grrr.
665echo "grimblepritz" >grimble
666if grep blurfldyick grimble >/dev/null 2>&1 ; then
667 contains=contains
668elif grep grimblepritz grimble >/dev/null 2>&1 ; then
669 contains=grep
670else
671 contains=contains
672fi
673rm -f grimble
674: the following should work in any shell
675case "$contains" in
676contains*)
677 echo " "
678 echo "AGH! Grep doesn't return a status. Attempting remedial action."
679 cat >contains <<'EOSS'
680grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
681EOSS
682chmod +x contains
683esac
684
685: first determine how to suppress newline on echo command
686echo " "
687echo "Checking echo to see how to suppress newlines..."
688(echo "hi there\c" ; echo " ") >.echotmp
689if $contains c .echotmp >/dev/null 2>&1 ; then
690 echo "...using -n."
691 n='-n'
692 c=''
693else
694 cat <<'EOM'
695...using \c
696EOM
697 n=''
698 c='\c'
699fi
700echo $n "The star should be here-->$c"
701echo '*'
702rm -f .echotmp
703
704: Now test for existence of everything in MANIFEST
705echo " "
706if test -f ../MANIFEST; then
707 echo "First let's make sure your kit is complete. Checking..." >&4
708 awk '$1 !~ /PACK[A-Z]+/ {print $1}' ../MANIFEST | split -50
709 rm -f missing
710 for filelist in x??; do
711 (cd ..; ls `cat UU/$filelist` >/dev/null 2>>UU/missing)
712 done
713 if test -s missing; then
714 cat missing >&4
715 cat >&4 <<'EOM'
716
717THIS PACKAGE SEEMS TO BE INCOMPLETE.
718
719You have the option of continuing the configuration process, despite the
720distinct possibility that your kit is damaged, by typing 'y'es. If you
721do, don't blame me if something goes wrong. I advise you to type 'n'o
722and contact the author (lwall@netlabs.com).
723
724EOM
725 echo $n "Continue? [n] $c" >&4
726 read ans
727 case "$ans" in
728 y*)
729 echo "Continuing..." >&4
730 rm -f missing
731 ;;
732 *)
733 echo "ABORTING..." >&4
734 kill $$
735 ;;
736 esac
737 else
738 echo "Looks good..." >&4
739 fi
740else
741 echo "There is no MANIFEST file. I hope your kit is complete !"
742fi
743rm -f missing x??
744
745: compute the number of columns on the terminal for proper question formatting
746case "$COLUMNS" in
747'') COLUMNS='80';;
748esac
749
750: set up the echo used in my read
751myecho="case \"\$xxxm\" in
752'') echo $n \"\$rp $c\" >&4;;
753*) case \"\$rp\" in
754 '') echo $n \"[\$xxxm] $c\";;
755 *)
756 if test \`echo \"\$rp [\$xxxm] \" | wc -c\` -ge $COLUMNS; then
757 echo \"\$rp\" >&4
758 echo $n \"[\$xxxm] $c\" >&4
759 else
760 echo $n \"\$rp [\$xxxm] $c\" >&4
761 fi
762 ;;
763 esac;;
764esac"
765
766: now set up to do reads with possible shell escape and default assignment
767cat <<EOSC >myread
768xxxm=\$dflt
769$myecho
770ans='!'
771case "\$fastread" in
772yes) case "\$dflt" in
773 '') ;;
774 *) ans='';
775 case "\$silent-\$rp" in
776 true-) ;;
777 *) echo " " >&4;;
778 esac;;
779 esac;;
780*) case "\$silent" in
781 true) case "\$rp" in
782 '') ans='';;
783 esac;;
784 esac;;
785esac
786while expr "X\$ans" : "X!" >/dev/null; do
787 read answ
788 set x \$xxxm
789 shift
790 aok=''; eval "ans=\"\$answ\"" && aok=y
791 case "\$answ" in
792 "\$ans")
793 case "\$ans" in
794 "!")
795 sh 1>&4
796 echo " "
797 $myecho
798 ;;
799 !*)
800 set x \`expr "X\$ans" : "X!\(.*\)\$"\`
801 shift
802 sh 1>&4 -c "\$*"
803 echo " "
804 $myecho
805 ;;
806 esac;;
807 *)
808 case "\$aok" in
809 y)
810 echo "*** Substitution done -- please confirm."
811 xxxm="\$ans"
812 ans=\`echo $n "\$ans$c" | tr '\012' ' '\`
813 xxxm="\$ans"
814 ans=!
815 ;;
816 *)
817 echo "*** Error -- try again."
818 ans=!
819 ;;
820 esac
821 $myecho
822 ;;
823 esac
824 case "\$ans\$xxxm\$nostick" in
825 '')
826 ans=!
827 $myecho
828 ;;
829 esac
830done
831case "\$ans" in
832'') ans="\$xxxm";;
833esac
834EOSC
835
836: create .config dir to save info across Configure sessions
837test -d ../.config || mkdir ../.config
838cat >../.config/README <<EOF
839This directory created by Configure to save information that should
840persist across sessions.
841
842You may safely delete it if you wish.
843EOF
844
845: general instructions
846needman=true
847firsttime=true
848user=`( (logname) 2>/dev/null || whoami) 2>&1`
849if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
850 firsttime=false
851 echo " "
852 rp='Would you like to see the instructions?'
853 dflt=n
854 . ./myread
855 case "$ans" in
856 [yY]*) ;;
857 *) needman=false;;
858 esac
859fi
860if $needman; then
861 cat <<EOH
862
863This installation shell script will examine your system and ask you questions
864to determine how the perl package should be installed. If you get
865stuck on a question, you may use a ! shell escape to start a subshell or
866execute a command. Many of the questions will have default answers in square
867brackets; typing carriage return will give you the default.
868
869On some of the questions which ask for file or directory names you are allowed
870to use the ~name construct to specify the login directory belonging to "name",
871even if you don't have a shell which knows about that. Questions where this is
872allowed will be marked "(~name ok)".
873
874EOH
875 rp=''
876 dflt='Type carriage return to continue'
877 . ./myread
878 cat <<'EOH'
879
880The prompter used in this script allows you to use shell variables and
881backticks in your answers. You may use $1, $2, etc... to refer to the words
882in the default answer, as if the default line was a set of arguments given to a
883script shell. This means you may also use $* to repeat the whole default line,
884so you do not have to re-type everything to add something to the default.
885
886Everytime there is a substitution, you will have to confirm. If there is an
887error (e.g. an unmatched backtick), the default answer will remain unchanged
888and you will be prompted again.
889
890If you are in a hurry, you may run 'Configure -d'. This will bypass nearly all
891the questions and use the computed defaults (or the previous answers if there
892was already a config.sh file). Type 'Configure -h' for a list of options.
893
894EOH
895 . ./myread
896 cat <<EOH
897
898Much effort has been expended to ensure that this shell script will run on any
899Unix system. If despite that it blows up on yours, your best bet is to edit
900Configure and run it again. Also, let me (lwall@netlabs.com)
901know how I blew it. If you can't run Configure for some reason, you'll have to
902generate a config.sh file by hand.
903
904This installation script affects things in two ways:
905
9061) it may do direct variable substitutions on some of the files included
907 in this kit.
9082) it builds a config.h file for inclusion in C programs. You may edit
909 any of these files as the need arises after running this script.
910
911If you make a mistake on a question, there is no easy way to back up to it
912currently. The easiest thing to do is to edit config.sh and rerun all the SH
913files. Configure will offer to let you do this before it runs the SH files.
914
915EOH
916 dflt='Type carriage return to continue'
917 . ./myread
918 case "$firsttime" in
919 true) echo $user >>../.config/instruct;;
920 esac
921fi
922
923: see if sh knows # comments
924echo " "
925echo "Checking your sh to see if it knows about # comments..." >&4
926if sh -c '#' >/dev/null 2>&1 ; then
927 echo "Your sh handles # comments correctly."
928 shsharp=true
929 spitshell=cat
930 echo " "
931 echo "Okay, let's see if #! works on this system..."
932 echo "#!/bin/cat" >try
933 $eunicefix try
934 chmod +x try
935 ./try > today
936 if test -s today; then
937 echo "It does."
938 sharpbang='#!'
939 else
940 echo "#! /bin/cat" > try
941 $eunicefix try
942 chmod +x try
943 ./try > today
944 if test -s today; then
945 echo "It does."
946 sharpbang='#! '
947 else
948 echo "It's just a comment."
949 sharpbang=': use '
950 fi
951 fi
952else
953 echo "Your sh doesn't grok # comments--I will strip them later on."
954 shsharp=false
955 echo "exec grep -v '^[ ]*#'" >spitshell
956 chmod +x spitshell
957 $eunicefix spitshell
958 spitshell=`pwd`/spitshell
959 echo "I presume that if # doesn't work, #! won't work either!"
960 sharpbang=': use '
961fi
962rm -f try today
963
964: figure out how to guarantee sh startup
965echo " "
966echo "Checking out how to guarantee sh startup..." >&4
967case "$SYSTYPE" in
968*bsd*|sys5*) startsh=$sharpbang"/$SYSTYPE/bin/sh";;
969*) startsh=$sharpbang'/bin/sh';;
970esac
971echo "Let's see if '$startsh' works..."
972cat >try <<EOSS
973$startsh
974set abc
975test "$?abc" != 1
976EOSS
977
978chmod +x try
979$eunicefix try
980if ./try; then
981 echo "Yup, it does."
982else
983echo "Nope. You may have to fix up the shell scripts to make sure sh runs them."
984fi
985rm -f try
986
987: find out where common programs are
988echo " "
989echo "Locating common programs..." >&4
990cat <<EOSC >loc
991$startsh
992case \$# in
9930) exit 1;;
994esac
995thing=\$1
996shift
997dflt=\$1
998shift
999for dir in \$*; do
1000 case "\$thing" in
1001 .)
1002 if test -d \$dir/\$thing; then
1003 echo \$dir
1004 exit 0
1005 fi
1006 ;;
1007 *)
1008 if test -f \$dir/\$thing; then
1009 echo \$dir/\$thing
1010 exit 0
1011 elif test -f \$dir/\$thing.exe; then
1012 : on Eunice apparently
1013 echo \$dir/\$thing
1014 exit 0
1015 fi
1016 ;;
1017 esac
1018done
1019echo \$dflt
1020exit 1
1021EOSC
1022chmod +x loc
1023$eunicefix loc
1024loclist="
1025awk
1026cat
1027cp
1028echo
1029expr
1030grep
85e6fe83 1031ln
2304df62
AD
1032mkdir
1033mv
1034rm
1035sed
1036sort
85e6fe83 1037touch
2304df62
AD
1038tr
1039uniq
1040"
1041trylist="
1042Mcc
1043bison
1044byacc
1045cpp
1046csh
1047date
1048egrep
1049find
1050line
1051nroff
1052perl
1053test
1054uname
1055"
1056pth=`echo $PATH | sed -e 's/:/ /g'`
1057pth="$pth /lib /usr/lib"
1058for file in $loclist; do
1059 xxx=`./loc $file $file $pth`
1060 eval $file=$xxx
1061 eval _$file=$xxx
1062 case "$xxx" in
1063 /*)
1064 echo $file is in $xxx.
1065 ;;
1066 *)
1067 echo "I don't know where $file is. I hope it's in everyone's PATH."
1068 ;;
1069 esac
1070done
1071echo " "
1072echo "Don't worry if any of the following aren't found..."
1073say=offhand
1074for file in $trylist; do
1075 xxx=`./loc $file $file $pth`
1076 eval $file=$xxx
1077 eval _$file=$xxx
1078 case "$xxx" in
1079 /*)
1080 echo $file is in $xxx.
1081 ;;
1082 *)
1083 echo "I don't see $file out there, $say."
1084 say=either
1085 ;;
1086 esac
1087done
1088case "$egrep" in
1089egrep)
1090 echo "Substituting grep for egrep."
1091 egrep=$grep
1092 ;;
1093esac
1094case "$test" in
1095test)
1096 echo "Hopefully test is built into your sh."
1097 ;;
1098*)
1099 if sh -c "PATH= test true" >/dev/null 2>&1; then
1100 echo "Using the test built into your sh."
1101 test=test
1102 _test=test
1103 fi
1104 ;;
1105esac
1106case "$echo" in
1107echo)
1108 echo "Hopefully echo is built into your sh."
1109 ;;
1110'') ;;
1111*)
1112 echo " "
1113echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
1114 $echo $n "hi there$c" >foo1
1115 echo $n "hi there$c" >foo2
1116 if cmp foo1 foo2 >/dev/null 2>&1; then
1117 echo "They are compatible. In fact, they may be identical."
1118 else
1119 case "$n" in
1120 '-n') n='' c='\c';;
1121 *) n='-n' c='';;
1122 esac
1123 cat <<FOO
1124They are not compatible! You are probably running ksh on a non-USG system.
1125I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1126have echo built in and we may have to run some Bourne shell scripts. That
1127means I'll have to use '$n$c' to suppress newlines now. Life is ridiculous.
1128
1129FOO
1130 $echo $n "The star should be here-->$c"
1131 $echo "*"
1132 fi
1133 $rm -f foo1 foo2
1134 ;;
1135esac
1136
1137: Try to determine whether config.sh was made on this system
1138case "$config_sh" in
1139'')
1140myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
1141myuname=`echo $myuname | $sed -e 's/^[^=]*=//' | \
1142 tr '[A-Z]' '[a-z]' | tr '\012' ' '`
1143dflt=n
1144if test "$fastread" = yes; then
1145 dflt=y
1146elif test -f ../config.sh; then
1147 oldmyuname=''
1148 if $contains myuname= ../config.sh >/dev/null 2>&1; then
1149 eval "old`grep myuname= ../config.sh`"
1150 fi
1151 if test "X$myuname" = "X$oldmyuname"; then
1152 dflt=y
1153 fi
1154fi
1155
1156: Get old answers from old config file if Configure was run on the
1157: same system, otherwise use the hints.
1158hint=default
1159cd ..
1160if test -f config.sh; then
1161 echo " "
1162 rp="I see a config.sh file. Shall I use it to set the defaults?"
1163 . UU/myread
1164 case "$ans" in
1165 n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
1166 *) echo "Fetching default answers from your old config.sh file..." >&4
1167 tmp="$n"
1168 tans="$c"
1169 . ./config.sh
1170 cp config.sh UU
1171 n="$tmp"
1172 c="$tans"
1173 hint=previous
1174 ;;
1175 esac
1176fi
1177if test ! -f config.sh; then
1178 $cat <<EOM
1179
1180First time through, eh? I have some defaults handy for the following systems:
1181
1182EOM
1183 cd hints; ls -C *.sh | $sed 's/\.sh/ /g' >&4
1184 dflt=''
1185 : Half the following guesses are probably wrong... If you have better
1186 : tests or hints, please send them to lwall@netlabs.com
1187 : The metaconfig authors would also appreciate a copy...
85e6fe83
LW
1188 $test -f /irix && osname=sgi
1189 $test -f /xenix && osname=sco_xenix
1190 $test -f /dynix && osname=dynix
1191 $test -f /dnix && osname=dnix
1192 $test -f /bin/mips && /bin/mips && osname=mips
1193 $test -d /NextApps && test -f /usr/adm/software_version && osname=next
1194 $test -d /usr/include/minix && osname=minix
2304df62
AD
1195 if $test -f $uname; then
1196 set X $myuname
1197 shift
1198
1199 $test -f $5.sh && dflt="$dflt $5"
1200
1201 case "$5" in
85e6fe83 1202 fps*) osname=fps ;;
2304df62
AD
1203 mips*)
1204 case "$4" in
85e6fe83
LW
1205 umips) osname=umips ;;
1206 *) osname=mips ;;
2304df62 1207 esac;;
85e6fe83
LW
1208 [23]100) osname=mips ;;
1209 next*) osname=next ;;
1210 news*) osname=news ;;
2304df62 1211 i386*) if $test -f /etc/kconfig; then
85e6fe83 1212 osname=isc
2304df62 1213 if $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
85e6fe83 1214 osvers=3.2.3
2304df62 1215 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
85e6fe83 1216 osvers=3.2.2
2304df62 1217 fi
2304df62
AD
1218 fi
1219 ;;
1220 esac
1221
1222 case "$1" in
85e6fe83
LW
1223 aix) osname=aix_rs ;;
1224 sunos) osname=sunos
1225 case "$3" in
1226 [34]*) osvers=$3 ;;
1227 5*) osname=solaris
1228 osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2304df62
AD
1229 esac
1230 ;;
85e6fe83
LW
1231 solaris) osname=solaris
1232 case "$3" in
1233 5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2304df62
AD
1234 esac
1235 ;;
85e6fe83
LW
1236 dnix) osname=dnix ;;
1237 dgux) osname=dgux ;;
1238 genix) osname=genix ;;
1239 hp*ux) osname=hpux ;;
1240 next) osname=next ;;
1241 irix) osname=sgi ;;
1242 ultrix) osname=ultrix
1243 case "$3" in
1244 1*) osvers=1 ;;
1245 2*) osvers=2 ;;
1246 3*) osvers=3 ;;
1247 4*) osvers=4 ;;
2304df62
AD
1248 esac
1249 ;;
85e6fe83
LW
1250 osf1) case "$5" in
1251 alpha) osname=dec_osf
1252 case "$3" in
1253 [vt]1\.*) osvers=1 ;;
1254 [vt]2\.*) osvers=2 ;;
1255 [vt]3\.*) osvers=3 ;;
1256 esac
1257 ;;
1258 hp*) osname=hp_osf1 ;; # TR
1259 mips) osname=mips_osf1 ;; # TR
1260 # TR = Technology Releases: (un^N)supported
1261 esac
1262 ;;
1263 uts) osname=uts ;;
1264 $2) case "$osname" in
2304df62
AD
1265 *isc*) ;;
1266 *) if test -f /etc/systemid; then
85e6fe83
LW
1267 osname=sco
1268 : Does anyone know if these next gyrations are needed
2304df62
AD
1269 set `echo $3 | $sed 's/\./ /g'` $4
1270 if $test -f sco_$1_$2_$3.sh; then
85e6fe83 1271 osvers=$1.$2.$3
2304df62 1272 elif $test -f sco_$1_$2.sh; then
85e6fe83 1273 osvers=$1.$2
2304df62 1274 elif $test -f sco_$1.sh; then
85e6fe83 1275 osvers=$1
2304df62
AD
1276 fi
1277 fi
1278 ;;
1279 esac
1280 ;;
1281 esac
1282 else
1283 if test -f /vmunix -a -f news_os.sh; then
1284 (what /vmunix | tr '[A-Z]' '[a-z]') > ../UU/kernel.what 2>&1
1285 if $contains news-os ../UU/kernel.what >/dev/null 2>&1; then
85e6fe83 1286 osname=news_os
2304df62
AD
1287 fi
1288 $rm -f ../UU/kernel.what
1289 fi
1290 fi
85e6fe83
LW
1291
1292 : Now look for a hint file osname_osvers
1293 file=`echo "${osname}_${osvers}" | sed -e 's@\.@_@g' -e 's@_$@@'`
1294 case "$file" in
1295 '') dflt=none ;;
1296 *) case "$osvers" in
1297 '') dflt=$file
1298 ;;
1299 *) if $test -f $file.sh ; then
1300 dflt=$file
1301 elif $test -f "${osname}.sh" ; then
1302 dflt="${osname}"
1303 else
1304 dflt=none
1305 fi
1306 ;;
1307 esac
1308 ;;
2304df62 1309 esac
85e6fe83 1310
2304df62
AD
1311 $cat <<EOM
1312
1313You may give one or more space-separated answers, or "none" if appropriate.
1314If your OS version has no hints, DO NOT give a wrong version -- say "none".
1315
1316EOM
1317 rp="Which of these apply, if any?"
1318 . ../UU/myread
85e6fe83
LW
1319 tans=$ans
1320 for file in $tans; do
2304df62
AD
1321 if $test -f $file.sh; then
1322 . ./$file.sh
1323 $cat $file.sh >> ../UU/config.sh
85e6fe83 1324 elif $test X$tans = X -o X$tans = Xnone ; then
2304df62
AD
1325 : nothing
1326 else
85e6fe83
LW
1327 : Give one chance to correct a possible typo.
1328 echo "$file.sh does not exist"
1329 dflt=$file
1330 rp="hint to use instead?"
1331 . ../UU/myread
1332 for file in $ans; do
1333 if $test -f "$file.sh"; then
1334 . ./$file.sh
1335 $cat $file.sh >> ../UU/config.sh
1336 elif $test X$ans = X -o X$ans = Xnone ; then
1337 : nothing
1338 else
1339 echo "$file.sh does not exist -- ignored."
1340 fi
1341 done
2304df62
AD
1342 fi
1343 done
85e6fe83 1344
2304df62 1345 hint=recommended
85e6fe83
LW
1346 : Remember our hint file for later.
1347 if $test -f "$file.sh" ; then
1348 hintfile="$file.sh"
1349 else
1350 hintfile=none
1351 fi
1352
2304df62
AD
1353 cd ..
1354fi
1355cd UU
1356;;
1357*)
1358 echo " "
1359 echo "Fetching default answers from $config_sh..." >&4
1360 tmp="$n"
1361 tans="$c"
1362 cd ..
1363 cp $config_sh config.sh 2>/dev/null
1364 . ./config.sh
1365 cd UU
1366 cp ../config.sh .
1367 n="$tmp"
1368 c="$tans"
1369 hint=previous
1370 ;;
1371esac
1372
1373: Restore computed paths
1374for file in $loclist $trylist; do
1375 eval $file="\$_$file"
1376done
1377
85e6fe83
LW
1378cat << EOM
1379Configure uses the operating system name and version to set some defaults.
1380Say "none" to leave it blank.
1381EOM
1382
1383case "$osname" in
1384 ''|' ')
1385 case "$hintfile" in
1386 none) dflt=none ;;
1387 *) dflt=`echo $hintfile | sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
1388 esac
1389 ;;
1390 *) dflt="$osname" ;;
1391esac
1392rp="Operating system name?"
1393. ./myread
1394case "$ans" in
1395 none) osname='' ;;
1396 *) osname="$ans" ;;
1397esac
1398
1399case "$osvers" in
1400 ''|' ')
1401 case "$hintfile" in
1402 none) dflt=none ;;
1403 *) dflt=`echo $hintfile | sed -e 's/\.sh$//' -e 's/^[^_]*//'`
1404 dflt=`echo $dflt | sed -e 's/^_//' -e 's/_/./g'` ;;
1405 esac
1406 ;;
1407 *) dflt="$osvers" ;;
1408esac
1409rp="Operating system version?"
1410. ./myread
1411case "$ans" in
1412 none) osvers='' ;;
1413 *) osvers="$ans" ;;
1414esac
2304df62
AD
1415: who configured the system
1416cf_time=`$date 2>&1`
1417cf_by=`( (logname) 2>/dev/null || whoami) 2>&1`
1418
1419: determine where manual pages are on this system
1420echo " "
1421case "$sysman" in
1422'')
1423 syspath='/usr/man/man1 /usr/man/man1 /usr/man/mann'
1424 syspath="$syspath /usr/man/manl /usr/man/local/man1"
1425 syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
1426 syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
1427 syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
1428 syspath="$syspath /usr/man/man.L /local/man/man1"
1429 sysman=`./loc . $syspath`
1430 ;;
1431esac
1432if $test -d "$sysman"; then
1433 echo "System manual is in $sysman." >&4
1434else
1435 echo "Could not find manual pages in source form." >&4
1436fi
1437
1438: see what memory models we can support
1439case "$models" in
1440'')
1441 $cat >pdp11.c <<'EOP'
1442main() {
1443#ifdef pdp11
1444 exit(0);
1445#else
1446 exit(1);
1447#endif
1448}
1449EOP
1450 cc -o pdp11 pdp11.c >/dev/null 2>&1
1451 if ./pdp11 2>/dev/null; then
1452 dflt='unsplit split'
1453 else
1454 tans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
1455 case "$tans" in
1456 X) dflt='none';;
1457 *) if $test -d /lib/small || $test -d /usr/lib/small; then
1458 dflt='small'
1459 else
1460 dflt=''
1461 fi
1462 if $test -d /lib/medium || $test -d /usr/lib/medium; then
1463 dflt="$dflt medium"
1464 fi
1465 if $test -d /lib/large || $test -d /usr/lib/large; then
1466 dflt="$dflt large"
1467 fi
1468 if $test -d /lib/huge || $test -d /usr/lib/huge; then
1469 dflt="$dflt huge"
1470 fi
1471 esac
1472 fi;;
1473*) dflt="$models";;
1474esac
1475$cat <<EOM
1476
1477Some systems have different model sizes. On most systems they are called
1478small, medium, large, and huge. On the PDP11 they are called unsplit and
1479split. If your system doesn't support different memory models, say "none".
1480If you wish to force everything to one memory model, say "none" here and
1481put the appropriate flags later when it asks you for other cc and ld flags.
1482Venix systems may wish to put "none" and let the compiler figure things out.
1483(In the following question multiple model names should be space separated.)
1484
1485EOM
1486rp="Which memory models are supported?"
1487. ./myread
1488models="$ans"
1489
1490case "$models" in
1491none)
1492 small=''
1493 medium=''
1494 large=''
1495 huge=''
1496 unsplit=''
1497 split=''
1498 ;;
1499*split)
1500 case "$split" in
1501 '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
1502 $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
1503 dflt='-i'
1504 else
1505 dflt='none'
1506 fi;;
1507 *) dflt="$split";;
1508 esac
1509 rp="What flag indicates separate I and D space?"
1510 . ./myread
1511 tans="$ans"
1512 case "$tans" in
1513 none) tans='';;
1514 esac
1515 split="$tans"
1516 unsplit='';;
1517*large*|*small*|*medium*|*huge*)
1518 case "$models" in
1519 *large*)
1520 case "$large" in
1521 '') dflt='-Ml';;
1522 *) dflt="$large";;
1523 esac
1524 rp="What flag indicates large model?"
1525 . ./myread
1526 tans="$ans"
1527 case "$tans" in
1528 none) tans='';
1529 esac
1530 large="$tans";;
1531 *) large='';;
1532 esac
1533 case "$models" in
1534 *huge*) case "$huge" in
1535 '') dflt='-Mh';;
1536 *) dflt="$huge";;
1537 esac
1538 rp="What flag indicates huge model?"
1539 . ./myread
1540 tans="$ans"
1541 case "$tans" in
1542 none) tans='';
1543 esac
1544 huge="$tans";;
1545 *) huge="$large";;
1546 esac
1547 case "$models" in
1548 *medium*) case "$medium" in
1549 '') dflt='-Mm';;
1550 *) dflt="$medium";;
1551 esac
1552 rp="What flag indicates medium model?"
1553 . ./myread
1554 tans="$ans"
1555 case "$tans" in
1556 none) tans='';
1557 esac
1558 medium="$tans";;
1559 *) medium="$large";;
1560 esac
1561 case "$models" in
1562 *small*) case "$small" in
1563 '') dflt='none';;
1564 *) dflt="$small";;
1565 esac
1566 rp="What flag indicates small model?"
1567 . ./myread
1568 tans="$ans"
1569 case "$tans" in
1570 none) tans='';
1571 esac
1572 small="$tans";;
1573 *) small='';;
1574 esac
1575 ;;
1576*)
1577 echo "Unrecognized memory models--you may have to edit Makefile.SH" >&4
1578 ;;
1579esac
1580
1581: make some quick guesses about what we are up against
1582echo " "
1583$echo $n "Hmm... $c"
1584echo exit 1 >bsd
1585echo exit 1 >usg
1586echo exit 1 >v7
1587echo exit 1 >osf1
1588echo exit 1 >eunice
1589echo exit 1 >xenix
1590echo exit 1 >venix
2304df62
AD
1591$cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
1592if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
1593then
1594 echo "Looks kind of like an OSF/1 system, but we'll see..."
1595 echo exit 0 >osf1
1596elif test `echo abc | tr a-z A-Z` = Abc ; then
1597 xxx=`./loc addbib blurfl $pth`
1598 if $test -f $xxx; then
1599 echo "Looks kind of like a USG system with BSD features, but we'll see..."
1600 echo exit 0 >bsd
1601 echo exit 0 >usg
1602 else
1603 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
1604 echo "Looks kind of like an extended USG system, but we'll see..."
1605 else
1606 echo "Looks kind of like a USG system, but we'll see..."
1607 fi
1608 echo exit 0 >usg
1609 fi
1610elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
1611 echo "Looks kind of like a BSD system, but we'll see..."
2304df62
AD
1612 echo exit 0 >bsd
1613else
1614 echo "Looks kind of like a Version 7 system, but we'll see..."
1615 echo exit 0 >v7
1616fi
1617case "$eunicefix" in
1618*unixtovms*)
1619 $cat <<'EOI'
1620There is, however, a strange, musty smell in the air that reminds me of
1621something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
1622EOI
1623 echo exit 0 >eunice
1624 d_eunice="$define"
1625: it so happens the Eunice I know will not run shell scripts in Unix format
1626 ;;
1627*)
1628 echo " "
1629 echo "Congratulations. You aren't running Eunice."
1630 d_eunice="$undef"
1631 ;;
1632esac
1633if test -f /xenix; then
1634 echo "Actually, this looks more like a XENIX system..."
1635 echo exit 0 >xenix
1636 d_xenix="$define"
1637else
1638 echo " "
1639 echo "It's not Xenix..."
1640 d_xenix="$undef"
1641fi
1642chmod +x xenix
1643$eunicefix xenix
1644if test -f /venix; then
1645 echo "Actually, this looks more like a VENIX system..."
1646 echo exit 0 >venix
1647else
1648 echo " "
1649 if xenix; then
1650 : null
1651 else
1652 echo "Nor is it Venix..."
1653 fi
1654fi
1655chmod +x bsd usg v7 osf1 eunice xenix venix
1656$eunicefix bsd usg v7 osf1 eunice xenix venix
1657$rm -f foo
1658
1659: see if we need a special compiler
1660echo " "
1661if usg; then
1662 case "$cc" in
1663 '') case "$Mcc" in
1664 /*) dflt='Mcc';;
1665 *) case "$large" in
1666 -M*) dflt='cc';;
1667 *) if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
1668 if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
1669 dflt='cc'
1670 else
1671 dflt='cc -M'
1672 fi
1673 else
1674 dflt='cc'
1675 fi;;
1676 esac;;
1677 esac;;
1678 *) dflt="$cc";;
1679 esac
1680 $cat <<'EOM'
1681On some systems the default C compiler will not resolve multiple global
1682references that happen to have the same name. On some such systems the "Mcc"
1683command may be used to force these to be resolved. On other systems a "cc -M"
1684command is required. (Note that the -M flag on other systems indicates a
1685memory model to use!) If you have the Gnu C compiler, you might wish to use
1686that instead.
1687
1688EOM
1689 rp="What command will force resolution on this system?"
1690 . ./myread
1691 cc="$ans"
1692else
1693 case "$cc" in
1694 '') dflt=cc;;
1695 *) dflt="$cc";;
1696 esac
1697 rp="Use which C compiler?"
1698 . ./myread
1699 cc="$ans"
1700fi
1701case "$cc" in
1702gcc*) echo "Checking out which version of gcc"
1703$cat >gccvers.c <<EOM
1704#include <stdio.h>
1705int main()
1706{
1707char *v;
1708v = "unknown";
1709#ifdef __GNUC__
1710# ifdef __VERSION__
1711 v = __VERSION__;
1712# endif
1713#endif
1714switch((int) v[0])
1715 {
1716 case '1': printf("1\n"); break;
1717 case '2': printf("2\n"); break;
1718 case '3': printf("3\n"); break;
1719 default: break;
1720 }
1721#ifdef __GNUC__
1722return 0;
1723#else
1724return 1;
1725#endif
1726}
1727EOM
85e6fe83 1728 if $cc -o gccvers gccvers.c >/dev/null 2>&1; then
2304df62
AD
1729 gccversion=`./gccvers`
1730 echo "You appear to have version $gccversion."
1731 else
1732 echo "Doesn't appear to be GNU cc."
1733 fi
1734 $rm -f gccvers*
1735 if $test "$gccversion" = '1'; then
1736 cpp=`./loc gcc-cpp $cpp $pth`
1737 fi
1738 ;;
1739esac
1740: decide how portable to be
1741case "$d_portable" in
1742"$define") dflt=y;;
1743*) dflt=n;;
1744esac
1745$cat <<'EOH'
1746
1747I can set things up so that your shell scripts and binaries are more portable,
1748at what may be a noticable cost in performance. In particular, if you
1749ask to be portable, the following happens:
1750
1751 1) Shell scripts will rely on the PATH variable rather than using
1752 the paths derived above.
1753 2) ~username interpretations will be done at run time rather than
1754 by Configure.
1755
1756EOH
1757rp="Do you expect to run these scripts and binaries on multiple machines?"
1758. ./myread
1759case "$ans" in
1760 y*) d_portable="$define"
1761 for file in $loclist $trylist; do
1762 eval $file="\$file"
1763 done
1764 ;;
1765 *) d_portable="$undef" ;;
1766esac
1767
1768: set up shell script to do ~ expansion
1769cat >filexp <<EOSS
1770$startsh
1771: expand filename
1772case "\$1" in
1773 ~/*|~)
1774 echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
1775 ;;
1776 ~*)
1777 if $test -f /bin/csh; then
1778 /bin/csh -f -c "glob \$1"
1779 failed=$?
1780 echo ""
1781 exit \$failed
1782 else
1783 name=\`$expr x\$1 : '..\([^/]*\)'\`
1784 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
1785 if $test ! -d "\$dir"; then
1786 me=\`basename \$0\`
1787 echo "\$me: can't locate home directory for: \$name" >&2
1788 exit 1
1789 fi
1790 case "\$1" in
1791 */*)
1792 echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
1793 ;;
1794 *)
1795 echo \$dir
1796 ;;
1797 esac
1798 fi
1799 ;;
1800*)
1801 echo \$1
1802 ;;
1803esac
1804EOSS
1805chmod +x filexp
1806$eunicefix filexp
1807
1808: now set up to get a file name
1809cat <<'EOSC' >getfile
1810tilde=''
1811fullpath=''
1812already=''
1813skip=''
1814none_ok=''
1815exp_file=''
1816orig_rp="$rp"
1817orig_dflt="$dflt"
1818
1819case "$fn" in
1820*~*) tilde=true;;
1821esac
1822case "$fn" in
1823*/*) fullpath=true;;
1824esac
1825case "$fn" in
1826*+*) skip=true;;
1827esac
1828case "$fn" in
1829*n*) none_ok=true;;
1830esac
1831case "$fn" in
1832*e*) exp_file=true;;
1833esac
1834
1835case "$fn" in
1836*f*) type='File';;
1837*d*) type='Directory';;
1838*l*) type='Locate'; fn=`expr $fn : '.*:\(.*\)'`;;
1839esac
1840
1841what="$type"
1842case "$what" in
1843Locate) what='File';;
1844esac
1845
1846case "$exp_file" in
1847'')
1848 case "$d_portable" in
1849 "$define") ;;
1850 *) exp_file=true;;
1851 esac
1852 ;;
1853esac
1854
1855cd ..
1856while test "$type"; do
1857 redo=''
1858 rp="$orig_rp"
1859 dflt="$orig_dflt"
1860 case "$tilde" in
1861 true) rp="$rp (~name ok)";;
1862 esac
1863 . UU/myread
1864 case "$ans" in
1865 none)
1866 value=''
1867 ansexp=''
1868 case "$none_ok" in
1869 true) type='';;
1870 esac
1871 ;;
1872 *)
1873 case "$tilde" in
1874 '') value="$ans"
1875 ansexp="$ans";;
1876 *)
1877 value=`UU/filexp $ans`
1878 case $? in
1879 0)
1880 if test "$ans" != "$value"; then
1881 echo "(That is $value on this particular system.)"
1882 fi
1883 ;;
1884 *) value="$ans";;
1885 esac
1886 ansexp="$value"
1887 case "$exp_file" in
1888 '') value="$ans";;
1889 esac
1890 ;;
1891 esac
1892 case "$fullpath" in
1893 true)
1894 case "$ansexp" in
1895 /*) value="$ansexp" ;;
1896 *)
1897 redo=true
1898 case "$already" in
1899 true)
1900 echo "I shall only accept a full path name, as in /bin/ls." >&4
1901 echo "Use a ! shell escape if you wish to check pathnames." >&4
1902 ;;
1903 *)
1904 echo "Please give a full path name, starting with slash." >&4
1905 case "$tilde" in
1906 true)
1907 echo "Note that using ~name is ok provided it expands well." >&4
1908 already=true
1909 ;;
1910 esac
1911 esac
1912 ;;
1913 esac
1914 ;;
1915 esac
1916 case "$redo" in
1917 '')
1918 case "$type" in
1919 File)
1920 if test -f "$ansexp"; then
1921 type=''
1922 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
1923 then
1924 echo "($value is not a plain file, but that's ok.)"
1925 type=''
1926 fi
1927 ;;
1928 Directory)
1929 if test -d "$ansexp"; then
1930 type=''
1931 fi
1932 ;;
1933 Locate)
1934 if test -d "$value"; then
1935 echo "(Looking for $fn in directory $value.)"
1936 value="$value/$fn"
1937 fi
1938 if test -f "$value"; then
1939 type=''
1940 fi
1941 ;;
1942 esac
1943
1944 case "$skip" in
1945 true) type='';
1946 esac
1947
1948 case "$type" in
1949 '') ;;
1950 *)
1951 if test "$fastread" = yes; then
1952 dflt=y
1953 else
1954 dflt=n
1955 fi
1956 rp="$what $value doesn't exist. Use that name anyway?"
1957 . UU/myread
1958 dflt=''
1959 case "$ans" in
1960 y*) type='';;
1961 *) echo " ";;
1962 esac
1963 ;;
1964 esac
1965 ;;
1966 esac
1967 ;;
1968 esac
1969done
1970cd UU
1971ans="$value"
1972rp="$orig_rp"
1973dflt="$orig_dflt"
1974EOSC
1975
1976: What should the include directory be ?
1977echo " "
1978$echo $n "Hmm... $c"
1979case "$usrinc" in
1980'') dflt='/usr/include';;
1981*) dflt=$usrinc;;
1982esac
1983incpath=''
1984mips_type=''
1985if $test -f /bin/mips && /bin/mips; then
1986 echo "Looks like a MIPS system..."
1987 $cat >usr.c <<'EOCP'
1988#ifdef SYSTYPE_BSD43
1989/bsd43
1990#endif
1991EOCP
1992 if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
1993 dflt='/bsd43/usr/include'
1994 incpath='/bsd43'
1995 mips_type='BSD 4.3'
1996 else
1997 mips_type='System V'
1998 fi
1999 $rm -f usr.c usr.out
2000 echo "and you're compiling with the $mips_type compiler and libraries."
2001else
2002 echo "Doesn't look like a MIPS system."
2003 echo "exit 1" >mips
2004 chmod +x mips
2005 $eunicefix mips
2006fi
2007echo " "
2008fn=d/
2009rp='Where are the include files you want to use?'
2010. ./getfile
2011usrinc="$ans"
2012
2013: determine optimize, if desired, or use for debug flag also
2014case "$optimize" in
2015' ') dflt="none";;
2016'') dflt="-g";;
2017*) dflt="$optimize";;
2018esac
2019$cat <<EOH
2020
2021Some C compilers have problems with their optimizers, by default, $package
2022compiles with the -O flag to use the optimizer. Alternately, you might want
2023to use the symbolic debugger, which uses the -g flag (on traditional Unix
2024systems). Either flag can be specified here. To use neither flag, specify
2025the word "none".
2026
2027EOH
2028rp="What optimizer/debugger flag should be used?"
2029. ./myread
2030optimize="$ans"
2031case "$optimize" in
2032'none') optimize=" ";;
2033esac
2034
85e6fe83 2035dflt=''
2304df62
AD
2036case "$ccflags" in
2037'') case "$cc" in
2038 *gcc*) if $test "$gccversion" = "1"; then
2039 dflt='-fpcc-struct-return'
2040 fi ;;
2304df62
AD
2041 esac
2042 case "$optimize" in
2043 *-g*) dflt="$dflt -DDEBUGGING";;
2044 esac
2045 case "$cc" in
2046 *gcc*) if test -d /etc/conf/kconfig.d &&
2047 $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
2048 then
2049 dflt="$dflt -posix"
2050 fi
2051 ;;
2052 esac
2053 ;;
2304df62
AD
2054esac
2055
2056case "$mips_type" in
2057*BSD*) ;;
2058'') ;;
2059*) inclwanted="$inclwanted $usrinc/bsd";;
2060esac
2061for thisincl in $inclwanted; do
2062 if $test -d $thisincl; then
2063 if $test x$thisincl != x$usrinc; then
2064 case "$dflt" in
2065 *$thisincl*);;
2066 *) dflt="$dflt -I$thisincl";;
2067 esac
2068 fi
2069 fi
2070done
2071
2072inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
2073 xxx=true;
2074elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
2075 xxx=true;
2076else
2077 xxx=false;
2078fi;
2079if $xxx; then
2080 case "$dflt" in
2081 *$2*);;
2082 *) dflt="$dflt -D$2";;
2083 esac;
2084fi'
2085
2086if ./osf1; then
2087 set signal.h __LANGUAGE_C__; eval $inctest
2088else
2089 set signal.h LANGUAGE_C; eval $inctest
2090fi
2091set signal.h NO_PROTOTYPE; eval $inctest
2092set signal.h _NO_PROTO; eval $inctest
2093
2094case "$dflt" in
2095'') dflt=none;;
2096esac
85e6fe83
LW
2097case "$ccflags" in
2098'') ;;
2099*) dflt="$ccflags";;
2100esac
2304df62
AD
2101$cat <<EOH
2102
2103Your C compiler may want other flags. For this question you should include
2104-I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
2105but you should NOT include libraries or ld flags like -lwhatever. If you
2106want $package to honor its debug switch, you should include -DDEBUGGING here.
2107To use no flags, specify the word "none".
2108
85e6fe83
LW
2109Your C compiler might also need additional flags, such as -DJMPCLOBBER,
2110-DHIDEMYMALLOC or -DCRIPPLED_CC.
2304df62
AD
2111EOH
2112set X $dflt
2113shift
2114dflt=${1+"$@"}
2115rp="Any additional cc flags?"
2116. ./myread
2117case "$ans" in
2118none) ccflags='';;
2119*) ccflags="$ans";;
2120esac
2121
2122: the following weeds options from ccflags that are of no interest to cpp
2123cppflags="$ccflags"
2124case "$cc" in
85e6fe83
LW
2125*gcc*) case "$gccversion" in
2126 1) cppflags="$cppflags -D__GNUC__" ;;
2127 esac
2128 ;;
2304df62
AD
2129esac
2130case "$mips_type" in
2131'');;
2132*BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
2133esac
2134case "$cppflags" in
2135'');;
2136*) set X $cppflags
2137 cppflags=''
2138 for flag
2139 do
2140 case $flag in
85e6fe83 2141 -D*|-I*|-traditional|-ansi|-nostdinc|-posix|-Xp) cppflags="$cppflags $flag";;
2304df62
AD
2142 esac
2143 done
2144 case "$cppflags" in
2145 *-*) echo "(C preprocessor flags: $cppflags)";;
2146 esac
2147 ;;
2148esac
2149
2150: flags used in final linking phase
2151case "$ldflags" in
2152'') if venix; then
2153 dflt='-i -z'
2154 else
2155 dflt='none'
2156 fi
2157 ;;
2158*) dflt="$ldflags";;
2159esac
2160echo " "
2161rp="Any additional ld flags (NOT including libraries)?"
2162. ./myread
2163case "$ans" in
2164none) ldflags='';;
2165*) ldflags="$ans";;
2166esac
2167rmlist="$rmlist pdp11"
2168
2169: Initialize h_fcntl
2170h_fcntl=false
2171
2172: Initialize h_sysfile
2173h_sysfile=false
2174
2175: Set private lib path
2176case "$plibpth" in
2177'') if mips; then
2178 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
2179 fi;;
2180esac
2181libpth="$plibpth $libpth"
2182: Now check and see which directories actually exist.
2183xxx=''
2184for yyy in $libpth
2185do
2186 if $test -d $yyy; then
2187 xxx="$xxx $yyy"
2188 fi
2189done
2190libpth="$xxx"
2191$cat <<EOM
2192Some systems have incompatible or broken versions of libraries. Where
2193should I look for libraries?
2194EOM
2195
2196dflt="$libpth"
2197echo " "
2198rp="Directories to use for library searches?"
2199. ./myread
2200case "$ans" in
2201none) libpth=' ';;
2202*) libpth="$ans";;
2203esac
2204: Looking for optional libraries
2205echo " "
2206echo "Checking for optional libraries..." >&4
2207case "$libs" in
2208' '|'') dflt='';;
2209*) dflt="$libs";;
2210esac
2211case "$libswanted" in
2212'') libswanted='c_s';;
2213esac
2214for thislib in $libswanted; do
2215 case "$thislib" in
2216 dbm) thatlib=ndbm;;
2217 *_s) thatlib=NONE;;
85e6fe83 2218 *) thatlib=${thislib}_s;;
2304df62
AD
2219 esac
2220 xxx=`./loc lib$thislib.a X $libpth`
2221 yyy=`./loc lib$thatlib.a X $libpth`
85e6fe83 2222 zzz=`./loc lib$thislib.so.[0-9]'*' X $libpth`
2304df62
AD
2223 if $test -f $xxx; then
2224 echo "Found -l$thislib."
2225 case "$dflt" in
85e6fe83 2226 *"-l$thislib "*|*-l$thislib|*"-l$thatlib "*|*-l$thatlib) ;;
2304df62
AD
2227 *) dflt="$dflt -l$thislib";;
2228 esac
2229 elif $test -f $yyy; then
2230 echo "Found -l$thatlib."
2231 case "$dflt" in
85e6fe83 2232 *"-l$thatlib "*|*-l$thatlib) ;;
2304df62
AD
2233 *) dflt="$dflt -l$thatlib";;
2234 esac
2235 elif $test -f $zzz; then
2236 echo "Found -$thislib."
2237 case "$dflt" in
85e6fe83 2238 *"-l$thislib "*|*-l$thislib) ;;
2304df62
AD
2239 *) dflt="$dflt -l$thislib";;
2240 esac
2241 else
2242 xxx=`./loc Slib$thislib.a X $xlibpth`
2243 yyy=`./loc Slib$thatlib.a X $xlibpth`
2244 if $test -f $xxx; then
2245 echo "Found -l$thislib."
2246 case "$dflt" in
85e6fe83 2247 *"-l$thislib "*|*-l$thislib|*"-l$thatlib "*|*-l$thatlib) ;;
2304df62
AD
2248 *) dflt="$dflt -l$thislib";;
2249 esac
2250 elif $test -f $yyy; then
2251 echo "Found -l$thatlib."
2252 case "$dflt" in
85e6fe83 2253 *"-l$thatlib "*|*-l$thatlib) ;;
2304df62
AD
2254 *) dflt="$dflt -l$thatlib";;
2255 esac
2256 else
2257 echo "No -l$thislib."
2258 fi
2259 fi
2260done
2261set X $dflt
2262shift
2263dflt="$*"
2264case "$libs" in
2265'') dflt="$dflt";;
2266*) dflt="$libs";;
2267esac
2268case "$dflt" in
2269' '|'') dflt='none';;
2270esac
2271
2272$cat <<EOM
2273
2274Some versions of Unix support shared libraries, which make executables smaller
2275but make load time slightly longer.
2276
2277On some systems, mostly newer Unix System V's, the shared library is included
2278by putting the option "-lc_s" as the last thing on the cc command line when
2279linking. Other systems use shared libraries by default. There may be other
2280libraries needed to compile $package on your machine as well. If your system
2281needs the "-lc_s" option, include it here. Include any other special libraries
2282here as well. Say "none" for none.
2283EOM
2284
2285echo " "
2286rp="Any additional libraries?"
2287. ./myread
2288case "$ans" in
2289none) libs=' ';;
2290*) libs="$ans";;
2291esac
2292
2293: see if nm is to be used to determine whether a symbol is defined or not
2294case "$usenm" in
2295'')
2296 dflt=`egrep 'inlibc|csym' ../Configure | wc -l 2>/dev/null`
2297 if $test $dflt -gt 20; then
2298 dflt=y
2299 else
2300 dflt=n
2301 fi
2302 ;;
2303*)
2304 case "$usenm" in
2305 true) dflt=y;;
2306 *) dflt=n;;
2307 esac
2308 ;;
2309esac
2310$cat <<EOM
2311
2312I can use 'nm' to extract the symbols from your C libraries. This is a time
2313consuming task which may generate huge output on the disk (up to 3 megabytes)
2314but that should make the symbols extraction faster. The alternative is to skip
2315the 'nm' extraction part and to compile a small test program instead to
2316determine whether each symbol is present. If you have a fast C compiler and/or
2317if your 'nm' output cannot be parsed, this may be the best solution.
2318
2319EOM
2320rp='Shall I use nm to extract C symbols from the libraries?'
2321. ./myread
2322case "$ans" in
2323n|N) usenm=false;;
2324*) usenm=true;;
2325esac
2326
2327runnm=$usenm
2328case "$reuseval" in
2329true) runnm=false;;
2330esac
2331
2332: nm options which may be necessary
2333case "$nm_opt" in
2334'') if $test -f /mach_boot; then
2335 nm_opt=''
2336 elif $test -d /usr/ccs/lib; then
2337 nm_opt='-p'
2338 elif $test -f /dgux; then
2339 nm_opt='-p'
2340 else
2341 nm_opt=''
2342 fi;;
2343esac
2344
2345case "$runnm" in
2346true)
2347: get list of predefined functions in a handy place
2348echo " "
2349case "$libc" in
2350'') libc=unknown
2351 case "$libs" in
2352 *-lc_s*) libc=`./loc libc_s.a $libc $libpth`
2353 esac
2354 ;;
2355esac
2356libpth="$plibpth $libpth"
2357libnames='';
2358case "$libs" in
2359'') ;;
2360*) for thislib in $libs; do
2361 case "$thislib" in
2362 -l*)
2363 thislib=`expr X$thislib : 'X-l\(.*\)'`
2364 try=`./loc lib$thislib.a blurfl/dyick $libpth`
2365 if test ! -f $try; then
2366 try=`./loc lib$thislib blurfl/dyick $libpth`
2367 if test ! -f $try; then
2368 try=`./loc lib$thislib.so.'*' blurfl/dyick $libpth`
2369 if test ! -f $try; then
2370 try=`./loc $thislib blurfl/dyick $libpth`
2371 if test ! -f $try; then
2372 try=`./loc Slib$thislib.a blurfl/dyick $xlibpth`
2373 if test ! -f $try; then
2374 try=''
2375 fi
2376 fi
2377 fi
2378 fi
2379 fi
2380 libnames="$libnames $try"
2381 ;;
2382 *) libnames="$libnames $thislib" ;;
2383 esac
2384 done
2385 ;;
2386esac
2387xxx=normal
2388case "$libc" in
2389unknown)
2390 set /usr/ccs/lib/libc.so
2391 $test -r $1 || set /usr/lib/libc.so
2392 $test -r $1 || set /usr/shlib/libc.so
2393 $test -r $1 || set /usr/lib/libc.so.[0-9]*
2394 $test -r $1 || set /lib/libsys_s.a
2395 eval set \$$#
2396 ;;
2397*)
2398 set blurfl
2399 ;;
2400esac
2401if $test -r "$1"; then
2402 echo "Your (shared) C library seems to be in $1."
2403 libc="$1"
2404elif $test -r /lib/libc && $test -r /lib/clib; then
2405 echo "Your C library seems to be in both /lib/clib and /lib/libc."
2406 xxx=apollo
2407 libc='/lib/clib /lib/libc'
2408 if $test -r /lib/syslib; then
2409 echo "(Your math library is in /lib/syslib.)"
2410 libc="$libc /lib/syslib"
2411 fi
2412elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
2413 echo "Your C library seems to be in $libc, as you said before."
2414elif $test -r $incpath/usr/lib/libc.a; then
2415 libc=$incpath/usr/lib/libc.a;
2416 echo "Your C library seems to be in $libc. That's fine."
2417elif $test -r /lib/libc.a; then
2418 libc=/lib/libc.a;
2419 echo "Your C library seems to be in $libc. You're normal."
2420else
2421 if tans=`./loc libc.a blurfl/dyick $libpth`; $test -r "$tans"; then
2422 :
2423 elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
2424 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
2425 elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
2426 :
2427 elif tans=`./loc Slibc.a blurfl/dyick $xlibpth`; $test -r "$tans"; then
2428 :
2429 elif tans=`./loc Mlibc.a blurfl/dyick $xlibpth`; $test -r "$tans"; then
2430 :
2431 else
2432 tans=`./loc Llibc.a blurfl/dyick $xlibpth`
2433 fi
2434 if $test -r "$tans"; then
2435 echo "Your C library seems to be in $tans, of all places."
2436 libc=$tans
2437 else
2438 libc='blurfl'
2439 fi
2440fi
2441if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
2442 dflt="$libc"
2443 cat <<EOM
2444
2445If the guess above is wrong (which it might be if you're using a strange
2446compiler, or your machine supports multiple models), you can override it here.
2447
2448EOM
2449else
2450 dflt=''
2451 echo $libpth | tr ' ' '\012' | sort | uniq > libpath
2452 cat >&4 <<EOM
2453I can't seem to find your C library. I've looked in the following places:
2454
2455EOM
2456 $sed 's/^/ /' libpath
2457 cat <<EOM
2458
2459None of these seems to contain your C library. I need to get its name...
2460
2461EOM
2462fi
2463fn=f
2464rp='Where is your C library?'
2465. ./getfile
2466libc="$ans"
2467
2468echo " "
2469echo $libc $libnames | tr ' ' '\012' | sort | uniq > libnames
2470set X `cat libnames`
2471shift
2472xxx=files
2473case $# in 1) xxx=file; esac
2474echo "Extracting names from the following $xxx for later perusal:" >&4
2475echo " "
2476$sed 's/^/ /' libnames >&4
2477echo " "
2478$echo $n "This may take a while...$c" >&4
2479
2480nm $nm_opt $* 2>/dev/null >libc.tmp
2481$echo $n ".$c"
2482$grep fprintf libc.tmp > libc.ptf
2483xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
2484xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
2485if com="$sed -n -e 's/^.* [ADTS] *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
2486 eval $xscan;\
2487 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2488 eval $xrun
2489elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
2490 eval $xscan;\
2491 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2492 eval $xrun
2493elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
2494 eval $xscan;\
2495 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2496 eval $xrun
2497elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
2498 eval $xscan;\
2499 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2500 eval $xrun
2501elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
2502 eval $xscan;\
2503 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2504 eval $xrun
2505elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
2506 eval $xscan;\
2507 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2508 eval $xrun
2509elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
2510 -e '/ file/d' -e 's/^\([^ ]*\).*/\1/p'";\
2511 eval $xscan;\
2512 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2513 eval $xrun
2514elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
2515 eval $xscan;\
2516 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2517 eval $xrun
2518elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
2519 eval $xscan;\
2520 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2521 eval $xrun
2522else
2523 nm -p $* 2>/dev/null >libc.tmp
2524 com="$sed -n -e 's/^.* [ADTS] *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
2525 eval "<libc.tmp $com >libc.list"
2526 if $contains '^fprintf$' libc.list >/dev/null 2>&1; then
2527 nm_opt='-p'
2528 echo "done" >&4
2529 else
2530 echo " "
2531 echo "nm didn't seem to work right. Trying ar instead..." >&4
2532 com=''
2533 if ar t $libc > libc.tmp; then
2534 for thisname in $libnames; do
2535 ar t $thisname >>libc.tmp
2536 done
2537 $sed -e 's/\.o$//' < libc.tmp > libc.list
2538 echo "Ok." >&4
2539 else
2540 echo "ar didn't seem to work right." >&4
2541 echo "Maybe this is a Cray...trying bld instead..." >&4
2542 if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
2543 for thisname in $libnames; do
2544 bld t $libnames | \
2545 $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
2546 ar t $thisname >>libc.tmp
2547 done
2548 echo "Ok." >&4
2549 else
2550 echo "That didn't work either. Giving up." >&4
2551 exit 1
2552 fi
2553 fi
2554 fi
2555fi
2556nm_extract="$com"
2557if $test -f /lib/syscalls.exp; then
2558 echo " "
2559 echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
2560 $sed -n 's/^\([^ ]*\)[ ]*syscall$/\1/p' /lib/syscalls.exp >>libc.list
2561fi
2562;;
2563esac
2564$rm -f libnames libpath
2565
2566: is a C symbol defined?
2567csym='tlook=$1;
2568case "$3" in
2569-v) tf=libc.tmp; tc=""; tdc="";;
2570-a) tf=libc.tmp; tc="[0]"; tdc=[];;
2571*) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
2572esac;
2573tx=yes;
2574case "$reuseval-$4" in
2575true-) ;;
2576true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
2577esac;
2578case "$tx" in
2579yes)
2580 case "$runnm" in
2581 true)
2582 if $contains $tlook $tf >/dev/null 2>&1;
2583 then tval=true;
2584 else tval=false;
2585 fi;;
2586 *)
2587 echo "main() { extern int $1$tdc; printf(\"%d\", $1$tc); }" > t.c;
2588 if $cc $ccflags -o t t.c $ldflags $libs >/dev/null 2>&1;
2589 then tval=true;
2590 else tval=false;
2591 fi;
2592 $rm -f t t.c;;
2593 esac;;
2594*)
2595 case "$tval" in
2596 $define) tval=true;;
2597 *) tval=false;;
2598 esac;;
2599esac;
2600eval "$2=$tval"'
2601
2602: set up the script used to warn in case of inconsistency
2603cat <<'EOSC' >whoa
2604dflt=y
2605echo " "
2606echo "*** WHOA THERE!!! ***" >&4
2607echo " The $hint value for \$$var on this machine was \"$was\"!" >&4
2608rp=" Keep the $hint value?"
2609. ./myread
2610case "$ans" in
2611y) td=$was; tu=$was;;
2612esac
2613EOSC
2614
2615: define an is-in-libc? function
2616inlibc='echo " "; td=$define; tu=$undef;
2617sym=$1; var=$2; eval "was=\$$2";
2618tx=yes;
2619case "$reuseval$was" in
2620true) ;;
2621true*) tx=no;;
2622esac;
2623case "$tx" in
2624yes)
2625 set $sym tres -f;
2626 eval $csym;
2627 case "$tres" in
2628 true)
2629 echo "$sym() found." >&4;
2630 case "$was" in $undef) . whoa; esac; eval "$var=\$td";;
2631 *)
2632 echo "$sym() NOT found." >&4;
2633 case "$was" in $define) . whoa; esac; eval "$var=\$tu";;
2634 esac;;
2635*)
2636 case "$was" in
2637 $define) echo "$sym() found." >&4;;
2638 *) echo "$sym() NOT found." >&4;;
2639 esac;;
2640esac'
2641
2642: see how we invoke the C preprocessor
2643echo " "
2644echo "Now, how can we feed standard input to your C preprocessor..." >&4
2645cat <<'EOT' >testcpp.c
2646#define ABC abc
2647#define XYZ xyz
2648ABC.XYZ
2649EOT
2650cd ..
2651echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
2652chmod 755 cppstdin
2653wrapper=`pwd`/cppstdin
2654ok='false'
2655cd UU
2656
2657if $test "X$cppstdin" != "X" && \
2658 $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
2659 $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
2660then
2661 echo "You used to use $cppstdin $cppminus so we'll use that again."
2662 case "$cpprun" in
2663 '') echo "But let's see if we can live without a wrapper..." ;;
2664 *)
2665 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
2666 $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
2667 then
2668 echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
2669 ok='true'
2670 else
2671 echo "(However, $cpprun $cpplast does not work, let's see...)"
2672 fi
2673 ;;
2674 esac
2675else
2676 case "$cppstdin" in
2677 '') ;;
2678 *)
2679 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
2680 ;;
2681 esac
2682fi
2683
2684if $ok; then
2685 : nothing
2686elif echo 'Maybe "'"$cc"' -E" will work...'; \
2687 $cc -E <testcpp.c >testcpp.out 2>&1; \
2688 $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2689 echo "Yup, it does."
2690 x_cpp="$cc -E"
2691 x_minus='';
2692elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
2693 $cc -E - <testcpp.c >testcpp.out 2>&1; \
2694 $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2695 echo "Yup, it does."
2696 x_cpp="$cc -E"
2697 x_minus='-';
2698elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
2699 $cc -P <testcpp.c >testcpp.out 2>&1; \
2700 $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2701 echo "Yipee, that works!"
2702 x_cpp="$cc -P"
2703 x_minus='';
2704elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
2705 $cc -P - <testcpp.c >testcpp.out 2>&1; \
2706 $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2707 echo "At long last!"
2708 x_cpp="$cc -P"
2709 x_minus='-';
2710elif echo 'No such luck, maybe "'$cpp'" will work...'; \
2711 $cpp <testcpp.c >testcpp.out 2>&1; \
2712 $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2713 echo "It works!"
2714 x_cpp="$cpp"
2715 x_minus='';
2716elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
2717 $cpp - <testcpp.c >testcpp.out 2>&1; \
2718 $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2719 echo "Hooray, it works! I was beginning to wonder."
2720 x_cpp="$cpp"
2721 x_minus='-';
2722elif echo 'Uh-uh. Time to get fancy. Trying a wrapper...'; \
2723 $wrapper <testcpp.c >testcpp.out 2>&1; \
2724 $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2725 x_cpp="$wrapper"
2726 x_minus=''
2727 echo "Eureka!"
2728else
2729 dflt=''
2730 rp="No dice. I can't find a C preprocessor. Name one:"
2731 . ./myread
2732 x_cpp="$ans"
2733 x_minus=''
2734 $x_cpp <testcpp.c >testcpp.out 2>&1
2735 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
2736 echo "OK, that will do." >&4
2737 else
2738echo "Sorry, I can't get that to work. Go find one and rerun Configure." >&4
2739 exit 1
2740 fi
2741fi
2742
2743case "$ok" in
2744false)
2745 cppstdin="$x_cpp"
2746 cppminus="$x_minus"
2747 cpprun="$x_cpp"
2748 cpplast="$x_minus"
2749 set X $x_cpp
2750 shift
2751 case "$1" in
2752 "$cpp")
2753 echo "Perhaps can we force $cc -E using a wrapper..."
2754 if $wrapper <testcpp.c >testcpp.out 2>&1; \
2755 $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
2756 then
2757 echo "Yup, we can."
2758 cppstdin="$wrapper"
2759 cppminus='';
2760 else
2761 echo "Nope, we'll have to live without it..."
2762 fi
2763 ;;
2764 esac
2765 case "$cpprun" in
2766 "$wrapper")
2767 cpprun=''
2768 cpplast=''
2769 ;;
2770 esac
2771 ;;
2772esac
2773
2774case "$cppstdin" in
2775"$wrapper") ;;
2776*) $rm -f $wrapper;;
2777esac
2778$rm -f testcpp.c testcpp.out
2779
2780: determine filename position in cpp output
2781echo " "
2782echo "Computing filename position in cpp output for #include directives..." >&4
2783echo '#include <stdio.h>' > foo.c
2784$cat >fieldn <<EOF
2785$startsh
2786$cppstdin $cppminus $cppflags <foo.c 2>/dev/null | \
2787$grep '^[ ]*#.*stdio\.h' | \
2788while read cline; do
2789 pos=1
2790 set \$cline
2791 while $test \$# -gt 0; do
2792 if $test -r \`echo \$1 | $tr -d '"'\`; then
2793 echo "\$pos"
2794 exit 0
2795 fi
2796 shift
2797 pos=\`expr \$pos + 1\`
2798 done
2799done
2800EOF
2801chmod +x fieldn
2802fieldn=`./fieldn`
2803$rm -f foo.c fieldn
2804case $fieldn in
2805'') pos='???';;
28061) pos=first;;
28072) pos=second;;
28083) pos=third;;
2809*) pos="${fieldn}th";;
2810esac
2811echo "Your cpp writes the filename in the $pos field of the line."
2812
2813: locate header file
2814$cat >findhdr <<EOF
2815$startsh
2816wanted=\$1
2817name=''
2818if test -f $usrinc/\$wanted; then
2819 echo "$usrinc/\$wanted"
2820 exit 0
2821fi
2822awkprg='{ print \$$fieldn }'
2823echo "#include <\$wanted>" > foo\$\$.c
2824$cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
2825$grep "^[ ]*#.*\$wanted" | \
2826while read cline; do
2827 name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
2828 case "\$name" in
2829 */\$wanted) echo "\$name"; exit 0;;
2830 *) name='';;
2831 esac;
2832done;
2833$rm -f foo\$\$.c;
2834case "\$name" in
2835'') exit 1;;
2836esac
2837EOF
2838chmod +x findhdr
2839
2840: access call always available on UNIX
2841set access d_access
2842eval $inlibc
2843
2844: locate the flags for 'access()'
2845case "$d_access" in
2846"$define")
2847 echo " "
2848 $cat >access.c <<'EOCP'
2849#include <sys/types.h>
2850#ifdef I_FCNTL
2851#include <fcntl.h>
2852#endif
2853#ifdef I_SYS_FILE
2854#include <sys/file.h>
2855#endif
2856#ifdef I_UNISTD
2857#include <unistd.h>
2858#endif
2859main() {
2860 exit(R_OK);
2861}
2862EOCP
2863 : check sys/file.h first, no particular reason here
2864 if $test `./findhdr sys/file.h` && \
2865 $cc $cppflags -DI_SYS_FILE access.c -o access >/dev/null 2>&1 ; then
2866 h_sysfile=true;
2867 echo "<sys/file.h> defines the *_OK access constants." >&4
2868 elif $test `./findhdr fcntl.h` && \
2869 $cc $cppflags -DI_FCNTL access.c -o access >/dev/null 2>&1 ; then
2870 h_fcntl=true;
2871 echo "<fcntl.h> defines the *_OK access constants." >&4
85e6fe83
LW
2872 elif $test `./findhdr unistd.h` && \
2873 $cc $cppflags -DI_UNISTD access.c -o access >/dev/null 2>&1 ; then
2874 echo "<unistd.h> defines the *_OK access constants." >&4
2304df62
AD
2875 else
2876 echo "I can't find the four *_OK access constants--I'll use mine." >&4
2877 fi
2878 ;;
2879esac
2880$rm -f access*
2881
2882: see if bcmp exists
2883set bcmp d_bcmp
2884eval $inlibc
2885
2886: see if bcopy exists
2887set bcopy d_bcopy
2888eval $inlibc
2889
2890: see if bzero exists
2891set bzero d_bzero
2892eval $inlibc
2893
2894: check for length of integer
2895echo " "
2896case "$intsize" in
2897'')
2898 echo "Checking to see how big your integers are..." >&4
2899 $cat >try.c <<'EOCP'
2900#include <stdio.h>
2901main()
2902{
2903 printf("%d\n", sizeof(int));
2904}
2905EOCP
2906 if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
2907 dflt=`./try`
2908 else
2909 dflt='4'
2910 echo "(I can't seem to compile the test program. Guessing...)"
2911 fi
2912 ;;
2913*)
2914 dflt="$intsize"
2915 ;;
2916esac
2917rp="What is the size of an integer (in bytes)?"
2918. ./myread
2919intsize="$ans"
2920$rm -f try.c try
2921
2922: function used to set $1 to $val
2923setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2924case "$val$was" in
2925$define$undef) . whoa; eval "$var=\$td";;
2926$undef$define) . whoa; eval "$var=\$tu";;
2927*) eval "$var=$val";;
2928esac'
2929
2930: check for ability to cast large floats to 32-bit ints.
2931echo " "
2932echo 'Checking whether your C compiler can cast large floats to int32.' >&4
85e6fe83 2933if $test "$intsize" -eq 4; then
2304df62
AD
2934 xxx=int
2935else
2936 xxx=long
2937fi
2938
2939$cat >try.c <<EOCP
2940#include <sys/types.h>
2941#include <signal.h>
2942blech() { exit(3); }
2943main()
2944{
2945 $xxx i32;
2946 double f;
2947 int result = 0;
2948 signal(SIGFPE, blech);
2949
2950 f = (double) 0x7fffffff;
2951 f = 10 * f;
2952 i32 = ( $xxx )f;
2953
2954 if (i32 != ( $xxx )f)
2955 result |= 1;
2956 exit(result);
2957}
2958EOCP
2959if $cc -o try $ccflags try.c >/dev/null 2>&1; then
2960 ./try
2961 yyy=$?
2962else
2963 yyy=1
2964fi
2965case "$yyy" in
29660) val="$define"
2967 echo "Yup, it can."
2968 ;;
2969*) val="$undef"
2970 echo "Nope, it can't."
2971 ;;
2972esac
2973set d_casti32
2974eval $setvar
85e6fe83 2975$rm -f try try.*
2304df62
AD
2976: check for ability to cast negative floats to unsigned
2977echo " "
2978echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
2979$cat >try.c <<'EOCP'
2980#include <signal.h>
2981blech() { exit(3); }
2982main()
2983{
2984 double f = -123;
2985 unsigned long along;
2986 unsigned int aint;
2987 unsigned short ashort;
2988 int result = 0;
2989
2990 signal(SIGFPE, blech);
2991 along = (unsigned long)f;
2992 aint = (unsigned int)f;
2993 ashort = (unsigned short)f;
2994 if (along != (unsigned long)-123)
2995 result |= 1;
2996 if (aint != (unsigned int)-123)
2997 result |= 1;
2998 if (ashort != (unsigned short)-123)
2999 result |= 1;
3000 f = (double)0x40000000;
3001 f = f + f;
3002 along = 0;
3003 along = (unsigned long)f;
3004 if (along != 0x80000000)
3005 result |= 2;
3006 f -= 1.;
3007 along = 0;
3008 along = (unsigned long)f;
3009 if (along != 0x7fffffff)
3010 result |= 1;
3011 f += 2.;
3012 along = 0;
3013 along = (unsigned long)f;
3014 if (along != 0x80000001)
3015 result |= 2;
3016 exit(result);
3017
3018}
3019EOCP
3020if $cc -o try $ccflags try.c >/dev/null 2>&1; then
3021 ./try
3022 castflags=$?
3023else
3024 castflags=3
3025fi
3026case "$castflags" in
30270) val="$define"
3028 echo "Yup, it can."
3029 ;;
3030*) val="$undef"
3031 echo "Nope, it can't."
3032 ;;
3033esac
3034set d_castneg
3035eval $setvar
3036$rm -f try.*
3037
3038: see if sprintf is declared as int or pointer to char
3039echo " "
3040$cat >ucbsprf.c <<'EOF'
3041main()
3042{
3043 int sprintf();
3044 char buf[10];
3045 exit((unsigned long)sprintf(buf,"%s","foo") > 10L);
3046}
3047EOF
3048if $cc ucbsprf.c -o ucbsprf >/dev/null 2>&1 && ./ucbsprf; then
3049 echo "Your sprintf() returns (int)." >&4
3050 val="$undef"
3051else
3052 echo "Your sprintf() returns (char*)." >&4
3053 val="$define"
3054fi
3055set d_charsprf
3056eval $setvar
3057$rm -f ucbsprf*
3058
3059: see if vprintf exists
3060echo " "
3061if set vprintf val -f d_vprintf; eval $csym; $val; then
3062 echo 'vprintf() found.' >&4
3063 val="$define"
3064 $cat >vprintf.c <<'EOF'
3065#include <varargs.h>
3066
3067main() { xxx("foo"); }
3068
3069xxx(va_alist)
3070va_dcl
3071{
3072 va_list args;
3073 char buf[10];
3074
3075 va_start(args);
3076 exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
3077}
3078EOF
3079 if $cc $ccflags vprintf.c -o vprintf >/dev/null 2>&1 && ./vprintf; then
3080 echo "Your vsprintf() returns (int)." >&4
3081 val2="$undef"
3082 else
3083 echo "Your vsprintf() returns (char*)." >&4
3084 val2="$define"
3085 fi
3086else
3087 echo 'vprintf() NOT found.' >&4
3088 val="$undef"
3089 val2="$undef"
3090fi
3091set d_vprintf
3092eval $setvar
3093val=$val2
3094set d_charvspr
3095eval $setvar
3096
3097: see if chsize exists
3098set chsize d_chsize
3099eval $inlibc
3100
3101: check for const keyword
3102echo " "
3103echo 'Checking to see if your C compiler knows about "const"...' >&4
3104$cat >const.c <<'EOCP'
3105typedef struct spug { int drokk; } spug;
3106main()
3107{
3108 const char *foo;
3109 const spug y;
3110}
3111EOCP
3112if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
3113 val="$define"
3114 echo "Yup, it does."
3115else
3116 val="$undef"
3117 echo "Nope, it doesn't."
3118fi
3119set d_const
3120eval $setvar
3121
3122: see if crypt exists
3123echo " "
3124if set crypt val -f d_crypt; eval $csym; $val; then
3125 echo 'crypt() found.' >&4
3126 val="$define"
3127 cryptlib=''
3128else
3129 cryptlib=`./loc Slibcrypt.a "" $xlibpth`
3130 if $test -z "$cryptlib"; then
3131 cryptlib=`./loc Mlibcrypt.a "" $xlibpth`
3132 else
3133 cryptlib=-lcrypt
3134 fi
3135 if $test -z "$cryptlib"; then
3136 cryptlib=`./loc Llibcrypt.a "" $xlibpth`
3137 else
3138 cryptlib=-lcrypt
3139 fi
3140 if $test -z "$cryptlib"; then
3141 cryptlib=`./loc libcrypt.a "" $libpth`
3142 else
3143 cryptlib=-lcrypt
3144 fi
3145 if $test -z "$cryptlib"; then
3146 echo 'crypt() NOT found.' >&4
3147 val="$undef"
3148 else
3149 val="$define"
3150 fi
3151fi
3152set d_crypt
3153eval $setvar
3154
3155: get csh whereabouts
3156case "$csh" in
3157'csh') val="$undef" ;;
3158*) val="$define" ;;
3159esac
3160set d_csh
3161eval $setvar
3162
3163: see if this is a dirent system
3164echo " "
3165if xinc=`./findhdr dirent.h`; $test "$xinc"; then
3166 val="$define"
3167 echo "<dirent.h> found." >&4
3168else
3169 val="$undef"
3170 if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
3171 echo "<sys/dir.h> found." >&4
3172 echo " "
3173 else
3174 xinc=`./findhdr sys/ndir.h`
3175 fi
3176 echo "<dirent.h> NOT found." >&4
3177fi
3178set i_dirent
3179eval $setvar
3180
3181: see if the directory entry stores field length
3182echo " "
3183if $contains 'd_namlen' $xinc >/dev/null 2>&1; then
3184 echo "Good, your directory entry keeps length information in d_namlen." >&4
3185 val="$define"
3186else
3187 echo "Your directory entry does not know about the d_namlen field." >&4
3188 val="$undef"
3189fi
3190set d_dirnamlen
3191eval $setvar
3192
3193: now see if they want to do setuid emulation
3194case "$d_dosuid" in
3195'') dflt=n;;
3196"$undef") dflt=n;;
3197*) dflt=y;;
3198esac
3199cat <<EOM
3200
3201Some sites have disabled setuid #! scripts because of a bug in the kernel
3202that prevents them from being secure. If you are on such a system, the
3203setuid/setgid bits on scripts are currently useless. It is possible for
3204$package to detect those bits and emulate setuid/setgid in a secure fashion
3205until a better solution is devised for the kernel problem.
3206
3207EOM
3208rp="Do you want to do setuid/setgid emulation?"
3209. ./myread
3210case "$ans" in
3211y*) d_dosuid="$define";;
3212*) d_dosuid="$undef";;
3213esac
3214
3215: see if dup2 exists
3216set dup2 d_dup2
3217eval $inlibc
3218
3219: see if fchmod exists
3220set fchmod d_fchmod
3221eval $inlibc
3222
3223: see if fchown exists
3224set fchown d_fchown
3225eval $inlibc
3226
3227: see if this is an fcntl system
3228set fcntl d_fcntl
3229eval $inlibc
3230
3231: see if we can have long filenames
3232echo " "
3233rmlist="$rmlist /tmp/cf$$"
3234$test -d /tmp/cf$$ || mkdir /tmp/cf$$
3235first=123456789abcdef
3236second=/tmp/cf$$/$first
3237$rm -f $first $second
3238if (echo hi >$first) 2>/dev/null; then
3239 if $test -f 123456789abcde; then
3240 echo 'You cannot have filenames longer than 14 characters. Sigh.' >&4
3241 val="$undef"
3242 else
3243 if (echo hi >$second) 2>/dev/null; then
3244 if $test -f /tmp/cf$$/123456789abcde; then
3245 $cat <<'EOM'
3246That's peculiar... You can have filenames longer than 14 characters, but only
3247on some of the filesystems. Maybe you are using NFS. Anyway, to avoid problems
3248I shall consider your system cannot support long filenames at all.
3249EOM
3250 val="$undef"
3251 else
3252 echo 'You can have filenames longer than 14 characters.' >&4
3253 val="$define"
3254 fi
3255 else
3256 $cat <<'EOM'
3257How confusing! Some of your filesystems are sane enough to allow filenames
3258longer than 14 characters but some others like /tmp can't even think about them.
3259So, for now on, I shall assume your kernel does not allow them at all.
3260EOM
3261 val="$undef"
3262 fi
3263 fi
3264else
3265 $cat <<'EOM'
3266You can't have filenames longer than 14 chars. You can't even think about them!
3267EOM
3268 val="$undef"
3269fi
3270set d_flexfnam
3271eval $setvar
3272$rm -rf /tmp/cf$$ 123456789abcde*
3273
3274: see if flock exists
3275set flock d_flock
3276eval $inlibc
3277
3278: see if gethostent exists
3279set gethostent d_gethent
3280eval $inlibc
3281
3282: see if getpgrp exists
3283set getpgrp d_getpgrp
3284eval $inlibc
3285
3286: see if getpgrp2 exists
3287set getpgrp2 d_getpgrp2
3288eval $inlibc
3289
3290: see if getpriority exists
3291set getpriority d_getprior
3292eval $inlibc
3293
85e6fe83
LW
3294: define an alternate in-header-list? function
3295inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
3296cont=true; xxf="echo \"<\$1> found.\" >&4";
3297case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
3298*) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
3299esac;
3300case $# in 4) instead=instead;; *) instead="at last";; esac;
3301while $test "$cont"; do
3302 xxx=`./findhdr $1`
3303 var=$2; eval "was=\$$2";
3304 if $test "$xxx" && $test -r "$xxx";
3305 then eval $xxf;
3306 eval "case \"\$$var\" in $undef) . whoa; esac"; eval "$var=\$td";
3307 cont="";
3308 else eval $xxnf;
3309 eval "case \"\$$var\" in $define) . whoa; esac"; eval "$var=\$tu"; fi;
3310 set $yyy; shift; shift; yyy=$@;
3311 case $# in 0) cont="";;
3312 2) xxf="echo \"but I found <\$1> $instead.\" >&4";
3313 xxnf="echo \"and I did not find <\$1> either.\" >&4";;
3314 *) xxf="echo \"but I found <\$1\> instead.\" >&4";
3315 xxnf="echo \"there is no <\$1>, ...\" >&4";;
3316 esac;
3317done;
3318while $test "$yyy";
3319do set $yyy; var=$2; eval "was=\$$2";
3320 eval "case \"\$$var\" in $define) . whoa; esac"; eval "$var=\$tu";
3321 set $yyy; shift; shift; yyy=$@;
3322done'
3323
3324: see if this is a netinet/in.h or sys/in.h system
3325set netinet/in.h i_niin sys/in.h i_sysin
3326eval $inhdr
3327
2304df62
AD
3328: see if htonl --and friends-- exists
3329set htonl d_htonl
3330eval $inlibc
85e6fe83
LW
3331: Maybe they are macros.
3332case "$d_htonl" in
3333'define') ;;
3334*) cat > try.c <<EOM
3335#include <stdio.h>
3336#include <sys/types.h>
3337#$i_niin I_NETINET_IN
3338#$i_sysin I_SYS_IN
3339#ifdef I_NETINET_IN
3340# include <netinet/in.h>
3341#endif
3342#ifdef I_SYS_IN
3343# include <sys/in.h>
3344#endif
3345int main()
3346{
3347 int x;
3348 printf("x = ", htonl(7));
3349}
3350EOM
3351 if $cc $ccflags -c try.c >/dev/null 2>&1; then
3352 d_htonl="$define"
3353 echo "But it seems to be defined as a macro."
3354 fi
3355 $rm -f try.* try
3356 ;;
3357esac
2304df62
AD
3358: Look for isascii
3359echo " "
3360$cat >isascii.c <<'EOCP'
3361#include <stdio.h>
3362#include <ctype.h>
3363main() {
3364 int c = 'A';
3365 if (isascii(c))
3366 exit(0);
3367 else
3368 exit(1);
3369}
3370EOCP
3371if $cc $cppflags -o isascii isascii.c >/dev/null 2>&1 ; then
3372 echo "isascii() found."
3373 val="$define"
3374else
3375 echo "isascii() NOT found."
3376 val="$undef"
3377fi
3378set d_isascii
3379eval $setvar
3380$rm -f isascii*
3381: see if killpg exists
3382set killpg d_killpg
3383eval $inlibc
3384
3385: see if link exists
3386set link d_link
3387eval $inlibc
3388
3389: see if lstat exists
3390set lstat d_lstat
3391eval $inlibc
3392
3393: see if memcmp exists
3394set memcmp d_memcmp
3395eval $inlibc
3396
3397: see if memcpy exists
3398set memcpy d_memcpy
3399eval $inlibc
3400
3401: see if memmove exists
3402set memmove d_memmove
3403eval $inlibc
3404
3405: see if memset exists
3406set memset d_memset
3407eval $inlibc
3408
3409: see if mkdir exists
3410set mkdir d_mkdir
3411eval $inlibc
3412
3413: see if msgctl exists
3414set msgctl d_msgctl
3415eval $inlibc
3416
3417: see if msgget exists
3418set msgget d_msgget
3419eval $inlibc
3420
3421: see if msgsnd exists
3422set msgsnd d_msgsnd
3423eval $inlibc
3424
3425: see if msgrcv exists
3426set msgrcv d_msgrcv
3427eval $inlibc
3428
3429: see how much of the 'msg*(2)' library is present.
3430h_msg=true
3431echo " "
3432case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
3433*"$undef"*) h_msg=false;;
3434esac
3435: we could also check for sys/ipc.h ...
3436if $h_msg && $test `./findhdr sys/msg.h`; then
3437 echo "You have the full msg*(2) library." >&4
3438 val="$define"
3439else
3440 echo "You don't have the full msg*(2) library." >&4
3441 val="$undef"
3442fi
3443set d_msg
3444eval $setvar
3445
85e6fe83
LW
3446: determine which malloc to compile in
3447: Old versions had dflt='y' only for bsd or v7.
3448echo " "
3449case "$usemymalloc" in
3450'')
3451 if bsd || v7; then
3452 dflt='y'
3453 else
3454 dflt='y'
3455 fi
3456 ;;
3457*) dflt="$usemymalloc"
3458 ;;
3459esac
3460rp="Do you wish to attempt to use the malloc that comes with $package?"
3461. ./myread
3462usemymalloc="$ans"
3463case "$ans" in
3464y*) mallocsrc='malloc.c'
3465 mallocobj='malloc.o'
3466 d_mymalloc="$define"
3467 ;;
3468*) mallocsrc=''
3469 mallocobj=''
3470 d_mymalloc="$undef"
3471 ;;
3472esac
3473
3474: compute the type returned by malloc
3475echo " "
3476case "$malloctype" in
3477'')
3478 if $test `./findhdr malloc.h`; then
3479 echo "#include <malloc.h>" > malloc.c
3480 fi
3481#include <malloc.h>
3482 $cat >>malloc.c <<'END'
3483void *malloc();
3484END
3485 if $cc $ccflags -c malloc.c >/dev/null 2>&1; then
3486 malloctype='void *'
3487 else
3488 malloctype='char *'
3489 fi
3490 $rm -f malloc.[co]
3491 ;;
3492esac
3493echo "Your system wants malloc to return '$malloctype', it would seem." >&4
3494
2304df62
AD
3495socketlib=''
3496sockethdr=''
3497: see whether socket exists
3498echo " "
3499$echo $n "Hmm... $c" >&4
3500if set socket val -f d_socket; eval $csym; $val; then
3501 echo "Looks like you have Berkeley networking support." >&4
3502 d_socket="$define"
3503 if set setsockopt val -f; eval $csym; $val; then
3504 d_oldsock="$undef"
3505 else
3506 echo "...but it uses the old 4.1c interface, rather than 4.2" >&4
3507 d_oldsock="$define"
3508 fi
3509else
3510 if $contains socklib libc.list >/dev/null 2>&1; then
3511 echo "Looks like you have Berkeley networking support." >&4
3512 d_socket="$define"
3513 : we will have to assume that it supports the 4.2 BSD interface
3514 d_oldsock="$undef"
3515 else
3516 echo "You don't have Berkeley networking in libc.a..." >&4
3517 if test -f /usr/lib/libnet.a; then
3518 ( (nm $nm_opt /usr/lib/libnet.a | eval $nm_extract) || \
3519 ar t /usr/lib/libnet.a) 2>/dev/null >> libc.list
3520 if $contains socket libc.list >/dev/null 2>&1; then
3521 echo "...but the Wollongong group seems to have hacked it in." >&4
3522 socketlib="-lnet"
3523 sockethdr="-I/usr/netinclude"
3524 d_socket="$define"
3525 if $contains setsockopt libc.list >/dev/null 2>&1; then
3526 d_oldsock="$undef"
3527 else
3528 echo "...using the old 4.1c interface, rather than 4.2" >&4
3529 d_oldsock="$define"
3530 fi
3531 else
3532 echo "or even in libnet.a, which is peculiar." >&4
3533 d_socket="$undef"
3534 d_oldsock="$undef"
3535 fi
3536 else
3537 echo "or anywhere else I see." >&4
3538 d_socket="$undef"
3539 d_oldsock="$undef"
3540 fi
3541 fi
3542fi
3543
3544: see if socketpair exists
3545set socketpair d_sockpair
3546eval $inlibc
3547
3548: Locate the flags for 'open()'
3549echo " "
3550$cat >open3.c <<'EOCP'
3551#include <sys/types.h>
3552#ifdef I_FCNTL
3553#include <fcntl.h>
3554#endif
3555#ifdef I_SYS_FILE
3556#include <sys/file.h>
3557#endif
3558main() {
3559 if(O_RDONLY);
3560#ifdef O_TRUNC
3561 exit(0);
3562#else
3563 exit(1);
3564#endif
3565}
3566EOCP
3567: check sys/file.h first to get FREAD on Sun
3568if $test `./findhdr sys/file.h` && \
3569 $cc $cppflags "-DI_SYS_FILE" open3.c -o open3 >/dev/null 2>&1 ; then
3570 h_sysfile=true;
3571 echo "<sys/file.h> defines the O_* constants..." >&4
3572 if ./open3; then
3573 echo "and you have the 3 argument form of open()." >&4
3574 val="$define"
3575 else
3576 echo "but not the 3 argument form of open(). Oh, well." >&4
3577 val="$undef"
3578 fi
3579elif $test `./findhdr fcntl.h` && \
3580 $cc "-DI_FCNTL" open3.c -o open3 >/dev/null 2>&1 ; then
3581 h_fcntl=true;
3582 echo "<fcntl.h> defines the O_* constants..." >&4
3583 if ./open3; then
3584 echo "and you have the 3 argument form of open()." >&4
3585 val="$define"
3586 else
3587 echo "but not the 3 argument form of open(). Oh, well." >&4
3588 val="$undef"
3589 fi
3590else
3591 val="$undef"
3592 echo "I can't find the O_* constant definitions! You got problems." >&4
3593fi
3594set d_open3
3595eval $setvar
3596$rm -f open3*
3597
3598: see if this is a pwd system
3599echo " "
3600xxx=`./findhdr pwd.h`
3601if $test "$xxx"; then
3602 i_pwd="$define"
3603 echo "<pwd.h> found." >&4
85e6fe83 3604 $cppstdin $cppflags $cppminus < $xxx >$$.h
2304df62
AD
3605 if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
3606 d_pwquota="$define"
3607 else
3608 d_pwquota="$undef"
3609 fi
3610 if $contains 'pw_age' $$.h >/dev/null 2>&1; then
3611 d_pwage="$define"
3612 else
3613 d_pwage="$undef"
3614 fi
3615 if $contains 'pw_change' $$.h >/dev/null 2>&1; then
3616 d_pwchange="$define"
3617 else
3618 d_pwchange="$undef"
3619 fi
3620 if $contains 'pw_class' $$.h >/dev/null 2>&1; then
3621 d_pwclass="$define"
3622 else
3623 d_pwclass="$undef"
3624 fi
3625 if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
3626 d_pwexpire="$define"
3627 else
3628 d_pwexpire="$undef"
3629 fi
3630 if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
3631 d_pwcomment="$define"
3632 else
3633 d_pwcomment="$undef"
3634 fi
3635 $rm -f $$.h
3636else
3637 i_pwd="$undef"
3638 d_pwquota="$undef"
3639 d_pwage="$undef"
3640 d_pwchange="$undef"
3641 d_pwclass="$undef"
3642 d_pwexpire="$undef"
3643 d_pwcomment="$undef"
3644 echo "<pwd.h> NOT found." >&4
3645fi
3646
85e6fe83 3647: see if readdir and friends exist
2304df62
AD
3648set readdir d_readdir
3649eval $inlibc
85e6fe83
LW
3650set seekdir d_seekdir
3651eval $inlibc
3652set telldir d_telldir
3653eval $inlibc
3654set rewinddir d_rewinddir
3655eval $inlibc
2304df62
AD
3656
3657: see if rename exists
3658set rename d_rename
3659eval $inlibc
3660
3661: see if rmdir exists
3662set rmdir d_rmdir
3663eval $inlibc
3664
3665: can bcopy handle overlapping blocks?
3666val="$undef"
3667case "$d_bcopy" in
3668"$define")
3669 echo " "
3670 echo "Checking to see if your bcopy() can do overlapping copies..." >&4
3671 $cat >foo.c <<'EOCP'
3672main()
3673{
85e6fe83
LW
3674char buf[128], abc[128];
3675char *b;
3676int len;
3677int off;
3678int align;
3679bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
2304df62
AD
3680
3681for (align = 7; align >= 0; align--) {
3682 for (len = 36; len; len--) {
3683 b = buf+align;
85e6fe83 3684 bcopy(abc, b, len);
2304df62
AD
3685 for (off = 1; off <= len; off++) {
3686 bcopy(b, b+off, len);
3687 bcopy(b+off, b, len);
85e6fe83 3688 if (bcmp(b, abc, len))
2304df62
AD
3689 exit(1);
3690 }
3691 }
3692}
3693exit(0);
3694}
3695EOCP
3696 if $cc foo.c -o safebcpy $ccflags $libs >/dev/null 2>&1 ; then
3697 if ./safebcpy 2>/dev/null; then
3698 echo "Yes, it can."
3699 val="$define"
3700 else
3701 echo "It can't, sorry."
3702 fi
3703 else
3704 echo "(I can't compile the test program, so we'll assume not...)"
3705 fi
3706 ;;
3707esac
3708$rm -f foo.* safebcpy core
3709set d_safebcpy
3710eval $setvar
3711
3712: can memcpy handle overlapping blocks?
3713val="$undef"
3714case "$d_memcpy" in
3715"$define")
3716 echo " "
3717 echo "Checking to see if your memcpy() can do overlapping copies..." >&4
3718 $cat >foo.c <<'EOCP'
3719main()
3720{
85e6fe83
LW
3721char buf[128], abc[128];
3722char *b;
3723int len;
3724int off;
3725int align;
3726
3727memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
2304df62
AD
3728
3729for (align = 7; align >= 0; align--) {
3730 for (len = 36; len; len--) {
3731 b = buf+align;
85e6fe83 3732 memcpy(abc, b, len);
2304df62
AD
3733 for (off = 1; off <= len; off++) {
3734 memcpy(b, b+off, len);
3735 memcpy(b+off, b, len);
85e6fe83 3736 if (memcmp(b, abc, len))
2304df62
AD
3737 exit(1);
3738 }
3739 }
3740}
3741exit(0);
3742}
3743EOCP
3744 if $cc foo.c -o safemcpy $ccflags $libs >/dev/null 2>&1 ; then
3745 if ./safemcpy 2>/dev/null; then
3746 echo "Yes, it can."
3747 val="$define"
3748 else
3749 echo "It can't, sorry."
3750 fi
3751 else
3752 echo "(I can't compile the test program, so we'll assume not...)"
3753 fi
3754 ;;
3755esac
3756$rm -f foo.* safemcpy core
3757set d_safemcpy
3758eval $setvar
3759
3760: see if select exists
3761set select d_select
3762eval $inlibc
3763
3764: see if semctl exists
3765set semctl d_semctl
3766eval $inlibc
3767
3768: see if semget exists
3769set semget d_semget
3770eval $inlibc
3771
3772: see if semop exists
3773set semop d_semop
3774eval $inlibc
3775
3776: see how much of the 'sem*(2)' library is present.
3777h_sem=true
3778echo " "
3779case "$d_semctl$d_semget$d_semop" in
3780*"$undef"*) h_sem=false;;
3781esac
3782: we could also check for sys/ipc.h ...
3783if $h_sem && $test `./findhdr sys/sem.h`; then
3784 echo "You have the full sem*(2) library." >&4
3785 val="$define"
3786else
3787 echo "You don't have the full sem*(2) library." >&4
3788 val="$undef"
3789fi
3790set d_sem
3791eval $setvar
3792
3793: see if setegid exists
3794set setegid d_setegid
3795eval $inlibc
3796
3797: see if seteuid exists
3798set seteuid d_seteuid
3799eval $inlibc
3800
3801: see if setlocale exists
3802set setlocale d_setlocale
3803eval $inlibc
3804: see if setpgid exists
3805set setpgid d_setpgid
3806eval $inlibc
3807
3808: see if setpgrp exists
3809set setpgrp d_setpgrp
3810eval $inlibc
3811
3812: see if setpgrp2 exists
3813set setpgrp2 d_setpgrp2
3814eval $inlibc
3815
3816: see if setpriority exists
3817set setpriority d_setprior
3818eval $inlibc
3819
3820: see if setregid exists
3821set setregid d_setregid
3822eval $inlibc
3823set setresgid d_setresgid
3824eval $inlibc
3825
3826: see if setreuid exists
3827set setreuid d_setreuid
3828eval $inlibc
3829set setresuid d_setresuid
3830eval $inlibc
3831
3832: see if setrgid exists
3833set setrgid d_setrgid
3834eval $inlibc
3835
3836: see if setruid exists
3837set setruid d_setruid
3838eval $inlibc
3839
3840: see if setsid exists
3841set setsid d_setsid
3842eval $inlibc
3843
3844: see if shmctl exists
3845set shmctl d_shmctl
3846eval $inlibc
3847
3848: see if shmget exists
3849set shmget d_shmget
3850eval $inlibc
3851
3852: see if shmat exists
3853set shmat d_shmat
3854eval $inlibc
85e6fe83
LW
3855: see what shmat returns
3856d_voidshmat="$undef"
3857case "$d_shmat" in
3858define)
3859 $cppstdin $cppflags $cppminus < $usrinc/sys/shm.h >voidshmat.txt 2>/dev/null
3860 if $contains "void.*shmat" voidshmat.txt >/dev/null 2>&1; then
3861 echo "and shmat returns (void*)"
3862 d_voidshmat="$define"
3863 else
3864 echo "and shmat returns (char*)"
3865 fi
3866 ;;
3867esac
2304df62
AD
3868: see if shmdt exists
3869set shmdt d_shmdt
3870eval $inlibc
3871
3872: see how much of the 'shm*(2)' library is present.
3873h_shm=true
3874echo " "
3875case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
3876*"$undef"*) h_shm=false;;
3877esac
3878: we could also check for sys/ipc.h ...
3879if $h_shm && $test `./findhdr sys/shm.h`; then
3880 echo "You have the full shm*(2) library." >&4
3881 val="$define"
3882else
3883 echo "You don't have the full shm*(2) library." >&4
3884 val="$undef"
3885fi
3886set d_shm
3887eval $setvar
3888
3889: see if stat knows about block sizes
3890echo " "
3891xxx=`./findhdr sys/stat.h`
3892if $contains 'st_blocks;' "$xxx" >/dev/null 2>&1 ; then
3893 if $contains 'st_blksize;' "$xxx" >/dev/null 2>&1 ; then
3894 echo "Your stat() knows about block sizes." >&4
3895 val="$define"
3896 else
3897 echo "Your stat() doesn't know about block sizes." >&4
3898 val="$undef"
3899 fi
3900else
3901 echo "Your stat() doesn't know about block sizes." >&4
3902 val="$undef"
3903fi
3904set d_statblks
3905eval $setvar
3906
3907: see if stdio is really std
3908echo " "
3909xxx=`./findhdr stdio.h`
3910if $contains 'char.*_ptr;' "$xxx" >/dev/null 2>&1 ; then
3911 if $contains '_cnt;' "$xxx" >/dev/null 2>&1 ; then
3912 echo "Your stdio is pretty std." >&4
3913 val="$define"
3914 else
3915 echo "Your stdio isn't very std." >&4
3916 val="$undef"
3917 fi
3918else
3919 echo "Your stdio isn't very std." >&4
3920 val="$undef"
3921fi
3922set d_stdstdio
3923eval $setvar
3924
3925: see which of string.h or strings.h is needed
3926echo " "
3927strings=`./findhdr string.h`
3928if $test "$strings" && $test -r "$strings"; then
3929 echo "Using <string.h> instead of <strings.h>." >&4
3930 val="$define"
3931else
3932 val="$undef"
3933 strings=`./findhdr strings.h`
3934 if $test "$strings" && $test -r "$strings"; then
3935 echo "Using <strings.h> instead of <string.h>." >&4
3936 else
3937 echo "No string header found -- You'll surely have problems." >&4
3938 fi
3939fi
3940set i_string
3941eval $setvar
3942case "$i_string" in
3943"$undef") strings=`./findhdr strings.h`;;
3944*) strings=`./findhdr string.h`;;
3945esac
3946
3947: index or strchr
3948echo " "
3949if set index val -f; eval $csym; $val; then
3950 if set strchr val -f d_strchr; eval $csym; $val; then
3951 if $contains strchr "$strings" >/dev/null 2>&1 ; then
3952 val="$define"
3953 vali="$undef"
3954 echo "strchr() found." >&4
3955 else
3956 val="$undef"
3957 vali="$define"
3958 echo "index() found." >&4
3959 fi
3960 else
3961 val="$undef"
3962 vali="$define"
3963 echo "index() found." >&4
3964 fi
3965else
3966 if set strchr val -f d_strchr; eval $csym; $val; then
3967 val="$define"
3968 vali="$undef"
3969 echo "strchr() found." >&4
3970 else
3971 echo "No index() or strchr() found!" >&4
3972 val="$undef"
3973 vali="$undef"
3974 fi
3975fi
3976set d_strchr; eval $setvar
3977val="$vali"
3978set d_index; eval $setvar
3979
3980: check for structure copying
3981echo " "
3982echo "Checking to see if your C compiler can copy structs..." >&4
3983$cat >try.c <<'EOCP'
3984main()
3985{
3986 struct blurfl {
3987 int dyick;
3988 } foo, bar;
3989
3990 foo = bar;
3991}
3992EOCP
3993if $cc -c try.c >/dev/null 2>&1 ; then
3994 val="$define"
3995 echo "Yup, it can."
3996else
3997 val="$undef"
3998 echo "Nope, it can't."
3999fi
4000set d_strctcpy
4001eval $setvar
4002$rm -f try.*
4003
4004: see if strerror and/or sys_errlist[] exist
4005echo " "
4006if set strerror val -f d_strerror; eval $csym; $val; then
4007 echo 'strerror() found.' >&4
4008 d_strerror="$define"
4009 d_strerrm="$undef"
4010 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
4011 echo "(You also have sys_errlist[], so we could roll our own strerror.)"
4012 d_syserrlst="$define"
4013 else
4014 echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
4015 d_syserrlst="$undef"
4016 fi
4017elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
4018 $contains '#[ ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
4019 echo 'strerror() found in string header.' >&4
4020 d_strerror="$define"
4021 d_strerrm="$undef"
4022 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
4023 echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
4024 d_syserrlst="$define"
4025 else
4026 echo "(You don't appear to have any sys_errlist[], how can this be?)"
4027 d_syserrlst="$undef"
4028 fi
4029elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
4030echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
4031 d_strerror="$undef"
4032 d_syserrlst="$define"
4033 d_strerrm="$define"
4034else
4035 echo 'strerror() and sys_errlist[] NOT found.' >&4
4036 d_strerror="$undef"
4037 d_syserrlst="$undef"
4038 d_strerrm="$undef"
4039fi
4040
4041: see if symlink exists
4042set symlink d_symlink
4043eval $inlibc
4044
4045: see if syscall exists
4046set syscall d_syscall
4047eval $inlibc
4048
4049: see if system exists
4050set system d_system
4051eval $inlibc
4052
4053: see if times exists
4054echo " "
4055if set times val -f d_times; eval $csym; $val; then
4056 echo 'times() found.' >&4
4057 d_times="$define"
4058 case "$clocktype" in
4059 '')
4060 if $contains 'clock_t;' `./findhdr sys/types.h` >/dev/null 2>&1 ; then
4061 dflt='clock_t';
4062 elif $contains 'clock_t;' `./findhdr sys/times.h` >/dev/null 2>&1; then
4063 dflt='clock_t';
4064 else
4065 dflt='long';
4066 fi
4067 ;;
4068 *) dflt="$clocktype"
4069 ;;
4070 esac
4071 echo " "
4072 rp="What type is returned by times() on this sytem?"
4073 . ./myread
4074 clocktype="$ans"
4075else
4076 echo 'times() not found, hope that will do.' >&4
4077 d_times="$undef"
4078 clocktype='int'
4079fi
4080
4081: see if truncate exists
4082set truncate d_truncate
4083eval $inlibc
4084
4085: see if we have to deal with yellow pages, now NIS.
4086if $test -d /usr/etc/yp || $test -d /etc/yp; then
4087 if $test -f /usr/etc/nibindd; then
4088 echo " "
4089 echo "I'm fairly confident you're on a NeXT."
4090 echo " "
4091 rp='Do you get the hosts file via NetInfo?'
4092 dflt=y
4093 case "$hostcat" in
4094 nidump*) ;;
4095 '') ;;
4096 *) dflt=n;;
4097 esac
4098 . ./myread
4099 case "$ans" in
4100 y*) hostcat='nidump hosts .';;
4101 *) hostcat='cat /etc/hosts';;
4102 esac
4103 fi
4104 case "$hostcat" in
4105 nidump*) ;;
4106 *)
4107 case "$hostcat" in
4108 *ypcat*) dflt=y;;
4109 '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
4110 dflt=y
4111 else
4112 dflt=n
4113 fi;;
4114 *) dflt=n;;
4115 esac
4116 echo " "
4117 rp='Are you getting the hosts file via yellow pages?'
4118 . ./myread
4119 case "$ans" in
4120 y*) hostcat='ypcat hosts';;
4121 *) hostcat='cat /etc/hosts';;
4122 esac
4123 ;;
4124 esac
4125fi
4126
4127: now get the host name
4128echo " "
4129echo "Figuring out host name..." >&4
4130case "$myhostname" in
4131'') cont=true
4132 echo 'Maybe "hostname" will work...'
4133 if tans=`sh -c hostname 2>&1` ; then
4134 myhostname=$tans
4135 phostname=hostname
4136 cont=''
4137 fi
4138 ;;
4139*) cont='';;
4140esac
4141if $test "$cont"; then
4142 if xenix; then
4143 echo 'Oh, dear. Maybe "/etc/systemid" is the key...'
4144 if tans=`cat /etc/systemid 2>&1` ; then
4145 myhostname=$tans
4146 phostname='cat /etc/systemid'
4147 echo "Whadyaknow. Xenix always was a bit strange..."
4148 cont=''
4149 fi
4150 elif $test -r /etc/systemid; then
4151 echo "(What is a non-Xenix system doing with /etc/systemid?)"
4152 fi
4153fi
4154if $test "$cont"; then
4155 echo 'No, maybe "uuname -l" will work...'
4156 if tans=`sh -c 'uuname -l' 2>&1` ; then
4157 myhostname=$tans
4158 phostname='uuname -l'
4159 else
4160 echo 'Strange. Maybe "uname -n" will work...'
4161 if tans=`sh -c 'uname -n' 2>&1` ; then
4162 myhostname=$tans
4163 phostname='uname -n'
4164 else
4165 echo 'Oh well, maybe I can mine it out of whoami.h...'
4166 if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
4167 myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
4168 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
4169 else
4170 case "$myhostname" in
4171 '') echo "Does this machine have an identity crisis or something?"
4172 phostname='';;
4173 *)
4174 echo "Well, you said $myhostname before..."
4175 phostname='echo $myhostname';;
4176 esac
4177 fi
4178 fi
4179 fi
4180fi
4181: you do not want to know about this
4182set $myhostname
4183myhostname=$1
4184
4185: translate upper to lower if necessary
4186case "$myhostname" in
4187*[A-Z]*)
4188 myhostname=`echo $myhostname | tr '[A-Z]' '[a-z]'`
4189 echo "(Normalizing case in your host name)"
4190 ;;
4191esac
4192
4193: verify guess
4194if $test "$myhostname" ; then
4195 dflt=y
4196 rp='Your host name appears to be "'$myhostname'".'" Right?"
4197 . ./myread
4198 case "$ans" in
4199 y*) ;;
4200 *) myhostname='';;
4201 esac
4202fi
4203
4204: bad guess or no guess
4205while $test "X$myhostname" = X ; do
4206 dflt=''
4207 rp="Please type the (one word) name of your host:"
4208 . ./myread
4209 myhostname="$ans"
4210done
4211
4212: a little sanity check here
4213case "$phostname" in
4214'') ;;
4215*)
4216 case `$phostname` in
4217 $myhostname$mydomain|$myhostname) ;;
4218 *)
4219 case "$phostname" in
4220 sed*)
4221 echo "(That doesn't agree with your whoami.h file, by the way.)"
4222 ;;
4223 *)
4224 echo "(That doesn't agree with your $phostname command, by the way.)"
4225 ;;
4226 esac
4227 ;;
4228 esac
4229 ;;
4230esac
4231
4232: see how we will look up host name
4233echo " "
4234if false; then
4235 : dummy stub to allow use of elif
4236elif set uname val -f d_uname; eval $csym; $val; then
4237 if xenix; then
4238 $cat <<'EOM'
4239uname() was found, but you're running xenix, and older versions of xenix
4240have a broken uname(). If you don't really know whether your xenix is old
4241enough to have a broken system call, use the default answer.
4242
4243EOM
4244 dflt=y
4245 case "$d_uname" in
4246 "$define") dflt=n;;
4247 esac
4248 rp='Is your uname() broken?'
4249 . ./myread
4250 case "$ans" in
4251 n*) d_uname="$define"; call=uname;;
4252 esac
4253 else
4254 echo 'uname() found.' >&4
4255 d_uname="$define"
4256 call=uname
4257 fi
4258fi
4259case "$d_gethname" in
4260'') d_gethname="$undef";;
4261esac
4262case "$d_uname" in
4263'') d_uname="$undef";;
4264esac
4265case "$d_phostname" in
4266'') d_phostname="$undef";;
4267esac
4268
2304df62
AD
4269: see if there is a vfork
4270set vfork d_vfork
4271eval $inlibc
85e6fe83
LW
4272: But do we want to use it. vfork is reportedly unreliable in
4273: perl in Solaris 2.x, and probably elsewhere.
4274case "$d_vfork" in
4275define)
4276 dflt='n'
4277 rp="Some systems have problems with vork. Do you want to use it?"
4278 . ./myread
4279 case "$ans" in
4280 y|Y) ;;
4281 *) echo "Ok, we won't use vfork."
4282 d_vfork="$undef"
4283 ;;
4284 esac
4285 ;;
4286esac
2304df62
AD
4287: see if signal is declared as pointer to function returning int or void
4288echo " "
4289xxx=`./findhdr signal.h`
4290$test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
4291if $contains 'int.*\*[ ]*signal' $$.tmp >/dev/null 2>&1 ; then
4292 echo "You have int (*signal())() instead of void." >&4
4293 val="$undef"
4294 signal_t="int"
4295elif $contains 'void.*\*[ ]*signal' $$.tmp >/dev/null 2>&1 ; then
4296 echo "You have void (*signal())() instead of int." >&4
4297 val="$define"
4298 signal_t="void"
4299elif $contains 'extern[ ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
4300 echo "You have int (*signal())() instead of void." >&4
4301 val="$undef"
4302 signal_t="int"
4303else
4304 case "$d_voidsig" in
4305 '')
4306 echo "I can't determine whether signal handler returns void or int..." >&4
4307 dflt=void
4308 rp="What type does your signal handler returns?"
4309 . ./myread
4310 case "$ans" in
4311 void) val="$define"; signal_t="void";;
4312 *) val="$undef"; signal_t="int";;
4313 esac;;
4314 *) echo "As you already told me, signal handler returns $signal_t." >&4;;
4315 esac
4316fi
4317set d_voidsig
4318eval $setvar
4319$rm -f $$.tmp
4320
4321: check for volatile keyword
4322echo " "
4323echo 'Checking to see if your C compiler knows about "volatile"...' >&4
4324$cat >try.c <<'EOCP'
4325main()
4326{
4327 typedef struct _goo_struct goo_struct;
4328 goo_struct * volatile goo = ((goo_struct *)0);
4329 struct _goo_struct {
4330 long long_int;
4331 int reg_int;
4332 char char_var;
4333 };
4334 typedef unsigned short foo_t;
4335 char *volatile foo;
4336 volatile int bar;
4337 volatile foo_t blech;
4338 foo = foo;
4339}
4340EOCP
4341if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
4342 val="$define"
4343 echo "Yup, it does."
4344else
4345 val="$undef"
4346 echo "Nope, it doesn't."
4347fi
4348set d_volatile
4349eval $setvar
4350$rm -f try.*
4351
4352: see if there is a wait4
4353set wait4 d_wait4
4354eval $inlibc
4355
4356: see if waitpid exists
4357set waitpid d_waitpid
4358eval $inlibc
4359
4360: preserve RCS keywords in files with variable substitution, grrr
4361Date='$Date'
4362Id='$Id'
4363Log='$Log'
4364RCSfile='$RCSfile'
4365Revision='$Revision'
4366
2304df62
AD
4367: is AFS running?
4368echo " "
4369if test -d /afs; then
4370 echo "AFS may be running... I'll be extra cautious then..." >&4
4371 afs=true
4372else
4373 echo "AFS does not seem to be running..." >&4
4374 afs=false
4375fi
4376
4377: determine where public executables go
4378echo " "
4379case "$bin" in
4380'')
4381 dflt=`./loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
4382 ;;
4383*)
4384 dflt="$bin"
4385 ;;
4386esac
4387fn=d~
4388rp='Pathname where the public executables will reside?'
4389. ./getfile
4390bin="$ans"
4391binexp="$ansexp"
4392if $afs; then
4393 $cat <<EOM
4394
4395Since you are running AFS, I need to distinguish the directory in which
4396executables reside from the directory in which they are installed (and from
4397which they are presumably copied to the former directory by occult means).
4398
4399EOM
4400 case "$installbin" in
4401 '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
4402 *) dflt="$installbin";;
4403 esac
4404 fn=de~
4405 rp='Where will public executables be installed?'
4406 . ./getfile
4407 installbin="$ans"
4408else
4409 installbin="$binexp"
4410fi
4411
4412: check for ordering of bytes in a long
4413case "$byteorder" in
4414'')
4415 $cat <<'EOM'
4416
4417In the following, larger digits indicate more significance. A big-endian
4418machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
4419little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
4420machines may have weird orders like 3412. A Cray will report 87654321. If
4421the test program works the default is probably right.
4422I'm now running the test program...
4423EOM
4424 $cat >try.c <<'EOCP'
4425#include <stdio.h>
4426main()
4427{
4428 int i;
4429 union {
4430 unsigned long l;
4431 char c[sizeof(long)];
4432 } u;
4433
4434 if (sizeof(long) > 4)
4435 u.l = (0x08070605L << 32) | 0x04030201L;
4436 else
4437 u.l = 0x04030201L;
4438 for (i = 0; i < sizeof(long); i++)
4439 printf("%c", u.c[i]+'0');
4440 printf("\n");
4441}
4442EOCP
4443 if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
4444 dflt=`./try`
4445 case "$dflt" in
4446 ????|????????) echo "(The test program ran ok.)";;
4447 *) echo "(The test program didn't run right for some reason.)";;
4448 esac
4449 else
4450 dflt='4321'
4451 cat <<'EOM'
4452(I can't seem to compile the test program. Guessing big-endian...)
4453EOM
4454 fi
4455 ;;
4456*)
4457 echo " "
4458 dflt="$byteorder"
4459 ;;
4460esac
4461rp="What is the order of bytes in a long?"
4462. ./myread
4463byteorder="$ans"
4464$rm -f try.c try
4465
2304df62
AD
4466: see if dlfcn is available
4467set dlfcn.h i_dlfcn
4468eval $inhdr
2304df62
AD
4469: determine which dynamic loading, if any, to compile in
4470echo " "
4471case "$usedl" in
85e6fe83
LW
4472'') case "$i_dlfcn" in
4473 define) dflt='y' ;;
4474 *) dflt='n' ;;
4475 esac
4476 : Does a dl.c file exist for this operating system
4477 $test -f ../ext/dl/dl_${osname}.c && dflt='y'
4478 ;;
4479define|y|true) dflt='y'
4480 usedl="$define"
4481 ;;
4482*) dflt='n'
4483 ;;
2304df62
AD
4484esac
4485rp="Do you wish to attempt to use dynamic loading?"
4486. ./myread
4487usedl="$ans"
4488case "$ans" in
85e6fe83
LW
4489y*) usedl="$define"
4490 if $test -f ../ext/dl/dl_${osname}.c ; then
4491 dflt="ext/dl/dl_${osname}.c"
4492 else
4493 dflt='ext/dl/dl.c'
4494 fi
4495 echo "The following dynamic loading files are available:"
4496 cd ..; ls -C ext/dl/dl*.c; cd UU
4497 rp="Source file to use for dynamic loading"
4498 fn="fne~"
4499 . ./getfile
4500 : emulate basename and dirname
4501 xxx=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@' -e 's@\.c$@@'`
4502 dlobj=$xxx.o
4503 dlsrc=$xxx.c
4504 dldir=`echo $ans | $sed 's@\(.*\)/[^/]*$@\1@'`
4505 case "$dldir" in
4506 '') dldir="." ;;
4507 *) ;;
4508 esac
4509 if $test -f ../$dldir/$dlsrc; then
4510 usedl="$define"
4511 else
4512 echo "File $dlsrc does not exist -- ignored"
4513 usedl="$undef"
4514 fi
4515
4516 cat << EOM
4517
4518Some systems may require passing special flags to $cc -c to
4519compile modules that will be used to create a shared library.
4520To use no flags, say "none".
4521EOM
4522 case "$cccdlflags" in
4523 ''|' ') case "$osname" in
4524 hpux) dflt='+z' ;;
4525 next) dflt='none' ;;
4526 sunos) dflt='none' ;;
4527 *) dflt='none' ;;
4528 esac
4529 ;;
4530 *) dflt="$cccdlflags" ;;
4531 esac
4532 rp="Any special flags to pass to $cc -c to compile shared library modules?"
4533 . ./myread
4534 case "$ans" in
4535 none) cccdlflags='' ;;
4536 *) cccdlflags="$ans" ;;
4537 esac
4538
4539 cat << 'EOM'
4540
4541Some systems may require passing special flags to ld to
4542create a shared library. To use no flags, say "none".
4543EOM
4544 case "$lddlflags" in
4545 ''|' ') case "$osname" in
4546 hpux) dflt='-b' ;;
4547 next) dflt='none' ;;
4548 sunos) dflt='none' ;;
4549 *) dflt='none' ;;
4550 esac
4551 ;;
4552 *) dflt="$lddlflags" ;;
4553 esac
4554 rp="Any special fla