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