perl 3.0 patch #15 (combined patch)
[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#
ff2452de 11# $Header: Configure,v 3.0.1.6 90/03/12 16:10:23 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
ff2452de 260libswanted="net_s net nsl_s nsl socket nm ndir ndbm dbm sun bsd BSD x c_s"
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 " "
ff2452de 641 rp="Where do you want to put the public executables? (~name ok) [$dflt]"
a687059c 642 $echo $n "$rp $c"
643 . myread
644 bin="$ans"
ff2452de 645 bin=`./filexp "$bin"`
a687059c 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 " "
ff2452de 678 rp="Where do the manual pages (source) go? (~name ok) [$dflt]"
a687059c 679 $echo $n "$rp $c"
680 . myread
ff2452de 681 mansrc=`./filexp "$ans"`
a687059c 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)
ff2452de 710 manext=p
a687059c 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..."
91407755 1113case "$libswanted" in
1114'') libswanted='c_s';;
1115esac
1116for thislib in $libswanted; do
d8f2e4cc 1117 case "$thislib" in
1118 dbm) thatlib=ndbm;;
1119 *_s) thatlib=NONE;;
1120 *) thatlib="${thislib}_s";;
1121 *) thatlib=NONE;;
1122 esac
0d3e774c 1123 xxx=`loc lib$thislib.a X /usr/lib /usr/local/lib /lib`
1124 if test -f $xxx; then
91407755 1125 echo "Found -l$thislib."
1126 case "$dflt" in
d8f2e4cc 1127 *-l$thislib*|*-l$thatlib*);;
91407755 1128 *) dflt="$dflt -l$thislib";;
1129 esac
91407755 1130 else
0d3e774c 1131 xxx=`loc lib$thislib.a X $libpth`
1132 if test -f $xxx; then
1133 echo "Found $xxx."
1134 case "$dflt" in
1135 *$xxx*);;
1136 *) dflt="$dflt $xxx";;
1137 esac
1138 else
d8f2e4cc 1139 xxx=`loc Slib$thislib.a X $xlibpth`
0d3e774c 1140 if test -f $xxx; then
1141 echo "Found -l$thislib."
1142 case "$dflt" in
d8f2e4cc 1143 *-l$thislib*|*-l$thatlib*);;
0d3e774c 1144 *) dflt="$dflt -l$thislib";;
1145 esac
1146 else
1147 echo "No -l$thislib."
1148 fi
1149 fi
91407755 1150 fi
1151done
1152set X $dflt
1153shift
1154dflt="$*"
ff2452de 1155case "$libs" in
1156*) dflt="$libs";;
1157esac
91407755 1158case "$dflt" in
1159'') dflt='none';;
1160esac
a687059c 1161
1162$cat <<EOM
1163
1164Some versions of Unix support shared libraries, which make
1165executables smaller but make load time slightly longer.
1166
1167On some systems, mostly newer Unix System V's, the shared library
1168is included by putting the option "-lc_s" as the last thing on the
1169cc command line when linking. Other systems use shared libraries
1170by default. There may be other libraries needed to compile $package
1171on your machine as well. If your system needs the "-lc_s" option,
1172include it here. Include any other special libraries here as well.
d8f2e4cc 1173Say "none" for none.
a687059c 1174EOM
1175
1176echo " "
1177rp="Any additional libraries? [$dflt]"
1178$echo $n "$rp $c"
1179. myread
1180case "$ans" in
1181none) ans='';
1182esac
1183libs="$ans"
1184
1185: check for ordering of bytes in a long
1186case "$byteorder" in
1187'')
1188cat <<'EOM'
1189
1190In the following, larger digits indicate more significance. A big-endian
1191machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
1192little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
91407755 1193machines may have weird orders like 3412. A Cray will report 87654321. If
1194the test program works the default is probably right.
1195I'm now running the test program...
a687059c 1196EOM
1197 $cat >try.c <<'EOCP'
1198#include <stdio.h>
1199main()
1200{
1201 int i;
1202 union {
1203 unsigned long l;
0d3e774c 1204 char c[sizeof(long)];
a687059c 1205 } u;
1206
0d3e774c 1207 if (sizeof(long) > 4)
ff2452de 1208 u.l = (0x08070605<<32) | 0x04030201;
0d3e774c 1209 else
1210 u.l = 0x04030201;
91407755 1211 for (i=0; i < sizeof(long); i++)
1212 printf("%c",u.c[i]+'0');
1213 printf("\n");
a687059c 1214}
1215EOCP
ff2452de 1216 if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
449aadca 1217 dflt=`./try`
a687059c 1218 case "$dflt" in
91407755 1219 ????|????????) echo "(The test program ran ok.)";;
a687059c 1220 *) echo "(The test program didn't run right for some reason.)";;
1221 esac
1222 else
1223 dflt='4321'
1224 echo "(I can't seem to compile the test program. Guessing big-endian...)"
1225 fi
1226 ;;
1227*)
1228 echo " "
1229 dflt="$byteorder"
1230 ;;
1231esac
1232rp="What is the order of bytes in a long? [$dflt]"
1233$echo $n "$rp $c"
1234. myread
1235byteorder="$ans"
1236$rm -f try.c try
1237
1238: see how we invoke the C preprocessor
1239echo " "
1240echo "Now, how can we feed standard input to your C preprocessor..."
1241cat <<'EOT' >testcpp.c
1242#define ABC abc
1243#define XYZ xyz
1244ABC.XYZ
1245EOT
1246echo 'Maybe "'"$cc"' -E" will work...'
1247$cc -E <testcpp.c >testcpp.out 2>&1
91407755 1248: try to force gcc preprocessor if that is the compiler they are using
1249case $? in
12500) cppstdin="$cc -E";;
1251*) case "$cc" in
1252 *gcc*)
1253 cd ..
1254 echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
1255 echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
1256 chmod 755 cppstdin
1257 cppstdin=`pwd`/cppstdin
1258 cppminus='';
1259 cd UU
1260 $cppstdin <testcpp.c >testcpp.out 2>&1
1261 ;;
1262 esac
1263 ;;
1264esac
a687059c 1265if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1266 echo "Yup, it does."
1267 cppstdin="$cc -E"
1268 cppminus='';
1269else
1270 echo 'Nope, maybe "'$cpp'" will work...'
1271 $cpp <testcpp.c >testcpp.out 2>&1
1272 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1273 echo "Yup, it does."
1274 cppstdin="$cpp"
1275 cppminus='';
1276 else
1277 echo 'No such luck...maybe "'$cpp' -" will work...'
1278 $cpp - <testcpp.c >testcpp.out 2>&1
1279 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1280 echo "It works!"
1281 cppstdin="$cpp"
1282 cppminus='-';
1283 else
1284 echo 'Nixed again...maybe "'"$cc"' -E -" will work...'
1285 $cc -E - <testcpp.c >testcpp.out 2>&1
1286 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1287 echo "Hooray, it works! I was beginning to wonder."
1288 cppstdin="$cc -E"
1289 cppminus='-';
1290 else
1291 echo 'Nope...maybe "'"$cc"' -P" will work...'
1292 $cc -P <testcpp.c >testcpp.out 2>&1
1293 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1294 echo "Yup, that does."
1295 cppstdin="$cc -P"
1296 cppminus='';
1297 else
1298 echo 'Nope...maybe "'"$cc"' -P -" will work...'
1299 $cc -P - <testcpp.c >testcpp.out 2>&1
1300 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1301 echo "Yup, that does."
1302 cppstdin="$cc -P"
1303 cppminus='-';
1304 else
1305 echo 'Hmm...perhaps you already told me...'
1306 case "$cppstdin" in
1307 '') ;;
1308 *) $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1;;
1309 esac
1310 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1311 echo "Hooray, you did! I was beginning to wonder."
1312 else
1313 echo 'Uh-uh. Time to get fancy...'
1314 cd ..
1315 echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
1316 echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
1317 chmod 755 cppstdin
1318 cppstdin=`pwd`/cppstdin
1319 cppminus='';
1320 cd UU
1321 $cppstdin <testcpp.c >testcpp.out 2>&1
1322 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1323 echo "Eureka!."
1324 else
1325 dflt=blurfl
1326 $echo $n "No dice. I can't find a C preprocessor. Name one: $c"
1327 rp='Name a C preprocessor:'
1328 . myread
1329 cppstdin="$ans"
1330 $cppstdin <testcpp.c >testcpp.out 2>&1
1331 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
1332 echo "OK, that will do."
1333 else
1334 echo "Sorry, I can't get that to work. Go find one."
1335 exit 1
1336 fi
1337 fi
1338 fi
1339 fi
1340 fi
1341 fi
1342 fi
1343 fi
1344fi
1345rm -f testcpp.c testcpp.out
1346
91407755 1347: get list of predefined functions in a handy place
1348echo " "
1349case "$libc" in
1350'') libc=unknown;;
1351esac
1352case "$libpth" in
1353'') libpth='/lib /usr/lib /usr/local/lib';;
1354esac
1355case "$libs" in
1356*-lc_s*) libc=`loc libc_s.a $libc $libpth`
1357esac
1358libnames='';
1359case "$libs" in
1360'') ;;
1361*) for thislib in $libs; do
1362 case "$thislib" in
1363 -l*) thislib=`expr X$thislib : 'X-l\(.*\)'`
1364 try=`loc lib$thislib.a blurfl/dyick $libpth`
1365 if test ! -f $try; then
1366 try=`loc lib$thislib blurfl/dyick $libpth`
1367 if test ! -f $try; then
1368 try=`loc $thislib blurfl/dyick $libpth`
1369 if test ! -f $try; then
d8f2e4cc 1370 try=`loc Slib$thislib.a blurfl/dyick $xlibpth`
1371 if test ! -f $try; then
1372 try=''
1373 fi
91407755 1374 fi
1375 fi
1376 fi
1377 libnames="$libnames $try"
1378 ;;
0d3e774c 1379 *) libnames="$libnames $thislib" ;;
91407755 1380 esac
1381 done
1382 ;;
1383esac
1384set /usr/lib/libc.so.[0-9]*
1385eval set \$$#
1386if test -f "$1"; then
1387 echo "Your shared C library is in $1."
1388 libc="$1"
1389elif test -f $libc; then
1390 echo "Your C library is in $libc, like you said before."
1391elif test -f /lib/libc.a; then
1392 echo "Your C library is in /lib/libc.a. You're normal."
1393 libc=/lib/libc.a
1394else
1395 ans=`loc libc.a blurfl/dyick $libpth`
1396 if test ! -f "$ans"; then
1397 ans=`loc libc blurfl/dyick $libpth`
1398 fi
1399 if test ! -f "$ans"; then
1400 ans=`loc clib blurfl/dyick $libpth`
1401 fi
1402 if test ! -f "$ans"; then
d8f2e4cc 1403 ans=`loc Slibc.a blurfl/dyick $xlibpth`
91407755 1404 fi
1405 if test ! -f "$ans"; then
d8f2e4cc 1406 ans=`loc Mlibc.a blurfl/dyick $xlibpth`
91407755 1407 fi
1408 if test ! -f "$ans"; then
d8f2e4cc 1409 ans=`loc Llibc.a blurfl/dyick $xlibpth`
91407755 1410 fi
1411 if test -f "$ans"; then
1412 echo "Your C library is in $ans, of all places."
1413 libc=$ans
1414 else
1415 cat <<EOM
1416
1417I can't seem to find your C library. I've looked in the following places:
1418
1419 $libpth
1420
1421None of these seems to contain your C library. What is the full name
1422EOM
1423 dflt=None
1424 $echo $n "of your C library? $c"
1425 rp='C library full name?'
1426 . myread
1427 libc="$ans"
1428 fi
1429fi
1430echo " "
449aadca 1431set `echo $libc $libnames | tr ' ' '\012' | sort | uniq`
91407755 1432$echo $n "Extracting names from $* for later perusal...$c"
1433nm $* 2>/dev/null >libc.tmp
1434$sed -n -e 's/^.* [AT] *_[_.]*//p' -e 's/^.* [AT] //p' <libc.tmp >libc.list
1435if $contains '^printf$' libc.list >/dev/null 2>&1; then
1436 echo "done"
1437else
1438 $sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p' <libc.tmp >libc.list
1439 $contains '^printf$' libc.list >/dev/null 2>&1 || \
1440 $sed -n -e 's/^.* D __*//p' -e 's/^.* D //p' <libc.tmp >libc.list
1441 $contains '^printf$' libc.list >/dev/null 2>&1 || \
1442 $sed -n -e 's/^_//' \
1443 -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p' <libc.tmp >libc.list
449aadca 1444 $contains '^printf$' libc.list >/dev/null 2>&1 || \
1445 $sed -n -e 's/^.*|FUNC |GLOB .*|//p' <libc.tmp >libc.list
91407755 1446 if $contains '^printf$' libc.list >/dev/null 2>&1; then
1447 echo "done"
1448 else
1449 echo " "
1450 echo "nm didn't seem to work right."
1451 echo "Trying ar instead..."
1452 if ar t $libc > libc.tmp; then
1453 for thisname in $libnames; do
1454 ar t $thisname >>libc.tmp
1455 done
1456 $sed -e 's/\.o$//' < libc.tmp > libc.list
1457 echo "Ok."
1458 else
1459 echo "ar didn't seem to work right."
1460 echo "Maybe this is a Cray...trying bld instead..."
1461 if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
1462 for thisname in $libnames; do
1463 bld t $libnames | \
1464 $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
1465 ar t $thisname >>libc.tmp
1466 done
1467 echo "Ok."
1468 else
1469 echo "That didn't work either. Giving up."
1470 exit 1
1471 fi
1472 fi
1473 fi
1474fi
1475
1476inlibc='echo " ";
1477if $contains "^$1\$" libc.list >/dev/null 2>&1;
1478then echo "$1() found"; eval "$2=$define";
1479else echo "$1() not found"; eval "$2=$undef"; fi'
1480
1481rmlist="$rmlist libc.tmp libc.list"
1482
a687059c 1483: see if bcmp exists
1484set bcmp d_bcmp
1485eval $inlibc
1486
1487: see if bcopy exists
1488set bcopy d_bcopy
1489eval $inlibc
1490
0d3e774c 1491: see if bzero exists
1492set bzero d_bzero
1493eval $inlibc
1494
a687059c 1495: see if sprintf is declared as int or pointer to char
1496echo " "
1497cat >.ucbsprf.c <<'EOF'
1498main() { char buf[10]; exit((unsigned long)sprintf(buf,"%s","foo") > 10L); }
1499EOF
1500if $cc $ccflags .ucbsprf.c -o .ucbsprf >/dev/null 2>&1 && .ucbsprf; then
1501 echo "Your sprintf() returns (int)."
1502 d_charsprf="$undef"
1503else
1504 echo "Your sprintf() returns (char*)."
1505 d_charsprf="$define"
1506fi
1507/bin/rm -f .ucbsprf.c .ucbsprf
1508
1509: see if vprintf exists
1510echo " "
1511if $contains '^vprintf$' libc.list >/dev/null 2>&1; then
1512 echo 'vprintf() found.'
1513 d_vprintf="$define"
1514 cat >.ucbsprf.c <<'EOF'
ff2452de 1515#include <stdio.h>
a687059c 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
ff2452de 1951if $cc -c $ccflags 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
ff2452de 2010 if $cc $ccflags \
d8f2e4cc 2011 $i_time $i_systime $d_systimekernel $s_timeval \
ff2452de 2012 try.c -o try >/dev/null 2>&1 ; then
d8f2e4cc 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{
ff2452de 2070 char *volatile foo;
2071 volatile int bar;
449aadca 2072 foo = foo;
2073}
2074EOCP
ff2452de 2075if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
449aadca 2076 d_volatile="$define"
2077 echo "Yup, it does."
2078else
2079 d_volatile="$undef"
2080 echo "Nope, it doesn't."
2081fi
2082$rm -f try.*
2083
91407755 2084: see if there is a wait4
2085set wait4 d_wait4
2086eval $inlibc
2087
8d063cd8 2088: check for void type
2089echo " "
2090$cat <<EOM
2091Checking to see how well your C compiler groks the void type...
2092
2093 Support flag bits are:
2094 1: basic void declarations.
2095 2: arrays of pointers to functions returning void.
2096 4: operations between pointers to and addresses of void functions.
2097
2098EOM
2099case "$voidflags" in
2100'')
2101 $cat >try.c <<'EOCP'
2102#if TRY & 1
2103void main() {
2104#else
2105main() {
2106#endif
a687059c 2107 extern void moo(); /* function returning void */
2108 void (*goo)(); /* ptr to func returning void */
8d063cd8 2109#if TRY & 2
2110 void (*foo[10])();
2111#endif
2112
2113#if TRY & 4
a687059c 2114 if(goo == moo) {
8d063cd8 2115 exit(0);
2116 }
2117#endif
2118 exit(0);
2119}
2120EOCP
ff2452de 2121 if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
a687059c 2122 voidflags=$defvoidused
2123 echo "It appears to support void."
8d063cd8 2124 if $contains warning .out >/dev/null 2>&1; then
2125 echo "However, you might get some warnings that look like this:"
2126 $cat .out
2127 fi
2128 else
a687059c 2129 echo "Hmm, your compiler has some difficulty with void. Checking further..."
ff2452de 2130 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1 ; then
8d063cd8 2131 echo "It supports 1..."
ff2452de 2132 if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1 ; then
8d063cd8 2133 voidflags=3
2134 echo "And it supports 2 but not 4."
2135 else
2136 echo "It doesn't support 2..."
ff2452de 2137 if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1 ; then
8d063cd8 2138 voidflags=5
2139 echo "But it supports 4."
2140 else
2141 voidflags=1
2142 echo "And it doesn't support 4."
2143 fi
2144 fi
2145 else
2146 echo "There is no support at all for void."
2147 voidflags=0
2148 fi
2149 fi
2150esac
2151dflt="$voidflags";
2152rp="Your void support flags add up to what? [$dflt]"
2153$echo $n "$rp $c"
2154. myread
2155voidflags="$ans"
2156$rm -f try.* .out
2157
378cc40b 2158: see what type gids are declared as in the kernel
0d3e774c 2159echo " "
378cc40b 2160case "$gidtype" in
2161'')
0d3e774c 2162 if $contains 'getgroups.*short' /usr/lib/lint/llib-lc >/dev/null 2>&1; then
2163 dflt='short'
2164 elif $contains 'getgroups.*int' /usr/lib/lint/llib-lc >/dev/null 2>&1; then
2165 dflt='int'
2166 elif $contains 'gid_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
2167 dflt='gid_t'
378cc40b 2168 else
2169 set `grep 'groups\[NGROUPS\];' /usr/include/sys/user.h 2>/dev/null` unsigned short
2170 case $1 in
2171 unsigned) dflt="$1 $2" ;;
2172 *) dflt="$1" ;;
2173 esac
2174 fi
2175 ;;
2176*) dflt="$gidtype"
2177 ;;
2178esac
2179cont=true
91407755 2180echo "(The following only matters if you have getgroups().)"
2181rp="What type are the group ids returned by getgroups()? [$dflt]"
378cc40b 2182$echo $n "$rp $c"
2183. myread
2184gidtype="$ans"
8d063cd8 2185
a687059c 2186: see if this is an fcntl system
2187echo " "
2188if $test -r /usr/include/fcntl.h ; then
2189 i_fcntl="$define"
2190 echo "fcntl.h found."
2191else
2192 i_fcntl="$undef"
2193 echo "No fcntl.h found, but that's ok."
2194fi
378cc40b 2195
a687059c 2196: see if this is an grp system
2197echo " "
2198if $test -r /usr/include/grp.h ; then
2199 i_grp="$define"
2200 echo "grp.h found."
2201else
2202 i_grp="$undef"
2203 echo "No grp.h found."
2204fi
378cc40b 2205
03a14243 2206: see if this is a netinet/in.h system
2207echo " "
0d3e774c 2208xxx=`loc netinet/in.h x /usr/include /usr/local/include $inclwanted`
2209if test -f $xxx; then
03a14243 2210 i_niin="$define"
2211 echo "netinet/in.h found."
2212else
2213 i_niin="$undef"
2214 echo "No netinet/in.h found."
2215fi
2216
a687059c 2217: see if this is a sys/dir.h system
378cc40b 2218echo " "
a687059c 2219if $test -r /usr/include/sys/dir.h ; then
2220 i_sysdir="$define"
d8f2e4cc 2221 echo "sys/dir.h found."
378cc40b 2222else
a687059c 2223 i_sysdir="$undef"
d8f2e4cc 2224 echo "No sys/dir.h found."
378cc40b 2225fi
2226
a687059c 2227: see if ioctl defs are in sgtty/termio or sys/ioctl
378cc40b 2228echo " "
a687059c 2229if $test -r /usr/include/sys/ioctl.h ; then
2230 i_sysioctl="$define"
2231 echo "sys/ioctl.h found."
2232else
2233 i_sysioctl="$undef"
2234 echo "sys/ioctl.h not found, assuming ioctl args are defined in sgtty.h."
2235fi
378cc40b 2236
d8f2e4cc 2237: see if this is a sys/ndir.h system
2238echo " "
2239xxx=`loc sys/ndir.h x /usr/include /usr/local/include $inclwanted`
2240if test -f $xxx; then
2241 i_sysndir="$define"
2242 echo "sys/ndir.h found."
2243else
2244 i_sysndir="$undef"
2245 echo "No sys/ndir.h found."
2246fi
2247
449aadca 2248: see if we should include utime.h
d8f2e4cc 2249echo " "
2250if $test -r /usr/include/utime.h ; then
2251 i_utime="$define"
2252 echo "utime.h found."
2253else
2254 i_utime="$undef"
2255 echo "No utime.h found, but that's ok."
2256fi
2257
a687059c 2258: see if this is a varargs system
2259echo " "
2260if $test -r /usr/include/varargs.h ; then
2261 i_varargs="$define"
2262 echo "varargs.h found."
2263else
2264 i_varargs="$undef"
2265 echo "No varargs.h found, but that's ok (I hope)."
2266fi
378cc40b 2267
a687059c 2268: see if this is a vfork system
2269echo " "
2270if $test -r /usr/include/vfork.h ; then
2271 i_vfork="$define"
2272 echo "vfork.h found."
2273else
2274 i_vfork="$undef"
2275 echo "No vfork.h found."
2276fi
8d063cd8 2277
a687059c 2278: check for length of integer
2279echo " "
2280case "$intsize" in
8d063cd8 2281'')
a687059c 2282 echo "Checking to see how big your integers are..."
2283 $cat >try.c <<'EOCP'
2284#include <stdio.h>
2285main()
2286{
2287 printf("%d\n", sizeof(int));
2288}
2289EOCP
ff2452de 2290 if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
449aadca 2291 dflt=`./try`
8d063cd8 2292 else
a687059c 2293 dflt='4'
2294 echo "(I can't seem to compile the test program. Guessing...)"
2295 fi
8d063cd8 2296 ;;
8d063cd8 2297*)
a687059c 2298 dflt="$intsize"
8d063cd8 2299 ;;
2300esac
a687059c 2301rp="What is the size of an integer (in bytes)? [$dflt]"
2302$echo $n "$rp $c"
2303. myread
2304intsize="$ans"
2305$rm -f try.c try
8d063cd8 2306
a687059c 2307: determine where private executables go
2308case "$privlib" in
8d063cd8 2309'')
a687059c 2310 dflt=/usr/lib/$package
2311 test -d /usr/local/lib && dflt=/usr/local/lib/$package
2312 ;;
2313*) dflt="$privlib"
8d063cd8 2314 ;;
8d063cd8 2315esac
2316$cat <<EOM
8d063cd8 2317
a687059c 2318The $package package has some auxiliary files that should be put in a library
2319that is accessible by everyone. Where do you want to put these "private"
8d063cd8 2320EOM
ff2452de 2321$echo $n "but accessible files? (~name ok) [$dflt] $c"
a687059c 2322rp="Put private files where? [$dflt]"
8d063cd8 2323. myread
ff2452de 2324privlib=`./filexp "$ans"`
8d063cd8 2325
a687059c 2326: check for size of random number generator
2327echo " "
2328case "$randbits" in
2329'')
2330 echo "Checking to see how many bits your rand function produces..."
2331 $cat >try.c <<'EOCP'
2332#include <stdio.h>
2333main()
2334{
2335 register int i;
2336 register unsigned long tmp;
2337 register unsigned long max = 0L;
2338
2339 for (i=1000; i; i--) {
2340 tmp = (unsigned long)rand();
2341 if (tmp > max) max = tmp;
2342 }
2343 for (i=0; max; i++)
2344 max /= 2;
2345 printf("%d\n",i);
2346}
2347EOCP
ff2452de 2348 if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
449aadca 2349 dflt=`./try`
a687059c 2350 else
2351 dflt='?'
2352 echo "(I can't seem to compile the test program...)"
2353 fi
8d063cd8 2354 ;;
a687059c 2355*)
2356 dflt="$randbits"
8d063cd8 2357 ;;
a687059c 2358esac
2359rp="How many bits does your rand() function produce? [$dflt]"
2360$echo $n "$rp $c"
2361. myread
2362randbits="$ans"
2363$rm -f try.c try
2364
2365: generate list of signal names
2366echo " "
2367case "$sig_name" in
2368'')
2369 echo "Generating a list of signal names..."
91407755 2370 set X `cat /usr/include/signal.h /usr/include/sys/signal.h 2>&1 | awk '
2371$1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $3 ~ /^[1-9][0-9]*$/ {
2372 sig[$3] = substr($2,4,20)
2373 if (max < $3 && $3 < 60) {
2374 max = $3
2375 }
2376}
2377
2378END {
2379 for (i=1; i<=max; i++) {
2380 if (sig[i] == "")
2381 printf "%d", i
2382 else
2383 printf "%s", sig[i]
2384 if (i < max)
2385 printf " "
2386 }
2387 printf "\n"
2388}
2389'`
a687059c 2390 shift
2391 case $# in
2392 0) echo 'kill -l' >/tmp/foo$$
91407755 2393 set X `$csh -f </tmp/foo$$`
a687059c 2394 shift
2395 case $# in
2396 0)set HUP INT QUIT ILL TRAP IOT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM
2397 ;;
8d063cd8 2398 esac
8d063cd8 2399 ;;
8d063cd8 2400 esac
a687059c 2401 sig_name="ZERO $*"
8d063cd8 2402 ;;
2403esac
a687059c 2404echo "Signals are: $sig_name"
8d063cd8 2405
a687059c 2406: see what type of char stdio uses.
8d063cd8 2407echo " "
449aadca 2408if $contains 'unsigned.*char.*_ptr.*;' /usr/include/stdio.h >/dev/null 2>&1 ; then
a687059c 2409 echo "Your stdio uses unsigned chars."
2410 stdchar="unsigned char"
2411else
2412 echo "Your stdio uses signed chars."
2413 stdchar="char"
2414fi
8d063cd8 2415
a687059c 2416: see what type uids are declared as in the kernel
2417case "$uidtype" in
2418'')
2419 if $contains 'uid_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
2420 dflt='uid_t';
8d063cd8 2421 else
a687059c 2422 set `grep '_ruid;' /usr/include/sys/user.h 2>/dev/null` unsigned short
2423 case $1 in
2424 unsigned) dflt="$1 $2" ;;
2425 *) dflt="$1" ;;
2426 esac
8d063cd8 2427 fi
2428 ;;
a687059c 2429*) dflt="$uidtype"
2430 ;;
8d063cd8 2431esac
a687059c 2432cont=true
8d063cd8 2433echo " "
03a14243 2434rp="What type are user ids returned by getuid(), etc.? [$dflt]"
8d063cd8 2435$echo $n "$rp $c"
2436. myread
a687059c 2437uidtype="$ans"
8d063cd8 2438
a687059c 2439: preserve RCS keywords in files with variable substitution, grrr
2440Log='$Log'
2441Header='$Header'
2442
2443
a1cc2bdc 2444: determine which malloc to compile in
2445echo " "
2446case "$usemymalloc" in
2447'')
2448 if bsd || v7; then
2449 dflt='y'
2450 else
2451 dflt='n'
2452 fi
2453 ;;
2454*) dflt="$usemymalloc"
2455 ;;
2456esac
2457rp="Do you wish to attempt to use the malloc that comes with $package? [$dflt]"
2458$echo $n "$rp $c"
2459. myread
2460case "$ans" in
2461'') ans=$dflt;;
2462esac
2463usemymalloc="$ans"
2464case "$ans" in
2465y*) mallocsrc='malloc.c'; mallocobj='malloc.o';;
2466*) mallocsrc=''; mallocobj='';;
2467esac
2468
d8f2e4cc 2469: determine compiler compiler
2470case "$yacc" in
2471'') dflt=yacc;;
2472*) dflt="$yacc";;
2473esac
2474cont=true
2475 echo " "
449aadca 2476rp="Which compiler compiler (yacc or bison -y) will you use? [$dflt]"
d8f2e4cc 2477$echo $n "$rp $c"
2478. myread
2479case "$ans" in
2480'') ans="$dflt";;
2481esac
2482yacc="$ans"
2483
8d063cd8 2484echo " "
2485echo "End of configuration questions."
2486echo " "
2487
2488: create config.sh file
2489echo " "
2490if test -d ../UU; then
2491 cd ..
2492fi
2493echo "Creating config.sh..."
2494$spitshell <<EOT >config.sh
2495$startsh
2496# config.sh
2497# This file was produced by running the Configure script.
2498
2499d_eunice='$d_eunice'
8d063cd8 2500define='$define'
91407755 2501eunicefix='$eunicefix'
8d063cd8 2502loclist='$loclist'
2503expr='$expr'
2504sed='$sed'
2505echo='$echo'
2506cat='$cat'
2507rm='$rm'
2508mv='$mv'
2509cp='$cp'
2510tail='$tail'
2511tr='$tr'
2512mkdir='$mkdir'
2513sort='$sort'
2514uniq='$uniq'
2515grep='$grep'
2516trylist='$trylist'
2517test='$test'
2518inews='$inews'
2519egrep='$egrep'
2520more='$more'
2521pg='$pg'
2522Mcc='$Mcc'
2523vi='$vi'
2524mailx='$mailx'
2525mail='$mail'
378cc40b 2526cpp='$cpp'
a687059c 2527perl='$perl'
2528emacs='$emacs'
2529ls='$ls'
2530rmail='$rmail'
2531sendmail='$sendmail'
2532shar='$shar'
2533smail='$smail'
2534tbl='$tbl'
2535troff='$troff'
2536nroff='$nroff'
2537uname='$uname'
2538uuname='$uuname'
2539line='$line'
2540chgrp='$chgrp'
2541chmod='$chmod'
2542lint='$lint'
2543sleep='$sleep'
2544pr='$pr'
2545tar='$tar'
2546ln='$ln'
2547lpr='$lpr'
2548lp='$lp'
2549touch='$touch'
2550make='$make'
2551date='$date'
91407755 2552csh='$csh'
8d063cd8 2553Log='$Log'
2554Header='$Header'
2555bin='$bin'
a687059c 2556byteorder='$byteorder'
8d063cd8 2557contains='$contains'
378cc40b 2558cppstdin='$cppstdin'
36ce8bec 2559cppminus='$cppminus'
a687059c 2560d_bcmp='$d_bcmp'
135863df 2561d_bcopy='$d_bcopy'
0d3e774c 2562d_bzero='$d_bzero'
8d063cd8 2563d_charsprf='$d_charsprf'
2e1b3b7e 2564d_crypt='$d_crypt'
a687059c 2565cryptlib='$cryptlib'
91407755 2566d_csh='$d_csh'
13281fa4 2567d_dosuid='$d_dosuid'
a687059c 2568d_dup2='$d_dup2'
378cc40b 2569d_fchmod='$d_fchmod'
2570d_fchown='$d_fchown'
a687059c 2571d_fcntl='$d_fcntl'
2572d_flock='$d_flock'
378cc40b 2573d_getgrps='$d_getgrps'
a687059c 2574d_gethent='$d_gethent'
2575d_getpgrp='$d_getpgrp'
d8f2e4cc 2576d_getpgrp2='$d_getpgrp2'
a687059c 2577d_getprior='$d_getprior'
2578d_htonl='$d_htonl'
8d063cd8 2579d_index='$d_index'
a687059c 2580d_ioctl='$d_ioctl'
378cc40b 2581d_killpg='$d_killpg'
0d3e774c 2582d_lstat='$d_lstat'
a687059c 2583d_memcmp='$d_memcmp'
378cc40b 2584d_memcpy='$d_memcpy'
a687059c 2585d_mkdir='$d_mkdir'
2586d_ndbm='$d_ndbm'
2587d_odbm='$d_odbm'
2588d_readdir='$d_readdir'
378cc40b 2589d_rename='$d_rename'
a687059c 2590d_rmdir='$d_rmdir'
378cc40b 2591d_setegid='$d_setegid'
2592d_seteuid='$d_seteuid'
a687059c 2593d_setpgrp='$d_setpgrp'
d8f2e4cc 2594d_setpgrp2='$d_setpgrp2'
a687059c 2595d_setprior='$d_setprior'
2596d_setregid='$d_setregid'
2597d_setresgid='$d_setresgid'
2598d_setreuid='$d_setreuid'
2599d_setresuid='$d_setresuid'
378cc40b 2600d_setrgid='$d_setrgid'
2601d_setruid='$d_setruid'
a687059c 2602d_socket='$d_socket'
2603d_sockpair='$d_sockpair'
2604d_oldsock='$d_oldsock'
2605socketlib='$socketlib'
135863df 2606d_statblks='$d_statblks'
36ce8bec 2607d_stdstdio='$d_stdstdio'
8d063cd8 2608d_strctcpy='$d_strctcpy'
d8f2e4cc 2609d_strerror='$d_strerror'
2e1b3b7e 2610d_symlink='$d_symlink'
a687059c 2611d_syscall='$d_syscall'
a687059c 2612d_varargs='$d_varargs'
8d063cd8 2613d_vfork='$d_vfork'
36ce8bec 2614d_voidsig='$d_voidsig'
449aadca 2615d_volatile='$d_volatile'
a687059c 2616d_vprintf='$d_vprintf'
2617d_charvspr='$d_charvspr'
91407755 2618d_wait4='$d_wait4'
378cc40b 2619gidtype='$gidtype'
a687059c 2620i_dirent='$i_dirent'
2621d_dirnamlen='$d_dirnamlen'
2622i_fcntl='$i_fcntl'
2623i_grp='$i_grp'
03a14243 2624i_niin='$i_niin'
a687059c 2625i_pwd='$i_pwd'
2626d_pwquota='$d_pwquota'
2627d_pwage='$d_pwage'
91407755 2628d_pwchange='$d_pwchange'
2629d_pwclass='$d_pwclass'
2630d_pwexpire='$d_pwexpire'
a687059c 2631i_sysdir='$i_sysdir'
2632i_sysioctl='$i_sysioctl'
d8f2e4cc 2633i_sysndir='$i_sysndir'
2634i_time='$i_time'
2635i_systime='$i_systime'
2636d_systimekernel='$d_systimekernel'
2637i_utime='$i_utime'
a687059c 2638i_varargs='$i_varargs'
2639i_vfork='$i_vfork'
2640intsize='$intsize'
8d063cd8 2641libc='$libc'
a1cc2bdc 2642mallocsrc='$mallocsrc'
2643mallocobj='$mallocobj'
2644usemymalloc='$usemymalloc'
8d063cd8 2645mansrc='$mansrc'
2646manext='$manext'
2647models='$models'
2648split='$split'
2649small='$small'
2650medium='$medium'
2651large='$large'
2652huge='$huge'
a687059c 2653optimize='$optimize'
8d063cd8 2654ccflags='$ccflags'
91407755 2655cppflags='$cppflags'
8d063cd8 2656ldflags='$ldflags'
a687059c 2657cc='$cc'
2658libs='$libs'
8d063cd8 2659n='$n'
2660c='$c'
2661package='$package'
a687059c 2662randbits='$randbits'
2663sig_name='$sig_name'
8d063cd8 2664spitshell='$spitshell'
2665shsharp='$shsharp'
2666sharpbang='$sharpbang'
2667startsh='$startsh'
36ce8bec 2668stdchar='$stdchar'
378cc40b 2669uidtype='$uidtype'
8d063cd8 2670voidflags='$voidflags'
2671defvoidused='$defvoidused'
d8f2e4cc 2672yacc='$yacc'
378cc40b 2673privlib='$privlib'
d8f2e4cc 2674lib='$lib'
8d063cd8 2675CONFIG=true
2676EOT
13281fa4 2677
8d063cd8 2678CONFIG=true
2679
2680echo " "
2681dflt=''
378cc40b 2682fastread=''
8d063cd8 2683echo "If you didn't make any mistakes, then just type a carriage return here."
2684rp="If you need to edit config.sh, do it as a shell escape here:"
2685$echo $n "$rp $c"
2686. UU/myread
2687case "$ans" in
2688'') ;;
2689*) : in case they cannot read
2690 eval $ans;;
2691esac
d8f2e4cc 2692: if this fails, just run all the .SH files by hand
378cc40b 2693. ./config.sh
8d063cd8 2694
2695echo " "
2696echo "Doing variable substitutions on .SH files..."
d96024cf 2697set x `awk '{print $1}' <MANIFEST | $grep '\.SH'`
36ce8bec 2698shift
2699case $# in
27000) set x *.SH; shift;;
2701esac
2702if test ! -f $1; then
2703 shift
2704fi
8d063cd8 2705for file in $*; do
2706 case "$file" in
2707 */*)
2708 dir=`$expr X$file : 'X\(.*\)/'`
2709 file=`$expr X$file : 'X.*/\(.*\)'`
2710 (cd $dir && . $file)
2711 ;;
2712 *)
2713 . $file
2714 ;;
2715 esac
2716done
2717if test -f config.h.SH; then
2718 if test ! -f config.h; then
2719 : oops, they left it out of MANIFEST, probably, so do it anyway.
2720 . config.h.SH
2721 fi
2722fi
2723
2724if $contains '^depend:' Makefile >/dev/null 2>&1; then
2725 dflt=n
2726 $cat <<EOM
2727
2728Now you need to generate make dependencies by running "make depend".
2729You might prefer to run it in background: "make depend > makedepend.out &"
2730It can take a while, so you might not want to run it right now.
2731
2732EOM
2733 rp="Run make depend now? [$dflt]"
2734 $echo $n "$rp $c"
2735 . UU/myread
2736 case "$ans" in
a687059c 2737 y*) make depend && echo "Now you must run a make."
8d063cd8 2738 ;;
2739 *) echo "You must run 'make depend' then 'make'."
2740 ;;
2741 esac
2742elif test -f Makefile; then
2743 echo " "
2744 echo "Now you must run a make."
2745else
2746 echo "Done."
2747fi
2748
2749$rm -f kit*isdone
13281fa4 2750: the following is currently useless
8d063cd8 2751cd UU && $rm -f $rmlist
13281fa4 2752: since this removes it all anyway
2753cd .. && $rm -rf UU
8d063cd8 2754: end of Configure