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