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