#! /bin/sh # # If these # comments don't work, trim them. Don't worry about any other # shell scripts, Configure will trim # comments from them for you. # # Note: if you are running ksh, be sure to say "sh Configure". # # (If you are trying to port this package to a machine without sh, I would # suggest you cut out the prototypical config.h from the end of Configure # and edit it to reflect your system. Some packages may include samples # of config.h for certain machines, so you might look for one of those.) # # $Header: Configure,v 2.0 86/09/17 15:32:58 lwall Exp $ # # $Log: Configure,v $ # Revision 2.0 86/09/17 15:32:58 lwall # Baseline for netwide release. # # # Yes, you may rip this off to use in other distribution packages. # # (Note: this Configure script was generated automatically. Rather than # working with this copy of Configure, you may wish to get metaconfig.) define='define' undef='/*undef' d_eunice='' eunicefix='' loclist='' expr='' sed='' echo='' cat='' rm='' mv='' cp='' tail='' tr='' mkdir='' sort='' uniq='' grep='' trylist='' test='' inews='' egrep='' more='' pg='' Mcc='' vi='' mailx='' Log='' Header='' bin='' cc='' contains='' cpp='' d_index='' d_void='' iandd='' libc='' mansrc='' manext='' n='' c='' package='' registers='' reg1='' reg2='' reg3='' reg4='' reg5='' reg6='' reg7='' reg8='' reg9='' reg10='' reg11='' reg12='' reg13='' reg14='' reg15='' reg16='' spitshell='' shsharp='' sharpbang='' startsh='' CONFIG='' package=patch echo "Beginning of configuration questions for $package kit." : Eunice requires " " instead of "", can you believe it echo " " : sanity checks PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc' export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$) if test ! -t 0; then echo "Say 'sh Configure', not 'sh grimble if grep blurfldyick grimble >/dev/null 2>&1 ; then contains=contains else if grep grimblepritz grimble >/dev/null 2>&1 ; then contains=grep else contains=contains fi fi rm -f grimble : the following should work in any shell case "$contains" in contains*) echo " " echo "AGH! Grep doesn't return a status. Attempting remedial action." cat >contains <<'EOSS' grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp EOSS chmod 755 contains esac : first determine how to suppress newline on echo command echo "Checking echo to see how to suppress newlines..." (echo "hi there\c" ; echo " ") >.echotmp if $contains c .echotmp >/dev/null 2>&1 ; then echo "...using -n." n='-n' c='' else echo "...using \\\c" echo "c." n='' c='\c' fi echo $n "Type carriage return to continue. Your cursor should be here-->$c" read ans rm -f .echotmp : now set up to do reads with possible shell escape : if this does not work on your machine, 1,$ s/. myread/read ans/ cat <myread ans='!' while expr "X\$ans" : "X!" >/dev/null; do read ans case "\$ans" in !) sh echo " " echo $n "\$rp $c" ;; !*) set \`expr "X\$ans" : "X!\(.*\)\$"\` sh -c "\$*" echo " " echo $n "\$rp $c" ;; esac done rp='Your answer:' EOSC : general instructions cat < libc.list; then echo "done" else echo " " echo "The archiver doesn't think $libc is a reasonable library." exit 1 fi : make some quick guesses about what we are up against echo " " echo $n "Hmm... $c" if $contains SIGTSTP /usr/include/signal.h >/dev/null 2>&1 ; then echo "Looks kind of like a BSD system, but we'll see..." echo exit 0 >bsd echo exit 1 >usg echo exit 1 >v7 else if $contains fcntl libc.list >/dev/null 2>&1 ; then echo "Looks kind of like a USG system, but we'll see..." echo exit 1 >bsd echo exit 0 >usg echo exit 1 >v7 else echo "Looks kind of like a version 7 system, but we'll see..." echo exit 1 >bsd echo exit 1 >usg echo exit 0 >v7 fi fi if $contains vmssystem libc.list >/dev/null 2>&1 ; then cat <<'EOI' There is, however, a strange, musty smell in the air that reminds me of something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit. EOI echo "exit 0" >eunice eunicefix=unixtovms d_eunice="$define" : it so happens the Eunice I know will not run shell scripts in Unix format else echo " " echo "Congratulations. You aren't running Eunice." eunicefix=':' d_eunice="$undef" echo "exit 1" >eunice fi chmod 755 bsd usg v7 eunice $eunicefix bsd usg v7 eunice : see if sh knows # comments echo " " echo "Checking your sh to see if it knows about # comments..." if sh -c '#' >/dev/null 2>&1 ; then echo "Your sh handles # comments correctly." shsharp=true spitshell=cat echo " " echo "Okay, let's see if #! works on this system..." echo "#!/bin/echo hi" > try $eunicefix try chmod 755 try try > today if test -s today; then echo "It does." sharpbang='#!' else echo "#! /bin/echo hi" > try $eunicefix try chmod 755 try try > today if test -s today; then echo "It does." sharpbang='#! ' else echo "It doesn't." sharpbang=': use ' fi fi else echo "Your sh doesn't grok # comments--I will strip them later on." shsharp=false echo "exec grep -v '^#'" >spitshell chmod 755 spitshell $eunicefix spitshell spitshell=`pwd`/spitshell echo "I presume that if # doesn't work, #! won't work either!" sharpbang=': use ' fi : figure out how to guarantee sh startup echo " " echo "Checking out how to guarantee sh startup..." startsh=$sharpbang'/bin/sh' echo "Let's see if '$startsh' works..." cat >try <loc $startsh thing=\$1 shift dflt=\$1 shift for dir in \$*; do case "\$thing" in .) if test -d \$dir/\$thing; then echo \$dir exit 0 fi ;; *) if test -f \$dir/\$thing; then echo \$dir/\$thing exit 0 fi ;; esac done echo \$dflt exit 1 EOSC chmod 755 loc $eunicefix loc loclist=" expr sed echo cat rm grep " trylist=" test Mcc " for file in $loclist; do xxx=`loc $file $file $pth` eval $file=$xxx case "$xxx" in /*) echo $file is in $xxx. ;; *) echo "I don't know where $file is. I hope it's in everyone's PATH." ;; esac done echo " " echo "Don't worry if any of the following aren't found..." ans=offhand for file in $trylist; do xxx=`loc $file $file $pth` eval $file=$xxx case "$xxx" in /*) echo $file is in $xxx. ;; *) echo "I don't see $file out there, $ans." ans=either ;; esac done case "$egrep" in egrep) echo "Substituting grep for egrep." egrep=$grep ;; esac case "$test" in test) echo "Hopefully test is built into your sh." ;; /bin/test) echo " " echo $n 'Is your "test" built into sh? [n] (OK to guess) '"$c" rp='test built into sh? [n]' . myread case "$ans" in y*) test=test ;; esac ;; *) test=test ;; esac case "$echo" in echo) echo "Hopefully echo is built into your sh." ;; /bin/echo) echo " " echo "Checking compatibility between /bin/echo and builtin echo (if any)..." $echo $n "hi there$c" >foo1 echo $n "hi there$c" >foo2 if cmp foo1 foo2 >/dev/null 2>&1; then echo "They are compatible. In fact, they may be identical." else echo "They are not compatible--the echo builtin will be used." echo=echo fi $rm -f foo1 foo2 ;; *) echo=echo ;; esac : index or strcpy $echo " " if $contains index libc.list >/dev/null 2>&1 ; then $echo "Your system appears to use index() and rindex() rather than strchr()" $echo $n "and strrchr(). Is this correct? [y] $c" rp='index() rather than strchr()? [y]' . myread case "$ans" in n*|f*) d_index="$define" ;; *) d_index="$undef" ;; esac else $echo "Your system appears to use strchr() and strrchr() rather than index()" $echo $n "and rindex(). Is this correct? [y] $c" rp='strchr() rather than index()? [y]' . myread case "$ans" in n*|f*) d_index="$undef" ;; *) d_index="$define" ;; esac fi : check for void type $echo " " $echo "Checking to see if your C compiler groks the void type..." $cat >try.c <<'EOCP' void main(); EOCP if cc -c try.c >/dev/null 2>&1 ; then d_void="$undef" $echo "Yup, it does." else d_void="$define" $echo "Nope, it doesn't (boo hiss). I will substitute int." fi $rm -f try.* : see how we invoke the C preprocessor echo " " echo "Checking to see how your C preprocessor is invoked..." cat <<'EOT' >testcpp.c #define ABC abc #define XYZ xyz ABC.XYZ EOT echo 'Maybe "cc -E" will work...' cc -E testcpp.c >testcpp.out 2>&1 if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then echo "Yup, it does." cpp='cc -E' else echo 'Nope...maybe "cc -P" will work...' cc -P testcpp.c >testcpp.out 2>&1 if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then echo "Yup, that does." cpp='cc -P' else echo 'Nixed again...maybe "/lib/cpp" will work...' /lib/cpp testcpp.c >testcpp.out 2>&1 if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then echo "Hooray, it works! I was beginning to wonder." cpp='/lib/cpp' else echo 'Hmm...maybe you already told me...' case "$cpp" in '') ;; *) $cpp testcpp.c >testcpp.out 2>&1;; esac if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then echo "Hooray, you did! I was beginning to wonder." else echo $n "Nope. I can't find a C preprocessor. Name one: $c" rp='Name a C preprocessor:' . myread cpp="$ans" $cpp testcpp.c >testcpp.out 2>&1 if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then echo "OK, that will do." else echo "Sorry, I can't get that to work. Go find one." exit 1 fi fi fi fi fi rm -f testcpp.c testcpp.out : get C preprocessor symbols handy echo " " cat <<'EOT' >Cppsym.c char *sym[] = { #ifdef mc68000 "mc68000", #endif #ifdef sun "sun", #endif #ifdef gcos "gcos", #endif #ifdef unix "unix", #endif #ifdef ibm "ibm", #endif #ifdef gimpel "gimpel", #endif #ifdef interdata "interdata", #endif #ifdef tss "tss", #endif #ifdef os "os", #endif #ifdef mert "mert", #endif #ifdef pyr "pyr", #endif #ifdef vax "vax", #endif #ifdef pdp11 "pdp11", #endif #ifdef i8086 "i8086", #endif #ifdef z8000 "z8000", #endif #ifdef 3b2 "3b2", #endif #ifdef 3b5 "3b5", #endif #ifdef 3b20 "3b20", #endif #ifdef 3b200 "3b200", #endif 0}; main(argc,argv) int argc; char **argv; { int i; for (argc--,argv++; argc; argc--,argv++) { for (i=0; sym[i]; i++) { if (strcmp(argv[0],sym[i]) == 0) exit(0); } } exit(1); } EOT echo "Your machine appears to have the following attributes:" $cpp Cppsym.c | sed -n -e 's/^ "\(.*\)",$/\1/p' cc Cppsym.c -o Cppsym rm -f Cppsym.c : see how many register declarations we want to use case "$registers" in '') if Cppsym pdp11 i8086 z8000; then dflt=3 else if Cppsym sun mc68000; then dflt=10 else : if you have any other numbers for me, send them in dflt=6 fi fi ;; *) dflt=$registers ;; esac cat <.foo . .foo awk "END { for (i=1; i<=$registers; i++) printf \"reg%d=register\n\", i}" \ .foo . .foo rm -f .foo : preserve RCS keywords in files with variable substitution, grrr Log='$Log' Header='$Header' : set up shell script to do ~ expansion cat >filexp <&2 exit 1 fi case "\$1" in */*) $echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\` ;; *) $echo \$dir ;; esac fi ;; *) $echo \$1 ;; esac EOSS chmod 755 filexp $eunicefix filexp : determine where public executables go case "$bin" in '') dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin` ;; *) dflt="$bin" ;; esac bin='blurfl/dyick' while $test ! -d "$bin" ; do case "$bin" in blurfl*) ;; *) $echo "$bin does not appear to exist." ;; esac $echo " " rp="Where do you want to put the public executables? [$dflt]" $echo $n "$rp $c" . myread bin="$ans" bin=`filexp $bin` case "$bin" in '') bin=$dflt ;; esac done : determine where manual pages go case "$mansrc" in '') dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1` ;; *) dflt="$mansrc" ;; esac mansrc='blurfl/dyick' while $test ! -d "$mansrc" ; do case "$mansrc" in blurfl*) ;; *) $echo "$mansrc does not appear to exist." ;; esac $echo " " rp="Where do the manual pages (source) go? [$dflt]" $echo $n "$rp $c" . myread mansrc=`filexp "$ans"` case "$mansrc" in '') mansrc=$dflt ;; esac done case "$mansrc" in *l) manext=l ;; *n) manext=n ;; *) manext=1 ;; esac : see if we need a special compiler $echo " " if usg; then case "$cc" in '') case "$Mcc" in /*) dflt='Mcc' ;; *) if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then dflt='cc -M' else dflt='cc' fi ;; esac ;; *) dflt="$cc";; esac $cat <<'EOM' On some systems the default C compiler will not resolve multiple global references that happen to have the same name. On some such systems the "Mcc" command may be used to force these to be resolved. On other systems a "cc -M" command is required. What command will force resolution on EOM $echo $n "this system? [$dflt] $c" rp="Command to resolve multiple refs? [$dflt]" . myread cc="$ans" case "$cc" in '') cc="$dflt" ;; esac else $echo "Not a USG system--assuming cc can resolve multiple definitions." cc=cc fi : see if we should throw a -i into the Makefile $echo " " if Cppsym pdp11 i8086 z8000; then if $contains '\-i' $mansrc/cc.1 >/dev/null 2>&1 ; then rp="Your system appears to have separate I and D space. Is this true? [y]" $echo $n "$rp $c" . myread case "$ans" in n*|f*) iandd='' ;; *) iandd='-i' ;; esac else $echo "Your system appears to NOT have separate I and D space." $echo $n "Is this correct? [y] $c" rp='No separate I and D. Correct? [y]' . myread case "$ans" in n*|f*) iandd='-i' ;; *) iandd='' ;; esac fi else $echo $n "Does your machine have separate I and D space? [n] $c" . myread case "$ans" in y*) iandd='-i' ;; *) iandd='' ;; esac fi $echo " " $echo "End of configuration questions." $echo " " : create config.sh file $echo " " $echo "Creating config.sh..." $spitshell <config.sh $startsh # config.sh # This file was produced by running the Configure script. d_eunice='$d_eunice' eunicefix='$eunicefix' loclist='$loclist' expr='$expr' sed='$sed' echo='$echo' cat='$cat' rm='$rm' mv='$mv' cp='$cp' tail='$tail' tr='$tr' mkdir='$mkdir' sort='$sort' uniq='$uniq' grep='$grep' trylist='$trylist' test='$test' inews='$inews' egrep='$egrep' more='$more' pg='$pg' Mcc='$Mcc' vi='$vi' mailx='$mailx' Log='$Log' Header='$Header' bin='$bin' cc='$cc' contains='$contains' cpp='$cpp' d_index='$d_index' d_void='$d_void' iandd='$iandd' libc='$libc' mansrc='$mansrc' manext='$manext' n='$n' c='$c' package='$package' registers='$registers' reg1='$reg1' reg2='$reg2' reg3='$reg3' reg4='$reg4' reg5='$reg5' reg6='$reg6' reg7='$reg7' reg8='$reg8' reg9='$reg9' reg10='$reg10' reg11='$reg11' reg12='$reg12' reg13='$reg13' reg14='$reg14' reg15='$reg15' reg16='$reg16' spitshell='$spitshell' shsharp='$shsharp' sharpbang='$sharpbang' startsh='$startsh' CONFIG=true EOT : create config.h file $echo " " $echo "Creating config.h..." $cat <config.h /* config.h * This file was produced by running the Configure script. * Feel free to modify any of this as the need arises. */ #$d_eunice EUNICE /* no file linking? */ #$d_eunice VMS /* other assorted ickies? */ #$d_index index strchr /* cultural */ #$d_index rindex strrchr /* differences? */ #$d_void void int /* is void to be avoided? */ /* How many register declarations are paid attention to? */ #define Reg1 $reg1 /**/ #define Reg2 $reg2 /**/ #define Reg3 $reg3 /**/ #define Reg4 $reg4 /**/ #define Reg5 $reg5 /**/ #define Reg6 $reg6 /**/ #define Reg7 $reg7 /**/ #define Reg8 $reg8 /**/ #define Reg9 $reg9 /**/ #define Reg10 $reg10 /**/ #define Reg11 $reg11 /**/ #define Reg12 $reg12 /**/ #define Reg13 $reg13 /**/ #define Reg14 $reg14 /**/ #define Reg15 $reg15 /**/ #define Reg16 $reg16 /**/ EOT CONFIG=true if $contains '\.SH' MANIFEST >/dev/null 2>&1; then $echo " " $echo "Doing variable substitutions on .SH files..." set `$grep /dev/null 2>&1; then $echo " " $echo 'Now you need to generate make dependencies by running "make depend".' $echo 'You might prefer to run it in background: "make depend > makedepend.out &"' $echo $n "Would you like me to run it for you (it takes quite a while)? [n] $c" rp="Run make depend now? [n]" . myread case "$ans" in y*) make depend;; esac fi $rm -f libc.list kit*isdone bsd usg v7 eunice loc Cppsym if test -f Makefile; then $echo " " $echo "Now you must run a make." else $echo "Done." fi : end of Configure