home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume20 / perl3.0 / part02 < prev    next >
Encoding:
Internet Message Format  |  1989-10-29  |  54.4 KB

  1. Subject:  v20i085:  Perl, a language with features of C/sed/awk/shell/etc, Part02/24
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Larry Wall <lwall@jpl-devvax.jpl.nasa.gov>
  7. Posting-number: Volume 20, Issue 85
  8. Archive-name: perl3.0/part02
  9.  
  10. #! /bin/sh
  11.  
  12. # Make a new directory for the perl sources, cd to it, and run kits 1
  13. # thru 24 through sh.  When all 24 kits have been run, read README.
  14.  
  15. echo "This is perl 3.0 kit 2 (of 24).  If kit 2 is complete, the line"
  16. echo '"'"End of kit 2 (of 24)"'" will echo at the end.'
  17. echo ""
  18. export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
  19. mkdir  2>/dev/null
  20. echo Extracting Configure
  21. sed >Configure <<'!STUFFY!FUNK!' -e 's/X//'
  22. X#! /bin/sh
  23. X#
  24. X# If these # comments don't work, trim them.  Don't worry about any other
  25. X# shell scripts, Configure will trim # comments from them for you.
  26. X#
  27. X# (If you are trying to port this package to a machine without sh, I would
  28. X# suggest you cut out the prototypical config.h from the end of Configure
  29. X# and edit it to reflect your system.  Some packages may include samples
  30. X# of config.h for certain machines, so you might look for one of those.)
  31. X#
  32. X# $Header: Configure,v 3.0 89/10/18 15:04:55 lwall Locked $
  33. X#
  34. X# Yes, you may rip this off to use in other distribution packages.
  35. X# (Note: this Configure script was generated automatically.  Rather than
  36. X# working with this copy of Configure, you may wish to get metaconfig.)
  37. X
  38. X: sanity checks
  39. XPATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin'
  40. Xexport PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  41. X
  42. Xif test ! -t 0; then
  43. X    echo "Say 'sh Configure', not 'sh <Configure'"
  44. X    exit 1
  45. Xfi
  46. X
  47. X(alias) >/dev/null 2>&1 && \
  48. X    echo "(I see you are using the Korn shell.  Some ksh's blow up on Configure," && \
  49. X    echo "especially on exotic machines.  If yours does, try the Bourne shell instead.)"
  50. X
  51. Xif test ! -d ../UU; then
  52. X    if test ! -d UU; then
  53. X    mkdir UU
  54. X    fi
  55. X    cd UU
  56. Xfi
  57. X
  58. Xcase "$1" in
  59. X-d) shift; fastread='yes';;
  60. Xesac
  61. X
  62. Xd_eunice=''
  63. Xeunicefix=''
  64. Xdefine=''
  65. Xloclist=''
  66. Xexpr=''
  67. Xsed=''
  68. Xecho=''
  69. Xcat=''
  70. Xrm=''
  71. Xmv=''
  72. Xcp=''
  73. Xtail=''
  74. Xtr=''
  75. Xmkdir=''
  76. Xsort=''
  77. Xuniq=''
  78. Xgrep=''
  79. Xtrylist=''
  80. Xtest=''
  81. Xinews=''
  82. Xegrep=''
  83. Xmore=''
  84. Xpg=''
  85. XMcc=''
  86. Xvi=''
  87. Xmailx=''
  88. Xmail=''
  89. Xcpp=''
  90. Xperl=''
  91. Xemacs=''
  92. Xls=''
  93. Xrmail=''
  94. Xsendmail=''
  95. Xshar=''
  96. Xsmail=''
  97. Xtbl=''
  98. Xtroff=''
  99. Xnroff=''
  100. Xuname=''
  101. Xuuname=''
  102. Xline=''
  103. Xchgrp=''
  104. Xchmod=''
  105. Xlint=''
  106. Xsleep=''
  107. Xpr=''
  108. Xtar=''
  109. Xln=''
  110. Xlpr=''
  111. Xlp=''
  112. Xtouch=''
  113. Xmake=''
  114. Xdate=''
  115. XLog=''
  116. XHeader=''
  117. Xbin=''
  118. Xbyteorder=''
  119. Xcontains=''
  120. Xcppstdin=''
  121. Xcppminus=''
  122. Xd_bcmp=''
  123. Xd_bcopy=''
  124. Xd_charsprf=''
  125. Xd_crypt=''
  126. Xcryptlib=''
  127. Xd_dosuid=''
  128. Xd_dup2=''
  129. Xd_fchmod=''
  130. Xd_fchown=''
  131. Xd_fcntl=''
  132. Xd_flock=''
  133. Xd_getgrps=''
  134. Xd_gethent=''
  135. Xd_getpgrp=''
  136. Xd_getprior=''
  137. Xd_htonl=''
  138. Xd_index=''
  139. Xd_ioctl=''
  140. Xd_killpg=''
  141. Xd_memcmp=''
  142. Xd_memcpy=''
  143. Xd_mkdir=''
  144. Xd_ndbm=''
  145. Xd_odbm=''
  146. Xd_readdir=''
  147. Xd_rename=''
  148. Xd_rmdir=''
  149. Xd_setegid=''
  150. Xd_seteuid=''
  151. Xd_setpgrp=''
  152. Xd_setprior=''
  153. Xd_setregid=''
  154. Xd_setresgid=''
  155. Xd_setreuid=''
  156. Xd_setresuid=''
  157. Xd_setrgid=''
  158. Xd_setruid=''
  159. Xd_socket=''
  160. Xd_sockpair=''
  161. Xd_oldsock=''
  162. Xsocketlib=''
  163. Xsockethdr=''
  164. Xd_statblks=''
  165. Xd_stdstdio=''
  166. Xd_strctcpy=''
  167. Xd_symlink=''
  168. Xd_syscall=''
  169. Xd_tminsys=''
  170. Xi_systime=''
  171. Xd_varargs=''
  172. Xd_vfork=''
  173. Xd_voidsig=''
  174. Xd_vprintf=''
  175. Xd_charvspr=''
  176. Xgidtype=''
  177. Xi_dirent=''
  178. Xd_dirnamlen=''
  179. Xi_fcntl=''
  180. Xi_grp=''
  181. Xi_pwd=''
  182. Xd_pwquota=''
  183. Xd_pwage=''
  184. Xi_sysdir=''
  185. Xi_sysioctl=''
  186. Xi_varargs=''
  187. Xi_vfork=''
  188. Xintsize=''
  189. Xlibc=''
  190. Xlibdbm=''
  191. Xlibndir=''
  192. Xlibnm=''
  193. Xmallocsrc=''
  194. Xmallocobj=''
  195. Xusemymalloc=''
  196. Xmansrc=''
  197. Xmanext=''
  198. Xmodels=''
  199. Xsplit=''
  200. Xsmall=''
  201. Xmedium=''
  202. Xlarge=''
  203. Xhuge=''
  204. Xoptimize=''
  205. Xccflags=''
  206. Xldflags=''
  207. Xcc=''
  208. Xlibs=''
  209. Xn=''
  210. Xc=''
  211. Xpackage=''
  212. Xrandbits=''
  213. Xsig_name=''
  214. Xspitshell=''
  215. Xshsharp=''
  216. Xsharpbang=''
  217. Xstartsh=''
  218. Xstdchar=''
  219. Xuidtype=''
  220. Xvoidflags=''
  221. Xdefvoidused=''
  222. Xlib=''
  223. Xprivlib=''
  224. XCONFIG=''
  225. X: set package name
  226. Xpackage=perl
  227. X
  228. Xecho " "
  229. Xecho "Beginning of configuration questions for $package kit."
  230. X: Eunice requires " " instead of "", can you believe it
  231. Xecho " "
  232. X
  233. Xdefine='define'
  234. Xundef='undef'
  235. Xlibpth='/usr/lib /usr/local/lib /usr/lib/386 /usr/lib/large /lib /lib/386 /lib/large /usr/lib/small /lib/small'
  236. Xsmallmach='pdp11 i8086 z8000 i80286 iAPX286'
  237. Xrmlist='kit[1-9]isdone kit[1-9][0-9]isdone'
  238. Xtrap 'echo " "; rm -f $rmlist; exit 1' 1 2 3
  239. X
  240. X: We must find out about Eunice early
  241. Xeunicefix=':'
  242. Xif test -f /etc/unixtovms; then
  243. X    eunicefix=/etc/unixtovms
  244. Xfi
  245. Xif test -f /etc/unixtovms.exe; then
  246. X    eunicefix=/etc/unixtovms.exe
  247. Xfi
  248. X
  249. X: Now test for existence of everything in MANIFEST
  250. X
  251. Xecho "First let's make sure your kit is complete.  Checking..."
  252. X(cd ..; awk '' `awk '$1 !~ /PACKINGLIST/ {print $1}' MANIFEST` >/dev/null || kill $$)
  253. Xecho " "
  254. X
  255. Xattrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr"
  256. Xattrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200"
  257. Xattrlist="$attrlist hpux hp9000s300 hp9000s500 hp9000s800"
  258. Xattrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc"
  259. Xattrlist="$attrlist nsc32000 sinix xenix venix posix ansi M_XENIX"
  260. Xattrlist="$attrlist $mc68k __STDC__ UTS M_I8086 M_I186 M_I286 M_I386"
  261. Xattrlist="$attrlist i186"
  262. 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"
  263. Xd_newshome="/usr/NeWS"
  264. Xdefvoidused=7
  265. X
  266. X: some greps do not return status, grrr.
  267. Xecho "grimblepritz" >grimble
  268. Xif grep blurfldyick grimble >/dev/null 2>&1 ; then
  269. X    contains=contains
  270. Xelif grep grimblepritz grimble >/dev/null 2>&1 ; then
  271. X    contains=grep
  272. Xelse
  273. X    contains=contains
  274. Xfi
  275. Xrm -f grimble
  276. X: the following should work in any shell
  277. Xcase "$contains" in
  278. Xcontains*)
  279. X    echo " "
  280. X    echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  281. X    cat >contains <<'EOSS'
  282. Xgrep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  283. XEOSS
  284. Xchmod +x contains
  285. Xesac
  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 (lwall@jpl-devvax.jpl.nasa.gov)
  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. Xmkdir
  435. Xmv
  436. Xrm
  437. Xsed
  438. Xsort
  439. Xtr
  440. Xuniq
  441. X"
  442. Xtrylist="
  443. XMcc
  444. Xcpp
  445. Xegrep
  446. Xtest
  447. Xuname
  448. X"
  449. Xfor file in $loclist; do
  450. X    xxx=`loc $file $file $pth`
  451. X    eval $file=$xxx
  452. X    eval _$file=$xxx
  453. X    case "$xxx" in
  454. X    /*)
  455. X    echo $file is in $xxx.
  456. X    ;;
  457. X    *)
  458. X    echo "I don't know where $file is.  I hope it's in everyone's PATH."
  459. X    ;;
  460. X    esac
  461. Xdone
  462. Xecho " "
  463. Xecho "Don't worry if any of the following aren't found..."
  464. Xans=offhand
  465. Xfor file in $trylist; do
  466. X    xxx=`loc $file $file $pth`
  467. X    eval $file=$xxx
  468. X    eval _$file=$xxx
  469. X    case "$xxx" in
  470. X    /*)
  471. X    echo $file is in $xxx.
  472. X    ;;
  473. X    *)
  474. X    echo "I don't see $file out there, $ans."
  475. X    ans=either
  476. X    ;;
  477. X    esac
  478. Xdone
  479. Xcase "$egrep" in
  480. Xegrep)
  481. X    echo "Substituting grep for egrep."
  482. X    egrep=$grep
  483. X    ;;
  484. Xesac
  485. Xcase "$test" in
  486. Xtest)
  487. X    echo "Hopefully test is built into your sh."
  488. X    ;;
  489. X/bin/test)
  490. X    if sh -c "PATH= test true" >/dev/null 2>&1; then
  491. X    echo "Using the test built into your sh."
  492. X    test=test
  493. X    fi
  494. X    ;;
  495. X*)
  496. X    test=test
  497. X    ;;
  498. Xesac
  499. Xcase "$echo" in
  500. Xecho)
  501. X    echo "Hopefully echo is built into your sh."
  502. X    ;;
  503. X/bin/echo)
  504. X    echo " "
  505. X    echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
  506. X    $echo $n "hi there$c" >foo1
  507. X    echo $n "hi there$c" >foo2
  508. X    if cmp foo1 foo2 >/dev/null 2>&1; then
  509. X    echo "They are compatible.  In fact, they may be identical."
  510. X    else
  511. X    case "$n" in
  512. X    '-n') n='' c='\c' ans='\c' ;;
  513. X    *) n='-n' c='' ans='-n' ;;
  514. X    esac
  515. X    cat <<FOO
  516. XThey are not compatible!  You are probably running ksh on a non-USG system.
  517. XI'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
  518. Xhave echo built in and we may have to run some Bourne shell scripts.  That
  519. Xmeans I'll have to use $ans to suppress newlines now.  Life is ridiculous.
  520. X
  521. XFOO
  522. X    rp="Your cursor should be here-->"
  523. X    $echo $n "$rp$c"
  524. X    . myread
  525. X    fi
  526. X    $rm -f foo1 foo2
  527. X    ;;
  528. X*)
  529. X    : cross your fingers
  530. X    echo=echo
  531. X    ;;
  532. Xesac
  533. Xrmlist="$rmlist loc"
  534. X
  535. X: get list of predefined functions in a handy place
  536. Xif $test -n "$uname"; then
  537. X    os=`$uname -s`
  538. Xelse
  539. X    os=unknown
  540. Xfi
  541. Xecho " "
  542. Xif test -f /lib/libc.a; then
  543. X    echo "Your C library is in /lib/libc.a.  You're normal."
  544. X    libc=/lib/libc.a
  545. Xelse
  546. X    if test "$os" = DomainOS ; then
  547. X    ans=`loc libc blurfl/dyick $libpth`
  548. X    else
  549. X    ans=`loc libc.a blurfl/dyick $libpth`
  550. X    fi
  551. X    if test ! -f "$ans"; then
  552. X    ans=`loc clib blurfl/dyick $libpth`
  553. X    fi
  554. X    if test ! -f "$ans"; then
  555. X    ans=`loc libc blurfl/dyick $libpth`
  556. X    fi
  557. X    if test ! -f "$ans"; then
  558. X    ans=`loc Slibc.a blurfl/dyick /usr/lib/386 /lib/386 $libpth`
  559. X    fi
  560. X    if test ! -f "$ans"; then
  561. X    ans=`loc Mlibc.a blurfl/dyick $libpth`
  562. X    fi
  563. X    if test ! -f "$ans"; then
  564. X    ans=`loc Llibc.a blurfl/dyick $libpth`
  565. X    fi
  566. X    if test -f "$ans"; then
  567. X    echo "Your C library is in $ans, of all places."
  568. X    libc=$ans
  569. X    else
  570. X    if test -f "$libc"; then
  571. X        echo "Your C library is in $libc, like you said before."
  572. X    else
  573. X        cat <<EOM
  574. XI can't seem to find your C library.  I've looked in the following places:
  575. X
  576. X    $libpth
  577. X
  578. XNone of these seems to contain your C library.  What is the full name
  579. XEOM
  580. X        dflt=None
  581. X        $echo $n "of your C library? $c"
  582. X        rp='C library full name?'
  583. X        . myread
  584. X        libc="$ans"
  585. X    fi
  586. X    fi
  587. Xfi
  588. Xecho " "
  589. X$echo $n "Extracting names from $libc for later perusal...$c"
  590. Xnm $libc 2>/dev/null >libc.tmp
  591. X$sed -n -e 's/^.* [AT]  *_[_.]*//p' -e 's/^.* [AT] //p' <libc.tmp >libc.list
  592. Xif $contains '^printf$' libc.list >/dev/null 2>&1; then
  593. X    echo "done"
  594. Xelse
  595. X    if test "$os" = DomainOS ; then
  596. X        $sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p' <libc.tmp >libc.list
  597. X    else
  598. X    $sed -n -e 's/^.* D __*//p' -e 's/^.* D //p' <libc.tmp >libc.list
  599. X    fi
  600. X    $contains '^printf$' libc.list >/dev/null 2>&1 || \
  601. X       $sed -n -e 's/^_//' \
  602. X          -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p' <libc.tmp >libc.list
  603. X    if $contains '^printf$' libc.list >/dev/null 2>&1; then
  604. X    echo "done"
  605. X    else
  606. X    echo " "
  607. X    echo "nm didn't seem to work right."
  608. X    echo "Trying ar instead..."
  609. X    if ar t $libc > libc.tmp; then
  610. X        $sed -e 's/\.o$//' < libc.tmp > libc.list
  611. X        echo "Ok."
  612. X    else
  613. X        echo "ar didn't seem to work right."
  614. X        echo "Maybe this is a Cray...trying bld instead..."
  615. X        if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
  616. X        echo "Ok."
  617. X        else
  618. X            echo "That didn't work either.  Giving up."
  619. X            exit 1
  620. X        fi
  621. X    fi
  622. X    fi
  623. Xfi
  624. X
  625. Xinlibc='echo " ";
  626. Xif $contains "^$1\$" libc.list >/dev/null 2>&1;
  627. Xthen echo "$1() found"; eval "$2=$define";
  628. Xelse echo "$1() not found"; eval "$2=$undef"; fi'
  629. X
  630. Xrmlist="$rmlist libc.tmp libc.list"
  631. X
  632. X: make some quick guesses about what we are up against
  633. Xecho " "
  634. X$echo $n "Hmm...  $c"
  635. Xcat /usr/include/signal.h /usr/include/sys/signal.h >foo
  636. Xif $contains SIGTSTP foo >/dev/null 2>&1 ; then
  637. X    echo "Looks kind of like a BSD system, but we'll see..."
  638. X    echo exit 0 >bsd
  639. X    echo exit 1 >usg
  640. X    echo exit 1 >v7
  641. Xelif $contains '^fcntl$' libc.list >/dev/null 2>&1 ; then
  642. X    echo "Looks kind of like a USG system, but we'll see..."
  643. X    echo exit 1 >bsd
  644. X    echo exit 0 >usg
  645. X    echo exit 1 >v7
  646. Xelse
  647. X    echo "Looks kind of like a version 7 system, but we'll see..."
  648. X    echo exit 1 >bsd
  649. X    echo exit 1 >usg
  650. X    echo exit 0 >v7
  651. Xfi
  652. Xif $contains '^vmssystem$' libc.list >/dev/null 2>&1 ; then
  653. X    cat <<'EOI'
  654. XThere is, however, a strange, musty smell in the air that reminds me of
  655. Xsomething...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  656. XEOI
  657. X    echo "exit 0" >eunice
  658. X    eunicefix=unixtovms
  659. X    d_eunice="$define"
  660. X: it so happens the Eunice I know will not run shell scripts in Unix format
  661. Xelse
  662. X    echo " "
  663. X    echo "Congratulations.  You aren't running Eunice."
  664. X    eunicefix=':'
  665. X    d_eunice="$undef"
  666. X    echo "exit 1" >eunice
  667. Xfi
  668. Xif test -f /xenix; then
  669. X    echo "Actually, this looks more like a XENIX system..."
  670. X    echo "exit 0" >xenix
  671. Xelse
  672. X    echo " "
  673. X    echo "It's not Xenix..."
  674. X    echo "exit 1" >xenix
  675. Xfi
  676. Xchmod +x xenix
  677. X$eunicefix xenix
  678. Xif test -f /venix; then
  679. X    echo "Actually, this looks more like a VENIX system..."
  680. X    echo "exit 0" >venix
  681. Xelse
  682. X    echo " "
  683. X    if xenix; then
  684. X    : null
  685. X    else
  686. X    echo "Nor is it Venix..."
  687. X    fi
  688. X    echo "exit 1" >venix
  689. Xfi
  690. Xchmod +x bsd usg v7 eunice venix
  691. X$eunicefix bsd usg v7 eunice venix
  692. Xrm -rf foo
  693. Xrmlist="$rmlist bsd usg v7 eunice venix xenix"
  694. X
  695. X: see if sh knows # comments
  696. Xecho " "
  697. Xecho "Checking your sh to see if it knows about # comments..."
  698. Xif sh -c '#' >/dev/null 2>&1 ; then
  699. X    echo "Your sh handles # comments correctly."
  700. X    shsharp=true
  701. X    spitshell=cat
  702. X    echo " "
  703. X    echo "Okay, let's see if #! works on this system..."
  704. X    echo "#!/bin/echo hi" > try
  705. X    $eunicefix try
  706. X    chmod +x try
  707. X    try > today
  708. X    if $contains hi today >/dev/null 2>&1; then
  709. X    echo "It does."
  710. X    sharpbang='#!'
  711. X    else
  712. X    echo "#! /bin/echo hi" > try
  713. X    $eunicefix try
  714. X    chmod +x try
  715. X    try > today
  716. X    if test -s today; then
  717. X        echo "It does."
  718. X        sharpbang='#! '
  719. X    else
  720. X        echo "It doesn't."
  721. X        sharpbang=': use '
  722. X    fi
  723. X    fi
  724. Xelse
  725. X    echo "Your sh doesn't grok # comments--I will strip them later on."
  726. X    shsharp=false
  727. X    echo "exec grep -v '^#'" >spitshell
  728. X    chmod +x spitshell
  729. X    $eunicefix spitshell
  730. X    spitshell=`pwd`/spitshell
  731. X    echo "I presume that if # doesn't work, #! won't work either!"
  732. X    sharpbang=': use '
  733. Xfi
  734. X
  735. X: figure out how to guarantee sh startup
  736. Xecho " "
  737. Xecho "Checking out how to guarantee sh startup..."
  738. Xstartsh=$sharpbang'/bin/sh'
  739. Xecho "Let's see if '$startsh' works..."
  740. Xcat >try <<EOSS
  741. X$startsh
  742. Xset abc
  743. Xtest "$?abc" != 1
  744. XEOSS
  745. X
  746. Xchmod +x try
  747. X$eunicefix try
  748. Xif try; then
  749. X    echo "Yup, it does."
  750. Xelse
  751. X    echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  752. Xfi
  753. Xrm -f try today
  754. X
  755. X: set up shell script to do ~ expansion
  756. Xcat >filexp <<EOSS
  757. X$startsh
  758. X: expand filename
  759. Xcase "\$1" in
  760. X ~/*|~)
  761. X    echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
  762. X    ;;
  763. X ~*)
  764. X    if $test -f /bin/csh; then
  765. X    /bin/csh -f -c "glob \$1"
  766. X    echo ""
  767. X    else
  768. X    name=\`$expr x\$1 : '..\([^/]*\)'\`
  769. X    dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
  770. X    if $test ! -d "\$dir"; then
  771. X        me=\`basename \$0\`
  772. X        echo "\$me: can't locate home directory for: \$name" >&2
  773. X        exit 1
  774. X    fi
  775. X    case "\$1" in
  776. X    */*)
  777. X        echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
  778. X        ;;
  779. X    *)
  780. X        echo \$dir
  781. X        ;;
  782. X    esac
  783. X    fi
  784. X    ;;
  785. X*)
  786. X    echo \$1
  787. X    ;;
  788. Xesac
  789. XEOSS
  790. Xchmod +x filexp
  791. X$eunicefix filexp
  792. X
  793. X: determine where public executables go
  794. Xcase "$bin" in
  795. X'')
  796. X    dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
  797. X    ;;
  798. X*)  dflt="$bin"
  799. X    ;;
  800. Xesac
  801. Xcont=true
  802. Xwhile $test "$cont" ; do
  803. X    echo " "
  804. X    rp="Where do you want to put the public executables? [$dflt]"
  805. X    $echo $n "$rp $c"
  806. X    . myread
  807. X    bin="$ans"
  808. X    bin=`filexp $bin`
  809. X    if test -d $bin; then
  810. X    cont=''
  811. X    else
  812. X    case "$fastread" in
  813. X    yes) dflt=y;;
  814. X    *) dflt=n;;
  815. X    esac
  816. X    rp="Directory $bin doesn't exist.  Use that name anyway? [$dflt]"
  817. X    $echo $n "$rp $c"
  818. X    . myread
  819. X    dflt=''
  820. X    case "$ans" in
  821. X    y*) cont='';;
  822. X    esac
  823. X    fi
  824. Xdone
  825. X
  826. X: determine where manual pages go
  827. X$cat <<EOM
  828. X  
  829. X$package has manual pages that need to be installed in source form.
  830. XEOM
  831. Xcase "$mansrc" in
  832. X'')
  833. X    dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1 /usr/man/man.L`
  834. X    ;;
  835. X*)  dflt="$mansrc"
  836. X    ;;
  837. Xesac
  838. Xcont=true
  839. Xwhile $test "$cont" ; do
  840. X    echo " "
  841. X    rp="Where do the manual pages (source) go? [$dflt]"
  842. X    $echo $n "$rp $c"
  843. X    . myread
  844. X    mansrc=`filexp "$ans"`
  845. X    if $test -d "$mansrc"; then
  846. X    cont=''
  847. X    else
  848. X    if $test "$fastread" = yes; then
  849. X        dflt=y
  850. X    else
  851. X        dflt=n
  852. X    fi
  853. X    rp="Directory $mansrc doesn't exist.  Use that name anyway? [$dflt]"
  854. X    $echo $n "$rp $c"
  855. X    . myread
  856. X    dflt=''
  857. X    case "$ans" in
  858. X    y*) cont='';;
  859. X    esac
  860. X    fi
  861. Xdone
  862. Xcase "$mansrc" in
  863. X*l)
  864. X    manext=l
  865. X    ;;
  866. X*n)
  867. X    manext=n
  868. X    ;;
  869. X*o)
  870. X    manext=l
  871. X    ;;
  872. X*p)
  873. X    manext=n
  874. X    ;;
  875. X*C)
  876. X    manext=C
  877. X    ;;
  878. X*L)
  879. X    manext=L
  880. X    ;;
  881. X*)
  882. X    manext=1
  883. X    ;;
  884. Xesac
  885. X
  886. X: see what memory models we can support
  887. Xcase "$models" in
  888. X'')
  889. X    : We may not use Cppsym or we get a circular dependency through cc.
  890. X    : But this should work regardless of which cc we eventually use.
  891. X    cat >pdp11.c <<'EOP'
  892. Xmain() {
  893. X#ifdef pdp11
  894. X    exit(0);
  895. X#else
  896. X    exit(1);
  897. X#endif
  898. X}
  899. XEOP
  900. X    cc -o pdp11 pdp11.c >/dev/null 2>&1
  901. X    if pdp11 2>/dev/null; then
  902. X    dflt='unsplit split'
  903. X    else
  904. X    ans=`loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
  905. X    case "$ans" in
  906. X    X) dflt='none';;
  907. X    *)  if $test -d /lib/small || $test -d /usr/lib/small; then
  908. X        dflt='small'
  909. X        else
  910. X        dflt=''
  911. X        fi
  912. X        if $test -d /lib/medium || $test -d /usr/lib/medium; then
  913. X        dflt="$dflt medium"
  914. X        fi
  915. X        if $test -d /lib/large || $test -d /usr/lib/large; then
  916. X        dflt="$dflt large"
  917. X        fi
  918. X        if $test -d /lib/huge || $test -d /usr/lib/huge; then
  919. X        dflt="$dflt huge"
  920. X        fi
  921. X    esac
  922. X    fi
  923. X    ;;
  924. X*)  dflt="$models" ;;
  925. Xesac
  926. X$cat <<EOM
  927. XSome systems have different model sizes.  On most systems they are called
  928. Xsmall, medium, large, and huge.  On the PDP11 they are called unsplit and
  929. Xsplit.  If your system doesn't support different memory models, say "none".
  930. XIf you wish to force everything to one memory model, say "none" here and
  931. Xput the appropriate flags later when it asks you for other cc and ld flags.
  932. XVenix systems may wish to put "none" and let the compiler figure things out.
  933. X(In the following question multiple model names should be space separated.)
  934. X
  935. XEOM
  936. Xrp="Which models are supported? [$dflt]"
  937. X$echo $n "$rp $c"
  938. X. myread
  939. Xmodels="$ans"
  940. X
  941. Xcase "$models" in
  942. Xnone)
  943. X    small=''
  944. X    medium=''
  945. X    large=''
  946. X    huge=''
  947. X    unsplit=''
  948. X    split=''
  949. X    ;;
  950. X*split)
  951. X    case "$split" in
  952. X    '') 
  953. X    if $contains '\-i' $mansrc/man1/ld.1 >/dev/null 2>&1 || \
  954. X       $contains '\-i' $mansrc/man1/cc.1 >/dev/null 2>&1; then
  955. X        dflt='-i'
  956. X    else
  957. X        dflt='none'
  958. X    fi
  959. X    ;;
  960. X    *) dflt="$split";;
  961. X    esac
  962. X    rp="What flag indicates separate I and D space? [$dflt]"
  963. X    $echo $n "$rp $c"
  964. X    . myread
  965. X    case "$ans" in
  966. X    none) ans='';;
  967. X    esac
  968. X    split="$ans"
  969. X    unsplit=''
  970. X    ;;
  971. X*large*|*small*|*medium*|*huge*)
  972. X    case "$models" in
  973. X    *large*)
  974. X    case "$large" in
  975. X    '') dflt='-Ml';;
  976. X    *) dflt="$large";;
  977. X    esac
  978. X    rp="What flag indicates large model? [$dflt]"
  979. X    $echo $n "$rp $c"
  980. X    . myread
  981. X    case "$ans" in
  982. X    none) ans='';
  983. X    esac
  984. X    large="$ans"
  985. X    ;;
  986. X    *) large='';;
  987. X    esac
  988. X    case "$models" in
  989. X    *huge*)
  990. X    case "$huge" in
  991. X    '') dflt='-Mh';;
  992. X    *) dflt="$huge";;
  993. X    esac
  994. X    rp="What flag indicates huge model? [$dflt]"
  995. X    $echo $n "$rp $c"
  996. X    . myread
  997. X    case "$ans" in
  998. X    none) ans='';
  999. X    esac
  1000. X    huge="$ans"
  1001. X    ;;
  1002. X    *) huge="$large";;
  1003. X    esac
  1004. X    case "$models" in
  1005. X    *medium*)
  1006. X    case "$medium" in
  1007. X    '') dflt='-Mm';;
  1008. X    *) dflt="$medium";;
  1009. X    esac
  1010. X    rp="What flag indicates medium model? [$dflt]"
  1011. X    $echo $n "$rp $c"
  1012. X    . myread
  1013. X    case "$ans" in
  1014. X    none) ans='';
  1015. X    esac
  1016. X    medium="$ans"
  1017. X    ;;
  1018. X    *) medium="$large";;
  1019. X    esac
  1020. X    case "$models" in
  1021. X    *small*)
  1022. X    case "$small" in
  1023. X    '') dflt='none';;
  1024. X    *) dflt="$small";;
  1025. X    esac
  1026. X    rp="What flag indicates small model? [$dflt]"
  1027. X    $echo $n "$rp $c"
  1028. X    . myread
  1029. X    case "$ans" in
  1030. X    none) ans='';
  1031. X    esac
  1032. X    small="$ans"
  1033. X    ;;
  1034. X    *) small='';;
  1035. X    esac
  1036. X    ;;
  1037. X*)
  1038. X    echo "Unrecognized memory models--you may have to edit Makefile.SH"
  1039. X    ;;
  1040. Xesac
  1041. X
  1042. X: see if we need a special compiler
  1043. Xecho " "
  1044. Xif usg; then
  1045. X    case "$cc" in
  1046. X    '')
  1047. X    case "$Mcc" in
  1048. X    /*) dflt='Mcc'
  1049. X        ;;
  1050. X    *)
  1051. X        case "$large" in
  1052. X        -M*)
  1053. X        dflt='cc'
  1054. X        ;;
  1055. X        *)
  1056. X        if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then
  1057. X            dflt='cc -M'
  1058. X        else
  1059. X            dflt='cc'
  1060. X        fi
  1061. X        ;;
  1062. X        esac
  1063. X        ;;
  1064. X    esac
  1065. X    ;;
  1066. X    *)  dflt="$cc";;
  1067. X    esac
  1068. X    $cat <<'EOM'
  1069. X  
  1070. XOn some systems the default C compiler will not resolve multiple global
  1071. Xreferences that happen to have the same name.  On some such systems the
  1072. X"Mcc" command may be used to force these to be resolved.  On other systems
  1073. Xa "cc -M" command is required.  (Note that the -M flag on other systems
  1074. Xindicates a memory model to use!)  If you have the Gnu C compiler, you
  1075. Xmight wish to use that instead.  What command will force resolution on
  1076. XEOM
  1077. X    $echo $n "this system? [$dflt] $c"
  1078. X    rp="Command to resolve multiple refs? [$dflt]"
  1079. X    . myread
  1080. X    cc="$ans"
  1081. Xelse
  1082. X    case "$cc" in
  1083. X    '') dflt=cc;;
  1084. X    *) dflt="$cc";;
  1085. X    esac
  1086. X    rp="Use which C compiler? [$dflt]"
  1087. X    $echo $n "$rp $c"
  1088. X    . myread
  1089. X    cc="$ans"
  1090. Xfi
  1091. Xcase "$cc" in
  1092. Xgcc*) cpp=`loc gcc-cpp $cpp $pth`;;
  1093. Xesac
  1094. X
  1095. X: determine optimize, if desired, or use for debug flag also
  1096. Xcase "$optimize" in
  1097. X' ') dflt="none"
  1098. X     ;;
  1099. X'') dflt="-O";
  1100. X    ;;
  1101. X*)  dflt="$optimize"
  1102. X    ;;
  1103. Xesac
  1104. Xcat <<EOH
  1105. XSome C compilers have problems with their optimizers, by default, $package
  1106. Xcompiles with the -O flag to use the optimizer.  Alternately, you might
  1107. Xwant to use the symbolic debugger, which uses the -g flag (on traditional
  1108. XUnix systems).  Either flag can be specified here.  To use neither flag,
  1109. Xspecify the word "none".
  1110. X  
  1111. XEOH
  1112. Xrp="What optimizer/debugger flag should be used? [$dflt]"
  1113. X$echo $n "$rp $c"
  1114. X. myread
  1115. Xoptimize="$ans"
  1116. Xcase "$optimize" in
  1117. X'none') optimize=" "
  1118. X     ;;
  1119. Xesac
  1120. X
  1121. Xcase "$ccflags" in
  1122. X'') case "$cc" in
  1123. X    gcc) dflt='-fpcc_struct_return';;
  1124. X    *) dflt='none';;
  1125. X    esac
  1126. X    ;;
  1127. X*) dflt="$ccflags";;
  1128. Xesac
  1129. Xecho " "
  1130. Xrp="Any additional cc flags? [$dflt]"
  1131. X$echo $n "$rp $c"
  1132. X. myread
  1133. Xcase "$ans" in
  1134. Xnone) ans='';
  1135. Xesac
  1136. Xccflags="$ans"
  1137. X
  1138. Xcase "$ldflags" in
  1139. X'') if venix; then
  1140. X    dflt='-i -z'
  1141. X    else
  1142. X    dflt='none'
  1143. X    fi
  1144. X    ;;
  1145. X*) dflt="$ldflags";;
  1146. Xesac
  1147. Xecho " "
  1148. Xrp="Any additional ld flags (NOT including libraries)? [$dflt]"
  1149. X$echo $n "$rp $c"
  1150. X. myread
  1151. Xcase "$ans" in
  1152. Xnone) ans='';
  1153. Xesac
  1154. Xldflags="$ans"
  1155. Xrmlist="$rmlist pdp11"
  1156. X
  1157. Xcase "$libs" in
  1158. X'') dflt='none';;
  1159. X*) dflt="$libs";;
  1160. Xesac
  1161. X
  1162. X$cat <<EOM
  1163. XSome versions of Unix support shared libraries, which make
  1164. Xexecutables smaller but make load time slightly longer.
  1165. X
  1166. XOn some systems, mostly newer Unix System V's, the shared library
  1167. Xis included by putting the option "-lc_s" as the last thing on the
  1168. Xcc command line when linking.  Other systems use shared libraries
  1169. Xby default.  There may be other libraries needed to compile $package
  1170. Xon your machine as well.  If your system needs the "-lc_s" option,
  1171. Xinclude it here.  Include any other special libraries here as well.
  1172. XEOM
  1173. X
  1174. Xecho " "
  1175. Xrp="Any additional libraries? [$dflt]"
  1176. X$echo $n "$rp $c"
  1177. X. myread
  1178. Xcase "$ans" in
  1179. Xnone) ans='';
  1180. Xesac
  1181. Xlibs="$ans"
  1182. X
  1183. X: check for ordering of bytes in a long
  1184. Xcase "$byteorder" in
  1185. X'')
  1186. Xcat <<'EOM'
  1187. X  
  1188. XIn the following, larger digits indicate more significance.  A big-endian
  1189. Xmachine like a Pyramid or a Motorola 680?0 chip will come out to 4321.  A
  1190. Xlittle-endian machine like a Vax or an Intel 80?86 chip would be 1234.  Other
  1191. Xmachines may have weird orders like 3412.  If the test program works the
  1192. Xdefault is probably right.  I'm now running the test program...
  1193. XEOM
  1194. X    $cat >try.c <<'EOCP'
  1195. X#include <stdio.h>
  1196. Xmain()
  1197. X{
  1198. X    int i;
  1199. X    union {
  1200. X    unsigned long l;
  1201. X    char c[4];
  1202. X    } u;
  1203. X
  1204. X    u.l = 0x04030201;
  1205. X    printf("%c%c%c%c\n", u.c[0]+'0', u.c[1]+'0', u.c[2]+'0', u.c[3]+'0');
  1206. X}
  1207. XEOCP
  1208. X    if $cc try.c -o try >/dev/null 2>&1 ; then
  1209. X    dflt=`try`
  1210. X    case "$dflt" in
  1211. X    ????) echo "(The test program ran ok.)";;
  1212. X    *) echo "(The test program didn't run right for some reason.)";;
  1213. X    esac
  1214. X    else
  1215. X    dflt='4321'
  1216. X    echo "(I can't seem to compile the test program.  Guessing big-endian...)"
  1217. X    fi
  1218. X    ;;
  1219. X*)
  1220. X    echo " "
  1221. X    dflt="$byteorder"
  1222. X    ;;
  1223. Xesac
  1224. Xrp="What is the order of bytes in a long? [$dflt]"
  1225. X$echo $n "$rp $c"
  1226. X. myread
  1227. Xbyteorder="$ans"
  1228. X$rm -f try.c try
  1229. X
  1230. X: see how we invoke the C preprocessor
  1231. Xecho " "
  1232. Xecho "Now, how can we feed standard input to your C preprocessor..."
  1233. Xcat <<'EOT' >testcpp.c
  1234. X#define ABC abc
  1235. X#define XYZ xyz
  1236. XABC.XYZ
  1237. XEOT
  1238. Xecho 'Maybe "'"$cc"' -E" will work...'
  1239. X$cc -E <testcpp.c >testcpp.out 2>&1
  1240. Xif $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1241. X    echo "Yup, it does."
  1242. X    cppstdin="$cc -E"
  1243. X    cppminus='';
  1244. Xelse
  1245. X    echo 'Nope, maybe "'$cpp'" will work...'
  1246. X    $cpp <testcpp.c >testcpp.out 2>&1
  1247. X    if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1248. X    echo "Yup, it does."
  1249. X    cppstdin="$cpp"
  1250. X    cppminus='';
  1251. X    else
  1252. X    echo 'No such luck...maybe "'$cpp' -" will work...'
  1253. X    $cpp - <testcpp.c >testcpp.out 2>&1
  1254. X    if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1255. X        echo "It works!"
  1256. X        cppstdin="$cpp"
  1257. X        cppminus='-';
  1258. X    else
  1259. X        echo 'Nixed again...maybe "'"$cc"' -E -" will work...'
  1260. X        $cc -E - <testcpp.c >testcpp.out 2>&1
  1261. X        if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1262. X        echo "Hooray, it works!  I was beginning to wonder."
  1263. X        cppstdin="$cc -E"
  1264. X        cppminus='-';
  1265. X        else
  1266. X        echo 'Nope...maybe "'"$cc"' -P" will work...'
  1267. X        $cc -P <testcpp.c >testcpp.out 2>&1
  1268. X        if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1269. X            echo "Yup, that does."
  1270. X            cppstdin="$cc -P"
  1271. X            cppminus='';
  1272. X        else
  1273. X            echo 'Nope...maybe "'"$cc"' -P -" will work...'
  1274. X            $cc -P - <testcpp.c >testcpp.out 2>&1
  1275. X            if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1276. X            echo "Yup, that does."
  1277. X            cppstdin="$cc -P"
  1278. X            cppminus='-';
  1279. X            else
  1280. X            echo 'Hmm...perhaps you already told me...'
  1281. X            case "$cppstdin" in
  1282. X            '') ;;
  1283. X            *) $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1;;
  1284. X            esac
  1285. X            if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1286. X                echo "Hooray, you did!  I was beginning to wonder."
  1287. X            else
  1288. X                echo 'Uh-uh.  Time to get fancy...'
  1289. X                cd ..
  1290. X                echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
  1291. X                echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
  1292. X                chmod 755 cppstdin
  1293. X                cppstdin=`pwd`/cppstdin
  1294. X                cppminus='';
  1295. X                cd UU
  1296. X                $cppstdin <testcpp.c >testcpp.out 2>&1
  1297. X                if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1298. X                echo "Eureka!."
  1299. X                else
  1300. X                dflt=blurfl
  1301. X                $echo $n "No dice.  I can't find a C preprocessor.  Name one: $c"
  1302. X                rp='Name a C preprocessor:'
  1303. X                . myread
  1304. X                cppstdin="$ans"
  1305. X                $cppstdin <testcpp.c >testcpp.out 2>&1
  1306. X                if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1307. X                    echo "OK, that will do."
  1308. X                else
  1309. X                    echo "Sorry, I can't get that to work.  Go find one."
  1310. X                    exit 1
  1311. X                fi
  1312. X                fi
  1313. X            fi
  1314. X            fi
  1315. X        fi
  1316. X        fi
  1317. X    fi
  1318. X    fi
  1319. Xfi
  1320. Xrm -f testcpp.c testcpp.out
  1321. X
  1322. X: see if bcmp exists
  1323. Xset bcmp d_bcmp
  1324. Xeval $inlibc
  1325. X
  1326. X: see if bcopy exists
  1327. Xset bcopy d_bcopy
  1328. Xeval $inlibc
  1329. X
  1330. X: see if sprintf is declared as int or pointer to char
  1331. Xecho " "
  1332. Xcat >.ucbsprf.c <<'EOF'
  1333. Xmain() { char buf[10]; exit((unsigned long)sprintf(buf,"%s","foo") > 10L); }
  1334. XEOF
  1335. Xif $cc $ccflags .ucbsprf.c -o .ucbsprf >/dev/null 2>&1 && .ucbsprf; then
  1336. X    echo "Your sprintf() returns (int)."
  1337. X    d_charsprf="$undef"
  1338. Xelse
  1339. X    echo "Your sprintf() returns (char*)."
  1340. X    d_charsprf="$define"
  1341. Xfi
  1342. X/bin/rm -f .ucbsprf.c .ucbsprf
  1343. X
  1344. X: see if vprintf exists
  1345. Xecho " "
  1346. Xif $contains '^vprintf$' libc.list >/dev/null 2>&1; then
  1347. X    echo 'vprintf() found.'
  1348. X    d_vprintf="$define"
  1349. X    cat >.ucbsprf.c <<'EOF'
  1350. X#include <varargs.h>
  1351. X
  1352. Xmain() { xxx("foo"); }
  1353. X
  1354. Xxxx(va_alist)
  1355. Xva_dcl
  1356. X{
  1357. X    va_list args;
  1358. X    char buf[10];
  1359. X
  1360. X    va_start(args);
  1361. X    exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
  1362. X}
  1363. XEOF
  1364. X    if $cc $ccflags .ucbsprf.c -o .ucbsprf >/dev/null 2>&1 && .ucbsprf; then
  1365. X    echo "Your vsprintf() returns (int)."
  1366. X    d_charvspr="$undef"
  1367. X    else
  1368. X    echo "Your vsprintf() returns (char*)."
  1369. X    d_charvspr="$define"
  1370. X    fi
  1371. X    /bin/rm -f .ucbsprf.c .ucbsprf
  1372. Xelse
  1373. X    echo 'vprintf() not found.'
  1374. X    d_vprintf="$undef"
  1375. X    d_charvspr="$undef"
  1376. Xfi
  1377. X
  1378. X: see if crypt exists
  1379. Xecho " "
  1380. Xif $contains '^crypt$' libc.list >/dev/null 2>&1; then
  1381. X    echo 'crypt() found.'
  1382. X    d_crypt="$define"
  1383. X    cryptlib=''
  1384. Xelse
  1385. X    cryptlib=`loc Slibcrypt.a "" /lib/386 /lib`
  1386. X    if $test -z "$cryptlib"; then
  1387. X    cryptlib=`loc Mlibcrypt.a "" /lib/386 /lib`
  1388. X    else
  1389. X    cryptlib=-lcrypt
  1390. X    fi
  1391. X    if $test -z "$cryptlib"; then
  1392. X    cryptlib=`loc Llibcrypt.a "" /lib/386 /lib`
  1393. X    else
  1394. X    cryptlib=-lcrypt
  1395. X    fi
  1396. X    if $test -z "$cryptlib"; then
  1397. X    cryptlib=`loc libcrypt.a "" $libpth`
  1398. X    else
  1399. X    cryptlib=-lcrypt
  1400. X    fi
  1401. X    if $test -z "$cryptlib"; then
  1402. X    echo 'crypt() not found.'
  1403. X    d_crypt="$undef"
  1404. X    else
  1405. X    d_crypt="$define"
  1406. X    fi
  1407. Xfi
  1408. X
  1409. X: see if this is a dirent system
  1410. Xecho " "
  1411. Xif $test -r /usr/include/dirent.h ; then
  1412. X    i_dirent="$define"
  1413. X    echo "dirent.h found."
  1414. X    if $contains 'd_namlen' /usr/include/sys/dirent.h >/dev/null 2>&1; then
  1415. X    d_dirnamlen="$define"
  1416. X    else
  1417. X    d_dirnamlen="$undef"
  1418. X    fi
  1419. Xelse
  1420. X    i_dirent="$undef"
  1421. X    d_dirnamlen="$define"
  1422. X    echo "No dirent.h found."
  1423. Xfi
  1424. X
  1425. X: now see if they want to do setuid emulation
  1426. Xcase "$d_dosuid" in
  1427. X'') dflt=n;;
  1428. X*undef*) dflt=n;;
  1429. X*) dflt=y;;
  1430. Xesac
  1431. Xcat <<EOM
  1432. XSome sites have disabled setuid #! scripts because of a bug in the kernel
  1433. Xthat prevents them from being secure.  If you are on such a system, the
  1434. Xsetuid/setgid bits on scripts are currently useless.  It is possible for
  1435. X$package to detect those bits and emulate setuid/setgid in a secure fashion
  1436. Xuntil a better solution is devised for the kernel problem.
  1437. X
  1438. XEOM
  1439. Xrp="Do you want to do setuid/setgid emulation? [$dflt]"
  1440. Xecho $n "$rp $c"
  1441. X. myread
  1442. Xcase "$ans" in
  1443. X'') $ans="$dflt";;
  1444. Xesac
  1445. Xcase "$ans" in
  1446. Xy*)  d_dosuid="$define";;
  1447. X*) d_dosuid="$undef";;
  1448. Xesac
  1449. X
  1450. X: see if dup2 exists
  1451. Xset dup2 d_dup2
  1452. Xeval $inlibc
  1453. X
  1454. X: see if fchmod exists
  1455. Xset fchmod d_fchmod
  1456. Xeval $inlibc
  1457. X
  1458. X: see if fchown exists
  1459. Xset fchown d_fchown
  1460. Xeval $inlibc
  1461. X
  1462. X: see if this is an fcntl system
  1463. Xecho " "
  1464. Xif $test -r /usr/include/fcntl.h ; then
  1465. X    d_fcntl="$define"
  1466. X    echo "fcntl.h found."
  1467. Xelse
  1468. X    d_fcntl="$undef"
  1469. X    echo "No fcntl.h found, but that's ok."
  1470. Xfi
  1471. X
  1472. X: see if flock exists
  1473. Xset flock d_flock
  1474. Xeval $inlibc
  1475. X
  1476. X: see if getgroups exists
  1477. Xset getgroups d_getgrps
  1478. Xeval $inlibc
  1479. X
  1480. X: see if gethostent exists
  1481. Xset gethostent d_gethent
  1482. Xeval $inlibc
  1483. X
  1484. X: see if getpgrp exists
  1485. Xset getpgrp d_getpgrp
  1486. Xeval $inlibc
  1487. X
  1488. X: see if getpriority exists
  1489. Xset getpriority d_getprior
  1490. Xeval $inlibc
  1491. X
  1492. X: see if htonl exists
  1493. Xset htonl d_htonl
  1494. Xeval $inlibc
  1495. X
  1496. X: index or strcpy
  1497. Xecho " "
  1498. Xcase "$d_index" in
  1499. Xn) dflt=n;;
  1500. X*) dflt=y;;
  1501. Xesac
  1502. Xif $contains '^index$' libc.list >/dev/null 2>&1 ; then
  1503. X    if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
  1504. X    echo "Your system has both index() and strchr().  Shall I use"
  1505. X    rp="index() rather than strchr()? [$dflt]"
  1506. X    $echo $n "$rp $c"
  1507. X    . myread
  1508. X    case "$ans" in
  1509. X        n*) d_index="$define" ;;
  1510. X        *)  d_index="$undef" ;;
  1511. X    esac
  1512. X    else
  1513. X    d_index="$undef"
  1514. X    echo "index() found."
  1515. X    fi
  1516. Xelse
  1517. X    if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
  1518. X    d_index="$define"
  1519. X    echo "strchr() found."
  1520. X    else
  1521. X    echo "No index() or strchr() found!"
  1522. X    d_index="$undef"
  1523. X    fi
  1524. Xfi
  1525. X
  1526. X: see if ioctl defs are in sgtty/termio or sys/ioctl
  1527. Xecho " "
  1528. Xif $test -r /usr/include/sys/ioctl.h ; then
  1529. X    d_ioctl="$define"
  1530. X    echo "sys/ioctl.h found."
  1531. Xelse
  1532. X    d_ioctl="$undef"
  1533. X    echo "sys/ioctl.h not found, assuming ioctl args are defined in sgtty.h."
  1534. Xfi
  1535. X
  1536. X: see if killpg exists
  1537. Xset killpg d_killpg
  1538. Xeval $inlibc
  1539. X
  1540. X: see if memcmp exists
  1541. Xset memcmp d_memcmp
  1542. Xeval $inlibc
  1543. X
  1544. X: see if memcpy exists
  1545. Xset memcpy d_memcpy
  1546. Xeval $inlibc
  1547. X
  1548. X: see if mkdir exists
  1549. Xset mkdir d_mkdir
  1550. Xeval $inlibc
  1551. X
  1552. X: see if ndbm is available
  1553. Xecho " "
  1554. Xif $test -r /usr/include/ndbm.h || $test -r /usr/local/include/ndbm.h; then
  1555. X    d_ndbm="$define"
  1556. X    echo "ndbm.h found."
  1557. Xelse
  1558. X    d_ndbm="$undef"
  1559. X    echo "ndbm.h not found."
  1560. Xfi
  1561. X
  1562. X: see if we have the old dbm
  1563. Xecho " "
  1564. Xif $test -r /usr/include/dbm.h ; then
  1565. X    d_odbm="$define"
  1566. X    echo "dbm.h found."
  1567. Xelse
  1568. X    d_odbm="$undef"
  1569. X    echo "dbm.h not found."
  1570. Xfi
  1571. X
  1572. X: see if this is an pwd system
  1573. Xecho " "
  1574. Xif $test -r /usr/include/pwd.h ; then
  1575. X    i_pwd="$define"
  1576. X    echo "pwd.h found."
  1577. X    if $contains 'pw_quota' /usr/include/pwd.h >/dev/null 2>&1; then
  1578. X    d_pwquota="$define"
  1579. X    else
  1580. X    d_pwquota="$undef"
  1581. X    fi
  1582. X    if $contains 'pw_age' /usr/include/pwd.h >/dev/null 2>&1; then
  1583. X    d_pwage="$define"
  1584. X    else
  1585. X    d_pwage="$undef"
  1586. X    fi
  1587. Xelse
  1588. X    i_pwd="$undef"
  1589. X    d_pwquota="$undef"
  1590. X    d_pwage="$undef"
  1591. X    echo "No pwd.h found."
  1592. Xfi
  1593. X
  1594. X: see if readdir exists
  1595. Xset readdir d_readdir
  1596. Xeval $inlibc
  1597. X
  1598. X: see if rename exists
  1599. Xset rename d_rename
  1600. Xeval $inlibc
  1601. X
  1602. X: see if rmdir exists
  1603. Xset rmdir d_rmdir
  1604. Xeval $inlibc
  1605. X
  1606. X: see if setegid exists
  1607. Xset setegid d_setegid
  1608. Xeval $inlibc
  1609. X
  1610. X: see if seteuid exists
  1611. Xset seteuid d_seteuid
  1612. Xeval $inlibc
  1613. X
  1614. X: see if setpgrp exists
  1615. Xset setpgrp d_setpgrp
  1616. Xeval $inlibc
  1617. X
  1618. X: see if setpriority exists
  1619. Xset setpriority d_setprior
  1620. Xeval $inlibc
  1621. X
  1622. X: see if setregid exists
  1623. Xset setregid d_setregid
  1624. Xeval $inlibc
  1625. Xset setresgid d_setresgid
  1626. Xeval $inlibc
  1627. X
  1628. X: see if setreuid exists
  1629. Xset setreuid d_setreuid
  1630. Xeval $inlibc
  1631. Xset setresuid d_setresuid
  1632. Xeval $inlibc
  1633. X
  1634. X: see if setrgid exists
  1635. Xset setrgid d_setrgid
  1636. Xeval $inlibc
  1637. X
  1638. X: see if setruid exists
  1639. Xset setruid d_setruid
  1640. Xeval $inlibc
  1641. X
  1642. Xsocketlib=''
  1643. Xsockethdr=''
  1644. X: see whether socket exists
  1645. Xecho " "
  1646. Xif $contains socket libc.list >/dev/null 2>&1; then
  1647. X    echo "Looks like you have Berkeley networking support."
  1648. X    d_socket="$define"
  1649. X    : now check for advanced features
  1650. X    if $contains setsockopt libc.list >/dev/null 2>&1; then
  1651. X    d_oldsock="$undef"
  1652. X    else
  1653. X    echo "...but it uses the old 4.1c interface, rather than 4.2"
  1654. X    d_oldsock="$define"
  1655. X    fi
  1656. Xelse
  1657. X    : hpux, for one, puts all the socket stuff in socklib.o
  1658. X    if $contains socklib libc.list >/dev/null 2>&1; then
  1659. X    echo "Looks like you have Berkeley networking support."
  1660. X    d_socket="$define"
  1661. X    : we will have to assume that it supports the 4.2 BSD interface
  1662. X    d_oldsock="$undef"
  1663. X    else
  1664. X    echo "Hmmm...you don't have Berkeley networking in libc.a..."
  1665. X    : look for an optional networking library
  1666. X    if test -f /usr/lib/libnet.a; then
  1667. X        (ar t /usr/lib/libnet.a ||
  1668. X        nm -g /usr/lib/libnet.a) 2>/dev/null >> libc.list
  1669. X        if $contains socket libc.list >/dev/null 2>&1; then
  1670. X        echo "but the Wollongong group seems to have hacked it in."
  1671. X        socketlib="-lnet"
  1672. X        sockethdr="-I/usr/netinclude"
  1673. X        d_socket="$define"
  1674. X        : now check for advanced features
  1675. X        if $contains setsockopt libc.list >/dev/null 2>&1; then
  1676. X            d_oldsock="$undef"
  1677. X        else
  1678. X            echo "...using the old 4.1c interface, rather than 4.2"
  1679. X            d_oldsock="$define"
  1680. X        fi
  1681. X        else
  1682. X        echo "or even in libnet.a, which is peculiar."
  1683. X        d_socket="$undef"
  1684. X        d_oldsock="$undef"
  1685. X        fi
  1686. X    else
  1687. X        echo "or anywhere else I see."
  1688. X        d_socket="$undef"
  1689. X        d_oldsock="$undef"
  1690. X    fi
  1691. X    fi
  1692. Xfi
  1693. Xif $contains socketpair libc.list >/dev/null 2>&1; then
  1694. X    d_sockpair="$define"
  1695. Xelse
  1696. X    d_sockpair="$undef"
  1697. Xfi
  1698. X
  1699. X: see if stat knows about block sizes
  1700. Xecho " "
  1701. Xif $contains 'st_blocks;' /usr/include/sys/stat.h >/dev/null 2>&1 ; then
  1702. X    if $contains 'st_blksize;' /usr/include/sys/stat.h >/dev/null 2>&1 ; then
  1703. X    echo "Your stat knows about block sizes."
  1704. X    d_statblks="$define"
  1705. X    else
  1706. X    echo "Your stat doesn't know about block sizes."
  1707. X    d_statblks="$undef"
  1708. X    fi
  1709. Xelse
  1710. X    echo "Your stat doesn't know about block sizes."
  1711. X    d_statblks="$undef"
  1712. Xfi
  1713. X
  1714. X: see if stdio is really std
  1715. Xecho " "
  1716. Xif $contains 'char.*_ptr;' /usr/include/stdio.h >/dev/null 2>&1 ; then
  1717. X    if $contains '_cnt;' /usr/include/stdio.h >/dev/null 2>&1 ; then
  1718. X    echo "Your stdio is pretty std."
  1719. X    d_stdstdio="$define"
  1720. X    else
  1721. X    echo "Your stdio isn't very std."
  1722. X    d_stdstdio="$undef"
  1723. X    fi
  1724. Xelse
  1725. X    echo "Your stdio isn't very std."
  1726. X    d_stdstdio="$undef"
  1727. Xfi
  1728. X
  1729. X: check for structure copying
  1730. Xecho " "
  1731. Xecho "Checking to see if your C compiler can copy structs..."
  1732. X$cat >try.c <<'EOCP'
  1733. Xmain()
  1734. X{
  1735. X    struct blurfl {
  1736. X        int dyick;
  1737. X    } foo, bar;
  1738. X
  1739. X    foo = bar;
  1740. X}
  1741. XEOCP
  1742. Xif $cc -c try.c >/dev/null 2>&1 ; then
  1743. X    d_strctcpy="$define"
  1744. X    echo "Yup, it can."
  1745. Xelse
  1746. X    d_strctcpy="$undef"
  1747. X    echo "Nope, it can't."
  1748. Xfi
  1749. X$rm -f try.*
  1750. X
  1751. X: see if symlink exists
  1752. Xset symlink d_symlink
  1753. Xeval $inlibc
  1754. X
  1755. X: see if syscall exists
  1756. Xset syscall d_syscall
  1757. Xeval $inlibc
  1758. X
  1759. X: see if struct tm is defined in sys/time.h
  1760. Xecho " "
  1761. Xif $contains 'struct tm' /usr/include/time.h >/dev/null 2>&1 ; then
  1762. X    echo "You have struct tm defined in <time.h> rather than <sys/time.h>."
  1763. X    d_tminsys="$undef"
  1764. X    if test -f /usr/include/sys/time.h; then
  1765. X    i_systime="$define"
  1766. X    else
  1767. X    i_systime="$undef"
  1768. X    fi
  1769. Xelse
  1770. X    echo "You have struct tm defined in <sys/time.h> rather than <time.h>."
  1771. X    d_tminsys="$define"
  1772. X    i_systime="$define"
  1773. Xfi
  1774. X
  1775. X: see if this is a varargs system
  1776. Xecho " "
  1777. Xif $test -r /usr/include/varargs.h ; then
  1778. X    d_varargs="$define"
  1779. X    echo "varargs.h found."
  1780. Xelse
  1781. X    d_varargs="$undef"
  1782. X    echo "No varargs.h found, but that's ok (I hope)."
  1783. Xfi
  1784. X
  1785. X: see if there is a vfork
  1786. Xset vfork d_vfork
  1787. Xeval $inlibc
  1788. X
  1789. X: see if signal is declared as pointer to function returning int or void
  1790. Xecho " "
  1791. Xif $contains 'void.*signal' /usr/include/signal.h >/dev/null 2>&1 ; then
  1792. X    echo "You have void (*signal())() instead of int."
  1793. X    d_voidsig="$define"
  1794. Xelse
  1795. X    echo "You have int (*signal())() instead of void."
  1796. X    d_voidsig="$undef"
  1797. Xfi
  1798. X
  1799. X: check for void type
  1800. Xecho " "
  1801. X$cat <<EOM
  1802. XChecking to see how well your C compiler groks the void type...
  1803. X
  1804. X  Support flag bits are:
  1805. X    1: basic void declarations.
  1806. X    2: arrays of pointers to functions returning void.
  1807. X    4: operations between pointers to and addresses of void functions.
  1808. X
  1809. XEOM
  1810. Xcase "$voidflags" in
  1811. X'')
  1812. X    $cat >try.c <<'EOCP'
  1813. X#if TRY & 1
  1814. Xvoid main() {
  1815. X#else
  1816. Xmain() {
  1817. X#endif
  1818. X    extern void moo();    /* function returning void */
  1819. X    void (*goo)();        /* ptr to func returning void */
  1820. X#if TRY & 2
  1821. X    void (*foo[10])();
  1822. X#endif
  1823. X
  1824. X#if TRY & 4
  1825. X    if(goo == moo) {
  1826. X        exit(0);
  1827. X    }
  1828. X#endif
  1829. X    exit(0);
  1830. X}
  1831. XEOCP
  1832. X    if $cc -S -DTRY=$defvoidused try.c >.out 2>&1 ; then
  1833. X    voidflags=$defvoidused
  1834. X    echo "It appears to support void."
  1835. X    if $contains warning .out >/dev/null 2>&1; then
  1836. X        echo "However, you might get some warnings that look like this:"
  1837. X        $cat .out
  1838. X    fi
  1839. X    else
  1840. X    echo "Hmm, your compiler has some difficulty with void.  Checking further..."
  1841. X    if $cc -S -DTRY=1 try.c >/dev/null 2>&1 ; then
  1842. X        echo "It supports 1..."
  1843. X        if $cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
  1844. X        voidflags=3
  1845. X        echo "And it supports 2 but not 4."
  1846. X        else
  1847. X        echo "It doesn't support 2..."
  1848. X        if $cc -S -DTRY=5 try.c >/dev/null 2>&1 ; then
  1849. X            voidflags=5
  1850. X            echo "But it supports 4."
  1851. X        else
  1852. X            voidflags=1
  1853. X            echo "And it doesn't support 4."
  1854. X        fi
  1855. X        fi
  1856. X    else
  1857. X        echo "There is no support at all for void."
  1858. X        voidflags=0
  1859. X    fi
  1860. X    fi
  1861. Xesac
  1862. Xdflt="$voidflags";
  1863. Xrp="Your void support flags add up to what? [$dflt]"
  1864. X$echo $n "$rp $c"
  1865. X. myread
  1866. Xvoidflags="$ans"
  1867. X$rm -f try.* .out
  1868. X
  1869. X: see what type gids are declared as in the kernel
  1870. Xcase "$gidtype" in
  1871. X'')
  1872. X    if $contains 'gid_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
  1873. X    dflt='gid_t';
  1874. X    else
  1875. X    set `grep 'groups\[NGROUPS\];' /usr/include/sys/user.h 2>/dev/null` unsigned short
  1876. X    case $1 in
  1877. X    unsigned) dflt="$1 $2" ;;
  1878. X    *) dflt="$1" ;;
  1879. X    esac
  1880. X    fi
  1881. X    ;;
  1882. X*)  dflt="$gidtype"
  1883. X    ;;
  1884. Xesac
  1885. Xcont=true
  1886. Xecho " "
  1887. Xrp="What type are group ids on this system declared as? [$dflt]"
  1888. X$echo $n "$rp $c"
  1889. X. myread
  1890. Xgidtype="$ans"
  1891. X
  1892. X: see if this is an fcntl system
  1893. Xecho " "
  1894. Xif $test -r /usr/include/fcntl.h ; then
  1895. X    i_fcntl="$define"
  1896. X    echo "fcntl.h found."
  1897. Xelse
  1898. X    i_fcntl="$undef"
  1899. X    echo "No fcntl.h found, but that's ok."
  1900. Xfi
  1901. X
  1902. X: see if this is an grp system
  1903. Xecho " "
  1904. Xif $test -r /usr/include/grp.h ; then
  1905. X    i_grp="$define"
  1906. X    echo "grp.h found."
  1907. Xelse
  1908. X    i_grp="$undef"
  1909. X    echo "No grp.h found."
  1910. Xfi
  1911. X
  1912. X: see if this is a sys/dir.h system
  1913. Xecho " "
  1914. Xif $test -r /usr/include/sys/dir.h ; then
  1915. X    i_sysdir="$define"
  1916. X    echo "sysdir.h found."
  1917. Xelse
  1918. X    i_sysdir="$undef"
  1919. X    echo "No sysdir.h found."
  1920. Xfi
  1921. X
  1922. X: see if ioctl defs are in sgtty/termio or sys/ioctl
  1923. Xecho " "
  1924. Xif $test -r /usr/include/sys/ioctl.h ; then
  1925. X    i_sysioctl="$define"
  1926. X    echo "sys/ioctl.h found."
  1927. Xelse
  1928. X    i_sysioctl="$undef"
  1929. X    echo "sys/ioctl.h not found, assuming ioctl args are defined in sgtty.h."
  1930. Xfi
  1931. X
  1932. X: see if this is a varargs system
  1933. Xecho " "
  1934. Xif $test -r /usr/include/varargs.h ; then
  1935. X    i_varargs="$define"
  1936. X    echo "varargs.h found."
  1937. Xelse
  1938. X    i_varargs="$undef"
  1939. X    echo "No varargs.h found, but that's ok (I hope)."
  1940. Xfi
  1941. X
  1942. X: see if this is a vfork system
  1943. Xecho " "
  1944. Xif $test -r /usr/include/vfork.h ; then
  1945. X    i_vfork="$define"
  1946. X    echo "vfork.h found."
  1947. Xelse
  1948. X    i_vfork="$undef"
  1949. X    echo "No vfork.h found."
  1950. Xfi
  1951. X
  1952. X: check for length of integer
  1953. Xecho " "
  1954. Xcase "$intsize" in
  1955. X'')
  1956. X    echo "Checking to see how big your integers are..."
  1957. X    $cat >try.c <<'EOCP'
  1958. X#include <stdio.h>
  1959. Xmain()
  1960. X{
  1961. X    printf("%d\n", sizeof(int));
  1962. X}
  1963. XEOCP
  1964. X    if $cc try.c -o try >/dev/null 2>&1 ; then
  1965. X    dflt=`try`
  1966. X    else
  1967. X    dflt='4'
  1968. X    echo "(I can't seem to compile the test program.  Guessing...)"
  1969. X    fi
  1970. X    ;;
  1971. X*)
  1972. X    dflt="$intsize"
  1973. X    ;;
  1974. Xesac
  1975. Xrp="What is the size of an integer (in bytes)? [$dflt]"
  1976. X$echo $n "$rp $c"
  1977. X. myread
  1978. Xintsize="$ans"
  1979. X$rm -f try.c try
  1980. X
  1981. X: determine where private executables go
  1982. Xcase "$privlib" in
  1983. X'')
  1984. X    dflt=/usr/lib/$package
  1985. X    test -d /usr/local/lib && dflt=/usr/local/lib/$package
  1986. X    ;;
  1987. X*)  dflt="$privlib"
  1988. X    ;;
  1989. Xesac
  1990. X$cat <<EOM
  1991. X
  1992. XThe $package package has some auxiliary files that should be put in a library
  1993. Xthat is accessible by everyone.  Where do you want to put these "private"
  1994. XEOM
  1995. X$echo $n "but accessible files? [$dflt] $c"
  1996. Xrp="Put private files where? [$dflt]"
  1997. X. myread
  1998. Xprivlib="$ans"
  1999. X
  2000. X: check for size of random number generator
  2001. Xecho " "
  2002. Xcase "$randbits" in
  2003. X'')
  2004. X    echo "Checking to see how many bits your rand function produces..."
  2005. X    $cat >try.c <<'EOCP'
  2006. X#include <stdio.h>
  2007. Xmain()
  2008. X{
  2009. X    register int i;
  2010. X    register unsigned long tmp;
  2011. X    register unsigned long max = 0L;
  2012. X
  2013. X    for (i=1000; i; i--) {
  2014. X    tmp = (unsigned long)rand();
  2015. X    if (tmp > max) max = tmp;
  2016. X    }
  2017. X    for (i=0; max; i++)
  2018. X    max /= 2;
  2019. X    printf("%d\n",i);
  2020. X}
  2021. XEOCP
  2022. X    if $cc try.c -o try >/dev/null 2>&1 ; then
  2023. X    dflt=`try`
  2024. X    else
  2025. X    dflt='?'
  2026. X    echo "(I can't seem to compile the test program...)"
  2027. X    fi
  2028. X    ;;
  2029. X*)
  2030. X    dflt="$randbits"
  2031. X    ;;
  2032. Xesac
  2033. Xrp="How many bits does your rand() function produce? [$dflt]"
  2034. X$echo $n "$rp $c"
  2035. X. myread
  2036. Xrandbits="$ans"
  2037. X$rm -f try.c try
  2038. X
  2039. X: generate list of signal names
  2040. Xecho " "
  2041. Xcase "$sig_name" in
  2042. X'')
  2043. X    echo "Generating a list of signal names..."
  2044. X    set X `kill -l 2>/dev/null`
  2045. X    shift
  2046. X    case $# in
  2047. X    0)  echo 'kill -l' >/tmp/foo$$
  2048. X    set X `/bin/csh -f </tmp/foo$$`
  2049. X    shift
  2050. X    case $# in
  2051. X    0)set HUP INT QUIT ILL TRAP IOT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM
  2052. X        ;;
  2053. X    esac
  2054. X    ;;
  2055. X    esac
  2056. X    sig_name="ZERO $*"
  2057. X    ;;
  2058. Xesac
  2059. Xecho "Signals are: $sig_name"
  2060. X
  2061. X: see what type of char stdio uses.
  2062. Xecho " "
  2063. Xif $contains 'unsigned.*char.*_ptr;' /usr/include/stdio.h >/dev/null 2>&1 ; then
  2064. X    echo "Your stdio uses unsigned chars."
  2065. X    stdchar="unsigned char"
  2066. Xelse
  2067. X    echo "Your stdio uses signed chars."
  2068. X    stdchar="char"
  2069. Xfi
  2070. X
  2071. X: see what type uids are declared as in the kernel
  2072. Xcase "$uidtype" in
  2073. X'')
  2074. X    if $contains 'uid_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
  2075. X    dflt='uid_t';
  2076. X    else
  2077. X    set `grep '_ruid;' /usr/include/sys/user.h 2>/dev/null` unsigned short
  2078. X    case $1 in
  2079. X    unsigned) dflt="$1 $2" ;;
  2080. X    *) dflt="$1" ;;
  2081. X    esac
  2082. X    fi
  2083. X    ;;
  2084. X*)  dflt="$uidtype"
  2085. X    ;;
  2086. Xesac
  2087. Xcont=true
  2088. Xecho " "
  2089. Xrp="What type are user ids on this system declared as? [$dflt]"
  2090. X$echo $n "$rp $c"
  2091. X. myread
  2092. Xuidtype="$ans"
  2093. X
  2094. X: preserve RCS keywords in files with variable substitution, grrr
  2095. XLog='$Log'
  2096. XHeader='$Header'
  2097. X
  2098. X
  2099. X: see if we should include -ldbm
  2100. Xecho " "
  2101. Xif $test -r /usr/lib/libdbm.a || $test -r /usr/local/lib/libdbm.a ; then
  2102. X    echo "-ldbm found."
  2103. X    libdbm='-ldbm'
  2104. Xelse
  2105. X    ans=`loc libdbm.a x $libpth`
  2106. X    case "$ans" in
  2107. X    x)
  2108. X    echo "No dbm library found."
  2109. X    libdbm=''
  2110. X    ;;
  2111. X    *)
  2112. X    echo "DBM library found in $ans."
  2113. X    libdbm="$ans"
  2114. X    ;;
  2115. X    esac
  2116. Xfi
  2117. X
  2118. X: see if we should include -lndir
  2119. Xecho " "
  2120. Xif $test -r /usr/lib/libndir.a || $test -r /usr/local/lib/libndir.a ; then
  2121. X    echo "New directory library found."
  2122. X    libndir='-lndir'
  2123. Xelse
  2124. X    ans=`loc libndir.a x $libpth`
  2125. X    case "$ans" in
  2126. X    x)
  2127. X    echo "No ndir library found."
  2128. X    libndir=''
  2129. X    ;;
  2130. X    *)
  2131. X    echo "New directory library found in $ans."
  2132. X    libndir="$ans"
  2133. X    ;;
  2134. X    esac
  2135. Xfi
  2136. Xcase "$libndir" in
  2137. X'') ;;
  2138. X*)
  2139. X    case "$d_readdir" in
  2140. X    $define)
  2141. X    echo "Since you have readdir in the C library, I'll ignore $libndir"
  2142. X    libndir=''
  2143. X    ;;
  2144. X    esac
  2145. X    ;;
  2146. Xesac
  2147. X
  2148. X: see if we should include -lnm
  2149. Xecho " "
  2150. Xif $test -r /usr/lib/libnm.a || $test -r /usr/local/lib/libnm.a ; then
  2151. X    echo "New math library found."
  2152. X    libnm='-lnm'
  2153. Xelse
  2154. X    ans=`loc libnm.a x $libpth`
  2155. X    case "$ans" in
  2156. X    x)
  2157. X    echo "No nm library found--the normal math library will have to do."
  2158. X    libnm=''
  2159. X    ;;
  2160. X    *)
  2161. X    echo "New math library found in $ans."
  2162. X    libnm="$ans"
  2163. X    ;;
  2164. X    esac
  2165. Xfi
  2166. X
  2167. X: determine which malloc to compile in
  2168. Xecho " "
  2169. Xcase "$usemymalloc" in
  2170. X'')
  2171. X    if bsd || v7; then
  2172. X    dflt='y'
  2173. X    else
  2174. X    dflt='n'
  2175. X    fi
  2176. X    ;;
  2177. X*)  dflt="$usemymalloc"
  2178. X    ;;
  2179. Xesac
  2180. Xrp="Do you wish to attempt to use the malloc that comes with $package? [$dflt]"
  2181. X$echo $n "$rp $c"
  2182. X. myread
  2183. Xcase "$ans" in
  2184. X'') ans=$dflt;;
  2185. Xesac
  2186. Xusemymalloc="$ans"
  2187. Xcase "$ans" in
  2188. Xy*) mallocsrc='malloc.c'; mallocobj='malloc.o';;
  2189. X*) mallocsrc=''; mallocobj='';;
  2190. Xesac
  2191. X
  2192. Xecho " "
  2193. Xecho "End of configuration questions."
  2194. Xecho " "
  2195. X
  2196. X: create config.sh file
  2197. Xecho " "
  2198. Xif test -d ../UU; then
  2199. X    cd ..
  2200. Xfi
  2201. Xecho "Creating config.sh..."
  2202. X$spitshell <<EOT >config.sh
  2203. X$startsh
  2204. X# config.sh
  2205. X# This file was produced by running the Configure script.
  2206. X
  2207. Xd_eunice='$d_eunice'
  2208. Xeunicefix='$eunicefix'
  2209. Xdefine='$define'
  2210. Xloclist='$loclist'
  2211. Xexpr='$expr'
  2212. Xsed='$sed'
  2213. Xecho='$echo'
  2214. Xcat='$cat'
  2215. Xrm='$rm'
  2216. Xmv='$mv'
  2217. Xcp='$cp'
  2218. Xtail='$tail'
  2219. Xtr='$tr'
  2220. Xmkdir='$mkdir'
  2221. Xsort='$sort'
  2222. Xuniq='$uniq'
  2223. Xgrep='$grep'
  2224. Xtrylist='$trylist'
  2225. Xtest='$test'
  2226. Xinews='$inews'
  2227. Xegrep='$egrep'
  2228. Xmore='$more'
  2229. Xpg='$pg'
  2230. XMcc='$Mcc'
  2231. Xvi='$vi'
  2232. Xmailx='$mailx'
  2233. Xmail='$mail'
  2234. Xcpp='$cpp'
  2235. Xperl='$perl'
  2236. Xemacs='$emacs'
  2237. Xls='$ls'
  2238. Xrmail='$rmail'
  2239. Xsendmail='$sendmail'
  2240. Xshar='$shar'
  2241. Xsmail='$smail'
  2242. Xtbl='$tbl'
  2243. Xtroff='$troff'
  2244. Xnroff='$nroff'
  2245. Xuname='$uname'
  2246. Xuuname='$uuname'
  2247. Xline='$line'
  2248. Xchgrp='$chgrp'
  2249. Xchmod='$chmod'
  2250. Xlint='$lint'
  2251. Xsleep='$sleep'
  2252. Xpr='$pr'
  2253. Xtar='$tar'
  2254. Xln='$ln'
  2255. Xlpr='$lpr'
  2256. Xlp='$lp'
  2257. Xtouch='$touch'
  2258. Xmake='$make'
  2259. Xdate='$date'
  2260. XLog='$Log'
  2261. XHeader='$Header'
  2262. Xbin='$bin'
  2263. Xbyteorder='$byteorder'
  2264. Xcontains='$contains'
  2265. Xcppstdin='$cppstdin'
  2266. Xcppminus='$cppminus'
  2267. Xd_bcmp='$d_bcmp'
  2268. Xd_bcopy='$d_bcopy'
  2269. Xd_charsprf='$d_charsprf'
  2270. Xd_crypt='$d_crypt'
  2271. Xcryptlib='$cryptlib'
  2272. Xd_dosuid='$d_dosuid'
  2273. Xd_dup2='$d_dup2'
  2274. Xd_fchmod='$d_fchmod'
  2275. Xd_fchown='$d_fchown'
  2276. Xd_fcntl='$d_fcntl'
  2277. Xd_flock='$d_flock'
  2278. Xd_getgrps='$d_getgrps'
  2279. Xd_gethent='$d_gethent'
  2280. Xd_getpgrp='$d_getpgrp'
  2281. Xd_getprior='$d_getprior'
  2282. Xd_htonl='$d_htonl'
  2283. Xd_index='$d_index'
  2284. Xd_ioctl='$d_ioctl'
  2285. Xd_killpg='$d_killpg'
  2286. Xd_memcmp='$d_memcmp'
  2287. Xd_memcpy='$d_memcpy'
  2288. Xd_mkdir='$d_mkdir'
  2289. Xd_ndbm='$d_ndbm'
  2290. Xd_odbm='$d_odbm'
  2291. Xd_readdir='$d_readdir'
  2292. Xd_rename='$d_rename'
  2293. Xd_rmdir='$d_rmdir'
  2294. Xd_setegid='$d_setegid'
  2295. Xd_seteuid='$d_seteuid'
  2296. Xd_setpgrp='$d_setpgrp'
  2297. Xd_setprior='$d_setprior'
  2298. Xd_setregid='$d_setregid'
  2299. Xd_setresgid='$d_setresgid'
  2300. Xd_setreuid='$d_setreuid'
  2301. Xd_setresuid='$d_setresuid'
  2302. Xd_setrgid='$d_setrgid'
  2303. Xd_setruid='$d_setruid'
  2304. Xd_socket='$d_socket'
  2305. Xd_sockpair='$d_sockpair'
  2306. Xd_oldsock='$d_oldsock'
  2307. Xsocketlib='$socketlib'
  2308. Xsockethdr='$sockethdr'
  2309. Xd_statblks='$d_statblks'
  2310. Xd_stdstdio='$d_stdstdio'
  2311. Xd_strctcpy='$d_strctcpy'
  2312. Xd_symlink='$d_symlink'
  2313. Xd_syscall='$d_syscall'
  2314. Xd_tminsys='$d_tminsys'
  2315. Xi_systime='$i_systime'
  2316. Xd_varargs='$d_varargs'
  2317. Xd_vfork='$d_vfork'
  2318. Xd_voidsig='$d_voidsig'
  2319. Xd_vprintf='$d_vprintf'
  2320. Xd_charvspr='$d_charvspr'
  2321. Xgidtype='$gidtype'
  2322. Xi_dirent='$i_dirent'
  2323. Xd_dirnamlen='$d_dirnamlen'
  2324. Xi_fcntl='$i_fcntl'
  2325. Xi_grp='$i_grp'
  2326. Xi_pwd='$i_pwd'
  2327. Xd_pwquota='$d_pwquota'
  2328. Xd_pwage='$d_pwage'
  2329. Xi_sysdir='$i_sysdir'
  2330. Xi_sysioctl='$i_sysioctl'
  2331. Xi_varargs='$i_varargs'
  2332. Xi_vfork='$i_vfork'
  2333. Xintsize='$intsize'
  2334. Xlibc='$libc'
  2335. Xlibdbm='$libdbm'
  2336. Xlibndir='$libndir'
  2337. Xlibnm='$libnm'
  2338. Xmallocsrc='$mallocsrc'
  2339. Xmallocobj='$mallocobj'
  2340. Xusemymalloc='$usemymalloc'
  2341. Xmansrc='$mansrc'
  2342. Xmanext='$manext'
  2343. Xmodels='$models'
  2344. Xsplit='$split'
  2345. Xsmall='$small'
  2346. Xmedium='$medium'
  2347. Xlarge='$large'
  2348. Xhuge='$huge'
  2349. Xoptimize='$optimize'
  2350. Xccflags='$ccflags'
  2351. Xldflags='$ldflags'
  2352. Xcc='$cc'
  2353. Xlibs='$libs'
  2354. Xn='$n'
  2355. Xc='$c'
  2356. Xpackage='$package'
  2357. Xrandbits='$randbits'
  2358. Xsig_name='$sig_name'
  2359. Xspitshell='$spitshell'
  2360. Xshsharp='$shsharp'
  2361. Xsharpbang='$sharpbang'
  2362. Xstartsh='$startsh'
  2363. Xstdchar='$stdchar'
  2364. Xuidtype='$uidtype'
  2365. Xvoidflags='$voidflags'
  2366. Xdefvoidused='$defvoidused'
  2367. Xlib='$lib'
  2368. Xprivlib='$privlib'
  2369. XCONFIG=true
  2370. XEOT
  2371. X
  2372. XCONFIG=true
  2373. X
  2374. Xecho " "
  2375. Xdflt=''
  2376. Xfastread=''
  2377. Xecho "If you didn't make any mistakes, then just type a carriage return here."
  2378. Xrp="If you need to edit config.sh, do it as a shell escape here:"
  2379. X$echo $n "$rp $c"
  2380. X. UU/myread
  2381. Xcase "$ans" in
  2382. X'') ;;
  2383. X*) : in case they cannot read
  2384. X    eval $ans;;
  2385. Xesac
  2386. X. ./config.sh
  2387. X
  2388. Xecho " "
  2389. Xecho "Doing variable substitutions on .SH files..."
  2390. Xset x `awk '{print $1}' <MANIFEST | $grep '\.SH'`
  2391. Xshift
  2392. Xcase $# in
  2393. X0) set x *.SH; shift;;
  2394. Xesac
  2395. Xif test ! -f $1; then
  2396. X    shift
  2397. Xfi
  2398. Xfor file in $*; do
  2399. X    case "$file" in
  2400. X    */*)
  2401. X    dir=`$expr X$file : 'X\(.*\)/'`
  2402. X    file=`$expr X$file : 'X.*/\(.*\)'`
  2403. X    (cd $dir && . $file)
  2404. X    ;;
  2405. X    *)
  2406. X    . $file
  2407. X    ;;
  2408. X    esac
  2409. Xdone
  2410. Xif test -f config.h.SH; then
  2411. X    if test ! -f config.h; then
  2412. X    : oops, they left it out of MANIFEST, probably, so do it anyway.
  2413. X    . config.h.SH
  2414. X    fi
  2415. Xfi
  2416. X
  2417. Xif $contains '^depend:' Makefile >/dev/null 2>&1; then
  2418. X    dflt=n
  2419. X    $cat <<EOM
  2420. X
  2421. XNow you need to generate make dependencies by running "make depend".
  2422. XYou might prefer to run it in background: "make depend > makedepend.out &"
  2423. XIt can take a while, so you might not want to run it right now.
  2424. X
  2425. XEOM
  2426. X    rp="Run make depend now? [$dflt]"
  2427. X    $echo $n "$rp $c"
  2428. X    . UU/myread
  2429. X    case "$ans" in
  2430. X    y*) make depend && echo "Now you must run a make."
  2431. X    ;;
  2432. X    *)  echo "You must run 'make depend' then 'make'."
  2433. X    ;;
  2434. X    esac
  2435. Xelif test -f Makefile; then
  2436. X    echo " "
  2437. X    echo "Now you must run a make."
  2438. Xelse
  2439. X    echo "Done."
  2440. Xfi
  2441. X
  2442. X$rm -f kit*isdone
  2443. X: the following is currently useless
  2444. Xcd UU && $rm -f $rmlist
  2445. X: since this removes it all anyway
  2446. Xcd .. && $rm -rf UU
  2447. X: end of Configure
  2448. !STUFFY!FUNK!
  2449. echo ""
  2450. echo "End of kit 2 (of 24)"
  2451. cat /dev/null >kit2isdone
  2452. run=''
  2453. config=''
  2454. 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; do
  2455.     if test -f kit${iskit}isdone; then
  2456.     run="$run $iskit"
  2457.     else
  2458.     todo="$todo $iskit"
  2459.     fi
  2460. done
  2461. case $todo in
  2462.     '')
  2463.     echo "You have run all your kits.  Please read README and then type Configure."
  2464.     chmod 755 Configure
  2465.     ;;
  2466.     *)  echo "You have run$run."
  2467.     echo "You still need to run$todo."
  2468.     ;;
  2469. esac
  2470. : Someone might mail this, so...
  2471. exit
  2472.  
  2473.