Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!sparky!kent From: lwall@netlabs.com (Larry Wall) Newsgroups: comp.sources.misc Subject: v18i025: perl - The perl programming language, Part07/36 Message-ID: <1991Apr15.015357.6834@sparky.IMD.Sterling.COM> Date: 15 Apr 91 01:53:57 GMT Sender: kent@sparky.IMD.Sterling.COM (Kent Landfield) Organization: NetLabs, Inc. Lines: 2209 Approved: kent@sparky.imd.sterling.com X-Checksum-Snefru: 6a990540 b618d9f7 88206bfa 46d975d5 Submitted-by: Larry Wall Posting-number: Volume 18, Issue 25 Archive-name: perl/part07 [There are 36 kits for perl version 4.0.] #! /bin/sh # Make a new directory for the perl sources, cd to it, and run kits 1 # thru 36 through sh. When all 36 kits have been run, read README. echo "This is perl 4.0 kit 7 (of 36). If kit 7 is complete, the line" echo '"'"End of kit 7 (of 36)"'" will echo at the end.' echo "" export PATH || (echo "You didn't use sh, you clunch." ; kill $$) mkdir 2>/dev/null echo Extracting Configure:AA sed >Configure:AA <<'!STUFFY!FUNK!' -e 's/X//' X#! /bin/sh X# X# If these # comments don't work, trim them. Don't worry about any other X# shell scripts, Configure will trim # comments from them for you. X# X# (If you are trying to port this package to a machine without sh, I would X# suggest you cut out the prototypical config.h from the end of Configure X# and edit it to reflect your system. Some packages may include samples X# of config.h for certain machines, so you might look for one of those.) X# X# $RCSfile: Configure,v $$Revision: 4.0.1.1 $$Date: 91/04/11 17:26:42 $ X# X# Yes, you may rip this off to use in other distribution packages. X# (Note: this Configure script was generated automatically. Rather than X# working with this copy of Configure, you may wish to get metaconfig.) X Xcat >/tmp/c1$$ </tmp/c2$$ </dev/null 2>&1 && \ X echo "(I see you are using the Korn shell. Some ksh's blow up on Configure," && \ X echo "especially on exotic machines. If yours does, try the Bourne shell instead.)" X Xif test ! -d ../UU; then X if test ! -d UU; then X mkdir UU X fi X cd UU Xfi X Xcase "$1" in X-d) shift; fastread='yes';; Xesac X Xd_eunice='' Xdefine='' Xeunicefix='' Xloclist='' Xexpr='' Xsed='' Xecho='' Xcat='' Xrm='' Xmv='' Xcp='' Xtail='' Xtr='' Xmkdir='' Xsort='' Xuniq='' Xgrep='' Xtrylist='' Xtest='' Xinews='' Xegrep='' Xmore='' Xpg='' XMcc='' Xvi='' Xmailx='' Xmail='' Xcpp='' Xperl='' Xemacs='' Xls='' Xrmail='' Xsendmail='' Xshar='' Xsmail='' Xtbl='' Xtroff='' Xnroff='' Xuname='' Xuuname='' Xline='' Xchgrp='' Xchmod='' Xlint='' Xsleep='' Xpr='' Xtar='' Xln='' Xlpr='' Xlp='' Xtouch='' Xmake='' Xdate='' Xcsh='' Xbash='' Xksh='' Xlex='' Xflex='' Xbison='' XLog='' XHeader='' XId='' Xlastuname='' Xalignbytes='' Xbin='' Xinstallbin='' Xbyteorder='' Xcontains='' Xcppstdin='' Xcppminus='' Xd_bcmp='' Xd_bcopy='' Xd_bzero='' Xd_castneg='' Xcastflags='' Xd_charsprf='' Xd_chsize='' Xd_crypt='' Xcryptlib='' Xd_csh='' Xd_dosuid='' Xd_dup2='' Xd_fchmod='' Xd_fchown='' Xd_fcntl='' Xd_flexfnam='' Xd_flock='' Xd_getgrps='' Xd_gethent='' Xd_getpgrp='' Xd_getpgrp2='' Xd_getprior='' Xd_htonl='' Xd_index='' Xd_killpg='' Xd_lstat='' Xd_memcmp='' Xd_memcpy='' Xd_mkdir='' Xd_msg='' Xd_msgctl='' Xd_msgget='' Xd_msgrcv='' Xd_msgsnd='' Xd_ndbm='' Xd_odbm='' Xd_open3='' Xd_readdir='' Xd_rename='' Xd_rmdir='' Xd_select='' Xd_sem='' Xd_semctl='' Xd_semget='' Xd_semop='' Xd_setegid='' Xd_seteuid='' Xd_setpgrp='' Xd_setpgrp2='' Xd_setprior='' Xd_setregid='' Xd_setresgid='' Xd_setreuid='' Xd_setresuid='' Xd_setrgid='' Xd_setruid='' Xd_shm='' Xd_shmat='' Xd_shmctl='' Xd_shmdt='' Xd_shmget='' Xd_socket='' Xd_sockpair='' Xd_oldsock='' Xsocketlib='' Xd_statblks='' Xd_stdstdio='' Xd_strctcpy='' Xd_strerror='' Xd_symlink='' Xd_syscall='' Xd_truncate='' Xd_vfork='' Xd_voidsig='' Xd_tosignal='' Xd_volatile='' Xd_vprintf='' Xd_charvspr='' Xd_wait4='' Xd_waitpid='' Xgidtype='' Xgroupstype='' Xi_fcntl='' Xi_gdbm='' Xi_grp='' Xi_niin='' Xi_sysin='' Xi_pwd='' Xd_pwquota='' Xd_pwage='' Xd_pwchange='' Xd_pwclass='' Xd_pwexpire='' Xd_pwcomment='' Xi_sys_file='' Xi_sysioctl='' Xi_time='' Xi_sys_time='' Xi_sys_select='' Xd_systimekernel='' Xi_utime='' Xi_varargs='' Xi_vfork='' Xintsize='' Xlibc='' Xnm_opts='' Xlibndir='' Xi_my_dir='' Xi_ndir='' Xi_sys_ndir='' Xi_dirent='' Xi_sys_dir='' Xd_dirnamlen='' Xndirc='' Xndiro='' Xmallocsrc='' Xmallocobj='' Xusemymalloc='' Xmallocptrtype='' Xmansrc='' Xmanext='' Xmodels='' Xsplit='' Xsmall='' Xmedium='' Xlarge='' Xhuge='' Xoptimize='' Xccflags='' Xcppflags='' Xldflags='' Xcc='' Xlibs='' Xn='' Xc='' Xpackage='' Xrandbits='' Xscriptdir='' Xsig_name='' Xspitshell='' Xshsharp='' Xsharpbang='' Xstartsh='' Xstdchar='' Xuidtype='' Xusrinclude='' XinclPath='' Xvoid='' Xvoidhave='' Xvoidwant='' Xw_localtim='' Xw_s_timevl='' Xw_s_tm='' Xyacc='' Xlib='' Xprivlib='' Xinstallprivlib='' XCONFIG='' X: get the name of the package Xpackage=perl X: Here we go... Xecho " " Xecho "Beginning of configuration questions for $package kit." X: Eunice requires " " instead of "", can you believe it Xecho " " X Xdefine='define' Xundef='undef' X: change the next line if compiling for Xenix/286 on Xenix/386 Xxlibpth='/usr/lib/386 /lib/386' Xlibpth='/usr/ccs/lib /usr/lib /usr/ucblib /usr/local/lib /usr/lib/large /lib '$xlibpth' /lib/large /usr/lib/small /lib/small' Xsmallmach='pdp11 i8086 z8000 i80286 iAPX286' Xtrap 'echo " "; exit 1' 1 2 3 X X: We must find out about Eunice early Xeunicefix=':' Xif test -f /etc/unixtovms; then X eunicefix=/etc/unixtovms Xfi Xif test -f /etc/unixtovms.exe; then X eunicefix=/etc/unixtovms.exe Xfi X Xattrlist="DGUX M_I186 M_I286 M_I386 M_I8086 M_XENIX UTS __DGUX__" Xattrlist="$attrlist __STDC__ __m88k__ ansi bsd4_2 gcos gimpel" Xattrlist="$attrlist hp9000s300 hp9000s500 hp9000s800 hpux" Xattrlist="$attrlist i186 i386 i8086 iAPX286 ibm interdata" Xattrlist="$attrlist m68k m88k mc300 mc500 mc68000 mc68k mc700 mert" Xattrlist="$attrlist ns16000 ns32000 nsc32000 os pdp11 posix pyr sinix" Xattrlist="$attrlist sparc sun tower tower32 tower32_600 tower32_800 tss" Xattrlist="$attrlist u3b2 u3b20 u3b200 u3b5 ultrix unix vax venix xenix" Xattrlist="$attrlist z8000" XboPATH="" XeoPATH="/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 /bsd43/usr/bin" Xd_newshome="/usr/NeWS" Xerrnolist=errnolist Xh_fcntl=false Xh_sys_file=false Xserve_shm="" Xserve_msg="$undef" Xserve_inet_udp="" Xserve_inet_tcp="" Xserve_unix_udp="" Xserve_unix_tcp="" Xd_ndir=ndir Xvoidwant=1 Xvoidwant=7 Xlibswanted="net_s net nsl_s nsl socket nm ndir ndbm dbm malloc sun m bsd BSD x c_s posix" Xinclwanted='/usr/include /usr/netinclude /usr/include/sun /usr/include/bsd /usr/include/lan' X X: Now test for existence of everything in MANIFEST X Xecho "First let's make sure your kit is complete. Checking..." Xawk '$1 !~ /PACKINGLIST/ {print $1}' ../MANIFEST | split -200 Xrm -f missing Xfor filelist in x??; do X (cd ..; ls `cat UU/$filelist` >/dev/null 2>>UU/missing) Xdone Xif test -s missing; then X cat missing X kill $$ Xfi Xecho "Looks good..." X X: some greps do not return status, grrr. Xecho "grimblepritz" >contains.txt Xif grep blurfldyick contains.txt >/dev/null 2>&1 ; then X contains=contains Xelif grep grimblepritz contains.txt >/dev/null 2>&1 ; then X contains=grep Xelse X contains=contains Xfi X: the following should work in any shell Xcase "$contains" in Xcontains*) X echo " " X echo "AGH! Grep doesn't return a status. Attempting remedial action." X cat >contains <<'EOSS' Xgrep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp XEOSS Xchmod +x contains Xesac X X: see if sh knows # comments Xecho " " Xecho "Checking your sh to see if it knows about # comments..." Xif sh -c '#' >/dev/null 2>&1 ; then X echo "Your sh handles # comments correctly." X shsharp=true X spitshell=cat X echo " " X echo "Okay, let's see if #! works on this system..." X if test -f /bsd43/bin/echo; then X echo "#!/bsd43/bin/echo hi" > spit.sh X else X echo "#!/bin/echo hi" > spit.sh X fi X $eunicefix spit.sh X chmod +x spit.sh X ./spit.sh > today X if $contains hi today >/dev/null 2>&1; then X echo "It does." X sharpbang='#!' X else X echo "#! /bin/echo hi" > spit.sh X $eunicefix spit.sh X chmod +x spit.sh X ./spit.sh > today X if test -s today; then X echo "It does." X sharpbang='#! ' X else X echo "It doesn't." X sharpbang=': use ' X fi X fi Xelse X echo "Your sh doesn't grok # comments--I will strip them later on." X shsharp=false X echo "exec grep -v '^#'" >spitshell X chmod +x spitshell X $eunicefix spitshell X spitshell=`pwd`/spitshell X echo "I presume that if # doesn't work, #! won't work either!" X sharpbang=': use ' Xfi X X: figure out how to guarantee sh startup Xecho " " Xecho "Checking out how to guarantee sh startup..." Xstartsh=$sharpbang'/bin/sh' Xecho "Let's see if '$startsh' works..." Xcat >start.sh <echotmp Xif $contains c echotmp >/dev/null 2>&1 ; then X echo "...using -n." X n='-n' X c='' Xelse X cat <<'EOM' X...using \c XEOM X n='' X c='\c' Xfi Xecho $n "Type carriage return to continue. Your cursor should be here-->$c" Xread ans X X: now set up to do reads with possible shell escape and default assignment Xcat <myread Xcase "\$fastread" in Xyes) ans=''; echo " " ;; X*) ans='!';; Xesac Xwhile expr "X\$ans" : "X!" >/dev/null; do X read ans X case "\$ans" in X !) X sh X echo " " X echo $n "\$rp $c" X ;; X !*) X set \`expr "X\$ans" : "X!\(.*\)\$"\` X sh -c "\$*" X echo " " X echo $n "\$rp $c" X ;; X esac Xdone Xrp='Your answer:' Xcase "\$ans" in X'') ans="\$dflt";; Xesac XEOSC X X: general instructions Xcat <loc X$startsh Xcase \$# in X0) exit 1;; Xesac Xthing=\$1 Xshift Xdflt=\$1 Xshift Xfor dir in \$*; do X case "\$thing" in X .) X if test -d \$dir/\$thing; then X echo \$dir X exit 0 X fi X ;; X *) X if test -f \$dir/\$thing; then X echo \$dir/\$thing X exit 0 X elif test -f \$dir/\$thing.exe; then X : on Eunice apparently X echo \$dir/\$thing X exit 0 X fi X ;; X esac Xdone Xecho \$dflt Xexit 1 XEOSC Xchmod +x loc X$eunicefix loc Xloclist=" Xcat Xcp Xecho Xexpr Xgrep Xmkdir Xmv Xrm Xsed Xsort Xtr Xuniq X" Xtrylist=" XMcc Xbison Xcpp Xcsh Xegrep Xnroff Xtest Xuname Xyacc X" Xpth=`echo :$boPATH:$PATH:$eoPATH: | sed -e 's/:/ /g'` Xfor file in $loclist; do X xxx=`./loc $file $file $pth` X eval $file=$xxx X eval _$file=$xxx X case "$xxx" in X /*) X echo $file is in $xxx. X ;; X *) X echo "I don't know where $file is. I hope it's in everyone's PATH." X ;; X esac Xdone Xecho " " Xecho "Don't worry if any of the following aren't found..." Xans=offhand Xfor file in $trylist; do X xxx=`./loc $file $file $pth` X eval $file=$xxx X eval _$file=$xxx X case "$xxx" in X /*) X echo $file is in $xxx. X ;; X *) X echo "I don't see $file out there, $ans." X ans=either X ;; X esac Xdone Xcase "$egrep" in Xegrep) X echo "Substituting grep for egrep." X egrep=$grep X ;; Xesac Xcase "$test" in Xtest) X echo "Hopefully test is built into your sh." X ;; X/bin/test) X if sh -c "PATH= test true" >/dev/null 2>&1; then X echo "Using the test built into your sh." X test=test X fi X ;; X*) X test=test X ;; Xesac Xcase "$echo" in Xecho) X echo "Hopefully echo is built into your sh." X ;; X/bin/echo) X echo " " X echo "Checking compatibility between /bin/echo and builtin echo (if any)..." X $echo $n "hi there$c" >Loc1.txt X echo $n "hi there$c" >Loc2.txt X if cmp Loc1.txt Loc2.txt >/dev/null 2>&1; then X echo "They are compatible. In fact, they may be identical." X else X case "$n" in X '-n') n='' c='\c' ans='\c' ;; X *) n='-n' c='' ans='-n' ;; X esac X cat <filexp <&2 X exit 1 X fi X case "\$1" in X */*) X echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\` X ;; X *) X echo \$dir X ;; X esac X fi X ;; X*) X echo \$1 X ;; Xesac XEOSS Xchmod +x filexp X$eunicefix filexp X X: get old answers, if there is a config file out there Xhint=default Xif test -f ../config.sh; then X echo " " X eval `grep lastuname ../config.sh` X uname=`(uname -a || hostname) 2>&1` X if test "X$uname" = "X$lastuname"; then X dflt=y X else X dflt=n X fi X lastuname="$uname" X rp="I see a config.sh file. Did Configure make it on THIS system? [$dflt]" X echo $n "$rp $c" X . myread X case "$ans" in X n*) echo "OK, I'll ignore it."; mv ../config.sh ../config.sh.old;; X *) echo "Fetching default answers from your old config.sh file..." X tmp="$n" X ans="$c" X . ../config.sh X n="$tmp" X c="$ans" X hint=previous X ;; X esac Xfi Xif test -d ../hints && test ! -f ../config.sh; then X echo ' ' X echo "First time through, eh? I have some defaults handy for the following systems:" X (cd ../hints; ls -C *.sh | sed 's/\.sh/ /g') X dflt='' X : Half the following guesses are probably wrong... X test -f /irix && dflt="$dflt sgi" X test -f /xenix && dflt="$dflt sco_xenix" X test -f /dynix && dflt="$dflt dynix" X test -f /dnix && dflt="$dflt dnix" X test -f /bin/mips && /bin/mips && dflt="$dflt mips" X if test -f /bin/uname || test -f /usr/bin/uname; then X set `uname -a | tr '[A-Z]' '[a-z]'` X X test -f "../hints/$5.sh" && dflt="$dflt $5" X X case "$5" in X 3b2) dflt="$dflt 3b2";; X fps*) dflt="$dflt fps";; X mips*) dflt="$dflt mips";; X [23]100) dflt="$dflt mips";; X next*) dflt="$dflt next" ;; X esac X X case "$1" in X aix) dflt="$dflt aix_rs" ;; X sunos) case "$3" in X 3.4) dflt="$dflt sunos_3_4" ;; X 3.5) dflt="$dflt sunos_3_5" ;; X 4.0.1) dflt="$dflt sunos_4_0_1" ;; X 4.0.2) dflt="$dflt sunos_4_0_2" ;; X esac X ;; X dnix) dflt="$dflt dnix" ;; X genix) dflt="$dflt genix" ;; X hp*ux) dflt="$dflt hpux" ;; X next) dflt="$dflt next" ;; X irix) dflt="$dflt sgi" ;; X ultrix) case "$3" in X 3*) dflt="$dflt ultrix_3" ;; X 4*) dflt="$dflt ultrix_4" ;; X esac X ;; X uts) dflt="$dflt uts" ;; X $2) if test -f /etc/systemid; then X set `echo $3 | sed 's/\./ /` $4 X if test -f ../hints/sco_$1_$2_$3.sh; then X dflt="$dflt sco_$1_$2_$3" X elif test -f ../hints/sco_$1_$2.sh; then X dflt="$dflt sco_$1_$2" X elif test -f ../hints/sco_$1.sh; then X dflt="$dflt sco_$1" X fi X fi X ;; X esac X fi X set X `echo $dflt | tr ' ' '\012' | sort | uniq` X shift X dflt=${1+"$@"} X case "$dflt" in X '') dflt=none;; X esac X echo '(You may give one or more space-separated answers, or "none" if appropriate.)' X rp="Which of these apply, if any? [$dflt]" X echo $n "$rp $c" X . myread X for file in $ans; do X if test -f ../hints/$file.sh; then X . ../hints/$file.sh X hint=recommended X fi X done Xfi X Xcat >whoa <<'EOF' Xeval "was=\$$2" Xdflt=y Xecho ' ' Xecho "*** WHOA THERE!!! ***" Xecho " The $hint value for \$$2 on this machine was \"$was\"!" Xrp=" Keep the $hint value? [y]" Xecho $n "$rp $c" X. myread Xcase "$ans" in Xy) td=$was; tu=$was;; Xesac XEOF X Xsetvar='td=$define; tu=$undef; set X $1; eval "was=\$$2"; Xcase "$val$was" in Xdefineundef) . whoa; eval "$2=\$td";; Xundefdefine) . whoa; eval "$2=\$tu";; X*) eval "$2=$val";; Xesac' X X: determine where manual pages go X$cat <usrinclude.c <<'EOCP' X#ifdef SYSTYPE_BSD43 X/bsd43 X#endif XEOCP X if cc -E usrinclude.c > usrinclude.out && $contains / usrinclude.out >/dev/null 2>&1 ; then X echo "and you're compiling with the BSD43 compiler and libraries." X dflt='/bsd43/usr/include' X inclPath='/bsd43' X else X echo "and you're compiling with the SysV compiler and libraries." X fi Xelse X echo "Doesn't look like a MIPS system." X echo "exit 1" >mips X chmod +x mips X $eunicefix mips Xfi X Xcont=true Xwhile $test "$cont" ; do X echo " " X rp="Where are the include files you want to use? [$dflt]" X $echo $n "$rp $c" X . myread X usrinclude="$ans" X if $test -d $ans; then X cont='' X else X if $test "$fastread" = yes; then X dflt=y X else X dflt=n X fi X rp="Directory $ans doesn't exist. Use that name anyway? [$dflt]" X $echo $n "$rp $c" X . myread X dflt='' X case "$ans" in X y*) cont='';; X esac X fi Xdone X X: make some quick guesses about what we are up against Xecho " " Xcat $usrinclude/signal.h $usrinclude/sys/signal.h >guess.txt 2>/dev/null Xif test "$usrinclude" = "/bsd43/usr/include" ; then X echo "Looks kind of like a SysV MIPS running BSD, but we'll see..." X echo exit 0 >bsd X echo exit 1 >usg X echo exit 1 >v7 Xelif test `echo abc | tr a-z A-Z` = Abc ; then X echo "Looks kind of like a USG system, but we'll see..." X echo exit 1 >bsd X echo exit 0 >usg X echo exit 1 >v7 Xelif $contains SIGTSTP guess.txt >/dev/null 2>&1 ; then X echo "Looks kind of like a BSD system, but we'll see..." X echo exit 0 >bsd X echo exit 1 >usg X echo exit 1 >v7 Xelse X echo "Looks kind of like a version 7 system, but we'll see..." X echo exit 1 >bsd X echo exit 1 >usg X echo exit 0 >v7 Xfi Xcase "$eunicefix" in X*unixtovms*) X cat <<'EOI' XThere is, however, a strange, musty smell in the air that reminds me of Xsomething...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit. XEOI X echo "exit 0" >eunice X d_eunice="$define" X ;; X*) X echo " " X echo "Congratulations. You aren't running Eunice." X d_eunice="$undef" X echo "exit 1" >eunice X ;; Xesac Xif test -f /xenix; then X echo "Actually, this looks more like a XENIX system..." X echo "exit 0" >xenix Xelse X echo " " X echo "It's not Xenix..." X echo "exit 1" >xenix Xfi Xchmod +x xenix X$eunicefix xenix Xif test -f /venix; then X echo "Actually, this looks more like a VENIX system..." X echo "exit 0" >venix Xelse X echo " " X if xenix; then X : null X else X echo "Nor is it Venix..." X fi X echo "exit 1" >venix Xfi Xchmod +x bsd usg v7 eunice venix X$eunicefix bsd usg v7 eunice venix X X: see what memory models we can support Xcase "$models" in X'') X : We may not use Cppsym or we get a circular dependency through cc. X : But this should work regardless of which cc we eventually use. X cat >pdp11.c <<'EOP' Xmain() { X#ifdef pdp11 X exit(0); X#else X exit(1); X#endif X} XEOP X cc -o pdp11 pdp11.c >/dev/null 2>&1 X if pdp11 2>/dev/null; then X dflt='unsplit split' X else X ans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge` X case "$ans" in X X) dflt='none';; X *) if $test -d /lib/small || $test -d /usr/lib/small; then X dflt='small' X else X dflt='' X fi X if $test -d /lib/medium || $test -d /usr/lib/medium; then X dflt="$dflt medium" X fi X if $test -d /lib/large || $test -d /usr/lib/large; then X dflt="$dflt large" X fi X if $test -d /lib/huge || $test -d /usr/lib/huge; then X dflt="$dflt huge" X fi X esac X fi X ;; X*) dflt="$models" ;; Xesac X$cat </dev/null 2>&1 || \ X $contains '\-i' $mansrc/man1/cc.1 >/dev/null 2>&1; then X dflt='-i' X else X dflt='none' X fi X ;; X *) dflt="$split";; X esac X rp="What flag indicates separate I and D space? [$dflt]" X $echo $n "$rp $c" X . myread X case "$ans" in X none) ans='';; X esac X split="$ans" X unsplit='' X ;; X*large*|*small*|*medium*|*huge*) X case "$models" in X *large*) X case "$large" in X '') dflt='-Ml';; X *) dflt="$large";; X esac X rp="What flag indicates large model? [$dflt]" X $echo $n "$rp $c" X . myread X case "$ans" in X none) ans=''; X esac X large="$ans" X ;; X *) large='';; X esac X case "$models" in X *huge*) X case "$huge" in X '') dflt='-Mh';; X *) dflt="$huge";; X esac X rp="What flag indicates huge model? [$dflt]" X $echo $n "$rp $c" X . myread X case "$ans" in X none) ans=''; X esac X huge="$ans" X ;; X *) huge="$large";; X esac X case "$models" in X *medium*) X case "$medium" in X '') dflt='-Mm';; X *) dflt="$medium";; X esac X rp="What flag indicates medium model? [$dflt]" X $echo $n "$rp $c" X . myread X case "$ans" in X none) ans=''; X esac X medium="$ans" X ;; X *) medium="$large";; X esac X case "$models" in X *small*) X case "$small" in X '') dflt='none';; X *) dflt="$small";; X esac X rp="What flag indicates small model? [$dflt]" X $echo $n "$rp $c" X . myread X case "$ans" in X none) ans=''; X esac X small="$ans" X ;; X *) small='';; X esac X ;; X*) X echo "Unrecognized memory models--you may have to edit Makefile.SH" X ;; Xesac X X: see if we need a special compiler Xecho " " Xif usg; then X case "$cc" in X '') X case "$Mcc" in X /*) dflt='Mcc' X ;; X *) X case "$large" in X -M*) X dflt='cc' X ;; X *) X if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then X dflt='cc -M' X else X dflt='cc' X fi X ;; X esac X ;; X esac X ;; X *) dflt="$cc";; X esac X $cat <<'EOM' X XOn some systems the default C compiler will not resolve multiple global Xreferences that happen to have the same name. On some such systems the X"Mcc" command may be used to force these to be resolved. On other systems Xa "cc -M" command is required. (Note that the -M flag on other systems Xindicates a memory model to use!) If you have the Gnu C compiler, you Xmight wish to use that instead. What command will force resolution on XEOM X $echo $n "this system? [$dflt] $c" X rp="Command to resolve multiple refs? [$dflt]" X . myread X cc="$ans" Xelse X case "$cc" in X '') dflt=cc;; X *) dflt="$cc";; X esac X rp="Use which C compiler? [$dflt]" X $echo $n "$rp $c" X . myread X cc="$ans" Xfi Xcase "$cc" in Xgcc*) cpp=`./loc gcc-cpp $cpp $pth`;; Xesac X X: determine optimize, if desired, or use for debug flag also Xcase "$optimize" in X' ') dflt="none" X ;; X'') dflt="-O"; X ;; X*) dflt="$optimize" X ;; Xesac Xcat </dev/null 2>&1; then X case "$dflt" in X *LANGUAGE_C*);; X *) dflt="$dflt -DLANGUAGE_C";; X esac Xfi Xif $contains '_NO_PROTO' $usrinclude/signal.h >/dev/null 2>&1; then X case "$dflt" in X *_NO_PROTO*);; X *) dflt="$dflt -D_NO_PROTO";; X esac Xfi Xcase "$dflt" in X'') dflt=none;; Xesac Xcat <try.c <<'EOCP' Xstruct foobar { X char foo; X double bar; X} try; Xmain() X{ X printf("%d\n", (char*)&try.bar - (char*)&try.foo); X} XEOCP X if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then X dflt=`./try` X else X dflt='?' X echo "(I can't seem to compile the test program...)" X fi X ;; X*) X dflt="$alignbytes" X ;; Xesac Xrp="Doubles must be aligned on a how-many-byte boundary? [$dflt]" X$echo $n "$rp $c" X. myread Xalignbytes="$ans" X$rm -f try.c try X X: determine where public executables go Xcat <byteorder.c <<'EOCP' X#include Xmain() X{ X int i; X union { X unsigned long l; X char c[sizeof(long)]; X } u; X X if (sizeof(long) > 4) X u.l = (0x08070605 << 32) | 0x04030201; X else X u.l = 0x04030201; X for (i=0; i < sizeof(long); i++) X printf("%c",u.c[i]+'0'); X printf("\n"); X} XEOCP X if $cc byteorder.c -o byteorder >/dev/null 2>&1 ; then X dflt=`./byteorder` X case "$dflt" in X ????|????????) echo "(The test program ran ok.)";; X *) echo "(The test program didn't run right for some reason.)";; X esac X else X dflt='4321' X echo "(I can't seem to compile the test program. Guessing big-endian...)" X fi X ;; X*) X echo " " X dflt="$byteorder" X ;; Xesac Xrp="What is the order of bytes in a long? [$dflt]" X$echo $n "$rp $c" X. myread Xbyteorder="$ans" X X: check for ability to cast negative floats to unsigned Xecho " " Xecho 'Checking to see if your C compiler can cast weird floats to unsigned' X$cat >try.c <<'EOCP' X#include X Xmain() X{ X double f = -123; X unsigned long along; X unsigned int aint; X unsigned short ashort; X int result = 0; X X signal(SIGFPE, SIG_IGN); X along = (unsigned long)f; X aint = (unsigned int)f; X ashort = (unsigned short)f; X if (along != (unsigned long)-123) X result |= 1; X if (aint != (unsigned int)-123) X result |= 1; X if (ashort != (unsigned short)-123) X result |= 1; X f = (double)0x40000000; X f = f + f; X along = 0; X along = (unsigned long)f; X if (along != 0x80000000) X result |= 2; X f -= 1; X along = 0; X along = (unsigned long)f; X if (along != 0x7fffffff) X result |= 1; X f += 2; X along = 0; X along = (unsigned long)f; X if (along != 0x80000001) X result |= 2; X exit(result); X} XEOCP Xif $cc -o try $ccflags try.c >/dev/null 2>&1; then X ./try X castflags=$? Xelse X castflags=3 Xfi Xcase "$castflags" in X0) val="$define" X echo "Yup, it does." X ;; X*) val="$undef" X echo "Nope, it doesn't." X ;; Xesac Xset d_castneg Xeval $setvar X$rm -f try.* X X: see how we invoke the C preprocessor Xecho " " Xecho "Now, how can we feed standard input to your C preprocessor..." Xcat <<'EOT' >testcpp.c X#define ABC abc X#define XYZ xyz XABC.XYZ XEOT Xecho 'Maybe "'"$cc"' -E" will work...' X$cc -E testcpp.out 2>&1 X: try to force gcc preprocessor if that is the compiler they are using Xcase $? in X0) cppstdin="$cc -E";; X*) case "$cc" in X *gcc*) X cd .. X echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)' X echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin X chmod 755 cppstdin X cppstdin=`pwd`/cppstdin X cppminus=''; X cd UU X $cppstdin testcpp.out 2>&1 X ;; X esac X ;; Xesac Xif $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Yup, it does." X cppstdin="$cc -E" X cppminus=''; Xelse X echo 'Nope...maybe "'"$cc"' -E -" will work...' X $cc -E - testcpp.out 2>&1 X if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Yup, it does." X cppstdin="$cc -E" X cppminus='-'; X else X echo 'No such luck, maybe "'$cpp'" will work...' X $cpp testcpp.out 2>&1 X if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then X echo "It works!" X cppstdin="$cpp" X cppminus=''; X else X echo 'Nixed again...maybe "'$cpp' -" will work...' X $cpp - testcpp.out 2>&1 X if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Hooray, it works! I was beginning to wonder." X cppstdin="$cpp" X cppminus='-'; X else X echo 'Nope...maybe "'"$cc"' -P" will work...' X $cc -P testcpp.out 2>&1 X if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Yup, that does." X cppstdin="$cc -P" X cppminus=''; X else X echo 'Nope...maybe "'"$cc"' -P -" will work...' X $cc -P - testcpp.out 2>&1 X if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Yup, that does." X cppstdin="$cc -P" X cppminus='-'; X else X echo 'Hmm...perhaps you already told me...' X case "$cppstdin" in X '') ;; X *) $cppstdin $cppminus testcpp.out 2>&1;; X esac X if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Hooray, you did! I was beginning to wonder." X else X echo 'Uh-uh. Time to get fancy...' X cd .. X echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)' X echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin X chmod 755 cppstdin X cppstdin=`pwd`/cppstdin X cppminus=''; X cd UU X $cppstdin testcpp.out 2>&1 X if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Eureka!." X else X dflt=blurfl X $echo $n "No dice. I can't find a C preprocessor. Name one: $c" X rp='Name a C preprocessor:' X . myread X cppstdin="$ans" X $cppstdin testcpp.out 2>&1 X if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then X echo "OK, that will do." X else X echo "Sorry, I can't get that to work. Go find one." X exit 1 X fi X fi X fi X fi X fi X fi X fi X fi Xfi X X: get list of predefined functions in a handy place Xecho " " Xcase "$libc" in X'') libc=unknown;; Xesac Xcase "$nm_opts" in X'') if test -f /mach_boot; then X nm_opts='' X elif test -d /usr/ccs/lib; then X nm_opts='-p' X else X nm_opts='' X fi X ;; Xesac X: on mips, we DO NOT want /lib, and we want inclPath/usr/lib Xcase "$libpth" in X'') if mips; then X libpth='$inclPath/usr/lib /usr/local/lib' X nm_opts="-B" X else X libpth='/usr/ccs/lib /lib /usr/lib /usr/ucblib /usr/local/lib' X fi X ;; Xesac Xcase "$libs" in X*-lc_s*) libc=`./loc libc_s.a $libc $libpth` Xesac Xlibnames=''; Xcase "$libs" in X'') ;; X*) for thislib in $libs; do X case "$thislib" in X -l*) thislib=`expr X$thislib : 'X-l\(.*\)'` X try=`./loc lib$thislib.a blurfl/dyick $libpth` X if test ! -f $try; then X try=`./loc lib$thislib blurfl/dyick $libpth` X if test ! -f $try; then X try=`./loc $thislib blurfl/dyick $libpth` X if test ! -f $try; then X try=`./loc Slib$thislib.a blurfl/dyick $xlibpth` X if test ! -f $try; then X try='' X fi X fi X fi X fi X libnames="$libnames $try" X ;; X *) libnames="$libnames $thislib" ;; X esac X done X ;; Xesac Xset /usr/ccs/lib/libc.so Xtest -f $1 || set /usr/lib/libc.so Xtest -f $1 || set /usr/lib/libc.so.[0-9]* Xtest -f $1 || set /lib/libsys_s.a Xeval set \$$# Xif test -f "$1"; then X echo "Your shared C library is in $1." X libc="$1" Xelif test -f "$libc"; then X echo "Your C library is in $libc." Xelif test -f /lib/libc.a; then X echo "Your C library is in /lib/libc.a. You're normal." X libc=/lib/libc.a Xelse X if ans=`./loc libc.a blurfl/dyick $libpth`; test -f "$ans"; then X : X elif ans=`./loc libc blurfl/dyick $libpth`; test -f "$ans"; then X libnames="$libnames "`./loc clib blurfl/dyick $libpth` X elif ans=`./loc clib blurfl/dyick $libpth`; test -f "$ans"; then X : X elif ans=`./loc Slibc.a blurfl/dyick $xlibpth`; test -f "$ans"; then X : X elif ans=`./loc Mlibc.a blurfl/dyick $xlibpth`; test -f "$ans"; then X : X elif ans=`./loc Llibc.a blurfl/dyick $xlibpth`; test -f "$ans"; then X : X fi X if test -f "$ans"; then X echo "Your C library is in $ans, of all places." X libc=$ans X else X cat </dev/null >libc.tmp X$sed -n -e 's/^.* [ATDS] *[_.]*//p' -e 's/^.* [ATDS] //p' libc.list Xif $contains '^printf$' libc.list >/dev/null 2>&1; then X echo done Xelif $sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p' \ X libc.list; \ X $contains '^printf$' libc.list >/dev/null 2>&1; then X echo done Xelif $sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p' libc.list; \ X $contains '^printf$' libc.list >/dev/null 2>&1; then X echo done Xelif $sed -n -e 's/^.* D __*//p' -e 's/^.* D //p' libc.list; \ X $contains '^printf$' libc.list >/dev/null 2>&1; then X echo done Xelif $sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p' \ X libc.list; \ X $contains '^printf$' libc.list >/dev/null 2>&1; then X echo done Xelif $grep '|' libc.list X $contains '^printf$' libc.list >/dev/null 2>&1; then X echo done Xelif $sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p' \ X libc.list; \ X $contains '^printf$' libc.list >/dev/null 2>&1; then X echo done Xelse X nm -p $* 2>/dev/null >libc.tmp X $sed -n -e 's/^.* [AT] *_[_.]*//p' -e 's/^.* [AT] //p' libc.list X if $contains '^printf$' libc.list >/dev/null 2>&1; then X nm_opts='-p' X echo "done" X else X echo " " X echo "nm didn't seem to work right." X echo "Trying ar instead..." X if ar t $libc > libc.tmp; then X for thisname in $libnames; do X ar t $thisname >>libc.tmp X done X $sed -e 's/\.o$//' < libc.tmp > libc.list X echo "Ok." X else X echo "ar didn't seem to work right." X echo "Maybe this is a Cray...trying bld instead..." X if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then X for thisname in $libnames; do X bld t $libnames | \ X $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list X ar t $thisname >>libc.tmp X done X echo "Ok." X else X echo "That didn't work either. Giving up." X exit 1 X fi X fi X fi Xfi X X: old version X Xinlibc='echo " "; Xif $contains "^$1\$" libc.list >/dev/null 2>&1; Xthen echo "$1() found"; eval "$2=$define"; Xelse echo "$1() not found"; eval "$2=$undef"; fi' X X: new version X Xinlibc='echo " "; td=$define; tu=$undef; Xif $contains "^$1\$" libc.list >/dev/null 2>&1; Xthen echo "$1() found"; X eval "case \"\$$2\" in undef) . whoa; esac"; eval "$2=\$td"; Xelse echo "$1() not found"; X eval "case \"\$$2\" in define) . whoa; esac"; eval "$2=\$tu"; fi' X X: see if bcmp exists Xset bcmp d_bcmp Xeval $inlibc X X: see if bcopy exists Xset bcopy d_bcopy Xeval $inlibc X X: see if bzero exists Xset bzero d_bzero Xeval $inlibc X X: see if sprintf is declared as int or pointer to char Xecho " " Xcat >ucbsprf.c <<'EOF' X#include Xmain() X{ X int sprintf(); X char buf[10]; X exit((unsigned long)sprintf(buf,"%s","foo") > 10L); X} XEOF Xif $cc $ccflags ucbsprf.c -o ucbsprf >/dev/null 2>&1 && ./ucbsprf; then X echo "Your sprintf() returns (int)." X val="$undef" Xelse X echo "Your sprintf() returns (char*)." X val="$define" Xfi Xset d_charsprf Xeval $setvar X X: see if vprintf exists Xecho " " Xif $contains '^vprintf$' libc.list >/dev/null 2>&1; then X echo 'vprintf() found.' X val="$define" X cat >vprintf.c <<'EOF' X#include X Xmain() { xxx("foo"); } X Xxxx(va_alist) Xva_dcl X{ X va_list args; X char buf[10]; X X va_start(args); X exit((unsigned long)vsprintf(buf,"%s",args) > 10L); X} XEOF X if $cc $ccflags vprintf.c -o vprintf >/dev/null 2>&1 && ./vprintf; then X echo "Your vsprintf() returns (int)." X val2="$undef" X else X echo "Your vsprintf() returns (char*)." X val2="$define" X fi Xelse X echo 'vprintf() not found.' X val="$undef" X val2="$undef" Xfi Xset d_vprintf Xeval $setvar Xval=$val2 Xset d_charvspr Xeval $setvar X X: see if chsize exists Xset chsize d_chsize Xeval $inlibc X X: see if crypt exists Xecho " " Xif $contains '^crypt$' libc.list >/dev/null 2>&1; then X echo 'crypt() found.' X val="$define" X cryptlib='' Xelse X cryptlib=`./loc Slibcrypt.a "" $xlibpth` X if $test -z "$cryptlib"; then X cryptlib=`./loc Mlibcrypt.a "" $xlibpth` X else X cryptlib=-lcrypt X fi X if $test -z "$cryptlib"; then X cryptlib=`./loc Llibcrypt.a "" $xlibpth` X else X cryptlib=-lcrypt X fi X if $test -z "$cryptlib"; then X cryptlib=`./loc libcrypt.a "" $libpth` X else X cryptlib=-lcrypt X fi X if $test -z "$cryptlib"; then X echo 'crypt() not found.' X val="$undef" X else X val="$define" X fi Xfi Xset d_crypt Xeval $setvar X X: get csh whereabouts Xcase "$csh" in X'csh') val="$undef" ;; X*) val="$define" ;; Xesac Xset d_csh Xeval $setvar X X: see if readdir exists Xset readdir d_readdir Xeval $inlibc X X: see if there are directory access routines out there Xecho " " Xxxx=`./loc ndir.h x $usrinclude /usr/local/include $inclwanted` Xcase "$xxx" in Xx) X xxx=`./loc sys/ndir.h x $usrinclude /usr/local/include $inclwanted` X ;; Xesac XD_dirnamlen="$undef" XI_dirent="$undef" XI_sys_dir="$undef" XI_my_dir="$undef" XI_ndir="$undef" XI_sys_ndir="$undef" Xlibndir='' Xndirc='' Xndiro='' Xif $test -r $usrinclude/dirent.h; then X echo "dirent.h found." X if $contains 'd_namlen' $usrinclude/dirent.h >/dev/null 2>&1; then X D_dirnamlen="$define" X fi X I_dirent="$define" Xelif $test -r $xxx; then X echo "You seem to use <$xxx>," X if $test "$d_readdir" = "$define"; then X echo "and I can get readdir() from your C library." X elif $test -r /usr/lib/libndir.a || $test -r /usr/local/lib/libndir.a; then X echo "and I'll get the routines using -lndir ." X libndir='-lndir' X else X ans=`./loc libndir.a x $libpth` X case "$ans" in X x) X echo "but I can't find the ndir library!" X ;; X *) X echo "and I found the directory library in $ans." X libndir="$ans" X ;; X esac X fi X if $contains 'd_namlen' $xxx >/dev/null 2>&1; then X D_dirnamlen="$define" X fi X case "$xxx" in X sys/) X I_sys_ndir="$define" X ;; X *) X I_ndir="$define" X ;; X esac Xelse X : The next line used to require this to be a bsd system. X if $contains '^readdir$' libc.list >/dev/null 2>&1 ; then X echo "No ndir library found, but you have readdir() so we'll use that." X if $contains 'd_namlen' $usrinclude/sys/dir.h >/dev/null 2>&1; then X D_dirnamlen="$define" X fi X I_sys_dir="$define" X else X echo "No ndir library found--using ./$d_ndir.c." X: This will lose since $d_ndir.h is in another directory. X: I doubt we can rely on it being in ../$d_ndir.h . X: At least it will fail in a conservative manner. X if $contains 'd_namlen' $d_ndir.h >/dev/null 2>&1; then X D_dirnamlen="$define" X fi X I_my_dir="$define" X ndirc="$d_ndir.c" X ndiro="$d_ndir.o" X fi Xfi !STUFFY!FUNK! echo " " echo "End of kit 7 (of 36)" cat /dev/null >kit7isdone run='' config='' for iskit in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36; do if test -f kit${iskit}isdone; then run="$run $iskit" else todo="$todo $iskit" fi done case $todo in '') echo "You have run all your kits. Please read README and then type Configure." for combo in *:AA; do if test -f "$combo"; then realfile=`basename $combo :AA` cat $realfile:[A-Z][A-Z] >$realfile rm -rf $realfile:[A-Z][A-Z] fi done rm -rf kit*isdone chmod 755 Configure ;; *) echo "You have run$run." echo "You still need to run$todo." ;; esac : Someone might mail this, so... exit exit 0 # Just in case... -- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM Sterling Software, IMD UUCP: uunet!sparky!kent Phone: (402) 291-8300 FAX: (402) 291-4362 Please send comp.sources.misc-related mail to kent@uunet.uu.net.