perl 3.0 patch #8 patch 7 continued
[p5sagit/p5-mst-13.2.git] / Configure
CommitLineData
8d063cd8 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, I would
7# suggest you cut out the prototypical config.h from the end of Configure
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#
d8f2e4cc 11# $Header: Configure,v 3.0.1.4 89/12/21 18:57:00 lwall Locked $
8d063cd8 12#
13# Yes, you may rip this off to use in other distribution packages.
14# (Note: this Configure script was generated automatically. Rather than
15# working with this copy of Configure, you may wish to get metaconfig.)
16
17: sanity checks
03a14243 18PATH=".:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin:$PATH"
8d063cd8 19export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$)
20
21if test ! -t 0; then
22 echo "Say 'sh Configure', not 'sh <Configure'"
23 exit 1
24fi
25
26(alias) >/dev/null 2>&1 && \
27 echo "(I see you are using the Korn shell. Some ksh's blow up on Configure," && \
28 echo "especially on exotic machines. If yours does, try the Bourne shell instead.)"
29
30if test ! -d ../UU; then
31 if test ! -d UU; then
32 mkdir UU
33 fi
34 cd UU
35fi
36
378cc40b 37case "$1" in
38-d) shift; fastread='yes';;
39esac
40
8d063cd8 41d_eunice=''
8d063cd8 42define=''
91407755 43eunicefix=''
8d063cd8 44loclist=''
45expr=''
46sed=''
47echo=''
48cat=''
49rm=''
50mv=''
51cp=''
52tail=''
53tr=''
54mkdir=''
55sort=''
56uniq=''
57grep=''
58trylist=''
59test=''
60inews=''
61egrep=''
62more=''
63pg=''
64Mcc=''
65vi=''
66mailx=''
67mail=''
378cc40b 68cpp=''
a687059c 69perl=''
70emacs=''
71ls=''
72rmail=''
73sendmail=''
74shar=''
75smail=''
76tbl=''
77troff=''
78nroff=''
79uname=''
80uuname=''
81line=''
82chgrp=''
83chmod=''
84lint=''
85sleep=''
86pr=''
87tar=''
88ln=''
89lpr=''
90lp=''
91touch=''
92make=''
93date=''
91407755 94csh=''
8d063cd8 95Log=''
96Header=''
97bin=''
a687059c 98byteorder=''
8d063cd8 99contains=''
378cc40b 100cppstdin=''
36ce8bec 101cppminus=''
a687059c 102d_bcmp=''
135863df 103d_bcopy=''
0d3e774c 104d_bzero=''
8d063cd8 105d_charsprf=''
2e1b3b7e 106d_crypt=''
a687059c 107cryptlib=''
91407755 108d_csh=''
13281fa4 109d_dosuid=''
a687059c 110d_dup2=''
378cc40b 111d_fchmod=''
112d_fchown=''
a687059c 113d_fcntl=''
114d_flock=''
378cc40b 115d_getgrps=''
a687059c 116d_gethent=''
117d_getpgrp=''
d8f2e4cc 118d_getpgrp2=''
a687059c 119d_getprior=''
120d_htonl=''
8d063cd8 121d_index=''
a687059c 122d_ioctl=''
378cc40b 123d_killpg=''
0d3e774c 124d_lstat=''
a687059c 125d_memcmp=''
378cc40b 126d_memcpy=''
a687059c 127d_mkdir=''
128d_ndbm=''
129d_odbm=''
130d_readdir=''
378cc40b 131d_rename=''
a687059c 132d_rmdir=''
378cc40b 133d_setegid=''
134d_seteuid=''
a687059c 135d_setpgrp=''
d8f2e4cc 136d_setpgrp2=''
a687059c 137d_setprior=''
138d_setregid=''
139d_setresgid=''
140d_setreuid=''
141d_setresuid=''
378cc40b 142d_setrgid=''
143d_setruid=''
a687059c 144d_socket=''
145d_sockpair=''
146d_oldsock=''
147socketlib=''
135863df 148d_statblks=''
36ce8bec 149d_stdstdio=''
8d063cd8 150d_strctcpy=''
d8f2e4cc 151d_strerror=''
2e1b3b7e 152d_symlink=''
a687059c 153d_syscall=''
a687059c 154d_varargs=''
8d063cd8 155d_vfork=''
36ce8bec 156d_voidsig=''
a687059c 157d_vprintf=''
158d_charvspr=''
91407755 159d_wait4=''
378cc40b 160gidtype=''
a687059c 161i_dirent=''
162d_dirnamlen=''
163i_fcntl=''
164i_grp=''
03a14243 165i_niin=''
a687059c 166i_pwd=''
167d_pwquota=''
168d_pwage=''
91407755 169d_pwchange=''
170d_pwclass=''
171d_pwexpire=''
a687059c 172i_sysdir=''
173i_sysioctl=''
d8f2e4cc 174i_sysndir=''
175i_time=''
176i_systime=''
177d_systimekernel=''
178i_utime=''
a687059c 179i_varargs=''
180i_vfork=''
181intsize=''
8d063cd8 182libc=''
a1cc2bdc 183mallocsrc=''
184mallocobj=''
185usemymalloc=''
8d063cd8 186mansrc=''
187manext=''
188models=''
189split=''
190small=''
191medium=''
192large=''
193huge=''
a687059c 194optimize=''
8d063cd8 195ccflags=''
91407755 196cppflags=''
8d063cd8 197ldflags=''
a687059c 198cc=''
199libs=''
8d063cd8 200n=''
201c=''
202package=''
a687059c 203randbits=''
204sig_name=''
8d063cd8 205spitshell=''
206shsharp=''
207sharpbang=''
208startsh=''
36ce8bec 209stdchar=''
378cc40b 210uidtype=''
8d063cd8 211voidflags=''
212defvoidused=''
d8f2e4cc 213yacc=''
378cc40b 214privlib=''
d8f2e4cc 215lib=''
8d063cd8 216CONFIG=''
8d063cd8 217: set package name
218package=perl
219
220echo " "
221echo "Beginning of configuration questions for $package kit."
222: Eunice requires " " instead of "", can you believe it
223echo " "
224
225define='define'
13281fa4 226undef='undef'
d8f2e4cc 227: change the next line if compiling for Xenix/286 on Xenix/386
228xlibpth='/usr/lib/386 /lib/386'
229libpth='/usr/lib /usr/local/lib /usr/lib/large /lib '$xlibpth' /lib/large /usr/lib/small /lib/small'
8d063cd8 230smallmach='pdp11 i8086 z8000 i80286 iAPX286'
231rmlist='kit[1-9]isdone kit[1-9][0-9]isdone'
232trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3
378cc40b 233
234: We must find out about Eunice early
235eunicefix=':'
236if test -f /etc/unixtovms; then
237 eunicefix=/etc/unixtovms
238fi
239if test -f /etc/unixtovms.exe; then
240 eunicefix=/etc/unixtovms.exe
241fi
242
a687059c 243: Now test for existence of everything in MANIFEST
244
245echo "First let's make sure your kit is complete. Checking..."
246(cd ..; awk '' `awk '$1 !~ /PACKINGLIST/ {print $1}' MANIFEST` >/dev/null || kill $$)
91407755 247echo "Looks good..."
a687059c 248
8d063cd8 249attrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr"
250attrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200"
a687059c 251attrlist="$attrlist hpux hp9000s300 hp9000s500 hp9000s800"
36ce8bec 252attrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc"
378cc40b 253attrlist="$attrlist nsc32000 sinix xenix venix posix ansi M_XENIX"
a687059c 254attrlist="$attrlist $mc68k __STDC__ UTS M_I8086 M_I186 M_I286 M_I386"
d8f2e4cc 255attrlist="$attrlist i186 __m88k__ m88k DGUX __DGUX__"
a687059c 256pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /usr/plx /usr/5bin /vol/local/bin /etc /usr/lib /lib /usr/local/lib /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/bin /bsd4.3/usr/ucb"
257d_newshome="/usr/NeWS"
8d063cd8 258defvoidused=7
d8f2e4cc 259libswanted="net_s net nsl_s nsl socket nm ndir ndbm dbm sun bsd x c_s"
260inclwanted='/usr/netinclude /usr/include/sun /usr/include/bsd /usr/include/lan'
8d063cd8 261: some greps do not return status, grrr.
262echo "grimblepritz" >grimble
263if grep blurfldyick grimble >/dev/null 2>&1 ; then
264 contains=contains
265elif grep grimblepritz grimble >/dev/null 2>&1 ; then
266 contains=grep
267else
268 contains=contains
269fi
270rm -f grimble
271: the following should work in any shell
272case "$contains" in
273contains*)
274 echo " "
275 echo "AGH! Grep doesn't return a status. Attempting remedial action."
276 cat >contains <<'EOSS'
277grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
278EOSS
378cc40b 279chmod +x contains
8d063cd8 280esac
281
91407755 282: see if sh knows # comments
283echo " "
284echo "Checking your sh to see if it knows about # comments..."
285if sh -c '#' >/dev/null 2>&1 ; then
286 echo "Your sh handles # comments correctly."
287 shsharp=true
288 spitshell=cat
289 echo " "
290 echo "Okay, let's see if #! works on this system..."
291 echo "#!/bin/echo hi" > try
292 $eunicefix try
293 chmod +x try
294 try > today
295 if $contains hi today >/dev/null 2>&1; then
296 echo "It does."
297 sharpbang='#!'
298 else
299 echo "#! /bin/echo hi" > try
300 $eunicefix try
301 chmod +x try
302 try > today
303 if test -s today; then
304 echo "It does."
305 sharpbang='#! '
306 else
307 echo "It doesn't."
308 sharpbang=': use '
309 fi
310 fi
311else
312 echo "Your sh doesn't grok # comments--I will strip them later on."
313 shsharp=false
314 echo "exec grep -v '^#'" >spitshell
315 chmod +x spitshell
316 $eunicefix spitshell
317 spitshell=`pwd`/spitshell
318 echo "I presume that if # doesn't work, #! won't work either!"
319 sharpbang=': use '
320fi
321
322: figure out how to guarantee sh startup
323echo " "
324echo "Checking out how to guarantee sh startup..."
325startsh=$sharpbang'/bin/sh'
326echo "Let's see if '$startsh' works..."
327cat >try <<EOSS
328$startsh
329set abc
330test "$?abc" != 1
331EOSS
332
333chmod +x try
334$eunicefix try
335if try; then
336 echo "Yup, it does."
337else
338 echo "Nope. You may have to fix up the shell scripts to make sure sh runs them."
339fi
340rm -f try today
341
8d063cd8 342: first determine how to suppress newline on echo command
343echo "Checking echo to see how to suppress newlines..."
344(echo "hi there\c" ; echo " ") >.echotmp
345if $contains c .echotmp >/dev/null 2>&1 ; then
346 echo "...using -n."
347 n='-n'
348 c=''
349else
350 cat <<'EOM'
351...using \c
352EOM
353 n=''
354 c='\c'
355fi
356echo $n "Type carriage return to continue. Your cursor should be here-->$c"
357read ans
358rm -f .echotmp
359
360: now set up to do reads with possible shell escape and default assignment
361cat <<EOSC >myread
378cc40b 362case "\$fastread" in
363yes) ans=''; echo " " ;;
364*) ans='!';;
365esac
8d063cd8 366while expr "X\$ans" : "X!" >/dev/null; do
367 read ans
368 case "\$ans" in
369 !)
370 sh
371 echo " "
372 echo $n "\$rp $c"
373 ;;
374 !*)
375 set \`expr "X\$ans" : "X!\(.*\)\$"\`
376 sh -c "\$*"
377 echo " "
378 echo $n "\$rp $c"
379 ;;
380 esac
381done
382rp='Your answer:'
383case "\$ans" in
384'') ans="\$dflt";;
385esac
386EOSC
387
388: general instructions
389cat <<EOH
390
391This installation shell script will examine your system and ask you questions
392to determine how the $package package should be installed. If you get stuck
393on a question, you may use a ! shell escape to start a subshell or execute
394a command. Many of the questions will have default answers in square
395brackets--typing carriage return will give you the default.
396
397On some of the questions which ask for file or directory names you are
398allowed to use the ~name construct to specify the login directory belonging
399to "name", even if you don't have a shell which knows about that. Questions
400where this is allowed will be marked "(~name ok)".
401
402EOH
403rp="[Type carriage return to continue]"
404echo $n "$rp $c"
405. myread
406cat <<EOH
407
408Much effort has been expended to ensure that this shell script will run
409on any Unix system. If despite that it blows up on you, your best bet is
36ce8bec 410to edit Configure and run it again. Also, let me (lwall@jpl-devvax.jpl.nasa.gov)
411know how I blew it. If you can't run Configure for some reason, you'll have
8d063cd8 412to generate a config.sh file by hand.
413
414This installation script affects things in two ways: 1) it may do direct
415variable substitutions on some of the files included in this kit, and
4162) it builds a config.h file for inclusion in C programs. You may edit
417any of these files as the need arises after running this script.
418
419If you make a mistake on a question, there is no easy way to back up to it
420currently. The easiest thing to do is to edit config.sh and rerun all the
421SH files. Configure will offer to let you do this before it runs the SH files.
422
423EOH
424rp="[Type carriage return to continue]"
425echo $n "$rp $c"
426. myread
427
428: get old answers, if there is a config file out there
429if test -f ../config.sh; then
430 echo " "
431 dflt=y
432 rp="I see a config.sh file. Did Configure make it on THIS system? [$dflt]"
433 echo $n "$rp $c"
434 . myread
435 case "$ans" in
436 n*) echo "OK, I'll ignore it.";;
437 *) echo "Fetching default answers from your old config.sh file..."
438 tmp="$n"
439 ans="$c"
440 . ../config.sh
441 n="$tmp"
442 c="$ans"
443 ;;
444 esac
445fi
446
447: find out where common programs are
448echo " "
449echo "Locating common programs..."
450cat <<EOSC >loc
451$startsh
452case \$# in
4530) exit 1;;
454esac
455thing=\$1
456shift
457dflt=\$1
458shift
459for dir in \$*; do
460 case "\$thing" in
461 .)
462 if test -d \$dir/\$thing; then
463 echo \$dir
464 exit 0
465 fi
466 ;;
467 *)
468 if test -f \$dir/\$thing; then
469 echo \$dir/\$thing
470 exit 0
378cc40b 471 elif test -f \$dir/\$thing.exe; then
472 : on Eunice apparently
473 echo \$dir/\$thing
474 exit 0
8d063cd8 475 fi
476 ;;
477 esac
478done
479echo \$dflt
480exit 1
481EOSC
378cc40b 482chmod +x loc
8d063cd8 483$eunicefix loc
484loclist="
8d063cd8 485cat
8d063cd8 486cp
a687059c 487echo
488expr
489grep
8d063cd8 490mkdir
a687059c 491mv
492rm
493sed
8d063cd8 494sort
a687059c 495tr
8d063cd8 496uniq
8d063cd8 497"
498trylist="
8d063cd8 499Mcc
378cc40b 500cpp
91407755 501csh
a687059c 502egrep
503test
8d063cd8 504"
505for file in $loclist; do
506 xxx=`loc $file $file $pth`
507 eval $file=$xxx
508 eval _$file=$xxx
509 case "$xxx" in
510 /*)
511 echo $file is in $xxx.
512 ;;
513 *)
514 echo "I don't know where $file is. I hope it's in everyone's PATH."
515 ;;
516 esac
517done
518echo " "
519echo "Don't worry if any of the following aren't found..."
520ans=offhand
521for file in $trylist; do
522 xxx=`loc $file $file $pth`
523 eval $file=$xxx
524 eval _$file=$xxx
525 case "$xxx" in
526 /*)
527 echo $file is in $xxx.
528 ;;
529 *)
530 echo "I don't see $file out there, $ans."
531 ans=either
532 ;;
533 esac
534done
535case "$egrep" in
536egrep)
537 echo "Substituting grep for egrep."
538 egrep=$grep
539 ;;
540esac
541case "$test" in
542test)
543 echo "Hopefully test is built into your sh."
544 ;;
545/bin/test)
a687059c 546 if sh -c "PATH= test true" >/dev/null 2>&1; then
547 echo "Using the test built into your sh."
548 test=test
549 fi
8d063cd8 550 ;;
551*)
552 test=test
553 ;;
554esac
555case "$echo" in
556echo)
557 echo "Hopefully echo is built into your sh."
558 ;;
559/bin/echo)
560 echo " "
561 echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
562 $echo $n "hi there$c" >foo1
563 echo $n "hi there$c" >foo2
564 if cmp foo1 foo2 >/dev/null 2>&1; then
565 echo "They are compatible. In fact, they may be identical."
566 else
567 case "$n" in
568 '-n') n='' c='\c' ans='\c' ;;
569 *) n='-n' c='' ans='-n' ;;
570 esac
571 cat <<FOO
572They are not compatible! You are probably running ksh on a non-USG system.
573I'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
574have echo built in and we may have to run some Bourne shell scripts. That
575means I'll have to use $ans to suppress newlines now. Life is ridiculous.
576
577FOO
578 rp="Your cursor should be here-->"
579 $echo $n "$rp$c"
580 . myread
581 fi
582 $rm -f foo1 foo2
583 ;;
584*)
585 : cross your fingers
586 echo=echo
587 ;;
588esac
589rmlist="$rmlist loc"
590
a687059c 591: set up shell script to do ~ expansion
592cat >filexp <<EOSS
593$startsh
594: expand filename
595case "\$1" in
596 ~/*|~)
597 echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
598 ;;
599 ~*)
600 if $test -f /bin/csh; then
601 /bin/csh -f -c "glob \$1"
602 echo ""
36ce8bec 603 else
a687059c 604 name=\`$expr x\$1 : '..\([^/]*\)'\`
605 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
606 if $test ! -d "\$dir"; then
607 me=\`basename \$0\`
608 echo "\$me: can't locate home directory for: \$name" >&2
609 exit 1
36ce8bec 610 fi
a687059c 611 case "\$1" in
612 */*)
613 echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
614 ;;
615 *)
616 echo \$dir
617 ;;
618 esac
13281fa4 619 fi
620 ;;
a687059c 621*)
622 echo \$1
623 ;;
13281fa4 624esac
a687059c 625EOSS
626chmod +x filexp
627$eunicefix filexp
13281fa4 628
a687059c 629: determine where public executables go
630case "$bin" in
631'')
632 dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
633 ;;
634*) dflt="$bin"
635 ;;
378cc40b 636esac
a687059c 637cont=true
638while $test "$cont" ; do
639 echo " "
640 rp="Where do you want to put the public executables? [$dflt]"
641 $echo $n "$rp $c"
642 . myread
643 bin="$ans"
644 bin=`filexp $bin`
645 if test -d $bin; then
646 cont=''
647 else
648 case "$fastread" in
649 yes) dflt=y;;
650 *) dflt=n;;
651 esac
652 rp="Directory $bin doesn't exist. Use that name anyway? [$dflt]"
378cc40b 653 $echo $n "$rp $c"
654 . myread
a687059c 655 dflt=''
378cc40b 656 case "$ans" in
a687059c 657 y*) cont='';;
378cc40b 658 esac
378cc40b 659 fi
a687059c 660done
378cc40b 661
a687059c 662: determine where manual pages go
663$cat <<EOM
664
665$package has manual pages that need to be installed in source form.
666EOM
667case "$mansrc" in
668'')
669 dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1 /usr/man/man.L`
670 ;;
671*) dflt="$mansrc"
672 ;;
673esac
674cont=true
675while $test "$cont" ; do
676 echo " "
677 rp="Where do the manual pages (source) go? [$dflt]"
678 $echo $n "$rp $c"
679 . myread
680 mansrc=`filexp "$ans"`
681 if $test -d "$mansrc"; then
682 cont=''
683 else
684 if $test "$fastread" = yes; then
685 dflt=y
686 else
687 dflt=n
688 fi
689 rp="Directory $mansrc doesn't exist. Use that name anyway? [$dflt]"
690 $echo $n "$rp $c"
691 . myread
692 dflt=''
693 case "$ans" in
694 y*) cont='';;
695 esac
696 fi
697done
698case "$mansrc" in
699*l)
700 manext=l
701 ;;
702*n)
703 manext=n
704 ;;
705*o)
706 manext=l
707 ;;
708*p)
709 manext=n
710 ;;
711*C)
712 manext=C
713 ;;
714*L)
715 manext=L
716 ;;
717*)
718 manext=1
719 ;;
720esac
721
91407755 722: make some quick guesses about what we are up against
723echo " "
724$echo $n "Hmm... $c"
725cat /usr/include/signal.h /usr/include/sys/signal.h >foo
726if test `echo abc | tr a-z A-Z` = Abc ; then
727 echo "Looks kind of like a USG system, but we'll see..."
728 echo exit 1 >bsd
729 echo exit 0 >usg
730 echo exit 1 >v7
731elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
732 echo "Looks kind of like a BSD system, but we'll see..."
733 echo exit 0 >bsd
734 echo exit 1 >usg
735 echo exit 1 >v7
736else
737 echo "Looks kind of like a version 7 system, but we'll see..."
738 echo exit 1 >bsd
739 echo exit 1 >usg
740 echo exit 0 >v7
741fi
742case "$eunicefix" in
743*unixtovms*)
744 cat <<'EOI'
745There is, however, a strange, musty smell in the air that reminds me of
746something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
747EOI
748 echo "exit 0" >eunice
749 d_eunice="$define"
750 ;;
751*)
752 echo " "
753 echo "Congratulations. You aren't running Eunice."
754 d_eunice="$undef"
755 echo "exit 1" >eunice
756 ;;
757esac
758if test -f /xenix; then
759 echo "Actually, this looks more like a XENIX system..."
760 echo "exit 0" >xenix
761else
762 echo " "
763 echo "It's not Xenix..."
764 echo "exit 1" >xenix
765fi
766chmod +x xenix
767$eunicefix xenix
768if test -f /venix; then
769 echo "Actually, this looks more like a VENIX system..."
770 echo "exit 0" >venix
771else
772 echo " "
773 if xenix; then
774 : null
775 else
776 echo "Nor is it Venix..."
777 fi
778 echo "exit 1" >venix
779fi
780chmod +x bsd usg v7 eunice venix
781$eunicefix bsd usg v7 eunice venix
782rm -rf foo
783rmlist="$rmlist bsd usg v7 eunice venix xenix"
784
a687059c 785: see what memory models we can support
786case "$models" in
787'')
788 : We may not use Cppsym or we get a circular dependency through cc.
789 : But this should work regardless of which cc we eventually use.
790 cat >pdp11.c <<'EOP'
791main() {
792#ifdef pdp11
793 exit(0);
794#else
795 exit(1);
796#endif
797}
798EOP
799 cc -o pdp11 pdp11.c >/dev/null 2>&1
800 if pdp11 2>/dev/null; then
801 dflt='unsplit split'
802 else
803 ans=`loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
804 case "$ans" in
805 X) dflt='none';;
806 *) if $test -d /lib/small || $test -d /usr/lib/small; then
807 dflt='small'
808 else
809 dflt=''
810 fi
811 if $test -d /lib/medium || $test -d /usr/lib/medium; then
812 dflt="$dflt medium"
813 fi
814 if $test -d /lib/large || $test -d /usr/lib/large; then
815 dflt="$dflt large"
816 fi
817 if $test -d /lib/huge || $test -d /usr/lib/huge; then
818 dflt="$dflt huge"
819 fi
820 esac
821 fi
822 ;;
823*) dflt="$models" ;;
824esac
825$cat <<EOM
826
827Some systems have different model sizes. On most systems they are called
828small, medium, large, and huge. On the PDP11 they are called unsplit and
829split. If your system doesn't support different memory models, say "none".
830If you wish to force everything to one memory model, say "none" here and
831put the appropriate flags later when it asks you for other cc and ld flags.
832Venix systems may wish to put "none" and let the compiler figure things out.
833(In the following question multiple model names should be space separated.)
834
835EOM
836rp="Which models are supported? [$dflt]"
837$echo $n "$rp $c"
838. myread
839models="$ans"
840
841case "$models" in
842none)
843 small=''
844 medium=''
845 large=''
846 huge=''
847 unsplit=''
848 split=''
849 ;;
850*split)
851 case "$split" in
852 '')
853 if $contains '\-i' $mansrc/man1/ld.1 >/dev/null 2>&1 || \
854 $contains '\-i' $mansrc/man1/cc.1 >/dev/null 2>&1; then
855 dflt='-i'
856 else
857 dflt='none'
858 fi
859 ;;
860 *) dflt="$split";;
861 esac
862 rp="What flag indicates separate I and D space? [$dflt]"
863 $echo $n "$rp $c"
864 . myread
865 case "$ans" in
866 none) ans='';;
867 esac
868 split="$ans"
869 unsplit=''
870 ;;
871*large*|*small*|*medium*|*huge*)
872 case "$models" in
873 *large*)
874 case "$large" in
875 '') dflt='-Ml';;
876 *) dflt="$large";;
877 esac
878 rp="What flag indicates large model? [$dflt]"
879 $echo $n "$rp $c"
880 . myread
881 case "$ans" in
882 none) ans='';
883 esac
884 large="$ans"
885 ;;
886 *) large='';;
887 esac
888 case "$models" in
889 *huge*)
890 case "$huge" in
891 '') dflt='-Mh';;
892 *) dflt="$huge";;
893 esac
894 rp="What flag indicates huge model? [$dflt]"
895 $echo $n "$rp $c"
896 . myread
897 case "$ans" in
898 none) ans='';
899 esac
900 huge="$ans"
901 ;;
902 *) huge="$large";;
903 esac
904 case "$models" in
905 *medium*)
906 case "$medium" in
907 '') dflt='-Mm';;
908 *) dflt="$medium";;
909 esac
910 rp="What flag indicates medium model? [$dflt]"
911 $echo $n "$rp $c"
912 . myread
913 case "$ans" in
914 none) ans='';
915 esac
916 medium="$ans"
917 ;;
918 *) medium="$large";;
919 esac
920 case "$models" in
921 *small*)
922 case "$small" in
923 '') dflt='none';;
924 *) dflt="$small";;
925 esac
926 rp="What flag indicates small model? [$dflt]"
927 $echo $n "$rp $c"
928 . myread
929 case "$ans" in
930 none) ans='';
931 esac
932 small="$ans"
933 ;;
934 *) small='';;
935 esac
936 ;;
937*)
938 echo "Unrecognized memory models--you may have to edit Makefile.SH"
939 ;;
940esac
941
942: see if we need a special compiler
943echo " "
944if usg; then
945 case "$cc" in
946 '')
947 case "$Mcc" in
948 /*) dflt='Mcc'
949 ;;
950 *)
951 case "$large" in
952 -M*)
953 dflt='cc'
954 ;;
955 *)
956 if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then
957 dflt='cc -M'
958 else
959 dflt='cc'
960 fi
961 ;;
962 esac
963 ;;
964 esac
965 ;;
966 *) dflt="$cc";;
967 esac
968 $cat <<'EOM'
969
970On some systems the default C compiler will not resolve multiple global
971references that happen to have the same name. On some such systems the
972"Mcc" command may be used to force these to be resolved. On other systems
973a "cc -M" command is required. (Note that the -M flag on other systems
974indicates a memory model to use!) If you have the Gnu C compiler, you
975might wish to use that instead. What command will force resolution on
976EOM
977 $echo $n "this system? [$dflt] $c"
978 rp="Command to resolve multiple refs? [$dflt]"
979 . myread
980 cc="$ans"
981else
982 case "$cc" in
983 '') dflt=cc;;
984 *) dflt="$cc";;
985 esac
986 rp="Use which C compiler? [$dflt]"
987 $echo $n "$rp $c"
988 . myread
989 cc="$ans"
990fi
991case "$cc" in
992gcc*) cpp=`loc gcc-cpp $cpp $pth`;;
993esac
994
995: determine optimize, if desired, or use for debug flag also
996case "$optimize" in
997' ') dflt="none"
998 ;;
999'') dflt="-O";
1000 ;;
1001*) dflt="$optimize"
1002 ;;
1003esac
1004cat <<EOH
91407755 1005
a687059c 1006Some C compilers have problems with their optimizers, by default, $package
1007compiles with the -O flag to use the optimizer. Alternately, you might
1008want to use the symbolic debugger, which uses the -g flag (on traditional
1009Unix systems). Either flag can be specified here. To use neither flag,
1010specify the word "none".
1011
1012EOH
1013rp="What optimizer/debugger flag should be used? [$dflt]"
1014$echo $n "$rp $c"
1015. myread
1016optimize="$ans"
1017case "$optimize" in
1018'none') optimize=" "
1019 ;;
1020esac
1021
1022case "$ccflags" in
1023'') case "$cc" in
91407755 1024 *gcc*) dflt='-fpcc-struct-return';;
0d3e774c 1025 *) dflt='';;
a687059c 1026 esac
1027 ;;
1028*) dflt="$ccflags";;
1029esac
0d3e774c 1030for thisincl in $inclwanted; do
1031 if test -d $thisincl; then
1032 case "$dflt" in
1033 *$thisincl*);;
1034 *) dflt="$dflt -I$thisincl";;
1035 esac
1036 fi
1037done
91407755 1038case "$optimize" in
1039-g*)
1040 case "$dflt" in
1041 *DEBUGGING*);;
1042 *) dflt="$dflt -DDEBUGGING";;
1043 esac
1044 ;;
1045esac
0d3e774c 1046case "$dflt" in
1047'') dflt=none;;
1048esac
91407755 1049cat <<EOH
1050
1051Your C compiler may want other flags. For this question you should
1052include -I/whatever and -DWHATEVER flags and any other flags used by
1053the C compiler, but you should NOT include libraries or ld flags like
1054-lwhatever. To use no flags, specify the word "none".
1055
1056EOH
a687059c 1057rp="Any additional cc flags? [$dflt]"
1058$echo $n "$rp $c"
1059. myread
1060case "$ans" in
1061none) ans='';
1062esac
1063ccflags="$ans"
1064
91407755 1065: the following weeds options from ccflags that are of no interest to cpp
1066cppflags="$ccflags"
1067case "$cc" in
1068*gcc*) cppflags="$cppflags -D__GNUC__";;
1069esac
1070case "$cppflags" in
1071'');;
1072*) set X $cppflags
1073 cppflags=''
1074 for flag do
1075 case $flag in
1076 -D*|-I*) cppflags="$cppflags $flag";;
1077 esac
1078 done
1079 case "$cppflags" in
1080 *-*) echo "(C preprocessor flags: $cppflags)";;
1081 esac
1082 ;;
1083esac
1084
a687059c 1085case "$ldflags" in
1086'') if venix; then
1087 dflt='-i -z'
1088 else
1089 dflt='none'
1090 fi
1091 ;;
1092*) dflt="$ldflags";;
1093esac
1094echo " "
1095rp="Any additional ld flags (NOT including libraries)? [$dflt]"
1096$echo $n "$rp $c"
1097. myread
1098case "$ans" in
1099none) ans='';
1100esac
1101ldflags="$ans"
1102rmlist="$rmlist pdp11"
1103
91407755 1104echo " "
1105echo "Checking for optional libraries..."
a687059c 1106case "$libs" in
91407755 1107'') dflt='';;
a687059c 1108*) dflt="$libs";;
1109esac
91407755 1110case "$libswanted" in
1111'') libswanted='c_s';;
1112esac
1113for thislib in $libswanted; do
d8f2e4cc 1114 case "$thislib" in
1115 dbm) thatlib=ndbm;;
1116 *_s) thatlib=NONE;;
1117 *) thatlib="${thislib}_s";;
1118 *) thatlib=NONE;;
1119 esac
0d3e774c 1120 xxx=`loc lib$thislib.a X /usr/lib /usr/local/lib /lib`
1121 if test -f $xxx; then
91407755 1122 echo "Found -l$thislib."
1123 case "$dflt" in
d8f2e4cc 1124 *-l$thislib*|*-l$thatlib*);;
91407755 1125 *) dflt="$dflt -l$thislib";;
1126 esac
91407755 1127 else
0d3e774c 1128 xxx=`loc lib$thislib.a X $libpth`
1129 if test -f $xxx; then
1130 echo "Found $xxx."
1131 case "$dflt" in
1132 *$xxx*);;
1133 *) dflt="$dflt $xxx";;
1134 esac
1135 else
d8f2e4cc 1136 xxx=`loc Slib$thislib.a X $xlibpth`
0d3e774c 1137 if test -f $xxx; then
1138 echo "Found -l$thislib."
1139 case "$dflt" in
d8f2e4cc 1140 *-l$thislib*|*-l$thatlib*);;
0d3e774c 1141 *) dflt="$dflt -l$thislib";;
1142 esac
1143 else
1144 echo "No -l$thislib."
1145 fi
1146 fi
91407755 1147 fi
1148done
1149set X $dflt
1150shift
1151dflt="$*"
1152case "$dflt" in
1153'') dflt='none';;
1154esac
a687059c 1155
1156$cat <<EOM
1157
1158Some versions of Unix support shared libraries, which make
1159executables smaller but make load time slightly longer.
1160
1161On some systems, mostly newer Unix System V's, the shared library
1162is included by putting the option "-lc_s" as the last thing on the
1163cc command line when linking. Other systems use shared libraries
1164by default. There may be other libraries needed to compile $package
1165on your machine as well. If your system needs the "-lc_s" option,
1166include it here. Include any other special libraries here as well.
d8f2e4cc 1167Say "none" for none.
a687059c 1168EOM
1169
1170echo " "
1171rp="Any additional libraries? [$dflt]"
1172$echo $n "$rp $c"
1173. myread
1174case "$ans" in
1175none) ans='';
1176esac
1177libs="$ans"
1178
1179: check for ordering of bytes in a long
1180case "$byteorder" in
1181'')
1182cat <<'EOM'
1183
1184In the following, larger digits indicate more significance. A big-endian
1185machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
1186little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
91407755 1187machines may have weird orders like 3412. A Cray will report 87654321. If
1188the test program works the default is probably right.
1189I'm now running the test program...
a687059c 1190EOM
1191 $cat >try.c <<'EOCP'
1192#include <stdio.h>
1193main()
1194{
1195 int i;
1196 union {
1197 unsigned long l;
0d3e774c 1198 char c[sizeof(long)];
a687059c 1199 } u;
1200
0d3e774c 1201 if (sizeof(long) > 4)
1202 u.l = 0x0807060504030201;
1203 else
1204 u.l = 0x04030201;
91407755 1205 for (i=0; i < sizeof(long); i++)
1206 printf("%c",u.c[i]+'0');
1207 printf("\n");
a687059c 1208}
1209EOCP
1210 if $cc try.c -o try >/dev/null 2>&1 ; then
1211 dflt=`try`
1212 case "$dflt" in
91407755 1213 ????|????????) echo "(The test program ran ok.)";;
a687059c 1214 *) echo "(The test program didn't run right for some reason.)";;
1215 esac
1216 else
1217 dflt='4321'
1218 echo "(I can't seem to compile the test program. Guessing big-endian...)"
1219 fi
1220 ;;
1221*)
1222 echo " "
1223 dflt="$byteorder"
1224 ;;
1225esac
1226rp="What is the order of bytes in a long? [$dflt]"
1227$echo $n "$rp $c"
1228. myread
1229byteorder="$ans"
1230$rm -f try.c try
1231
1232: see how we invoke the C preprocessor
1233echo " "
1234echo "Now, how can we feed standard input to your C preprocessor..."
1235cat <<'EOT' >testcpp.c
1236#define ABC abc
1237#define XYZ xyz
1238ABC.XYZ
1239EOT
1240echo 'Maybe "'"$cc"' -E" will work...'
1241$cc -E <testcpp.c >testcpp.out 2>&1
91407755 1242: try to force gcc preprocessor if that is the compiler they are using
1243case $? in
12440) cppstdin="$cc -E";;
1245*) case "$cc" in
1246 *gcc*)
1247 cd ..
1248 echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
1249 echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
1250 chmod 755 cppstdin
1251 cppstdin=`pwd`/cppstdin
1252 cppminus='';
1253 cd UU
1254 $cppstdin <testcpp.c >testcpp.out 2>&1
1255 ;;
1256 esac
1257 ;;
1258esac
a687059c 1259if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1260 echo "Yup, it does."
1261 cppstdin="$cc -E"
1262 cppminus='';
1263else
1264 echo 'Nope, maybe "'$cpp'" will work...'
1265 $cpp <testcpp.c >testcpp.out 2>&1
1266 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1267 echo "Yup, it does."
1268 cppstdin="$cpp"
1269 cppminus='';
1270 else
1271 echo 'No such luck...maybe "'$cpp' -" will work...'
1272 $cpp - <testcpp.c >testcpp.out 2>&1
1273 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1274 echo "It works!"
1275 cppstdin="$cpp"
1276 cppminus='-';
1277 else
1278 echo 'Nixed again...maybe "'"$cc"' -E -" will work...'
1279 $cc -E - <testcpp.c >testcpp.out 2>&1
1280 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1281 echo "Hooray, it works! I was beginning to wonder."
1282 cppstdin="$cc -E"
1283 cppminus='-';
1284 else
1285 echo 'Nope...maybe "'"$cc"' -P" will work...'
1286 $cc -P <testcpp.c >testcpp.out 2>&1
1287 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1288 echo "Yup, that does."
1289 cppstdin="$cc -P"
1290 cppminus='';
1291 else
1292 echo 'Nope...maybe "'"$cc"' -P -" will work...'
1293 $cc -P - <testcpp.c >testcpp.out 2>&1
1294 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1295 echo "Yup, that does."
1296 cppstdin="$cc -P"
1297 cppminus='-';
1298 else
1299 echo 'Hmm...perhaps you already told me...'
1300 case "$cppstdin" in
1301 '') ;;
1302 *) $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1;;
1303 esac
1304 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1305 echo "Hooray, you did! I was beginning to wonder."
1306 else
1307 echo 'Uh-uh. Time to get fancy...'
1308 cd ..
1309 echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
1310 echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
1311 chmod 755 cppstdin
1312 cppstdin=`pwd`/cppstdin
1313 cppminus='';
1314 cd UU
1315 $cppstdin <testcpp.c >testcpp.out 2>&1
1316 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1317 echo "Eureka!."
1318 else
1319 dflt=blurfl
1320 $echo $n "No dice. I can't find a C preprocessor. Name one: $c"
1321 rp='Name a C preprocessor:'
1322 . myread
1323 cppstdin="$ans"
1324 $cppstdin <testcpp.c >testcpp.out 2>&1
1325 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1326 echo "OK, that will do."
1327 else
1328 echo "Sorry, I can't get that to work. Go find one."
1329 exit 1
1330 fi
1331 fi
1332 fi
1333 fi
1334 fi
1335 fi
1336 fi
1337 fi
1338fi
1339rm -f testcpp.c testcpp.out
1340
91407755 1341: get list of predefined functions in a handy place
1342echo " "
1343case "$libc" in
1344'') libc=unknown;;
1345esac
1346case "$libpth" in
1347'') libpth='/lib /usr/lib /usr/local/lib';;
1348esac
1349case "$libs" in
1350*-lc_s*) libc=`loc libc_s.a $libc $libpth`
1351esac
1352libnames='';
1353case "$libs" in
1354'') ;;
1355*) for thislib in $libs; do
1356 case "$thislib" in
1357 -l*) thislib=`expr X$thislib : 'X-l\(.*\)'`
1358 try=`loc lib$thislib.a blurfl/dyick $libpth`
1359 if test ! -f $try; then
1360 try=`loc lib$thislib blurfl/dyick $libpth`
1361 if test ! -f $try; then
1362 try=`loc $thislib blurfl/dyick $libpth`
1363 if test ! -f $try; then
d8f2e4cc 1364 try=`loc Slib$thislib.a blurfl/dyick $xlibpth`
1365 if test ! -f $try; then
1366 try=''
1367 fi
91407755 1368 fi
1369 fi
1370 fi
1371 libnames="$libnames $try"
1372 ;;
0d3e774c 1373 *) libnames="$libnames $thislib" ;;
91407755 1374 esac
1375 done
1376 ;;
1377esac
1378set /usr/lib/libc.so.[0-9]*
1379eval set \$$#
1380if test -f "$1"; then
1381 echo "Your shared C library is in $1."
1382 libc="$1"
1383elif test -f $libc; then
1384 echo "Your C library is in $libc, like you said before."
1385elif test -f /lib/libc.a; then
1386 echo "Your C library is in /lib/libc.a. You're normal."
1387 libc=/lib/libc.a
1388else
1389 ans=`loc libc.a blurfl/dyick $libpth`
1390 if test ! -f "$ans"; then
1391 ans=`loc libc blurfl/dyick $libpth`
1392 fi
1393 if test ! -f "$ans"; then
1394 ans=`loc clib blurfl/dyick $libpth`
1395 fi
1396 if test ! -f "$ans"; then
d8f2e4cc 1397 ans=`loc Slibc.a blurfl/dyick $xlibpth`
91407755 1398 fi
1399 if test ! -f "$ans"; then
d8f2e4cc 1400 ans=`loc Mlibc.a blurfl/dyick $xlibpth`
91407755 1401 fi
1402 if test ! -f "$ans"; then
d8f2e4cc 1403 ans=`loc Llibc.a blurfl/dyick $xlibpth`
91407755 1404 fi
1405 if test -f "$ans"; then
1406 echo "Your C library is in $ans, of all places."
1407 libc=$ans
1408 else
1409 cat <<EOM
1410
1411I can't seem to find your C library. I've looked in the following places:
1412
1413 $libpth
1414
1415None of these seems to contain your C library. What is the full name
1416EOM
1417 dflt=None
1418 $echo $n "of your C library? $c"
1419 rp='C library full name?'
1420 . myread
1421 libc="$ans"
1422 fi
1423fi
1424echo " "
1425set $libc $libnames
1426$echo $n "Extracting names from $* for later perusal...$c"
1427nm $* 2>/dev/null >libc.tmp
1428$sed -n -e 's/^.* [AT] *_[_.]*//p' -e 's/^.* [AT] //p' <libc.tmp >libc.list
1429if $contains '^printf$' libc.list >/dev/null 2>&1; then
1430 echo "done"
1431else
1432 $sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p' <libc.tmp >libc.list
1433 $contains '^printf$' libc.list >/dev/null 2>&1 || \
1434 $sed -n -e 's/^.* D __*//p' -e 's/^.* D //p' <libc.tmp >libc.list
1435 $contains '^printf$' libc.list >/dev/null 2>&1 || \
1436 $sed -n -e 's/^_//' \
1437 -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p' <libc.tmp >libc.list
1438 if $contains '^printf$' libc.list >/dev/null 2>&1; then
1439 echo "done"
1440 else
1441 echo " "
1442 echo "nm didn't seem to work right."
1443 echo "Trying ar instead..."
1444 if ar t $libc > libc.tmp; then
1445 for thisname in $libnames; do
1446 ar t $thisname >>libc.tmp
1447 done
1448 $sed -e 's/\.o$//' < libc.tmp > libc.list
1449 echo "Ok."
1450 else
1451 echo "ar didn't seem to work right."
1452 echo "Maybe this is a Cray...trying bld instead..."
1453 if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
1454 for thisname in $libnames; do
1455 bld t $libnames | \
1456 $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
1457 ar t $thisname >>libc.tmp
1458 done
1459 echo "Ok."
1460 else
1461 echo "That didn't work either. Giving up."
1462 exit 1
1463 fi
1464 fi
1465 fi
1466fi
1467
1468inlibc='echo " ";
1469if $contains "^$1\$" libc.list >/dev/null 2>&1;
1470then echo "$1() found"; eval "$2=$define";
1471else echo "$1() not found"; eval "$2=$undef"; fi'
1472
1473rmlist="$rmlist libc.tmp libc.list"
1474
a687059c 1475: see if bcmp exists
1476set bcmp d_bcmp
1477eval $inlibc
1478
1479: see if bcopy exists
1480set bcopy d_bcopy
1481eval $inlibc
1482
0d3e774c 1483: see if bzero exists
1484set bzero d_bzero
1485eval $inlibc
1486
a687059c 1487: see if sprintf is declared as int or pointer to char
1488echo " "
1489cat >.ucbsprf.c <<'EOF'
1490main() { char buf[10]; exit((unsigned long)sprintf(buf,"%s","foo") > 10L); }
1491EOF
1492if $cc $ccflags .ucbsprf.c -o .ucbsprf >/dev/null 2>&1 && .ucbsprf; then
1493 echo "Your sprintf() returns (int)."
1494 d_charsprf="$undef"
1495else
1496 echo "Your sprintf() returns (char*)."
1497 d_charsprf="$define"
1498fi
1499/bin/rm -f .ucbsprf.c .ucbsprf
1500
1501: see if vprintf exists
1502echo " "
1503if $contains '^vprintf$' libc.list >/dev/null 2>&1; then
1504 echo 'vprintf() found.'
1505 d_vprintf="$define"
1506 cat >.ucbsprf.c <<'EOF'
1507#include <varargs.h>
1508
1509main() { xxx("foo"); }
1510
1511xxx(va_alist)
1512va_dcl
1513{
1514 va_list args;
1515 char buf[10];
1516
1517 va_start(args);
1518 exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
1519}
1520EOF
1521 if $cc $ccflags .ucbsprf.c -o .ucbsprf >/dev/null 2>&1 && .ucbsprf; then
1522 echo "Your vsprintf() returns (int)."
1523 d_charvspr="$undef"
1524 else
1525 echo "Your vsprintf() returns (char*)."
1526 d_charvspr="$define"
1527 fi
1528 /bin/rm -f .ucbsprf.c .ucbsprf
1529else
1530 echo 'vprintf() not found.'
1531 d_vprintf="$undef"
1532 d_charvspr="$undef"
1533fi
1534
1535: see if crypt exists
1536echo " "
1537if $contains '^crypt$' libc.list >/dev/null 2>&1; then
1538 echo 'crypt() found.'
1539 d_crypt="$define"
1540 cryptlib=''
1541else
d8f2e4cc 1542 cryptlib=`loc Slibcrypt.a "" $xlibpth`
a687059c 1543 if $test -z "$cryptlib"; then
d8f2e4cc 1544 cryptlib=`loc Mlibcrypt.a "" $xlibpth`
a687059c 1545 else
1546 cryptlib=-lcrypt
1547 fi
1548 if $test -z "$cryptlib"; then
d8f2e4cc 1549 cryptlib=`loc Llibcrypt.a "" $xlibpth`
a687059c 1550 else
1551 cryptlib=-lcrypt
1552 fi
1553 if $test -z "$cryptlib"; then
1554 cryptlib=`loc libcrypt.a "" $libpth`
1555 else
1556 cryptlib=-lcrypt
1557 fi
1558 if $test -z "$cryptlib"; then
1559 echo 'crypt() not found.'
1560 d_crypt="$undef"
1561 else
1562 d_crypt="$define"
1563 fi
1564fi
1565
91407755 1566: get csh whereabouts
1567case "$csh" in
1568'csh') d_csh="$undef" ;;
1569*) d_csh="$define" ;;
1570esac
1571
a687059c 1572: see if this is a dirent system
1573echo " "
1574if $test -r /usr/include/dirent.h ; then
1575 i_dirent="$define"
1576 echo "dirent.h found."
1577 if $contains 'd_namlen' /usr/include/sys/dirent.h >/dev/null 2>&1; then
1578 d_dirnamlen="$define"
1579 else
1580 d_dirnamlen="$undef"
1581 fi
1582else
1583 i_dirent="$undef"
0d3e774c 1584 if $contains 'd_namlen' /usr/include/sys/dir.h >/dev/null 2>&1; then
1585 d_dirnamlen="$define"
1586 else
1587 d_dirnamlen="$undef"
1588 fi
a687059c 1589 echo "No dirent.h found."
1590fi
1591
1592: now see if they want to do setuid emulation
1593case "$d_dosuid" in
1594'') dflt=n;;
1595*undef*) dflt=n;;
1596*) dflt=y;;
1597esac
1598cat <<EOM
1599
1600Some sites have disabled setuid #! scripts because of a bug in the kernel
1601that prevents them from being secure. If you are on such a system, the
1602setuid/setgid bits on scripts are currently useless. It is possible for
1603$package to detect those bits and emulate setuid/setgid in a secure fashion
1604until a better solution is devised for the kernel problem.
1605
1606EOM
1607rp="Do you want to do setuid/setgid emulation? [$dflt]"
1608echo $n "$rp $c"
1609. myread
1610case "$ans" in
1611'') $ans="$dflt";;
1612esac
1613case "$ans" in
1614y*) d_dosuid="$define";;
1615*) d_dosuid="$undef";;
1616esac
1617
1618: see if dup2 exists
1619set dup2 d_dup2
1620eval $inlibc
1621
1622: see if fchmod exists
1623set fchmod d_fchmod
1624eval $inlibc
1625
1626: see if fchown exists
1627set fchown d_fchown
1628eval $inlibc
1629
1630: see if this is an fcntl system
1631echo " "
1632if $test -r /usr/include/fcntl.h ; then
1633 d_fcntl="$define"
1634 echo "fcntl.h found."
1635else
1636 d_fcntl="$undef"
1637 echo "No fcntl.h found, but that's ok."
1638fi
1639
1640: see if flock exists
1641set flock d_flock
1642eval $inlibc
1643
1644: see if getgroups exists
1645set getgroups d_getgrps
1646eval $inlibc
1647
1648: see if gethostent exists
1649set gethostent d_gethent
1650eval $inlibc
1651
1652: see if getpgrp exists
1653set getpgrp d_getpgrp
1654eval $inlibc
1655
d8f2e4cc 1656: see if getpgrp2 exists
1657set getpgrp2 d_getpgrp2
1658eval $inlibc
1659
a687059c 1660: see if getpriority exists
1661set getpriority d_getprior
1662eval $inlibc
1663
1664: see if htonl exists
1665set htonl d_htonl
1666eval $inlibc
1667
1668: index or strcpy
378cc40b 1669echo " "
a687059c 1670case "$d_index" in
1671n) dflt=n;;
1672*) dflt=y;;
1673esac
1674if $contains '^index$' libc.list >/dev/null 2>&1 ; then
1675 if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
1676 echo "Your system has both index() and strchr(). Shall I use"
1677 rp="index() rather than strchr()? [$dflt]"
1678 $echo $n "$rp $c"
1679 . myread
1680 case "$ans" in
1681 n*) d_index="$define" ;;
1682 *) d_index="$undef" ;;
1683 esac
1684 else
1685 d_index="$undef"
1686 echo "index() found."
1687 fi
378cc40b 1688else
a687059c 1689 if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
1690 d_index="$define"
1691 echo "strchr() found."
1692 else
1693 echo "No index() or strchr() found!"
1694 d_index="$undef"
1695 fi
378cc40b 1696fi
1697
a687059c 1698: see if ioctl defs are in sgtty/termio or sys/ioctl
378cc40b 1699echo " "
a687059c 1700if $test -r /usr/include/sys/ioctl.h ; then
1701 d_ioctl="$define"
1702 echo "sys/ioctl.h found."
378cc40b 1703else
a687059c 1704 d_ioctl="$undef"
1705 echo "sys/ioctl.h not found, assuming ioctl args are defined in sgtty.h."
378cc40b 1706fi
1707
a687059c 1708: see if killpg exists
1709set killpg d_killpg
1710eval $inlibc
1711
0d3e774c 1712: see if lstat exists
1713set lstat d_lstat
1714eval $inlibc
1715
a687059c 1716: see if memcmp exists
1717set memcmp d_memcmp
1718eval $inlibc
1719
1720: see if memcpy exists
1721set memcpy d_memcpy
1722eval $inlibc
1723
1724: see if mkdir exists
1725set mkdir d_mkdir
1726eval $inlibc
1727
1728: see if ndbm is available
378cc40b 1729echo " "
0d3e774c 1730xxx=`loc ndbm.h x /usr/include /usr/local/include $inclwanted`
1731if test -f $xxx; then
a687059c 1732 d_ndbm="$define"
1733 echo "ndbm.h found."
378cc40b 1734else
a687059c 1735 d_ndbm="$undef"
1736 echo "ndbm.h not found."
378cc40b 1737fi
1738
a687059c 1739: see if we have the old dbm
378cc40b 1740echo " "
0d3e774c 1741xxx=`loc dbm.h x /usr/include /usr/local/include $inclwanted`
1742if test -f $xxx; then
a687059c 1743 d_odbm="$define"
1744 echo "dbm.h found."
378cc40b 1745else
a687059c 1746 d_odbm="$undef"
1747 echo "dbm.h not found."
378cc40b 1748fi
1749
03a14243 1750: see if this is a pwd system
378cc40b 1751echo " "
a687059c 1752if $test -r /usr/include/pwd.h ; then
1753 i_pwd="$define"
1754 echo "pwd.h found."
91407755 1755 $cppstdin $cppflags </usr/include/pwd.h >$$.h
1756 if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
a687059c 1757 d_pwquota="$define"
1758 else
1759 d_pwquota="$undef"
1760 fi
91407755 1761 if $contains 'pw_age' $$.h >/dev/null 2>&1; then
a687059c 1762 d_pwage="$define"
1763 else
1764 d_pwage="$undef"
1765 fi
91407755 1766 if $contains 'pw_change' $$.h >/dev/null 2>&1; then
03a14243 1767 d_pwchange="$define"
1768 else
1769 d_pwchange="$undef"
1770 fi
91407755 1771 if $contains 'pw_class' $$.h >/dev/null 2>&1; then
03a14243 1772 d_pwclass="$define"
1773 else
1774 d_pwclass="$undef"
1775 fi
91407755 1776 if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
03a14243 1777 d_pwexpire="$define"
1778 else
1779 d_pwexpire="$undef"
1780 fi
91407755 1781 rm -f $$.h
378cc40b 1782else
a687059c 1783 i_pwd="$undef"
1784 d_pwquota="$undef"
1785 d_pwage="$undef"
03a14243 1786 d_pwchange="$undef"
1787 d_pwclass="$undef"
1788 d_pwexpire="$undef"
a687059c 1789 echo "No pwd.h found."
378cc40b 1790fi
1791
a687059c 1792: see if readdir exists
1793set readdir d_readdir
1794eval $inlibc
1795
1796: see if rename exists
1797set rename d_rename
1798eval $inlibc
1799
1800: see if rmdir exists
1801set rmdir d_rmdir
1802eval $inlibc
1803
1804: see if setegid exists
1805set setegid d_setegid
1806eval $inlibc
1807
1808: see if seteuid exists
1809set seteuid d_seteuid
1810eval $inlibc
1811
1812: see if setpgrp exists
1813set setpgrp d_setpgrp
1814eval $inlibc
1815
d8f2e4cc 1816: see if setpgrp2 exists
1817set setpgrp2 d_setpgrp2
1818eval $inlibc
1819
a687059c 1820: see if setpriority exists
1821set setpriority d_setprior
1822eval $inlibc
1823
1824: see if setregid exists
1825set setregid d_setregid
1826eval $inlibc
1827set setresgid d_setresgid
1828eval $inlibc
1829
1830: see if setreuid exists
1831set setreuid d_setreuid
1832eval $inlibc
1833set setresuid d_setresuid
1834eval $inlibc
1835
1836: see if setrgid exists
1837set setrgid d_setrgid
1838eval $inlibc
1839
378cc40b 1840: see if setruid exists
a687059c 1841set setruid d_setruid
1842eval $inlibc
1843
1844socketlib=''
a687059c 1845: see whether socket exists
378cc40b 1846echo " "
a687059c 1847if $contains socket libc.list >/dev/null 2>&1; then
1848 echo "Looks like you have Berkeley networking support."
1849 d_socket="$define"
1850 : now check for advanced features
1851 if $contains setsockopt libc.list >/dev/null 2>&1; then
1852 d_oldsock="$undef"
1853 else
1854 echo "...but it uses the old 4.1c interface, rather than 4.2"
1855 d_oldsock="$define"
1856 fi
1857else
1858 : hpux, for one, puts all the socket stuff in socklib.o
1859 if $contains socklib libc.list >/dev/null 2>&1; then
1860 echo "Looks like you have Berkeley networking support."
1861 d_socket="$define"
1862 : we will have to assume that it supports the 4.2 BSD interface
1863 d_oldsock="$undef"
1864 else
1865 echo "Hmmm...you don't have Berkeley networking in libc.a..."
1866 : look for an optional networking library
1867 if test -f /usr/lib/libnet.a; then
1868 (ar t /usr/lib/libnet.a ||
1869 nm -g /usr/lib/libnet.a) 2>/dev/null >> libc.list
1870 if $contains socket libc.list >/dev/null 2>&1; then
1871 echo "but the Wollongong group seems to have hacked it in."
1872 socketlib="-lnet"
a687059c 1873 d_socket="$define"
1874 : now check for advanced features
1875 if $contains setsockopt libc.list >/dev/null 2>&1; then
1876 d_oldsock="$undef"
1877 else
1878 echo "...using the old 4.1c interface, rather than 4.2"
1879 d_oldsock="$define"
1880 fi
1881 else
1882 echo "or even in libnet.a, which is peculiar."
1883 d_socket="$undef"
1884 d_oldsock="$undef"
1885 fi
1886 else
1887 echo "or anywhere else I see."
1888 d_socket="$undef"
1889 d_oldsock="$undef"
1890 fi
1891 fi
1892fi
1893if $contains socketpair libc.list >/dev/null 2>&1; then
1894 d_sockpair="$define"
378cc40b 1895else
a687059c 1896 d_sockpair="$undef"
8d063cd8 1897fi
1898
135863df 1899: see if stat knows about block sizes
1900echo " "
1901if $contains 'st_blocks;' /usr/include/sys/stat.h >/dev/null 2>&1 ; then
1902 if $contains 'st_blksize;' /usr/include/sys/stat.h >/dev/null 2>&1 ; then
1903 echo "Your stat knows about block sizes."
1904 d_statblks="$define"
1905 else
1906 echo "Your stat doesn't know about block sizes."
1907 d_statblks="$undef"
1908 fi
1909else
1910 echo "Your stat doesn't know about block sizes."
1911 d_statblks="$undef"
1912fi
1913
36ce8bec 1914: see if stdio is really std
1915echo " "
1916if $contains 'char.*_ptr;' /usr/include/stdio.h >/dev/null 2>&1 ; then
1917 if $contains '_cnt;' /usr/include/stdio.h >/dev/null 2>&1 ; then
1918 echo "Your stdio is pretty std."
1919 d_stdstdio="$define"
1920 else
1921 echo "Your stdio isn't very std."
1922 d_stdstdio="$undef"
1923 fi
1924else
1925 echo "Your stdio isn't very std."
1926 d_stdstdio="$undef"
1927fi
1928
8d063cd8 1929: check for structure copying
1930echo " "
1931echo "Checking to see if your C compiler can copy structs..."
1932$cat >try.c <<'EOCP'
1933main()
1934{
1935 struct blurfl {
1936 int dyick;
1937 } foo, bar;
1938
1939 foo = bar;
1940}
1941EOCP
a687059c 1942if $cc -c try.c >/dev/null 2>&1 ; then
8d063cd8 1943 d_strctcpy="$define"
1944 echo "Yup, it can."
1945else
1946 d_strctcpy="$undef"
1947 echo "Nope, it can't."
1948fi
1949$rm -f try.*
1950
d8f2e4cc 1951: see if strerror exists
1952set strerror d_strerror
1953eval $inlibc
1954
378cc40b 1955: see if symlink exists
a687059c 1956set symlink d_symlink
1957eval $inlibc
1958
1959: see if syscall exists
1960set syscall d_syscall
1961eval $inlibc
378cc40b 1962
d8f2e4cc 1963: see if we should include time.h, sys/time.h, or both
1964cat <<'EOM'
1965
1966Testing to see if we should include <time.h>, <sys/time.h> or both.
1967I'm now running the test program...
1968EOM
1969$cat >try.c <<'EOCP'
1970#ifdef I_TIME
1971#include <time.h>
1972#endif
1973#ifdef I_SYSTIME
1974#ifdef SYSTIMEKERNEL
1975#define KERNEL
1976#endif
1977#include <sys/time.h>
1978#endif
1979main()
1980{
1981 struct tm foo;
1982#ifdef S_TIMEVAL
1983 struct timeval bar;
1984#endif
1985 if (foo.tm_sec == foo.tm_sec)
1986 exit(0);
1987#ifdef S_TIMEVAL
1988 if (bar.tv_sec == bar.tv_sec)
1989 exit(0);
1990#endif
1991 exit(1);
1992}
1993EOCP
1994flags=''
1995for s_timeval in '-DS_TIMEVAL' ''; do
1996 for d_systimekernel in '' '-DSYSTIMEKERNEL'; do
1997 for i_time in '' '-DI_TIME'; do
1998 for i_systime in '-DI_SYSTIME' ''; do
1999 case "$flags" in
2000 '') echo Trying $i_time $i_systime $d_systimekernel $s_timeval
2001 if $cc try.c $ccflags \
2002 $i_time $i_systime $d_systimekernel $s_timeval \
2003 -o try >/dev/null 2>&1 ; then
2004 set X $i_time $i_systime $d_systimekernel $s_timeval
2005 shift
2006 flags="$*"
2007 echo Succeeded with $flags
2008 fi
2009 ;;
2010 esac
2011 done
2012 done
2013 done
2014done
2015case "$flags" in
2016*SYSTIMEKERNEL*) d_systimekernel="$define";;
2017*) d_systimekernel="$undef";;
2018esac
2019case "$flags" in
2020*I_TIME*) i_time="$define";;
2021*) i_time="$undef";;
2022esac
2023case "$flags" in
2024*I_SYSTIME*) i_systime="$define";;
2025*) i_systime="$undef";;
2026esac
2027$rm -f try.c try
135863df 2028
a687059c 2029: see if this is a varargs system
8d063cd8 2030echo " "
a687059c 2031if $test -r /usr/include/varargs.h ; then
2032 d_varargs="$define"
2033 echo "varargs.h found."
8d063cd8 2034else
a687059c 2035 d_varargs="$undef"
2036 echo "No varargs.h found, but that's ok (I hope)."
8d063cd8 2037fi
2038
a687059c 2039: see if there is a vfork
2040set vfork d_vfork
2041eval $inlibc
2042
36ce8bec 2043: see if signal is declared as pointer to function returning int or void
2044echo " "
0d3e774c 2045$cppstdin $cppflags < /usr/include/signal.h >$$.tmp
2046if $contains 'void.*signal' $$.tmp >/dev/null 2>&1 ; then
36ce8bec 2047 echo "You have void (*signal())() instead of int."
2048 d_voidsig="$define"
2049else
2050 echo "You have int (*signal())() instead of void."
2051 d_voidsig="$undef"
2052fi
0d3e774c 2053rm -f $$.tmp
36ce8bec 2054
91407755 2055: see if there is a wait4
2056set wait4 d_wait4
2057eval $inlibc
2058
8d063cd8 2059: check for void type
2060echo " "
2061$cat <<EOM
2062Checking to see how well your C compiler groks the void type...
2063
2064 Support flag bits are:
2065 1: basic void declarations.
2066 2: arrays of pointers to functions returning void.
2067 4: operations between pointers to and addresses of void functions.
2068
2069EOM
2070case "$voidflags" in
2071'')
2072 $cat >try.c <<'EOCP'
2073#if TRY & 1
2074void main() {
2075#else
2076main() {
2077#endif
a687059c 2078 extern void moo(); /* function returning void */
2079 void (*goo)(); /* ptr to func returning void */
8d063cd8 2080#if TRY & 2
2081 void (*foo[10])();
2082#endif
2083
2084#if TRY & 4
a687059c 2085 if(goo == moo) {
8d063cd8 2086 exit(0);
2087 }
2088#endif
2089 exit(0);
2090}
2091EOCP
a687059c 2092 if $cc -S -DTRY=$defvoidused try.c >.out 2>&1 ; then
2093 voidflags=$defvoidused
2094 echo "It appears to support void."
8d063cd8 2095 if $contains warning .out >/dev/null 2>&1; then
2096 echo "However, you might get some warnings that look like this:"
2097 $cat .out
2098 fi
2099 else
a687059c 2100 echo "Hmm, your compiler has some difficulty with void. Checking further..."
2101 if $cc -S -DTRY=1 try.c >/dev/null 2>&1 ; then
8d063cd8 2102 echo "It supports 1..."
a687059c 2103 if $cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
8d063cd8 2104 voidflags=3
2105 echo "And it supports 2 but not 4."
2106 else
2107 echo "It doesn't support 2..."
a687059c 2108 if $cc -S -DTRY=5 try.c >/dev/null 2>&1 ; then
8d063cd8 2109 voidflags=5
2110 echo "But it supports 4."
2111 else
2112 voidflags=1
2113 echo "And it doesn't support 4."
2114 fi
2115 fi
2116 else
2117 echo "There is no support at all for void."
2118 voidflags=0
2119 fi
2120 fi
2121esac
2122dflt="$voidflags";
2123rp="Your void support flags add up to what? [$dflt]"
2124$echo $n "$rp $c"
2125. myread
2126voidflags="$ans"
2127$rm -f try.* .out
2128
378cc40b 2129: see what type gids are declared as in the kernel
0d3e774c 2130echo " "
378cc40b 2131case "$gidtype" in
2132'')
0d3e774c 2133 if $contains 'getgroups.*short' /usr/lib/lint/llib-lc >/dev/null 2>&1; then
2134 dflt='short'
2135 elif $contains 'getgroups.*int' /usr/lib/lint/llib-lc >/dev/null 2>&1; then
2136 dflt='int'
2137 elif $contains 'gid_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
2138 dflt='gid_t'
378cc40b 2139 else
2140 set `grep 'groups\[NGROUPS\];' /usr/include/sys/user.h 2>/dev/null` unsigned short
2141 case $1 in
2142 unsigned) dflt="$1 $2" ;;
2143 *) dflt="$1" ;;
2144 esac
2145 fi
2146 ;;
2147*) dflt="$gidtype"
2148 ;;
2149esac
2150cont=true
91407755 2151echo "(The following only matters if you have getgroups().)"
2152rp="What type are the group ids returned by getgroups()? [$dflt]"
378cc40b 2153$echo $n "$rp $c"
2154. myread
2155gidtype="$ans"
8d063cd8 2156
a687059c 2157: see if this is an fcntl system
2158echo " "
2159if $test -r /usr/include/fcntl.h ; then
2160 i_fcntl="$define"
2161 echo "fcntl.h found."
2162else
2163 i_fcntl="$undef"
2164 echo "No fcntl.h found, but that's ok."
2165fi
378cc40b 2166
a687059c 2167: see if this is an grp system
2168echo " "
2169if $test -r /usr/include/grp.h ; then
2170 i_grp="$define"
2171 echo "grp.h found."
2172else
2173 i_grp="$undef"
2174 echo "No grp.h found."
2175fi
378cc40b 2176
03a14243 2177: see if this is a netinet/in.h system
2178echo " "
0d3e774c 2179xxx=`loc netinet/in.h x /usr/include /usr/local/include $inclwanted`
2180if test -f $xxx; then
03a14243 2181 i_niin="$define"
2182 echo "netinet/in.h found."
2183else
2184 i_niin="$undef"
2185 echo "No netinet/in.h found."
2186fi
2187
a687059c 2188: see if this is a sys/dir.h system
378cc40b 2189echo " "
a687059c 2190if $test -r /usr/include/sys/dir.h ; then
2191 i_sysdir="$define"
d8f2e4cc 2192 echo "sys/dir.h found."
378cc40b 2193else
a687059c 2194 i_sysdir="$undef"
d8f2e4cc 2195 echo "No sys/dir.h found."
378cc40b 2196fi
2197
a687059c 2198: see if ioctl defs are in sgtty/termio or sys/ioctl
378cc40b 2199echo " "
a687059c 2200if $test -r /usr/include/sys/ioctl.h ; then
2201 i_sysioctl="$define"
2202 echo "sys/ioctl.h found."
2203else
2204 i_sysioctl="$undef"
2205 echo "sys/ioctl.h not found, assuming ioctl args are defined in sgtty.h."
2206fi
378cc40b 2207
d8f2e4cc 2208: see if this is a sys/ndir.h system
2209echo " "
2210xxx=`loc sys/ndir.h x /usr/include /usr/local/include $inclwanted`
2211if test -f $xxx; then
2212 i_sysndir="$define"
2213 echo "sys/ndir.h found."
2214else
2215 i_sysndir="$undef"
2216 echo "No sys/ndir.h found."
2217fi
2218
2219: see if this is DG/UX with a funky utime.h
2220echo " "
2221if $test -r /usr/include/utime.h ; then
2222 i_utime="$define"
2223 echo "utime.h found."
2224else
2225 i_utime="$undef"
2226 echo "No utime.h found, but that's ok."
2227fi
2228
a687059c 2229: see if this is a varargs system
2230echo " "
2231if $test -r /usr/include/varargs.h ; then
2232 i_varargs="$define"
2233 echo "varargs.h found."
2234else
2235 i_varargs="$undef"
2236 echo "No varargs.h found, but that's ok (I hope)."
2237fi
378cc40b 2238
a687059c 2239: see if this is a vfork system
2240echo " "
2241if $test -r /usr/include/vfork.h ; then
2242 i_vfork="$define"
2243 echo "vfork.h found."
2244else
2245 i_vfork="$undef"
2246 echo "No vfork.h found."
2247fi
8d063cd8 2248
a687059c 2249: check for length of integer
2250echo " "
2251case "$intsize" in
8d063cd8 2252'')
a687059c 2253 echo "Checking to see how big your integers are..."
2254 $cat >try.c <<'EOCP'
2255#include <stdio.h>
2256main()
2257{
2258 printf("%d\n", sizeof(int));
2259}
2260EOCP
2261 if $cc try.c -o try >/dev/null 2>&1 ; then
2262 dflt=`try`
8d063cd8 2263 else
a687059c 2264 dflt='4'
2265 echo "(I can't seem to compile the test program. Guessing...)"
2266 fi
8d063cd8 2267 ;;
8d063cd8 2268*)
a687059c 2269 dflt="$intsize"
8d063cd8 2270 ;;
2271esac
a687059c 2272rp="What is the size of an integer (in bytes)? [$dflt]"
2273$echo $n "$rp $c"
2274. myread
2275intsize="$ans"
2276$rm -f try.c try
8d063cd8 2277
a687059c 2278: determine where private executables go
2279case "$privlib" in
8d063cd8 2280'')
a687059c 2281 dflt=/usr/lib/$package
2282 test -d /usr/local/lib && dflt=/usr/local/lib/$package
2283 ;;
2284*) dflt="$privlib"
8d063cd8 2285 ;;
8d063cd8 2286esac
2287$cat <<EOM
8d063cd8 2288
a687059c 2289The $package package has some auxiliary files that should be put in a library
2290that is accessible by everyone. Where do you want to put these "private"
8d063cd8 2291EOM
a687059c 2292$echo $n "but accessible files? [$dflt] $c"
2293rp="Put private files where? [$dflt]"
8d063cd8 2294. myread
a687059c 2295privlib="$ans"
8d063cd8 2296
a687059c 2297: check for size of random number generator
2298echo " "
2299case "$randbits" in
2300'')
2301 echo "Checking to see how many bits your rand function produces..."
2302 $cat >try.c <<'EOCP'
2303#include <stdio.h>
2304main()
2305{
2306 register int i;
2307 register unsigned long tmp;
2308 register unsigned long max = 0L;
2309
2310 for (i=1000; i; i--) {
2311 tmp = (unsigned long)rand();
2312 if (tmp > max) max = tmp;
2313 }
2314 for (i=0; max; i++)
2315 max /= 2;
2316 printf("%d\n",i);
2317}
2318EOCP
2319 if $cc try.c -o try >/dev/null 2>&1 ; then
2320 dflt=`try`
2321 else
2322 dflt='?'
2323 echo "(I can't seem to compile the test program...)"
2324 fi
8d063cd8 2325 ;;
a687059c 2326*)
2327 dflt="$randbits"
8d063cd8 2328 ;;
a687059c 2329esac
2330rp="How many bits does your rand() function produce? [$dflt]"
2331$echo $n "$rp $c"
2332. myread
2333randbits="$ans"
2334$rm -f try.c try
2335
2336: generate list of signal names
2337echo " "
2338case "$sig_name" in
2339'')
2340 echo "Generating a list of signal names..."
91407755 2341 set X `cat /usr/include/signal.h /usr/include/sys/signal.h 2>&1 | awk '
2342$1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $3 ~ /^[1-9][0-9]*$/ {
2343 sig[$3] = substr($2,4,20)
2344 if (max < $3 && $3 < 60) {
2345 max = $3
2346 }
2347}
2348
2349END {
2350 for (i=1; i<=max; i++) {
2351 if (sig[i] == "")
2352 printf "%d", i
2353 else
2354 printf "%s", sig[i]
2355 if (i < max)
2356 printf " "
2357 }
2358 printf "\n"
2359}
2360'`
a687059c 2361 shift
2362 case $# in
2363 0) echo 'kill -l' >/tmp/foo$$
91407755 2364 set X `$csh -f </tmp/foo$$`
a687059c 2365 shift
2366 case $# in
2367 0)set HUP INT QUIT ILL TRAP IOT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM
2368 ;;
8d063cd8 2369 esac
8d063cd8 2370 ;;
8d063cd8 2371 esac
a687059c 2372 sig_name="ZERO $*"
8d063cd8 2373 ;;
2374esac
a687059c 2375echo "Signals are: $sig_name"
8d063cd8 2376
a687059c 2377: see what type of char stdio uses.
8d063cd8 2378echo " "
a687059c 2379if $contains 'unsigned.*char.*_ptr;' /usr/include/stdio.h >/dev/null 2>&1 ; then
2380 echo "Your stdio uses unsigned chars."
2381 stdchar="unsigned char"
2382else
2383 echo "Your stdio uses signed chars."
2384 stdchar="char"
2385fi
8d063cd8 2386
a687059c 2387: see what type uids are declared as in the kernel
2388case "$uidtype" in
2389'')
2390 if $contains 'uid_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
2391 dflt='uid_t';
8d063cd8 2392 else
a687059c 2393 set `grep '_ruid;' /usr/include/sys/user.h 2>/dev/null` unsigned short
2394 case $1 in
2395 unsigned) dflt="$1 $2" ;;
2396 *) dflt="$1" ;;
2397 esac
8d063cd8 2398 fi
2399 ;;
a687059c 2400*) dflt="$uidtype"
2401 ;;
8d063cd8 2402esac
a687059c 2403cont=true
8d063cd8 2404echo " "
03a14243 2405rp="What type are user ids returned by getuid(), etc.? [$dflt]"
8d063cd8 2406$echo $n "$rp $c"
2407. myread
a687059c 2408uidtype="$ans"
8d063cd8 2409
a687059c 2410: preserve RCS keywords in files with variable substitution, grrr
2411Log='$Log'
2412Header='$Header'
2413
2414
a1cc2bdc 2415: determine which malloc to compile in
2416echo " "
2417case "$usemymalloc" in
2418'')
2419 if bsd || v7; then
2420 dflt='y'
2421 else
2422 dflt='n'
2423 fi
2424 ;;
2425*) dflt="$usemymalloc"
2426 ;;
2427esac
2428rp="Do you wish to attempt to use the malloc that comes with $package? [$dflt]"
2429$echo $n "$rp $c"
2430. myread
2431case "$ans" in
2432'') ans=$dflt;;
2433esac
2434usemymalloc="$ans"
2435case "$ans" in
2436y*) mallocsrc='malloc.c'; mallocobj='malloc.o';;
2437*) mallocsrc=''; mallocobj='';;
2438esac
2439
d8f2e4cc 2440: determine compiler compiler
2441case "$yacc" in
2442'') dflt=yacc;;
2443*) dflt="$yacc";;
2444esac
2445cont=true
2446 echo " "
2447rp="Which compiler compiler (yacc or bison) will you use? [$dflt]"
2448$echo $n "$rp $c"
2449. myread
2450case "$ans" in
2451'') ans="$dflt";;
2452esac
2453yacc="$ans"
2454
8d063cd8 2455echo " "
2456echo "End of configuration questions."
2457echo " "
2458
2459: create config.sh file
2460echo " "
2461if test -d ../UU; then
2462 cd ..
2463fi
2464echo "Creating config.sh..."
2465$spitshell <<EOT >config.sh
2466$startsh
2467# config.sh
2468# This file was produced by running the Configure script.
2469
2470d_eunice='$d_eunice'
8d063cd8 2471define='$define'
91407755 2472eunicefix='$eunicefix'
8d063cd8 2473loclist='$loclist'
2474expr='$expr'
2475sed='$sed'
2476echo='$echo'
2477cat='$cat'
2478rm='$rm'
2479mv='$mv'
2480cp='$cp'
2481tail='$tail'
2482tr='$tr'
2483mkdir='$mkdir'
2484sort='$sort'
2485uniq='$uniq'
2486grep='$grep'
2487trylist='$trylist'
2488test='$test'
2489inews='$inews'
2490egrep='$egrep'
2491more='$more'
2492pg='$pg'
2493Mcc='$Mcc'
2494vi='$vi'
2495mailx='$mailx'
2496mail='$mail'
378cc40b 2497cpp='$cpp'
a687059c 2498perl='$perl'
2499emacs='$emacs'
2500ls='$ls'
2501rmail='$rmail'
2502sendmail='$sendmail'
2503shar='$shar'
2504smail='$smail'
2505tbl='$tbl'
2506troff='$troff'
2507nroff='$nroff'
2508uname='$uname'
2509uuname='$uuname'
2510line='$line'
2511chgrp='$chgrp'
2512chmod='$chmod'
2513lint='$lint'
2514sleep='$sleep'
2515pr='$pr'
2516tar='$tar'
2517ln='$ln'
2518lpr='$lpr'
2519lp='$lp'
2520touch='$touch'
2521make='$make'
2522date='$date'
91407755 2523csh='$csh'
8d063cd8 2524Log='$Log'
2525Header='$Header'
2526bin='$bin'
a687059c 2527byteorder='$byteorder'
8d063cd8 2528contains='$contains'
378cc40b 2529cppstdin='$cppstdin'
36ce8bec 2530cppminus='$cppminus'
a687059c 2531d_bcmp='$d_bcmp'
135863df 2532d_bcopy='$d_bcopy'
0d3e774c 2533d_bzero='$d_bzero'
8d063cd8 2534d_charsprf='$d_charsprf'
2e1b3b7e 2535d_crypt='$d_crypt'
a687059c 2536cryptlib='$cryptlib'
91407755 2537d_csh='$d_csh'
13281fa4 2538d_dosuid='$d_dosuid'
a687059c 2539d_dup2='$d_dup2'
378cc40b 2540d_fchmod='$d_fchmod'
2541d_fchown='$d_fchown'
a687059c 2542d_fcntl='$d_fcntl'
2543d_flock='$d_flock'
378cc40b 2544d_getgrps='$d_getgrps'
a687059c 2545d_gethent='$d_gethent'
2546d_getpgrp='$d_getpgrp'
d8f2e4cc 2547d_getpgrp2='$d_getpgrp2'
a687059c 2548d_getprior='$d_getprior'
2549d_htonl='$d_htonl'
8d063cd8 2550d_index='$d_index'
a687059c 2551d_ioctl='$d_ioctl'
378cc40b 2552d_killpg='$d_killpg'
0d3e774c 2553d_lstat='$d_lstat'
a687059c 2554d_memcmp='$d_memcmp'
378cc40b 2555d_memcpy='$d_memcpy'
a687059c 2556d_mkdir='$d_mkdir'
2557d_ndbm='$d_ndbm'
2558d_odbm='$d_odbm'
2559d_readdir='$d_readdir'
378cc40b 2560d_rename='$d_rename'
a687059c 2561d_rmdir='$d_rmdir'
378cc40b 2562d_setegid='$d_setegid'
2563d_seteuid='$d_seteuid'
a687059c 2564d_setpgrp='$d_setpgrp'
d8f2e4cc 2565d_setpgrp2='$d_setpgrp2'
a687059c 2566d_setprior='$d_setprior'
2567d_setregid='$d_setregid'
2568d_setresgid='$d_setresgid'
2569d_setreuid='$d_setreuid'
2570d_setresuid='$d_setresuid'
378cc40b 2571d_setrgid='$d_setrgid'
2572d_setruid='$d_setruid'
a687059c 2573d_socket='$d_socket'
2574d_sockpair='$d_sockpair'
2575d_oldsock='$d_oldsock'
2576socketlib='$socketlib'
135863df 2577d_statblks='$d_statblks'
36ce8bec 2578d_stdstdio='$d_stdstdio'
8d063cd8 2579d_strctcpy='$d_strctcpy'
d8f2e4cc 2580d_strerror='$d_strerror'
2e1b3b7e 2581d_symlink='$d_symlink'
a687059c 2582d_syscall='$d_syscall'
a687059c 2583d_varargs='$d_varargs'
8d063cd8 2584d_vfork='$d_vfork'
36ce8bec 2585d_voidsig='$d_voidsig'
a687059c 2586d_vprintf='$d_vprintf'
2587d_charvspr='$d_charvspr'
91407755 2588d_wait4='$d_wait4'
378cc40b 2589gidtype='$gidtype'
a687059c 2590i_dirent='$i_dirent'
2591d_dirnamlen='$d_dirnamlen'
2592i_fcntl='$i_fcntl'
2593i_grp='$i_grp'
03a14243 2594i_niin='$i_niin'
a687059c 2595i_pwd='$i_pwd'
2596d_pwquota='$d_pwquota'
2597d_pwage='$d_pwage'
91407755 2598d_pwchange='$d_pwchange'
2599d_pwclass='$d_pwclass'
2600d_pwexpire='$d_pwexpire'
a687059c 2601i_sysdir='$i_sysdir'
2602i_sysioctl='$i_sysioctl'
d8f2e4cc 2603i_sysndir='$i_sysndir'
2604i_time='$i_time'
2605i_systime='$i_systime'
2606d_systimekernel='$d_systimekernel'
2607i_utime='$i_utime'
a687059c 2608i_varargs='$i_varargs'
2609i_vfork='$i_vfork'
2610intsize='$intsize'
8d063cd8 2611libc='$libc'
a1cc2bdc 2612mallocsrc='$mallocsrc'
2613mallocobj='$mallocobj'
2614usemymalloc='$usemymalloc'
8d063cd8 2615mansrc='$mansrc'
2616manext='$manext'
2617models='$models'
2618split='$split'
2619small='$small'
2620medium='$medium'
2621large='$large'
2622huge='$huge'
a687059c 2623optimize='$optimize'
8d063cd8 2624ccflags='$ccflags'
91407755 2625cppflags='$cppflags'
8d063cd8 2626ldflags='$ldflags'
a687059c 2627cc='$cc'
2628libs='$libs'
8d063cd8 2629n='$n'
2630c='$c'
2631package='$package'
a687059c 2632randbits='$randbits'
2633sig_name='$sig_name'
8d063cd8 2634spitshell='$spitshell'
2635shsharp='$shsharp'
2636sharpbang='$sharpbang'
2637startsh='$startsh'
36ce8bec 2638stdchar='$stdchar'
378cc40b 2639uidtype='$uidtype'
8d063cd8 2640voidflags='$voidflags'
2641defvoidused='$defvoidused'
d8f2e4cc 2642yacc='$yacc'
378cc40b 2643privlib='$privlib'
d8f2e4cc 2644lib='$lib'
8d063cd8 2645CONFIG=true
2646EOT
13281fa4 2647
8d063cd8 2648CONFIG=true
2649
2650echo " "
2651dflt=''
378cc40b 2652fastread=''
8d063cd8 2653echo "If you didn't make any mistakes, then just type a carriage return here."
2654rp="If you need to edit config.sh, do it as a shell escape here:"
2655$echo $n "$rp $c"
2656. UU/myread
2657case "$ans" in
2658'') ;;
2659*) : in case they cannot read
2660 eval $ans;;
2661esac
d8f2e4cc 2662: if this fails, just run all the .SH files by hand
378cc40b 2663. ./config.sh
8d063cd8 2664
2665echo " "
2666echo "Doing variable substitutions on .SH files..."
d96024cf 2667set x `awk '{print $1}' <MANIFEST | $grep '\.SH'`
36ce8bec 2668shift
2669case $# in
26700) set x *.SH; shift;;
2671esac
2672if test ! -f $1; then
2673 shift
2674fi
8d063cd8 2675for file in $*; do
2676 case "$file" in
2677 */*)
2678 dir=`$expr X$file : 'X\(.*\)/'`
2679 file=`$expr X$file : 'X.*/\(.*\)'`
2680 (cd $dir && . $file)
2681 ;;
2682 *)
2683 . $file
2684 ;;
2685 esac
2686done
2687if test -f config.h.SH; then
2688 if test ! -f config.h; then
2689 : oops, they left it out of MANIFEST, probably, so do it anyway.
2690 . config.h.SH
2691 fi
2692fi
2693
2694if $contains '^depend:' Makefile >/dev/null 2>&1; then
2695 dflt=n
2696 $cat <<EOM
2697
2698Now you need to generate make dependencies by running "make depend".
2699You might prefer to run it in background: "make depend > makedepend.out &"
2700It can take a while, so you might not want to run it right now.
2701
2702EOM
2703 rp="Run make depend now? [$dflt]"
2704 $echo $n "$rp $c"
2705 . UU/myread
2706 case "$ans" in
a687059c 2707 y*) make depend && echo "Now you must run a make."
8d063cd8 2708 ;;
2709 *) echo "You must run 'make depend' then 'make'."
2710 ;;
2711 esac
2712elif test -f Makefile; then
2713 echo " "
2714 echo "Now you must run a make."
2715else
2716 echo "Done."
2717fi
2718
2719$rm -f kit*isdone
13281fa4 2720: the following is currently useless
8d063cd8 2721cd UU && $rm -f $rmlist
13281fa4 2722: since this removes it all anyway
2723cd .. && $rm -rf UU
8d063cd8 2724: end of Configure