home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume15 / getty_ps / part02 < prev    next >
Text File  |  1990-10-05  |  53KB  |  2,277 lines

  1. Newsgroups: comp.sources.misc
  2. X-UNIX-From: paul@devon.lns.pa.us
  3. organization: Devon Computer Services, Lancaster, PA
  4. keywords: getty uugetty
  5. subject: v15i005: Enhanced SYSV Getty/Uugetty, Ver 2.0, part 2 of 5
  6. from: paul@devon.lns.pa.us (Paul Sutcliffe Jr.)
  7. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  8.  
  9. Posting-number: Volume 15, Issue 5
  10. Submitted-by: paul@devon.lns.pa.us (Paul Sutcliffe Jr.)
  11. Archive-name: getty_ps/part02
  12.  
  13. #! /bin/sh
  14.  
  15. # Make a new directory for the getty sources, cd to it, and run kits 1
  16. # thru 5 through sh.  When all 5 kits have been run, read README.
  17.  
  18. echo "This is getty 2.0 kit 2 (of 5).  If kit 2 is complete, the line"
  19. echo '"'"End of kit 2 (of 5)"'" will echo at the end.'
  20. echo ""
  21. export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
  22. mkdir  2>/dev/null
  23. echo Extracting Configure
  24. sed >Configure <<'!STUFFY!FUNK!' -e 's/X//'
  25. X#! /bin/sh
  26. X#
  27. X# If these # comments don't work, trim them.  Don't worry about any other
  28. X# shell scripts, Configure will trim # comments from them for you.
  29. X#
  30. X# (If you are trying to port this package to a machine without sh, I would
  31. X# suggest you cut out the prototypical config.h from the end of Configure
  32. X# and edit it to reflect your system.  Some packages may include samples
  33. X# of config.h for certain machines, so you might look for one of those.)
  34. X#
  35. X# $Id: Configure,v 2.0 90/09/19 19:23:44 paul Rel $
  36. X#
  37. X# Yes, you may rip this off to use in other distribution packages.
  38. X# (Note: this Configure script was generated automatically.  Rather than
  39. X# working with this copy of Configure, you may wish to get metaconfig.)
  40. X#
  41. X# $Log:    Configure,v $
  42. X# Revision 2.0  90/09/19  19:23:44  paul
  43. X# Initial 2.0 release
  44. X# 
  45. X#
  46. X
  47. X: sanity checks
  48. XPATH=".:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin:$PATH"
  49. Xexport PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  50. X
  51. Xif test ! -t 0; then
  52. X    echo "Say 'sh Configure', not 'sh <Configure'"
  53. X    exit 1
  54. Xfi
  55. X
  56. X(alias) >/dev/null 2>&1 && \
  57. X    echo "(I see you are using the Korn shell.  Some ksh's blow up on Configure," && \
  58. X    echo "especially on exotic machines.  If yours does, try the Bourne shell instead.)"
  59. X
  60. Xif test ! -d ../UU; then
  61. X    if test ! -d UU; then
  62. X    mkdir UU
  63. X    fi
  64. X    cd UU
  65. Xfi
  66. X
  67. Xcase "$1" in
  68. X-d) shift; fastread='yes';;
  69. Xesac
  70. X
  71. Xd_getutent=''
  72. Xd_strdup=''
  73. Xd_putenv=''
  74. Xd_ttytype=''
  75. Xttytype=''
  76. Xgettytab=''
  77. Xutmp=''
  78. Xwtmp=''
  79. Xuucpid=''
  80. Xlock=''
  81. Xd_asciipid=''
  82. Xmailer=''
  83. Xhostname=''
  84. Xphostname=''
  85. Xd_douname=''
  86. Xd_phostname=''
  87. Xd_portable=''
  88. Xtermlib=''
  89. Xllib_termlib=''
  90. Xxenix=''
  91. Xd_eunice=''
  92. Xdefine=''
  93. Xundef=''
  94. Xeunicefix=''
  95. Xloclist=''
  96. Xexpr=''
  97. Xsed=''
  98. Xecho=''
  99. Xcat=''
  100. Xrm=''
  101. Xmv=''
  102. Xcp=''
  103. Xtr=''
  104. Xsort=''
  105. Xuniq=''
  106. Xgrep=''
  107. Xtrylist=''
  108. Xtest=''
  109. Xegrep=''
  110. XMcc=''
  111. Xcpp=''
  112. Xmail=''
  113. Xmailx=''
  114. Xsendmail=''
  115. Xuname=''
  116. Xuuname=''
  117. XLog=''
  118. XId=''
  119. Xbin=''
  120. Xcontains=''
  121. Xcppstdin=''
  122. Xcppminus=''
  123. Xd_fcntl=''
  124. Xd_index=''
  125. Xd_ioctl=''
  126. Xd_varargs=''
  127. Xd_voidsig=''
  128. Xgidtype=''
  129. Xi_fcntl=''
  130. Xi_pwd=''
  131. Xi_sysioctl=''
  132. Xi_time=''
  133. Xi_systime=''
  134. Xd_systimekernel=''
  135. Xi_varargs=''
  136. Xlibc=''
  137. Xmodels=''
  138. Xsplit=''
  139. Xsmall=''
  140. Xmedium=''
  141. Xlarge=''
  142. Xhuge=''
  143. Xoptimize=''
  144. Xccflags=''
  145. Xcppflags=''
  146. Xldflags=''
  147. Xcc=''
  148. Xlibs=''
  149. Xn=''
  150. Xc=''
  151. Xpackage=''
  152. Xspitshell=''
  153. Xshsharp=''
  154. Xsharpbang=''
  155. Xstartsh=''
  156. Xstdchar=''
  157. Xuidtype=''
  158. Xvoidflags=''
  159. Xdefvoidused=''
  160. Xlib=''
  161. XCONFIG=''
  162. X: set package name
  163. Xpackage=getty
  164. X
  165. Xecho " "
  166. Xecho "Beginning of configuration questions for $package kit."
  167. X: Eunice requires " " instead of "", can you believe it
  168. Xecho " "
  169. X
  170. Xdefine='define'
  171. Xundef='undef'
  172. X: change the next line if compiling for Xenix/286 on Xenix/386
  173. Xxlibpth='/usr/lib/386 /lib/386'
  174. Xlibpth='/usr/lib /usr/local/lib /usr/lib/large /lib '$xlibpth' /lib/large /usr/lib/small /lib/small'
  175. Xsmallmach='pdp11 i8086 z8000 i80286 iAPX286'
  176. Xrmlist='kit[1-9]isdone kit[1-9][0-9]isdone'
  177. Xtrap 'echo " "; rm -f $rmlist; exit 1' 1 2 3
  178. X
  179. X: We must find out about Eunice early
  180. Xeunicefix=':'
  181. Xif test -f /etc/unixtovms; then
  182. X    eunicefix=/etc/unixtovms
  183. Xfi
  184. Xif test -f /etc/unixtovms.exe; then
  185. X    eunicefix=/etc/unixtovms.exe
  186. Xfi
  187. X
  188. X: Now test for existence of everything in MANIFEST
  189. X
  190. Xecho "First let's make sure your kit is complete.  Checking..."
  191. X(cd ..; cat `awk 'NR>4{print $1}' MANIFEST` >/dev/null || kill $$)
  192. Xecho "Looks good..."
  193. X
  194. Xattrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr"
  195. Xattrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200"
  196. Xattrlist="$attrlist hpux hp9000s300 hp9000s500 hp9000s800"
  197. Xattrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc"
  198. Xattrlist="$attrlist nsc32000 sinix xenix venix posix ansi M_XENIX"
  199. Xattrlist="$attrlist $mc68k __STDC__ UTS M_I8086 M_I186 M_I286 M_I386"
  200. Xattrlist="$attrlist i186 __m88k__ m88k DGUX __DGUX__"
  201. Xpth="/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"
  202. Xdefvoidused=7
  203. Xlibswanted="x c_s"
  204. Xinclwanted=''
  205. X
  206. X: some greps do not return status, grrr.
  207. Xecho "grimblepritz" >grimble
  208. Xif grep blurfldyick grimble >/dev/null 2>&1 ; then
  209. X    contains=contains
  210. Xelif grep grimblepritz grimble >/dev/null 2>&1 ; then
  211. X    contains=grep
  212. Xelse
  213. X    contains=contains
  214. Xfi
  215. Xrm -f grimble
  216. X: the following should work in any shell
  217. Xcase "$contains" in
  218. Xcontains*)
  219. X    echo " "
  220. X    echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  221. X    cat >contains <<'EOSS'
  222. Xgrep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  223. XEOSS
  224. Xchmod +x contains
  225. Xesac
  226. X
  227. X: see if sh knows # comments
  228. Xecho " "
  229. Xecho "Checking your sh to see if it knows about # comments..."
  230. Xif sh -c '#' >/dev/null 2>&1 ; then
  231. X    echo "Your sh handles # comments correctly."
  232. X    shsharp=true
  233. X    spitshell=cat
  234. X    echo " "
  235. X    echo "Okay, let's see if #! works on this system..."
  236. X    echo "#!/bin/echo hi" > try
  237. X    $eunicefix try
  238. X    chmod +x try
  239. X    ./try > today
  240. X    if $contains hi today >/dev/null 2>&1; then
  241. X    echo "It does."
  242. X    sharpbang='#!'
  243. X    else
  244. X    echo "#! /bin/echo hi" > try
  245. X    $eunicefix try
  246. X    chmod +x try
  247. X    ./try > today
  248. X    if test -s today; then
  249. X        echo "It does."
  250. X        sharpbang='#! '
  251. X    else
  252. X        echo "It doesn't."
  253. X        sharpbang=': use '
  254. X    fi
  255. X    fi
  256. Xelse
  257. X    echo "Your sh doesn't grok # comments--I will strip them later on."
  258. X    shsharp=false
  259. X    echo "exec grep -v '^#'" >spitshell
  260. X    chmod +x spitshell
  261. X    $eunicefix spitshell
  262. X    spitshell=`pwd`/spitshell
  263. X    echo "I presume that if # doesn't work, #! won't work either!"
  264. X    sharpbang=': use '
  265. Xfi
  266. X
  267. X: figure out how to guarantee sh startup
  268. Xecho " "
  269. Xecho "Checking out how to guarantee sh startup..."
  270. Xstartsh=$sharpbang'/bin/sh'
  271. Xecho "Let's see if '$startsh' works..."
  272. Xcat >try <<EOSS
  273. X$startsh
  274. Xset abc
  275. Xtest "$?abc" != 1
  276. XEOSS
  277. X
  278. Xchmod +x try
  279. X$eunicefix try
  280. Xif ./try; then
  281. X    echo "Yup, it does."
  282. Xelse
  283. X    echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  284. Xfi
  285. Xrm -f try today
  286. X
  287. X: first determine how to suppress newline on echo command
  288. Xecho "Checking echo to see how to suppress newlines..."
  289. X(echo "hi there\c" ; echo " ") >.echotmp
  290. Xif $contains c .echotmp >/dev/null 2>&1 ; then
  291. X    echo "...using -n."
  292. X    n='-n'
  293. X    c=''
  294. Xelse
  295. X    cat <<'EOM'
  296. X...using \c
  297. XEOM
  298. X    n=''
  299. X    c='\c'
  300. Xfi
  301. Xecho $n "Type carriage return to continue.  Your cursor should be here-->$c"
  302. Xread ans
  303. Xrm -f .echotmp
  304. X
  305. X: now set up to do reads with possible shell escape and default assignment
  306. Xcat <<EOSC >myread
  307. Xcase "\$fastread" in
  308. Xyes) ans=''; echo " " ;;
  309. X*) ans='!';;
  310. Xesac
  311. Xwhile expr "X\$ans" : "X!" >/dev/null; do
  312. X    read ans
  313. X    case "\$ans" in
  314. X    !)
  315. X    sh
  316. X    echo " "
  317. X    echo $n "\$rp $c"
  318. X    ;;
  319. X    !*)
  320. X    set \`expr "X\$ans" : "X!\(.*\)\$"\`
  321. X    sh -c "\$*"
  322. X    echo " "
  323. X    echo $n "\$rp $c"
  324. X    ;;
  325. X    esac
  326. Xdone
  327. Xrp='Your answer:'
  328. Xcase "\$ans" in
  329. X'') ans="\$dflt";;
  330. Xesac
  331. XEOSC
  332. X
  333. X: general instructions
  334. Xcat <<EOH
  335. XThis installation shell script will examine your system and ask you questions
  336. Xto determine how the $package package should be installed.  If you get stuck
  337. Xon a question, you may use a ! shell escape to start a subshell or execute
  338. Xa command.  Many of the questions will have default answers in square
  339. Xbrackets--typing carriage return will give you the default.
  340. X
  341. XOn some of the questions which ask for file or directory names you are
  342. Xallowed to use the ~name construct to specify the login directory belonging
  343. Xto "name", even if you don't have a shell which knows about that.  Questions
  344. Xwhere this is allowed will be marked "(~name ok)".
  345. X
  346. XEOH
  347. Xrp="[Type carriage return to continue]"
  348. Xecho $n "$rp $c"
  349. X. myread
  350. Xcat <<EOH
  351. X
  352. XMuch effort has been expended to ensure that this shell script will run
  353. Xon any Unix system.  If despite that it blows up on you, your best bet is
  354. Xto edit Configure and run it again. Also, let me (paul@devon.lns.pa.us)
  355. Xknow how I blew it.  If you can't run Configure for some reason, you'll have
  356. Xto generate a config.sh file by hand.
  357. X
  358. XThis installation script affects things in two ways: 1) it may do direct
  359. Xvariable substitutions on some of the files included in this kit, and
  360. X2) it builds a config.h file for inclusion in C programs.  You may edit
  361. Xany of these files as the need arises after running this script.
  362. X
  363. XIf you make a mistake on a question, there is no easy way to back up to it
  364. Xcurrently.  The easiest thing to do is to edit config.sh and rerun all the
  365. XSH files.  Configure will offer to let you do this before it runs the SH files.
  366. X
  367. XEOH
  368. Xrp="[Type carriage return to continue]"
  369. Xecho $n "$rp $c"
  370. X. myread
  371. X
  372. X: get old answers, if there is a config file out there
  373. Xif test -f ../config.sh; then
  374. X    echo " "
  375. X    dflt=y
  376. X    rp="I see a config.sh file.  Did Configure make it on THIS system? [$dflt]"
  377. X    echo $n "$rp $c"
  378. X    . myread
  379. X    case "$ans" in
  380. X    n*) echo "OK, I'll ignore it.";;
  381. X    *)  echo "Fetching default answers from your old config.sh file..."
  382. X    tmp="$n"
  383. X    ans="$c"
  384. X        . ../config.sh
  385. X    n="$tmp"
  386. X    c="$ans"
  387. X    ;;
  388. X    esac
  389. Xfi
  390. X
  391. X: find out where common programs are
  392. Xecho " "
  393. Xecho "Locating common programs..."
  394. Xcat <<EOSC >loc
  395. X$startsh
  396. Xcase \$# in
  397. X0) exit 1;;
  398. Xesac
  399. Xthing=\$1
  400. Xshift
  401. Xdflt=\$1
  402. Xshift
  403. Xfor dir in \$*; do
  404. X    case "\$thing" in
  405. X    .)
  406. X    if test -d \$dir/\$thing; then
  407. X        echo \$dir
  408. X        exit 0
  409. X    fi
  410. X    ;;
  411. X    *)
  412. X    if test -f \$dir/\$thing; then
  413. X        echo \$dir/\$thing
  414. X        exit 0
  415. X    elif test -f \$dir/\$thing.exe; then
  416. X        : on Eunice apparently
  417. X        echo \$dir/\$thing
  418. X        exit 0
  419. X    fi
  420. X    ;;
  421. X    esac
  422. Xdone
  423. Xecho \$dflt
  424. Xexit 1
  425. XEOSC
  426. Xchmod +x loc
  427. X$eunicefix loc
  428. Xloclist="
  429. Xcat
  430. Xcp
  431. Xecho
  432. Xexpr
  433. Xgrep
  434. Xmv
  435. Xrm
  436. Xsed
  437. Xsort
  438. Xtr
  439. Xuniq
  440. X"
  441. Xtrylist="
  442. XMcc
  443. Xcpp
  444. Xegrep
  445. Xmail
  446. Xmailx
  447. Xsendmail
  448. Xtest
  449. X"
  450. Xfor file in $loclist; do
  451. X    xxx=`loc $file $file $pth`
  452. X    eval $file=$xxx
  453. X    eval _$file=$xxx
  454. X    case "$xxx" in
  455. X    /*)
  456. X    echo $file is in $xxx.
  457. X    ;;
  458. X    *)
  459. X    echo "I don't know where $file is.  I hope it's in everyone's PATH."
  460. X    ;;
  461. X    esac
  462. Xdone
  463. Xecho " "
  464. Xecho "Don't worry if any of the following aren't found..."
  465. Xans=offhand
  466. Xfor file in $trylist; do
  467. X    xxx=`loc $file $file $pth`
  468. X    eval $file=$xxx
  469. X    eval _$file=$xxx
  470. X    case "$xxx" in
  471. X    /*)
  472. X    echo $file is in $xxx.
  473. X    ;;
  474. X    *)
  475. X    echo "I don't see $file out there, $ans."
  476. X    ans=either
  477. X    ;;
  478. X    esac
  479. Xdone
  480. Xcase "$egrep" in
  481. Xegrep)
  482. X    echo "Substituting grep for egrep."
  483. X    egrep=$grep
  484. X    ;;
  485. Xesac
  486. Xcase "$test" in
  487. Xtest)
  488. X    echo "Hopefully test is built into your sh."
  489. X    ;;
  490. X/bin/test)
  491. X    if sh -c "PATH= test true" >/dev/null 2>&1; then
  492. X    echo "Using the test built into your sh."
  493. X    test=test
  494. X    fi
  495. X    ;;
  496. X*)
  497. X    test=test
  498. X    ;;
  499. Xesac
  500. Xcase "$echo" in
  501. Xecho)
  502. X    echo "Hopefully echo is built into your sh."
  503. X    ;;
  504. X/bin/echo)
  505. X    echo " "
  506. X    echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
  507. X    $echo $n "hi there$c" >foo1
  508. X    echo $n "hi there$c" >foo2
  509. X    if cmp foo1 foo2 >/dev/null 2>&1; then
  510. X    echo "They are compatible.  In fact, they may be identical."
  511. X    else
  512. X    case "$n" in
  513. X    '-n') n='' c='\c' ans='\c' ;;
  514. X    *) n='-n' c='' ans='-n' ;;
  515. X    esac
  516. X    cat <<FOO
  517. XThey are not compatible!  You are probably running ksh on a non-USG system.
  518. XI'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
  519. Xhave echo built in and we may have to run some Bourne shell scripts.  That
  520. Xmeans I'll have to use $ans to suppress newlines now.  Life is ridiculous.
  521. X
  522. XFOO
  523. X    rp="Your cursor should be here-->"
  524. X    $echo $n "$rp$c"
  525. X    . myread
  526. X    fi
  527. X    $rm -f foo1 foo2
  528. X    ;;
  529. X*)
  530. X    : cross your fingers
  531. X    echo=echo
  532. X    ;;
  533. Xesac
  534. Xrmlist="$rmlist loc"
  535. X
  536. X: set up shell script to do ~ expansion
  537. Xcat >filexp <<EOSS
  538. X$startsh
  539. X: expand filename
  540. Xcase "\$1" in
  541. X ~/*|~)
  542. X    echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
  543. X    ;;
  544. X ~*)
  545. X    if $test -f /bin/csh; then
  546. X    /bin/csh -f -c "glob \$1"
  547. X    echo ""
  548. X    else
  549. X    name=\`$expr x\$1 : '..\([^/]*\)'\`
  550. X    dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
  551. X    if $test ! -d "\$dir"; then
  552. X        me=\`basename \$0\`
  553. X        echo "\$me: can't locate home directory for: \$name" >&2
  554. X        exit 1
  555. X    fi
  556. X    case "\$1" in
  557. X    */*)
  558. X        echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
  559. X        ;;
  560. X    *)
  561. X        echo \$dir
  562. X        ;;
  563. X    esac
  564. X    fi
  565. X    ;;
  566. X*)
  567. X    echo \$1
  568. X    ;;
  569. Xesac
  570. XEOSS
  571. Xchmod +x filexp
  572. X$eunicefix filexp
  573. X
  574. X: determine where public executables go
  575. Xcase "$bin" in
  576. X'')
  577. X    dflt=`loc . /etc /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
  578. X    ;;
  579. X*)  dflt="$bin"
  580. X    ;;
  581. Xesac
  582. Xcont=true
  583. Xwhile $test "$cont" ; do
  584. X    echo " "
  585. X    rp="Where do you want to put the public executables? (~name ok) [$dflt]"
  586. X    $echo $n "$rp $c"
  587. X    . myread
  588. X    bin="$ans"
  589. X    bin=`./filexp "$bin"`
  590. X    if test -d $bin; then
  591. X    cont=''
  592. X    else
  593. X    case "$fastread" in
  594. X    yes) dflt=y;;
  595. X    *) dflt=n;;
  596. X    esac
  597. X    rp="Directory $bin doesn't exist.  Use that name anyway? [$dflt]"
  598. X    $echo $n "$rp $c"
  599. X    . myread
  600. X    dflt=''
  601. X    case "$ans" in
  602. X    y*) cont='';;
  603. X    esac
  604. X    fi
  605. Xdone
  606. X
  607. X: make some quick guesses about what we are up against
  608. Xecho " "
  609. X$echo $n "Hmm...  $c"
  610. Xcat /usr/include/signal.h /usr/include/sys/signal.h >foo
  611. Xif test `echo abc | tr a-z A-Z` = Abc ; then
  612. X    echo "Looks kind of like a USG system, but we'll see..."
  613. X    echo exit 1 >bsd
  614. X    echo exit 0 >usg
  615. X    echo exit 1 >v7
  616. Xelif $contains SIGTSTP foo >/dev/null 2>&1 ; then
  617. X    echo "Looks kind of like a BSD system, but we'll see..."
  618. X    echo exit 0 >bsd
  619. X    echo exit 1 >usg
  620. X    echo exit 1 >v7
  621. Xelse
  622. X    echo "Looks kind of like a version 7 system, but we'll see..."
  623. X    echo exit 1 >bsd
  624. X    echo exit 1 >usg
  625. X    echo exit 0 >v7
  626. Xfi
  627. Xcase "$eunicefix" in
  628. X*unixtovms*)
  629. X    cat <<'EOI'
  630. XThere is, however, a strange, musty smell in the air that reminds me of
  631. Xsomething...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  632. XEOI
  633. X    echo "exit 0" >eunice
  634. X    d_eunice="$define"
  635. X    ;;
  636. X*)
  637. X    echo " "
  638. X    echo "Congratulations.  You aren't running Eunice."
  639. X    d_eunice="$undef"
  640. X    echo "exit 1" >eunice
  641. X    ;;
  642. Xesac
  643. Xif test -f /xenix; then
  644. X    echo "Actually, this looks more like a XENIX system..."
  645. X    echo "exit 0" >xenix
  646. X    xenix="$define"
  647. Xelse
  648. X    echo " "
  649. X    echo "It's not Xenix..."
  650. X    echo "exit 1" >xenix
  651. X    xenix="$undef"
  652. Xfi
  653. Xchmod +x xenix
  654. X$eunicefix xenix
  655. Xif test -f /venix; then
  656. X    echo "Actually, this looks more like a VENIX system..."
  657. X    echo "exit 0" >venix
  658. Xelse
  659. X    echo " "
  660. X    if xenix; then
  661. X    : null
  662. X    else
  663. X    echo "Nor is it Venix..."
  664. X    fi
  665. X    echo "exit 1" >venix
  666. Xfi
  667. Xchmod +x bsd usg v7 eunice venix
  668. X$eunicefix bsd usg v7 eunice venix
  669. Xrm -rf foo
  670. Xrmlist="$rmlist bsd usg v7 eunice venix xenix"
  671. X
  672. X: Warnings
  673. Xif v7; then
  674. X    cat <<'EOM'
  675. X
  676. XNOTE: many V7 systems do not have a way to do a non-blocking read.  If you
  677. Xdon't have any of FIONREAD, O_NDELAY, or rdchk(), the $package package
  678. Xmay not work as well as it might.  It might not work at all.
  679. XEOM
  680. Xfi
  681. X
  682. X: see what memory models we can support
  683. Xcase "$models" in
  684. X'')
  685. X    : We may not use Cppsym or we get a circular dependency through cc.
  686. X    : But this should work regardless of which cc we eventually use.
  687. X    cat >pdp11.c <<'EOP'
  688. Xmain() {
  689. X#ifdef pdp11
  690. X    exit(0);
  691. X#else
  692. X    exit(1);
  693. X#endif
  694. X}
  695. XEOP
  696. X    cc -o pdp11 pdp11.c >/dev/null 2>&1
  697. X    if pdp11 2>/dev/null; then
  698. X    dflt='unsplit split'
  699. X    else
  700. X    ans=`loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
  701. X    case "$ans" in
  702. X    X) dflt='none';;
  703. X    *)  if $test -d /lib/small || $test -d /usr/lib/small; then
  704. X        dflt='small'
  705. X        else
  706. X        dflt=''
  707. X        fi
  708. X        if $test -d /lib/medium || $test -d /usr/lib/medium; then
  709. X        dflt="$dflt medium"
  710. X        fi
  711. X        if $test -d /lib/large || $test -d /usr/lib/large; then
  712. X        dflt="$dflt large"
  713. X        fi
  714. X        if $test -d /lib/huge || $test -d /usr/lib/huge; then
  715. X        dflt="$dflt huge"
  716. X        fi
  717. X    esac
  718. X    fi
  719. X    ;;
  720. X*)  dflt="$models" ;;
  721. Xesac
  722. X$cat <<EOM
  723. XSome systems have different model sizes.  On most systems they are called
  724. Xsmall, medium, large, and huge.  On the PDP11 they are called unsplit and
  725. Xsplit.  If your system doesn't support different memory models, say "none".
  726. XIf you wish to force everything to one memory model, say "none" here and
  727. Xput the appropriate flags later when it asks you for other cc and ld flags.
  728. XVenix systems may wish to put "none" and let the compiler figure things out.
  729. X(In the following question multiple model names should be space separated.)
  730. X
  731. XEOM
  732. Xrp="Which models are supported? [$dflt]"
  733. X$echo $n "$rp $c"
  734. X. myread
  735. Xmodels="$ans"
  736. X
  737. Xcase "$models" in
  738. Xnone)
  739. X    small=''
  740. X    medium=''
  741. X    large=''
  742. X    huge=''
  743. X    unsplit=''
  744. X    split=''
  745. X    ;;
  746. X*split)
  747. X    case "$split" in
  748. X    '') dflt='-i';;
  749. X    *) dflt="$split";;
  750. X    esac
  751. X    rp="What flag indicates separate I and D space? [$dflt]"
  752. X    $echo $n "$rp $c"
  753. X    . myread
  754. X    case "$ans" in
  755. X    none) ans='';;
  756. X    esac
  757. X    split="$ans"
  758. X    unsplit=''
  759. X    ;;
  760. X*large*|*small*|*medium*|*huge*)
  761. X    case "$models" in
  762. X    *large*)
  763. X    case "$large" in
  764. X    '') dflt='-Ml';;
  765. X    *) dflt="$large";;
  766. X    esac
  767. X    rp="What flag indicates large model? [$dflt]"
  768. X    $echo $n "$rp $c"
  769. X    . myread
  770. X    case "$ans" in
  771. X    none) ans='';
  772. X    esac
  773. X    large="$ans"
  774. X    ;;
  775. X    *) large='';;
  776. X    esac
  777. X    case "$models" in
  778. X    *huge*)
  779. X    case "$huge" in
  780. X    '') dflt='-Mh';;
  781. X    *) dflt="$huge";;
  782. X    esac
  783. X    rp="What flag indicates huge model? [$dflt]"
  784. X    $echo $n "$rp $c"
  785. X    . myread
  786. X    case "$ans" in
  787. X    none) ans='';
  788. X    esac
  789. X    huge="$ans"
  790. X    ;;
  791. X    *) huge="$large";;
  792. X    esac
  793. X    case "$models" in
  794. X    *medium*)
  795. X    case "$medium" in
  796. X    '') dflt='-Mm';;
  797. X    *) dflt="$medium";;
  798. X    esac
  799. X    rp="What flag indicates medium model? [$dflt]"
  800. X    $echo $n "$rp $c"
  801. X    . myread
  802. X    case "$ans" in
  803. X    none) ans='';
  804. X    esac
  805. X    medium="$ans"
  806. X    ;;
  807. X    *) medium="$large";;
  808. X    esac
  809. X    case "$models" in
  810. X    *small*)
  811. X    case "$small" in
  812. X    '') dflt='none';;
  813. X    *) dflt="$small";;
  814. X    esac
  815. X    rp="What flag indicates small model? [$dflt]"
  816. X    $echo $n "$rp $c"
  817. X    . myread
  818. X    case "$ans" in
  819. X    none) ans='';
  820. X    esac
  821. X    small="$ans"
  822. X    ;;
  823. X    *) small='';;
  824. X    esac
  825. X    ;;
  826. X*)
  827. X    echo "Unrecognized memory models--you may have to edit Makefile.SH"
  828. X    ;;
  829. Xesac
  830. X
  831. X: see if we need a special compiler
  832. Xecho " "
  833. Xif usg; then
  834. X    case "$cc" in
  835. X    '') case "$Mcc" in
  836. X    /*) dflt='Mcc';;
  837. X    *) dflt='cc';;
  838. X    esac
  839. X    ;;
  840. X    *)  dflt="$cc";;
  841. X    esac
  842. X    $cat <<'EOM'
  843. X  
  844. XOn some systems the default C compiler will not resolve multiple global
  845. Xreferences that happen to have the same name.  On some such systems the
  846. X"Mcc" command may be used to force these to be resolved.  On other systems
  847. Xa "cc -M" command is required.  (Note that the -M flag on other systems
  848. Xindicates a memory model to use!)  If you have the Gnu C compiler, you
  849. Xmight wish to use that instead.  What command will force resolution on
  850. XEOM
  851. X    $echo $n "this system? [$dflt] $c"
  852. X    rp="Command to resolve multiple refs? [$dflt]"
  853. X    . myread
  854. X    cc="$ans"
  855. Xelse
  856. X    case "$cc" in
  857. X    '') dflt=cc;;
  858. X    *) dflt="$cc";;
  859. X    esac
  860. X    rp="Use which C compiler? [$dflt]"
  861. X    $echo $n "$rp $c"
  862. X    . myread
  863. X    cc="$ans"
  864. Xfi
  865. Xcase "$cc" in
  866. Xgcc*) cpp=`loc gcc-cpp $cpp $pth`;;
  867. Xesac
  868. X
  869. X: determine optimize, if desired, or use for debug flag also
  870. Xcase "$optimize" in
  871. X' ') dflt="none"
  872. X     ;;
  873. X'') dflt="-O";
  874. X    ;;
  875. X*)  dflt="$optimize"
  876. X    ;;
  877. Xesac
  878. Xcat <<EOH
  879. X
  880. XSome C compilers have problems with their optimizers, by default, $package
  881. Xcompiles with the -O flag to use the optimizer.  Alternately, you might
  882. Xwant to use the symbolic debugger, which uses the -g flag (on traditional
  883. XUnix systems).  Either flag can be specified here.  To use neither flag,
  884. Xspecify the word "none".
  885. X  
  886. XEOH
  887. Xrp="What optimizer/debugger flag should be used? [$dflt]"
  888. X$echo $n "$rp $c"
  889. X. myread
  890. Xoptimize="$ans"
  891. Xcase "$optimize" in
  892. X'none') optimize=" "
  893. X     ;;
  894. Xesac
  895. X
  896. Xcase "$ccflags" in
  897. X'') case "$cc" in
  898. X    *gcc*) dflt='-fpcc-struct-return';;
  899. X    *) dflt='';;
  900. X    esac
  901. X    ;;
  902. X*) dflt="$ccflags";;
  903. Xesac
  904. Xfor thisincl in $inclwanted; do
  905. X    if test -d $thisincl; then
  906. X    case "$dflt" in
  907. X    *$thisincl*);;
  908. X    *) dflt="$dflt -I$thisincl";;
  909. X    esac
  910. X    fi
  911. Xdone
  912. Xcase "$optimize" in
  913. X-g*)
  914. X    case "$dflt" in
  915. X    *DEBUGGING*);;
  916. X    *) dflt="$dflt -DDEBUGGING";;
  917. X    esac
  918. X    ;;
  919. Xesac
  920. Xif $contains 'LANGUAGE_C' /usr/include/signal.h >/dev/null 2>&1; then
  921. X    case "$dflt" in
  922. X    *LANGUAGE_C*);;
  923. X    *) dflt="$dflt -DLANGUAGE_C";;
  924. X    esac
  925. Xfi
  926. Xcase "$dflt" in
  927. X'') dflt=none;;
  928. Xesac
  929. Xcat <<EOH
  930. X
  931. XYour C compiler may want other flags.  For this question you should
  932. Xinclude -I/whatever and -DWHATEVER flags and any other flags used by
  933. Xthe C compiler, but you should NOT include libraries or ld flags like
  934. X-lwhatever.  To use no flags, specify the word "none".
  935. X  
  936. XEOH
  937. Xrp="Any additional cc flags? [$dflt]"
  938. X$echo $n "$rp $c"
  939. X. myread
  940. Xcase "$ans" in
  941. Xnone) ans='';
  942. Xesac
  943. Xccflags="$ans"
  944. X
  945. X: the following weeds options from ccflags that are of no interest to cpp
  946. Xcppflags="$ccflags"
  947. Xcase "$cc" in
  948. X*gcc*) cppflags="$cppflags -D__GNUC__";;
  949. Xesac
  950. Xcase "$cppflags" in
  951. X'');;
  952. X*)  set X $cppflags
  953. X    cppflags=''
  954. X    for flag do
  955. X    case $flag in
  956. X    -D*|-I*) cppflags="$cppflags $flag";;
  957. X    esac
  958. X    done
  959. X    case "$cppflags" in
  960. X    *-*)  echo "(C preprocessor flags: $cppflags)";;
  961. X    esac
  962. X    ;;
  963. Xesac
  964. X
  965. Xcase "$ldflags" in
  966. X'') if venix; then
  967. X    dflt='-i -z'
  968. X    else
  969. X    dflt='none'
  970. X    fi
  971. X    ;;
  972. X*) dflt="$ldflags";;
  973. Xesac
  974. Xecho " "
  975. Xrp="Any additional ld flags (NOT including libraries)? [$dflt]"
  976. X$echo $n "$rp $c"
  977. X. myread
  978. Xcase "$ans" in
  979. Xnone) ans='';
  980. Xesac
  981. Xldflags="$ans"
  982. Xrmlist="$rmlist pdp11"
  983. X
  984. X: where do we get termlib routines from
  985. Xecho " "
  986. Xans=`loc libcurses.a x $libpth`
  987. Xcase "$ans" in
  988. X/*)
  989. X    ar t $ans >grimble
  990. X    if $contains tputs.o grimble >/dev/null 2>&1; then
  991. X    termlib='-lcurses'
  992. X    echo "Terminfo library found."
  993. X    else
  994. X    ans=x
  995. X    fi
  996. X    rm -f grimble
  997. X    ;;
  998. Xesac
  999. Xcase "$ans" in
  1000. Xx)
  1001. X    ans=`loc libtermlib.a x $libpth`
  1002. X    case "$ans" in
  1003. X    /usr/lib*|/lib*)
  1004. X    termlib='-ltermlib'
  1005. X    echo "Termlib library found."
  1006. X    ;;
  1007. X    /*)
  1008. X    termlib="$ans"
  1009. X    echo "Termlib library found."
  1010. X    ;;
  1011. X    *)
  1012. X    ans=`loc libtermcap.a x $libpth`
  1013. X    case "$ans" in
  1014. X    /usr/lib*|/lib*)
  1015. X        termlib='-ltermcap'
  1016. X        echo "Termcap library found."
  1017. X        ;;
  1018. X    /*)
  1019. X        termlib="$ans"
  1020. X        echo "Termcap library found."
  1021. X        ;;
  1022. X    *)
  1023. X        case "$termlib" in
  1024. X        '')
  1025. X        dflt=y
  1026. X        rp="Your system appears to NOT have termlib-style routines.  Is this true? [$dflt]"
  1027. X        $echo $n "$rp $c"
  1028. X        . myread
  1029. X        case "$ans" in
  1030. X            n*|f*)
  1031. X              echo "Then where are the termlib-style routines kept (specify either -llibname"
  1032. X              $echo $n " or full pathname (~name ok))? $c"
  1033. X              rp='Specify termlib:'
  1034. X              . myread
  1035. X              termlib=`filexp $ans`
  1036. X              ;;
  1037. X            *)    termlib=''
  1038. X              echo "You will have to play around with main.c then."
  1039. X              ;;
  1040. X        esac
  1041. X        echo " "
  1042. X        ;;
  1043. X        *)  echo "You said termlib was $termlib before."
  1044. X        ;;
  1045. X        esac
  1046. X        ;;
  1047. X    esac
  1048. X    ;;
  1049. X    esac
  1050. X    ;;
  1051. Xesac
  1052. Xans=`loc llib${termlib}.ln x $libpth`
  1053. Xcase "$ans" in
  1054. X/usr/lib*|/lib*)
  1055. X    echo "Termlib lint library found."
  1056. X    llib_termlib="$termlib"
  1057. X    ;;
  1058. Xesac
  1059. X
  1060. Xecho " "
  1061. Xecho "Checking for optional libraries..."
  1062. Xdflt=''
  1063. Xcase "$libswanted" in
  1064. X'') libswanted='c_s';;
  1065. Xesac
  1066. Xfor thislib in $libswanted; do
  1067. X    case "$thislib" in
  1068. X    dbm) thatlib=ndbm;;
  1069. X    *_s) thatlib=NONE;;
  1070. X    *) thatlib="${thislib}_s";;
  1071. X    *) thatlib=NONE;;
  1072. X    esac
  1073. X    xxx=`loc lib$thislib.a X /usr/lib /usr/local/lib /lib`
  1074. X    if test -f $xxx; then
  1075. X    echo "Found -l$thislib."
  1076. X    case "$dflt" in
  1077. X    *-l$thislib*|*-l$thatlib*);;
  1078. X    *) dflt="$dflt -l$thislib";;
  1079. X    esac
  1080. X    else
  1081. X    xxx=`loc lib$thislib.a X $libpth`
  1082. X    if test -f $xxx; then
  1083. X        echo "Found $xxx."
  1084. X        case "$dflt" in
  1085. X        *$xxx*);;
  1086. X        *) dflt="$dflt $xxx";;
  1087. X        esac
  1088. X    else
  1089. X        xxx=`loc Slib$thislib.a X $xlibpth`
  1090. X        if test -f $xxx; then
  1091. X        echo "Found -l$thislib."
  1092. X        case "$dflt" in
  1093. X        *-l$thislib*|*-l$thatlib*);;
  1094. X        *) dflt="$dflt -l$thislib";;
  1095. X        esac
  1096. X        else
  1097. X        echo "No -l$thislib."
  1098. X        fi
  1099. X    fi
  1100. X    fi
  1101. Xdone
  1102. Xset X $termlib $dflt
  1103. Xshift
  1104. Xdflt="$*"
  1105. Xcase "$libs" in
  1106. X'') dflt="$dflt";;
  1107. X*) dflt="$libs";;
  1108. Xesac
  1109. Xcase "$dflt" in
  1110. X'') dflt='none';;
  1111. Xesac
  1112. X
  1113. X$cat <<EOM
  1114. XSome versions of Unix support shared libraries, which make
  1115. Xexecutables smaller but make load time slightly longer.
  1116. X
  1117. XOn some systems, mostly newer Unix System V's, the shared library
  1118. Xis included by putting the option "-lc_s" as the last thing on the
  1119. Xcc command line when linking.  Other systems use shared libraries
  1120. Xby default.  There may be other libraries needed to compile $package
  1121. Xon your machine as well.  If your system needs the "-lc_s" option,
  1122. Xinclude it here.  Include any other special libraries here as well.
  1123. XSay "none" for none.
  1124. XEOM
  1125. X
  1126. Xecho " "
  1127. Xrp="Any additional libraries? [$dflt]"
  1128. X$echo $n "$rp $c"
  1129. X. myread
  1130. Xcase "$ans" in
  1131. Xnone) ans='';
  1132. Xesac
  1133. Xlibs="$ans"
  1134. X
  1135. X: see how we invoke the C preprocessor
  1136. Xecho " "
  1137. Xecho "Now, how can we feed standard input to your C preprocessor..."
  1138. Xcat <<'EOT' >testcpp.c
  1139. X#define ABC abc
  1140. X#define XYZ xyz
  1141. XABC.XYZ
  1142. XEOT
  1143. Xecho 'Maybe "'"$cc"' -E" will work...'
  1144. X$cc -E <testcpp.c >testcpp.out 2>&1
  1145. X: try to force gcc preprocessor if that is the compiler they are using
  1146. Xcase $? in
  1147. X0) cppstdin="$cc -E";;
  1148. X*) case "$cc" in
  1149. X    *gcc*)
  1150. X    cd ..
  1151. X    echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
  1152. X    echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
  1153. X    chmod 755 cppstdin
  1154. X    cppstdin=`pwd`/cppstdin
  1155. X    cppminus='';
  1156. X    cd UU
  1157. X    $cppstdin <testcpp.c >testcpp.out 2>&1
  1158. X    ;;
  1159. X    esac
  1160. X    ;;
  1161. Xesac
  1162. Xif $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1163. X    echo "Yup, it does."
  1164. X    cppstdin="$cc -E"
  1165. X    cppminus='';
  1166. Xelse
  1167. X    echo 'Nope, maybe "'$cpp'" will work...'
  1168. X    $cpp <testcpp.c >testcpp.out 2>&1
  1169. X    if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1170. X    echo "Yup, it does."
  1171. X    cppstdin="$cpp"
  1172. X    cppminus='';
  1173. X    else
  1174. X    echo 'No such luck...maybe "'$cpp' -" will work...'
  1175. X    $cpp - <testcpp.c >testcpp.out 2>&1
  1176. X    if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1177. X        echo "It works!"
  1178. X        cppstdin="$cpp"
  1179. X        cppminus='-';
  1180. X    else
  1181. X        echo 'Nixed again...maybe "'"$cc"' -E -" will work...'
  1182. X        $cc -E - <testcpp.c >testcpp.out 2>&1
  1183. X        if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1184. X        echo "Hooray, it works!  I was beginning to wonder."
  1185. X        cppstdin="$cc -E"
  1186. X        cppminus='-';
  1187. X        else
  1188. X        echo 'Nope...maybe "'"$cc"' -P" will work...'
  1189. X        $cc -P <testcpp.c >testcpp.out 2>&1
  1190. X        if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1191. X            echo "Yup, that does."
  1192. X            cppstdin="$cc -P"
  1193. X            cppminus='';
  1194. X        else
  1195. X            echo 'Nope...maybe "'"$cc"' -P -" will work...'
  1196. X            $cc -P - <testcpp.c >testcpp.out 2>&1
  1197. X            if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1198. X            echo "Yup, that does."
  1199. X            cppstdin="$cc -P"
  1200. X            cppminus='-';
  1201. X            else
  1202. X            echo 'Hmm...perhaps you already told me...'
  1203. X            case "$cppstdin" in
  1204. X            '') ;;
  1205. X            *) $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1;;
  1206. X            esac
  1207. X            if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1208. X                echo "Hooray, you did!  I was beginning to wonder."
  1209. X            else
  1210. X                echo 'Uh-uh.  Time to get fancy...'
  1211. X                cd ..
  1212. X                echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
  1213. X                echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
  1214. X                chmod 755 cppstdin
  1215. X                cppstdin=`pwd`/cppstdin
  1216. X                cppminus='';
  1217. X                cd UU
  1218. X                $cppstdin <testcpp.c >testcpp.out 2>&1
  1219. X                if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1220. X                echo "Eureka!."
  1221. X                else
  1222. X                dflt=blurfl
  1223. X                $echo $n "No dice.  I can't find a C preprocessor.  Name one: $c"
  1224. X                rp='Name a C preprocessor:'
  1225. X                . myread
  1226. X                cppstdin="$ans"
  1227. X                $cppstdin <testcpp.c >testcpp.out 2>&1
  1228. X                if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1229. X                    echo "OK, that will do."
  1230. X                else
  1231. X                    echo "Sorry, I can't get that to work.  Go find one."
  1232. X                    exit 1
  1233. X                fi
  1234. X                fi
  1235. X            fi
  1236. X            fi
  1237. X        fi
  1238. X        fi
  1239. X    fi
  1240. X    fi
  1241. Xfi
  1242. Xrm -f testcpp.c testcpp.out
  1243. X
  1244. X: get list of predefined functions in a handy place
  1245. Xecho " "
  1246. Xcase "$libc" in
  1247. X'') libc=unknown;;
  1248. Xesac
  1249. Xcase "$libpth" in
  1250. X'') libpth='/lib /usr/lib /usr/local/lib';;
  1251. Xesac
  1252. Xcase "$libs" in
  1253. X*-lc_s*) libc=`loc libc_s.a $libc $libpth`
  1254. Xesac
  1255. Xlibnames='';
  1256. Xcase "$libs" in
  1257. X'') ;;
  1258. X*)  for thislib in $libs; do
  1259. X    case "$thislib" in
  1260. X    -l*) thislib=`expr X$thislib : 'X-l\(.*\)'`
  1261. X        try=`loc lib$thislib.a blurfl/dyick $libpth`
  1262. X        if test ! -f $try; then
  1263. X        try=`loc lib$thislib blurfl/dyick $libpth`
  1264. X        if test ! -f $try; then
  1265. X            try=`loc $thislib blurfl/dyick $libpth`
  1266. X            if test ! -f $try; then
  1267. X            try=`loc Slib$thislib.a blurfl/dyick $xlibpth`
  1268. X            if test ! -f $try; then
  1269. X                try=''
  1270. X            fi
  1271. X            fi
  1272. X        fi
  1273. X        fi
  1274. X        libnames="$libnames $try"
  1275. X        ;;
  1276. X    *) libnames="$libnames $thislib" ;;
  1277. X    esac
  1278. X    done
  1279. X    ;;
  1280. Xesac
  1281. Xset /usr/lib/libc.so.[0-9]*
  1282. Xeval set \$$#
  1283. Xif test -f "$1"; then
  1284. X    echo "Your shared C library is in $1."
  1285. X    libc="$1"
  1286. Xelif test -f $libc; then
  1287. X    echo "Your C library is in $libc, like you said before."
  1288. Xelif test -f /lib/libc.a; then
  1289. X    echo "Your C library is in /lib/libc.a.  You're normal."
  1290. X    libc=/lib/libc.a
  1291. Xelse
  1292. X    ans=`loc libc.a blurfl/dyick $libpth`
  1293. X    if test ! -f "$ans"; then
  1294. X    ans=`loc libc blurfl/dyick $libpth`
  1295. X    fi
  1296. X    if test ! -f "$ans"; then
  1297. X    ans=`loc clib blurfl/dyick $libpth`
  1298. X    fi
  1299. X    if test ! -f "$ans"; then
  1300. X    ans=`loc Slibc.a blurfl/dyick $xlibpth`
  1301. X    fi
  1302. X    if test ! -f "$ans"; then
  1303. X    ans=`loc Mlibc.a blurfl/dyick $xlibpth`
  1304. X    fi
  1305. X    if test ! -f "$ans"; then
  1306. X    ans=`loc Llibc.a blurfl/dyick $xlibpth`
  1307. X    fi
  1308. X    if test -f "$ans"; then
  1309. X    echo "Your C library is in $ans, of all places."
  1310. X    libc=$ans
  1311. X    else
  1312. X    cat <<EOM
  1313. XI can't seem to find your C library.  I've looked in the following places:
  1314. X
  1315. X    $libpth
  1316. X
  1317. XNone of these seems to contain your C library.  What is the full name
  1318. XEOM
  1319. X    dflt=None
  1320. X    $echo $n "of your C library? $c"
  1321. X    rp='C library full name?'
  1322. X    . myread
  1323. X    libc="$ans"
  1324. X    fi
  1325. Xfi
  1326. Xecho " "
  1327. Xset `echo $libc $libnames | tr ' ' '\012' | sort | uniq`
  1328. X$echo $n "Extracting names from $* for later perusal...$c"
  1329. Xnm $* 2>/dev/null >libc.tmp
  1330. X$sed -n -e 's/^.* [AT]  *_[_.]*//p' -e 's/^.* [AT] //p' <libc.tmp >libc.list
  1331. Xif $contains '^printf$' libc.list >/dev/null 2>&1; then
  1332. X    echo "done"
  1333. Xelse
  1334. X    $sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p' <libc.tmp >libc.list
  1335. X    $contains '^printf$' libc.list >/dev/null 2>&1 || \
  1336. X    $sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p' <libc.tmp >libc.list
  1337. X    $contains '^printf$' libc.list >/dev/null 2>&1 || \
  1338. X    $sed -n -e 's/^.* D __*//p' -e 's/^.* D //p' <libc.tmp >libc.list
  1339. X    $contains '^printf$' libc.list >/dev/null 2>&1 || \
  1340. X       $sed -n -e 's/^_//' \
  1341. X          -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p' <libc.tmp >libc.list
  1342. X    $contains '^printf$' libc.list >/dev/null 2>&1 || \
  1343. X    $sed -n -e 's/^.*|FUNC |GLOB .*|//p' <libc.tmp >libc.list
  1344. X    if $contains '^printf$' libc.list >/dev/null 2>&1; then
  1345. X    echo "done"
  1346. X    else
  1347. X    echo " "
  1348. X    echo "nm didn't seem to work right."
  1349. X    echo "Trying ar instead..."
  1350. X    if ar t $libc > libc.tmp; then
  1351. X        for thisname in $libnames; do
  1352. X        ar t $thisname >>libc.tmp
  1353. X        done
  1354. X        $sed -e 's/\.o$//' < libc.tmp > libc.list
  1355. X        echo "Ok."
  1356. X    else
  1357. X        echo "ar didn't seem to work right."
  1358. X        echo "Maybe this is a Cray...trying bld instead..."
  1359. X        if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
  1360. X        for thisname in $libnames; do
  1361. X            bld t $libnames | \
  1362. X            $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
  1363. X            ar t $thisname >>libc.tmp
  1364. X        done
  1365. X        echo "Ok."
  1366. X        else
  1367. X            echo "That didn't work either.  Giving up."
  1368. X            exit 1
  1369. X        fi
  1370. X    fi
  1371. X    fi
  1372. Xfi
  1373. Xrmlist="$rmlist libc.tmp libc.list"
  1374. X
  1375. X: see if this is an fcntl system
  1376. Xecho " "
  1377. Xif $test -r /usr/include/fcntl.h ; then
  1378. X    d_fcntl="$define"
  1379. X    i_fcntl="$define"
  1380. X    echo "fcntl.h found."
  1381. Xelse
  1382. X    d_fcntl="$undef"
  1383. X    i_fcntl="$undef"
  1384. X    echo "No fcntl.h found, but that's ok."
  1385. Xfi
  1386. X
  1387. X: index or strcpy
  1388. Xecho " "
  1389. Xcase "$d_index" in
  1390. Xn) dflt=n;;
  1391. X*) dflt=y;;
  1392. Xesac
  1393. Xif $contains '^index$' libc.list >/dev/null 2>&1 ; then
  1394. X    if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
  1395. X    echo "Your system has both index() and strchr().  Shall I use"
  1396. X    rp="index() rather than strchr()? [$dflt]"
  1397. X    $echo $n "$rp $c"
  1398. X    . myread
  1399. X    case "$ans" in
  1400. X        n*) d_index="$define" ;;
  1401. X        *)  d_index="$undef" ;;
  1402. X    esac
  1403. X    else
  1404. X    d_index="$undef"
  1405. X    echo "index() found."
  1406. X    fi
  1407. Xelse
  1408. X    if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
  1409. X    d_index="$define"
  1410. X    echo "strchr() found."
  1411. X    else
  1412. X    d_index="$undef"
  1413. X    echo "No index() or strchr() found!"
  1414. X    fi
  1415. Xfi
  1416. X
  1417. X: see if ioctl defs are in termio or sys/ioctl
  1418. Xecho " "
  1419. Xif $test -r /usr/include/sys/ioctl.h ; then
  1420. X    d_ioctl="$define"
  1421. X    i_sysioctl="$define"
  1422. X    echo "sys/ioctl.h found."
  1423. Xelse
  1424. X    d_ioctl="$undef"
  1425. X    i_sysioctl="$undef"
  1426. X    echo "sys/ioctl.h not found, assuming ioctl args are defined in termio.h."
  1427. Xfi
  1428. X
  1429. X: see if this is a pwd system
  1430. Xecho " "
  1431. Xif $test -r /usr/include/pwd.h ; then
  1432. X    i_pwd="$define"
  1433. X    echo "pwd.h found."
  1434. Xelse
  1435. X    i_pwd="$undef"
  1436. X    echo "No pwd.h found."
  1437. Xfi
  1438. X
  1439. X: see if we should include time.h, sys/time.h, or both
  1440. Xcat <<'EOM'
  1441. X  
  1442. XTesting to see if we should include <time.h>, <sys/time.h> or both.
  1443. XI'm now running the test program...
  1444. XEOM
  1445. X$cat >try.c <<'EOCP'
  1446. X#ifdef I_TIME
  1447. X#include <time.h>
  1448. X#endif
  1449. X#ifdef I_SYSTIME
  1450. X#ifdef SYSTIMEKERNEL
  1451. X#define KERNEL
  1452. X#endif
  1453. X#include <sys/time.h>
  1454. X#endif
  1455. Xmain()
  1456. X{
  1457. X    struct tm foo;
  1458. X#ifdef S_TIMEVAL
  1459. X    struct timeval bar;
  1460. X#endif
  1461. X    if (foo.tm_sec == foo.tm_sec)
  1462. X    exit(0);
  1463. X#ifdef S_TIMEVAL
  1464. X    if (bar.tv_sec == bar.tv_sec)
  1465. X    exit(0);
  1466. X#endif
  1467. X    exit(1);
  1468. X}
  1469. XEOCP
  1470. Xflags=''
  1471. Xfor s_timeval in '-DS_TIMEVAL' ''; do
  1472. X    for d_systimekernel in '' '-DSYSTIMEKERNEL'; do
  1473. X    for i_time in '' '-DI_TIME'; do
  1474. X        for i_systime in '-DI_SYSTIME' ''; do
  1475. X        case "$flags" in
  1476. X        '') echo Trying $i_time $i_systime $d_systimekernel $s_timeval
  1477. X            if $cc $ccflags \
  1478. X                $i_time $i_systime $d_systimekernel $s_timeval \
  1479. X                try.c -o try >/dev/null 2>&1 ; then
  1480. X            set X $i_time $i_systime $d_systimekernel $s_timeval
  1481. X            shift
  1482. X            flags="$*"
  1483. X            echo Succeeded with $flags
  1484. X            fi
  1485. X            ;;
  1486. X        esac
  1487. X        done
  1488. X    done
  1489. X    done
  1490. Xdone
  1491. Xcase "$flags" in
  1492. X*SYSTIMEKERNEL*) d_systimekernel="$define";;
  1493. X*) d_systimekernel="$undef";;
  1494. Xesac
  1495. Xcase "$flags" in
  1496. X*I_TIME*) i_time="$define";;
  1497. X*) i_time="$undef";;
  1498. Xesac
  1499. Xcase "$flags" in
  1500. X*I_SYSTIME*) i_systime="$define";;
  1501. X*) i_systime="$undef";;
  1502. Xesac
  1503. X$rm -f try.c try
  1504. X
  1505. X: see if this is a varargs system
  1506. Xecho " "
  1507. Xif $test -r /usr/include/varargs.h ; then
  1508. X    d_varargs="$define"
  1509. X    echo "varargs.h found."
  1510. Xelse
  1511. X    d_varargs="$undef"
  1512. X    echo "No varargs.h found, but that's ok (I hope)."
  1513. Xfi
  1514. X
  1515. X: see if signal is declared as pointer to function returning int or void
  1516. Xecho " "
  1517. X$cppstdin $cppflags < /usr/include/signal.h >$$.tmp
  1518. Xif $contains 'void.*signal' $$.tmp >/dev/null 2>&1 ; then
  1519. X    echo "You have void (*signal())() instead of int."
  1520. X    d_voidsig="$define"
  1521. Xelse
  1522. X    echo "You have int (*signal())() instead of void."
  1523. X    d_voidsig="$undef"
  1524. Xfi
  1525. Xrm -f $$.tmp
  1526. X
  1527. X: check for void type
  1528. Xecho " "
  1529. X$cat <<EOM
  1530. XChecking to see how well your C compiler groks the void type...
  1531. X
  1532. X  Support flag bits are:
  1533. X    1: basic void declarations.
  1534. X    2: arrays of pointers to functions returning void.
  1535. X    4: operations between pointers to and addresses of void functions.
  1536. X
  1537. XEOM
  1538. Xcase "$voidflags" in
  1539. X'')
  1540. X    $cat >try.c <<'EOCP'
  1541. X#if TRY & 1
  1542. Xvoid main() {
  1543. X#else
  1544. Xmain() {
  1545. X#endif
  1546. X    extern void moo();    /* function returning void */
  1547. X    void (*goo)();        /* ptr to func returning void */
  1548. X#if TRY & 2
  1549. X    void (*foo[10])();
  1550. X#endif
  1551. X
  1552. X#if TRY & 4
  1553. X    if(goo == moo) {
  1554. X        exit(0);
  1555. X    }
  1556. X#endif
  1557. X    exit(0);
  1558. X}
  1559. XEOCP
  1560. X    if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
  1561. X    voidflags=$defvoidused
  1562. X    echo "It appears to support void."
  1563. X    if $contains warning .out >/dev/null 2>&1; then
  1564. X        echo "However, you might get some warnings that look like this:"
  1565. X        $cat .out
  1566. X    fi
  1567. X    else
  1568. X    echo "Hmm, your compiler has some difficulty with void.  Checking further..."
  1569. X    if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1 ; then
  1570. X        echo "It supports 1..."
  1571. X        if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1 ; then
  1572. X        voidflags=3
  1573. X        echo "And it supports 2 but not 4."
  1574. X        else
  1575. X        echo "It doesn't support 2..."
  1576. X        if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1 ; then
  1577. X            voidflags=5
  1578. X            echo "But it supports 4."
  1579. X        else
  1580. X            voidflags=1
  1581. X            echo "And it doesn't support 4."
  1582. X        fi
  1583. X        fi
  1584. X    else
  1585. X        echo "There is no support at all for void."
  1586. X        voidflags=0
  1587. X    fi
  1588. X    fi
  1589. Xesac
  1590. Xdflt="$voidflags";
  1591. Xrp="Your void support flags add up to what? [$dflt]"
  1592. X$echo $n "$rp $c"
  1593. X. myread
  1594. Xvoidflags="$ans"
  1595. X$rm -f try.* .out
  1596. X
  1597. X: see what type uids are declared as in the kernel
  1598. Xcase "$uidtype" in
  1599. X'')
  1600. X    if $contains 'uid_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
  1601. X    dflt='uid_t'
  1602. X    else
  1603. X    set `grep 'u_uid;' /usr/include/sys/user.h 2>/dev/null` unsigned short
  1604. X    case $1 in
  1605. X    unsigned) dflt="$1 $2" ;;
  1606. X    *) dflt="$1" ;;
  1607. X    esac
  1608. X    fi
  1609. X    ;;
  1610. X*)  dflt="$uidtype"
  1611. X    ;;
  1612. Xesac
  1613. Xcont=true
  1614. Xecho " "
  1615. Xrp="What type are user ids returned by getuid(), etc.? [$dflt]"
  1616. X$echo $n "$rp $c"
  1617. X. myread
  1618. Xuidtype="$ans"
  1619. X
  1620. X: see what type gids are declared as in the kernel
  1621. Xcase "$gidtype" in
  1622. X'')
  1623. X    if $contains 'gid_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
  1624. X    dflt='gid_t'
  1625. X    else
  1626. X    set `grep 'u_gid;' /usr/include/sys/user.h 2>/dev/null` unsigned short
  1627. X    case $1 in
  1628. X    unsigned) dflt="$1 $2" ;;
  1629. X    *) dflt="$1" ;;
  1630. X    esac
  1631. X    fi
  1632. X    ;;
  1633. X*)  dflt="$gidtype"
  1634. X    ;;
  1635. Xesac
  1636. Xcont=true
  1637. Xecho " "
  1638. Xrp="What type are group ids returned by getgid(), etc.? [$dflt]"
  1639. X$echo $n "$rp $c"
  1640. X. myread
  1641. Xgidtype="$ans"
  1642. X
  1643. X: see if this is a varargs system
  1644. Xecho " "
  1645. Xif $test -r /usr/include/varargs.h ; then
  1646. X    i_varargs="$define"
  1647. X    echo "varargs.h found."
  1648. Xelse
  1649. X    i_varargs="$undef"
  1650. X    echo "No varargs.h found, but that's ok (I hope)."
  1651. Xfi
  1652. X
  1653. X: see what type of char stdio uses.
  1654. Xecho " "
  1655. Xif $contains 'unsigned.*char.*_ptr.*;' /usr/include/stdio.h >/dev/null 2>&1 ; then
  1656. X    echo "Your stdio uses unsigned chars."
  1657. X    stdchar="unsigned char"
  1658. Xelse
  1659. X    echo "Your stdio uses signed chars."
  1660. X    stdchar="char"
  1661. Xfi
  1662. X
  1663. X: see if there is the getut family
  1664. Xecho " "
  1665. Xif $contains '^getut' libc.list >/dev/null 2>&1 ; then
  1666. X    echo "getutent() found."
  1667. X    d_getutent="$define"
  1668. Xelse
  1669. X    echo "No getutent() found--will use my own."
  1670. X    d_getutent="$undef"
  1671. Xfi
  1672. X
  1673. X: see if there is a strdup
  1674. Xif $contains '^strdup$' libc.list >/dev/null 2>&1 ; then
  1675. X    echo "strdup() found."
  1676. X    d_strdup="$define"
  1677. Xelse
  1678. X    echo "No strdup() found--will use my own."
  1679. X    d_strdup="$undef"
  1680. Xfi
  1681. X
  1682. X: see if there is a putenv
  1683. Xif $contains '^putenv$' libc.list >/dev/null 2>&1 ; then
  1684. X    echo "putenv() found."
  1685. X    d_putenv="$define"
  1686. Xelse
  1687. X    echo "No putenv() found--will use my own."
  1688. X    d_putenv="$undef"
  1689. Xfi
  1690. X
  1691. X: now get the host name
  1692. Xecho " "
  1693. Xecho "Figuring out host name..."
  1694. Xecho 'Maybe "hostname" will work...'
  1695. Xif ans=`sh -c hostname 2>&1` ; then
  1696. X    hostname=$ans
  1697. X    phostname=hostname
  1698. Xelse
  1699. X    echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
  1700. X    if ans=`cat /etc/systemid 2>&1` ; then
  1701. X    hostname=$ans
  1702. X    phostname='cat /etc/systemid'
  1703. X    if xenix; then
  1704. X        echo "Whadyaknow.  Xenix always was a bit strange..."
  1705. X    else
  1706. X        echo "What is a non-Xenix system doing with /etc/systemid?"
  1707. X    fi
  1708. X    else
  1709. X    echo 'No, maybe "uuname -l" will work...'
  1710. X    if ans=`sh -c 'uuname -l' 2>&1` ; then
  1711. X        hostname=$ans
  1712. X        phostname='uuname -l'
  1713. X    else
  1714. X        echo 'Strange.  Maybe "uname -n" will work...'
  1715. X        if ans=`sh -c 'uname -n' 2>&1` ; then
  1716. X        hostname=$ans
  1717. X        phostname='uname -n'
  1718. X        else
  1719. X        echo 'Oh well, maybe I can mine it out of whoami.h...'
  1720. X        if ans=`sh -c $contains' sysname /usr/include/whoami.h' 2>&1` ; then
  1721. X            hostname=`echo "$ans" | $sed 's/^.*"\(.*\)"/\1/'`
  1722. X            phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' </usr/include/whoami.h"
  1723. X        else
  1724. X            case "$hostname" in
  1725. X            '') echo "Does this machine have an identity crisis or something?"
  1726. X            phostname=''
  1727. X            ;;
  1728. X            *)  echo "Well, you said $hostname before...";;
  1729. X            esac
  1730. X        fi
  1731. X        fi
  1732. X    fi
  1733. X    fi
  1734. Xfi
  1735. X: you do not want to know about this
  1736. Xset $hostname
  1737. Xhostname=$1
  1738. X
  1739. X: translate upper to lower if necessary
  1740. Xcase "$hostname" in
  1741. X    *[A-Z]*)
  1742. X    hostname=`echo $hostname | $tr '[A-Z]' '[a-z]'`
  1743. X    echo "(Normalizing case in your host name)"
  1744. X    ;;
  1745. Xesac
  1746. X
  1747. X: verify guess
  1748. Xif $test "$hostname" ; then
  1749. X    dflt=y
  1750. X    echo 'Your host name appears to be "'$hostname'".'
  1751. X    $echo $n "Is this correct? [$dflt] $c"
  1752. X    rp="Sitename is $hostname? [$dflt]"
  1753. X    . myread
  1754. X    case "$ans" in
  1755. X      y*)  ;;
  1756. X      *)      hostname='' ;;
  1757. X    esac
  1758. Xfi
  1759. X
  1760. X: bad guess or no guess
  1761. Xwhile $test "X$hostname" = X ; do
  1762. X    dflt=''
  1763. X    rp="Please type the (one word) name of your host:"
  1764. X    $echo $n "$rp $c"
  1765. X    . myread
  1766. X    hostname="$ans"
  1767. Xdone
  1768. X
  1769. X: a little sanity check here
  1770. Xcase "$phostname" in
  1771. X'') ;;
  1772. X*)  case `$phostname` in
  1773. X    $hostname) ;;
  1774. X    *)
  1775. X    case "$phostname" in
  1776. X    sed*)
  1777. X        echo "(That doesn't agree with your whoami.h file, by the way.)"
  1778. X        ;;
  1779. X    *)
  1780. X        echo "(That doesn't agree with your $phostname command, by the way.)"
  1781. X        ;;
  1782. X    esac
  1783. X    phostname=''
  1784. X    ;;
  1785. X    esac
  1786. X    ;;
  1787. Xesac
  1788. X
  1789. X: see how we will look up host name
  1790. Xd_douname="$undef"
  1791. Xd_phostname="$undef"
  1792. X
  1793. X# if xenix; then
  1794. X#     echo " "
  1795. X#     echo "(Assuming Xenix uname() is broken.)"
  1796. X# el
  1797. Xif $contains '^uname$' libc.list >/dev/null 2>&1 ; then
  1798. X    echo "uname() found."
  1799. X    d_douname="$define"
  1800. X    ans=uname
  1801. Xfi
  1802. X
  1803. Xcase "$d_douname" in
  1804. X*define*)
  1805. X    dflt=n
  1806. X    cat <<EOM
  1807. XEvery now and then someone has a $ans() that lies about the hostname
  1808. Xbut can't be fixed for political or economic reasons.  Would you like to
  1809. XEOM
  1810. X    rp="pretend $ans() isn't there and maybe compile in the hostname? [$dflt]"
  1811. X    $echo $n "$rp $c"
  1812. X    . myread
  1813. X    case "$ans" in
  1814. X    y*) d_douname="$undef"
  1815. X    $echo $n "Okay... $c"
  1816. X    ;;
  1817. X    esac
  1818. X    ;;
  1819. Xesac
  1820. X
  1821. Xcase "$d_douname" in
  1822. X*define*) ;;
  1823. X*)
  1824. X    case "$phostname" in
  1825. X      '') ;;
  1826. X      *)
  1827. X    $cat <<EOT
  1828. XThere is no uname() on this system.  You have two possibilities at this point:
  1829. X
  1830. X1)  You can have your host name ($hostname) compiled into $package, which
  1831. X    lets $package start up faster, but makes your binaries non-portable, or
  1832. X2)  you can have $package use a
  1833. X    
  1834. X    popen("$phostname","r")
  1835. X
  1836. X    which will start slower but be more portable.
  1837. X
  1838. XOption 1 will give you the option of using whoami.h if you have one.  If you
  1839. Xwant option 2 but with a different command, you can edit config.sh at the
  1840. Xend of this shell script.
  1841. X
  1842. XEOT
  1843. X    case "$d_phostname" in
  1844. X    "$define") dflt=n;;
  1845. X    "$undef")  dflt=y;;
  1846. X    '')
  1847. X        case "$d_portable" in
  1848. X        "$define") dflt=n ;;
  1849. X        *)      dflt=y ;;
  1850. X        esac
  1851. X        ;;
  1852. X    esac
  1853. X    rp="Do you want your host name compiled in? [$dflt]"
  1854. X    $echo $n "$rp $c"
  1855. X    . myread
  1856. X    case "$ans" in
  1857. X      n*) d_phostname="$define" ;;
  1858. X      *)  phostname=''
  1859. X          d_phostname="$undef"
  1860. X          ;;
  1861. X    esac
  1862. X    ;;
  1863. X    esac
  1864. X    case "$phostname" in
  1865. X      '')
  1866. X    case "$d_whoami" in
  1867. X      "$define")
  1868. X        dflt=y
  1869. X        $cat <<EOM
  1870. XNo hostname function--you can either use the whoami.h file, which has this line:
  1871. X
  1872. X    `grep sysname /usr/include/whoami.h`
  1873. X
  1874. Xor you can have the name we came up with earlier ($hostname) hardwired in.
  1875. XEOM
  1876. X        rp="Use whoami.h to get hostname? [$dflt]"
  1877. X        $echo $n "$rp $c"
  1878. X        . myread
  1879. X        case "$ans" in
  1880. X        n*) d_whoami="$undef";;
  1881. X        esac
  1882. X        ;;
  1883. X      "$undef")
  1884. X        echo 'No hostname function and no whoami.h--hardwiring "'$hostname'".'
  1885. X        ;;
  1886. X    esac
  1887. X    ;;
  1888. X    esac
  1889. X    ;;
  1890. Xesac
  1891. X
  1892. X: see if there is a ttytype file
  1893. Xecho " "
  1894. Xif ttytype=`loc ttytype x /etc`; then
  1895. X    echo "Found $ttytype."
  1896. X    d_ttytype="$define"
  1897. Xelse
  1898. X    d_ttytype="$undef"
  1899. Xfi
  1900. X
  1901. X: see if there is a gettydefs file
  1902. Xif gettytab=`loc gettydefs x /etc`; then
  1903. X    echo "Found $gettytab."
  1904. Xelse
  1905. X    dflt=/etc/gettydefs
  1906. X    echo " "
  1907. X    $echo "No /etc/gettydefs found.  I'll let you create your own."
  1908. X    $echo $n "What do you want to call your gettytab file? [$dflt] $c"
  1909. X    rp='Specify gettytab:'
  1910. X    . myread
  1911. X    gettytab=$ans
  1912. X    echo " "
  1913. Xfi
  1914. X
  1915. X: find the utmp file
  1916. Xif utmp=`loc utmp utmp /etc /usr/adm`; then
  1917. X    echo "Found $utmp."
  1918. Xelse
  1919. X    dflt=/etc/utmp
  1920. X    echo " "
  1921. X    $echo $n "Where is your utmp file? [$dflt] $c"
  1922. X    rp="Utmp filename? [$dflt]"
  1923. X    . myread
  1924. X    utmp="$ans"
  1925. X    echo " "
  1926. Xfi
  1927. X
  1928. X: find the wtmp file
  1929. Xif wtmp=`loc wtmp wtmp /etc /usr/adm`; then
  1930. X    echo "Found $wtmp."
  1931. Xelse
  1932. X    dflt=/etc/wtmp
  1933. X    echo " "
  1934. X    $echo $n "Where is your wtmp file? [$dflt] $c"
  1935. X    rp="Wtmp filename? [$dflt]"
  1936. X    . myread
  1937. X    wtmp="$ans"
  1938. X    echo " "
  1939. Xfi
  1940. X
  1941. X: decide how portable to be
  1942. Xcase "$d_portable" in
  1943. X"$define") dflt=y;;
  1944. X*)    dflt=n;;
  1945. Xesac
  1946. X$cat <<EOH
  1947. XI can set things up so that your $package binaries are more portable,
  1948. Xat what may be a noticable cost in performance.  In particular, if you
  1949. Xask to be portable, the system name will be determined at run time,
  1950. Xif at all possible.
  1951. X
  1952. XEOH
  1953. Xrp="Do you expect to run the $package binaries on multiple machines? [$dflt]"
  1954. X$echo $n "$rp $c"
  1955. X. myread
  1956. Xcase "$ans" in
  1957. X    y*) d_portable="$define" ;;
  1958. X    *)  d_portable="$undef" ;;
  1959. Xesac
  1960. X
  1961. X: determine uucp id
  1962. Xecho " "
  1963. Xuucpid=`$sed -e "/uucp:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/" -e "q" -e "}" -e "d" </etc/passwd`
  1964. Xcase "$uucpid" in
  1965. X  '') uucpid=0 ;;
  1966. X  *)  echo "uucp uid = $uucpid" ;;
  1967. Xesac
  1968. X
  1969. X: determine uucp lock files scheme
  1970. Xcase "$lock" in
  1971. X'')
  1972. X    if $test -d /usr/spool/locks; then
  1973. X    dflt=/usr/spool/locks
  1974. X    else
  1975. X    dflt=/usr/spool/uucp
  1976. X    fi
  1977. X    ;;
  1978. X*)  dflt="$lock";;
  1979. Xesac
  1980. Xcont=true
  1981. Xwhile $test "$cont" ; do
  1982. X    echo " "
  1983. X    $echo $n "Directory where UUCP lock files live: [$dflt] $c"
  1984. X    rp="Directory for UUCP lock files: [$dflt]"
  1985. X    . myread
  1986. X    lock="$ans"
  1987. X    if test -d $ans; then
  1988. X    cont=''
  1989. X    else
  1990. X    dflt=n
  1991. X    rp="Directory $ans doesn't exist.  Use that name anyway? [$dflt]"
  1992. X    $echo $n "$rp $c"
  1993. X    . myread
  1994. X    dflt=''
  1995. X    case "$ans" in
  1996. X    y*) cont='';;
  1997. X    esac
  1998. X    fi
  1999. Xdone
  2000. X
  2001. Xecho " "
  2002. Xcase "$d_asciipid" in
  2003. X"$define") dflt=y;;
  2004. X*)    dflt=n;;
  2005. Xesac
  2006. Xecho "The PID of the locking process is kept in the lock file."
  2007. X$echo $n "Does your UUCP store the PID in ASCII format? [$dflt] $c"
  2008. Xrp="PID stored in ASCII? [$dflt]"
  2009. X. myread
  2010. Xcase "$ans" in
  2011. Xy*) d_asciipid="$define";;
  2012. X*) d_asciipid="$undef";;
  2013. Xesac
  2014. X
  2015. X: determine mailer to use
  2016. Xcase "$mailer" in
  2017. X'')
  2018. X    if $test -f $sendmail; then
  2019. X    dflt=$sendmail
  2020. X    elif Cppsym M_XENIX; then
  2021. X    dflt=/usr/lib/mail/execmail
  2022. X    elif $test -f $mailx; then
  2023. X    dflt="$mailx"
  2024. X    else
  2025. X    dflt=$mail
  2026. X    fi
  2027. X    ;;
  2028. X*)  dflt="$mailer";;
  2029. Xesac
  2030. Xcont=true
  2031. Xwhile $test "$cont" ; do
  2032. X    echo " "
  2033. X    echo "Give the full path name of the program used to deliver mail on your"
  2034. X    $echo $n "system: [$dflt] $c"
  2035. X    rp="Preferred mailer: [$dflt]"
  2036. X    . myread
  2037. X    mailer="$ans"
  2038. X    if test -f $ans; then
  2039. X    cont=''
  2040. X    else
  2041. X    dflt=n
  2042. X    rp="File $ans doesn't exist.  Use that name anyway? [$dflt]"
  2043. X    $echo $n "$rp $c"
  2044. X    . myread
  2045. X    dflt=''
  2046. X    case "$ans" in
  2047. X    y*) cont='';;
  2048. X    esac
  2049. X    fi
  2050. Xdone
  2051. X
  2052. X: preserve RCS keywords in files with variable substitution, grrr
  2053. XId='$Id'
  2054. XHeader='$Header'
  2055. X
  2056. Xecho " "
  2057. Xecho "End of configuration questions."
  2058. Xecho " "
  2059. X
  2060. X: create config.sh file
  2061. Xecho " "
  2062. Xif test -d ../UU; then
  2063. X    cd ..
  2064. Xfi
  2065. Xecho "Creating config.sh..."
  2066. X$spitshell <<EOT >config.sh
  2067. X$startsh
  2068. X# config.sh
  2069. X# This file was produced by running the Configure script.
  2070. X
  2071. Xd_getutent='$d_getutent'
  2072. Xd_strdup='$d_strdup'
  2073. Xd_putenv='$d_putenv'
  2074. Xd_ttytype='$d_ttytype'
  2075. Xttytype='$ttytype'
  2076. Xgettytab='$gettytab'
  2077. Xutmp='$utmp'
  2078. Xwtmp='$wtmp'
  2079. Xuucpid='$uucpid'
  2080. Xlock='$lock'
  2081. Xd_asciipid='$d_asciipid'
  2082. Xmailer='$mailer'
  2083. Xhostname='$hostname'
  2084. Xphostname='$phostname'
  2085. Xd_douname='$d_douname'
  2086. Xd_phostname='$d_phostname'
  2087. Xd_portable='$d_portable'
  2088. Xtermlib='$termlib'
  2089. Xllib_termlib='$llib_termlib'
  2090. Xxenix='$xenix'
  2091. Xd_eunice='$d_eunice'
  2092. Xdefine='$define'
  2093. Xundef='$undef'
  2094. Xeunicefix='$eunicefix'
  2095. Xloclist='$loclist'
  2096. Xexpr='$expr'
  2097. Xsed='$sed'
  2098. Xecho='$echo'
  2099. Xcat='$cat'
  2100. Xrm='$rm'
  2101. Xmv='$mv'
  2102. Xcp='$cp'
  2103. Xtr='$tr'
  2104. Xsort='$sort'
  2105. Xuniq='$uniq'
  2106. Xgrep='$grep'
  2107. Xtrylist='$trylist'
  2108. Xtest='$test'
  2109. Xegrep='$egrep'
  2110. XMcc='$Mcc'
  2111. Xcpp='$cpp'
  2112. Xmail='$mail'
  2113. Xmailx='$mailx'
  2114. Xsendmail='$sendmail'
  2115. Xuname='$uname'
  2116. Xuuname='$uuname'
  2117. XLog='$Log'
  2118. XId='$Id'
  2119. Xbin='$bin'
  2120. Xcontains='$contains'
  2121. Xcppstdin='$cppstdin'
  2122. Xcppminus='$cppminus'
  2123. Xd_fcntl='$d_fcntl'
  2124. Xd_index='$d_index'
  2125. Xd_ioctl='$d_ioctl'
  2126. Xd_varargs='$d_varargs'
  2127. Xd_voidsig='$d_voidsig'
  2128. Xgidtype='$gidtype'
  2129. Xi_fcntl='$i_fcntl'
  2130. Xi_pwd='$i_pwd'
  2131. Xi_sysioctl='$i_sysioctl'
  2132. Xi_time='$i_time'
  2133. Xi_systime='$i_systime'
  2134. Xd_systimekernel='$d_systimekernel'
  2135. Xi_varargs='$i_varargs'
  2136. Xlibc='$libc'
  2137. Xmodels='$models'
  2138. Xsplit='$split'
  2139. Xsmall='$small'
  2140. Xmedium='$medium'
  2141. Xlarge='$large'
  2142. Xhuge='$huge'
  2143. Xoptimize='$optimize'
  2144. Xccflags='$ccflags'
  2145. Xcppflags='$cppflags'
  2146. Xldflags='$ldflags'
  2147. Xcc='$cc'
  2148. Xlibs='$libs'
  2149. Xn='$n'
  2150. Xc='$c'
  2151. Xpackage='$package'
  2152. Xspitshell='$spitshell'
  2153. Xshsharp='$shsharp'
  2154. Xsharpbang='$sharpbang'
  2155. Xstartsh='$startsh'
  2156. Xstdchar='$stdchar'
  2157. Xuidtype='$uidtype'
  2158. Xvoidflags='$voidflags'
  2159. Xdefvoidused='$defvoidused'
  2160. Xlib='$lib'
  2161. XCONFIG=true
  2162. XEOT
  2163. X
  2164. XCONFIG=true
  2165. X
  2166. Xecho " "
  2167. Xdflt=''
  2168. Xfastread=''
  2169. Xecho "If you didn't make any mistakes, then just type a carriage return here."
  2170. Xrp="If you need to edit config.sh, do it as a shell escape here:"
  2171. X$echo $n "$rp $c"
  2172. X. UU/myread
  2173. Xcase "$ans" in
  2174. X'') ;;
  2175. X*) : in case they cannot read
  2176. X    eval $ans;;
  2177. Xesac
  2178. X: if this fails, just run all the .SH files by hand
  2179. X. ./config.sh
  2180. X
  2181. Xecho " "
  2182. Xecho "Doing variable substitutions on .SH files..."
  2183. Xset x `awk '{print $1}' <MANIFEST | $grep '\.SH'`
  2184. Xshift
  2185. Xcase $# in
  2186. X0) set x *.SH; shift;;
  2187. Xesac
  2188. Xif test ! -f $1; then
  2189. X    shift
  2190. Xfi
  2191. Xfor file in $*; do
  2192. X    case "$file" in
  2193. X    */*)
  2194. X    dir=`$expr X$file : 'X\(.*\)/'`
  2195. X    file=`$expr X$file : 'X.*/\(.*\)'`
  2196. X    (cd $dir && . $file)
  2197. X    ;;
  2198. X    *)
  2199. X    . $file
  2200. X    ;;
  2201. X    esac
  2202. Xdone
  2203. Xif test -f config.h.SH; then
  2204. X    if test ! -f config.h; then
  2205. X    : oops, they left it out of MANIFEST, probably, so do it anyway.
  2206. X    . config.h.SH
  2207. X    fi
  2208. Xfi
  2209. X
  2210. Xif $contains '^depend:' Makefile >/dev/null 2>&1; then
  2211. X    dflt=n
  2212. X    $cat <<EOM
  2213. X
  2214. XNow you need to generate make dependencies by running "make depend".
  2215. XYou might prefer to run it in background: "make depend > makedepend.out &"
  2216. XIt can take a while, so you might not want to run it right now.
  2217. X
  2218. XEOM
  2219. X    rp="Run make depend now? [$dflt]"
  2220. X    $echo $n "$rp $c"
  2221. X    . UU/myread
  2222. X    case "$ans" in
  2223. X    y*) make depend && echo "Now you must run a make."
  2224. X    ;;
  2225. X    *)  echo "You must run 'make depend' then 'make'."
  2226. X    ;;
  2227. X    esac
  2228. Xelif test -f Makefile; then
  2229. X    echo " "
  2230. X    echo "Now you must run a make."
  2231. Xelse
  2232. X    echo "Done."
  2233. Xfi
  2234. X
  2235. X$rm -f kit*isdone
  2236. X: the following is currently useless
  2237. Xcd UU && $rm -f $rmlist
  2238. X: since this removes it all anyway
  2239. Xcd .. && $rm -rf UU
  2240. X: end of Configure
  2241. !STUFFY!FUNK!
  2242. echo ""
  2243. echo "End of kit 2 (of 5)"
  2244. cat /dev/null >kit2isdone
  2245. run=''
  2246. config=''
  2247. for iskit in 1 2 3 4 5; do
  2248.     if test -f kit${iskit}isdone; then
  2249.     run="$run $iskit"
  2250.     else
  2251.     todo="$todo $iskit"
  2252.     fi
  2253. done
  2254. case $todo in
  2255.     '')
  2256.     echo "You have run all your kits.  Please read README and then type Configure."
  2257.     chmod 755 Configure
  2258.     ;;
  2259.     *)  echo "You have run$run."
  2260.     echo "You still need to run$todo."
  2261.     ;;
  2262. esac
  2263. : Someone might mail this, so...
  2264. exit
  2265.  
  2266. INTERNET:  paul@devon.lns.pa.us        |      If life's a bitch, then
  2267. UUCP:      ...!rutgers!devon!paul      |      we must be her puppies.
  2268.  
  2269.