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