home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume42 / c2man-2.0 / part02 < prev    next >
Internet Message Format  |  1994-05-06  |  52KB

  1. From: greyham@research.canon.oz.au (Graham Stoney)
  2. Newsgroups: comp.sources.misc
  3. Subject: v42i056:  c2man-2.0 - automatic C documentation generator, Part02/09
  4. Date: 25 Apr 1994 22:29:54 -0500
  5. Organization: Canon Information Systems Research Australia
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <2pi1ri$jic@sparky.sterling.com>
  9. References: <csm-v42i055=c2man-2.0.222803@sparky.sterling.com>
  10. Summary: a complete posting of the latest c2man: version 2.0 patchlevel 27
  11. X-Md4-Signature: 71d8031b7d16cf6abf968020cd592b66
  12.  
  13. Submitted-by: greyham@research.canon.oz.au (Graham Stoney)
  14. Posting-number: Volume 42, Issue 56
  15. Archive-name: c2man-2.0/part02
  16. Environment: UNIX, DOS, OS/2, lex, yacc
  17.  
  18. #! /bin/sh
  19. #
  20. # This is c2man version 2.0 at patchlevel 27.
  21. # Make a new directory for the c2man sources, cd to it, and run kits 1 up
  22. # to 9 through sh.  When all 9 kits have been run, read README.
  23. #
  24. echo " "
  25. cat <<EOM
  26. This is c2man 2.0 at patchlevel 27, kit 2 (of 9):
  27. If this shell archive is complete, the line "End of kit 2 (of 9)"
  28. will echo at the end.
  29. EOM
  30. export PATH || (echo "Please use sh to unpack this archive." ; kill $$)
  31. mkdir  2>/dev/null
  32. echo Extracting Configure:AA
  33. sed >Configure:AA <<'!STUFFY!FUNK!' -e 's/X//'
  34. X#! /bin/sh
  35. X#
  36. X# If these # comments don't work, trim them. Don't worry about any other
  37. X# shell scripts, Configure will trim # comments from them for you.
  38. X#
  39. X# (If you are trying to port this package to a machine without sh,
  40. X# I would suggest you have a look at the prototypical config_h.SH file
  41. X# and edit it to reflect your system. Some packages may include samples
  42. X# of config.h for certain machines, so you might look for one of those.)
  43. X#
  44. X# Yes, you may rip this off to use in other distribution packages. This
  45. X# script belongs to the public domain and cannot be copyrighted.
  46. X#
  47. X# (Note: this Configure script was generated automatically. Rather than
  48. X# working with this copy of Configure, you may wish to get metaconfig.
  49. X# The dist-3.0 package (which contains metaconfig) was posted in
  50. X# comp.sources.misc so you may fetch it yourself from your nearest
  51. X# archive site. Check with Archie if you don't know where that can be.)
  52. X#
  53. X
  54. X# $Id: Configure,v 2.0.1.31 1994/02/23 07:08:43 greyham Exp $
  55. X#
  56. X# Generated on Wed Feb 23 17:43:56 EST 1994 [metaconfig 3.0 PL22]
  57. X
  58. Xcat >/tmp/c1$$ <<EOF
  59. XARGGGHHHH!!!!!
  60. X
  61. XSCO csh still thinks true is false.  Write to SCO today and tell them that next
  62. Xyear Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
  63. X
  64. X(Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
  65. Xwe'd have to do is go in and swap the && and || tokens, wherever they are.)
  66. X
  67. X[End of diatribe. We now return you to your regularly scheduled programming...]
  68. XEOF
  69. Xcat >/tmp/c2$$ <<EOF
  70. X
  71. XOOPS!  You naughty creature!  You didn't run Configure with sh!
  72. XI will attempt to remedy the situation by running sh for you...
  73. XEOF
  74. X
  75. Xtrue || cat /tmp/c1$$ /tmp/c2$$
  76. Xtrue || exec sh $0 $argv:q
  77. X
  78. X(exit $?0) || cat /tmp/c2$$
  79. X(exit $?0) || exec sh $0 $argv:q
  80. Xrm -f /tmp/c1$$ /tmp/c2$$
  81. X
  82. X: Sanity checks
  83. XPATH=".:$PATH:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin"
  84. XPATH=$PATH:'/usr/5bin:/etc:/usr/gnu/bin:/usr/new:/usr/new/bin:/usr/nbin'
  85. XPATH=$PATH:'/sys5.3/bin:/sys5.3/usr/bin:/bsd4.3/bin:/bsd4.3/usr/ucb'
  86. XPATH=$PATH:'/bsd4.3/usr/bin:/usr/bsd:/bsd43/bin:/usr/ccs/bin'
  87. XPATH=$PATH:'/etc:/usr/lib:/usr/ucblib:/lib:/usr/ccs/lib'
  88. XPATH=$PATH:'/sbin:/usr/sbin:/usr/libexec'
  89. Xexport PATH
  90. X
  91. Xif test ! -t 0; then
  92. X    echo "Say 'sh Configure', not 'sh <Configure'"
  93. X    exit 1
  94. Xfi
  95. X
  96. X: On HP-UX, large Configure scripts may exercise a bug in /bin/sh
  97. Xif test -f /hp-ux -a -f /bin/ksh; then
  98. X    if (PATH=.; alias -x) >/dev/null 2>&1; then
  99. X        : already under /bin/ksh
  100. X    else
  101. X        cat <<'EOM'
  102. X(Feeding myself to ksh to avoid nasty sh bug in "here document" expansion.)
  103. XEOM
  104. X        exec /bin/ksh $0 "$@"
  105. X    fi
  106. Xelse
  107. X    : Warn them if they use ksh on other systems
  108. X    (PATH=.; alias -x) >/dev/null 2>&1 && \
  109. X        cat <<'EOM'
  110. X(I see you are using the Korn shell.  Some ksh's blow up on Configure,
  111. Xespecially on exotic machines.  If yours does, try the Bourne shell instead.)
  112. XEOM
  113. Xfi
  114. X
  115. X: Configure runs within the UU subdirectory
  116. Xtest -d UU || mkdir UU
  117. Xcd UU && rm -f *
  118. X
  119. Xd_bsd=''
  120. Xd_eunice=''
  121. Xd_xenix=''
  122. Xeunicefix=''
  123. XMcc=''
  124. Xawk=''
  125. Xbash=''
  126. Xbison=''
  127. Xcat=''
  128. Xchgrp=''
  129. Xchmod=''
  130. Xchown=''
  131. Xcompress=''
  132. Xcp=''
  133. Xcpio=''
  134. Xcpp=''
  135. Xcsh=''
  136. Xdate=''
  137. Xecho=''
  138. Xegrep=''
  139. Xemacs=''
  140. Xexpr=''
  141. Xflex=''
  142. Xgcc=''
  143. Xgrep=''
  144. Xinews=''
  145. Xksh=''
  146. Xless=''
  147. Xline=''
  148. Xlint=''
  149. Xln=''
  150. Xlp=''
  151. Xlpr=''
  152. Xls=''
  153. Xmail=''
  154. Xmailx=''
  155. Xmake=''
  156. Xmkdir=''
  157. Xmore=''
  158. Xmv=''
  159. Xnroff=''
  160. Xperl=''
  161. Xpg=''
  162. Xpmake=''
  163. Xpr=''
  164. Xrm=''
  165. Xrmail=''
  166. Xsed=''
  167. Xsendmail=''
  168. Xsh=''
  169. Xshar=''
  170. Xsleep=''
  171. Xsmail=''
  172. Xsort=''
  173. Xsubmit=''
  174. Xtail=''
  175. Xtar=''
  176. Xtbl=''
  177. Xtest=''
  178. Xtouch=''
  179. Xtr=''
  180. Xtroff=''
  181. Xuname=''
  182. Xuniq=''
  183. Xuuname=''
  184. Xvi=''
  185. Xzcat=''
  186. Xmailpatches=''
  187. Xnotifypatches=''
  188. Xusermail=''
  189. Xhint=''
  190. Xmyuname=''
  191. XAuthor=''
  192. XDate=''
  193. XHeader=''
  194. XId=''
  195. XLocker=''
  196. XLog=''
  197. XRCSfile=''
  198. XRevision=''
  199. XSource=''
  200. XState=''
  201. Xafs=''
  202. Xbaserev=''
  203. Xbin=''
  204. Xbinexp=''
  205. Xinstallbin=''
  206. Xcc=''
  207. Xccflags=''
  208. Xcppflags=''
  209. Xldflags=''
  210. Xlkflags=''
  211. Xoptimize=''
  212. Xcf_email=''
  213. Xcf_by=''
  214. Xcf_time=''
  215. Xcontains=''
  216. Xcppfilecom=''
  217. Xcppstdinflags=''
  218. Xd_cppcanstdin=''
  219. Xd_cppignhdrs=''
  220. Xcpplast=''
  221. Xcppminus=''
  222. Xcpprun=''
  223. Xcppstdin=''
  224. Xd_access=''
  225. Xd_const=''
  226. Xd_flexfnam=''
  227. Xd_link=''
  228. Xd_open3=''
  229. Xd_portable=''
  230. Xd_index=''
  231. Xd_strchr=''
  232. Xd_strftime=''
  233. Xd_strstr=''
  234. Xd_symlink=''
  235. Xd_time=''
  236. Xtimetype=''
  237. Xd_voidsig=''
  238. Xsignal_t=''
  239. Xd_volatile=''
  240. Xh_fcntl=''
  241. Xh_sysfile=''
  242. Xi_fcntl=''
  243. Xi_stdarg=''
  244. Xi_stddef=''
  245. Xi_stdlib=''
  246. Xi_string=''
  247. Xstrings=''
  248. Xi_sysfile=''
  249. Xi_systypes=''
  250. Xi_systime=''
  251. Xi_systimek=''
  252. Xi_time=''
  253. Xtimeincl=''
  254. Xi_unistd=''
  255. Xi_varargs=''
  256. Xi_varhdr=''
  257. Xlex=''
  258. Xlibc=''
  259. Xliblex=''
  260. Xlibpth=''
  261. Xplibpth=''
  262. Xxlibpth=''
  263. Xlibs=''
  264. Xlibyacc=''
  265. Xmailer=''
  266. Xinstallmansrc=''
  267. Xmanext=''
  268. Xmansrc=''
  269. Xmansrcexp=''
  270. Xmkdep=''
  271. Xmydomain=''
  272. Xmyhostname=''
  273. Xphostname=''
  274. Xc=''
  275. Xn=''
  276. Xd_berknames=''
  277. Xd_passnames=''
  278. Xd_usgnames=''
  279. Xnametype=''
  280. Xgroupcat=''
  281. Xhostcat=''
  282. Xpasscat=''
  283. Xpackage=''
  284. Xspackage=''
  285. Xpatchlevel=''
  286. Xinstallprivlib=''
  287. Xprivlib=''
  288. Xprivlibexp=''
  289. Xprototype=''
  290. Xsharpbang=''
  291. Xshsharp=''
  292. Xspitshell=''
  293. Xstartsh=''
  294. Xsysman=''
  295. Xnm_opt=''
  296. Xrunnm=''
  297. Xusenm=''
  298. Xincpath=''
  299. Xmips=''
  300. Xmips_type=''
  301. Xusrinc=''
  302. Xvaproto=''
  303. Xdefvoidused=''
  304. Xvoidflags=''
  305. Xwarnflags=''
  306. Xyacc=''
  307. Xyaccflags=''
  308. XCONFIG=''
  309. X
  310. X: script used to extract .SH files with variable substitutions
  311. Xcat >extract <<'EOS'
  312. XCONFIG=true
  313. Xecho "Doing variable substitutions on .SH files..."
  314. Xif test -f MANIFEST; then
  315. X    set x `awk '{print $1}' <MANIFEST | grep '\.SH'`
  316. Xelse
  317. X    echo "(Looking for .SH files under the current directory.)"
  318. X    set x `find . -name "*.SH" -print`
  319. Xfi
  320. Xshift
  321. Xcase $# in
  322. X0) set x *.SH; shift;;
  323. Xesac
  324. Xif test ! -f $1; then
  325. X    shift
  326. Xfi
  327. Xfor file in $*; do
  328. X    case "$file" in
  329. X    */*)
  330. X        dir=`expr X$file : 'X\(.*\)/'`
  331. X        file=`expr X$file : 'X.*/\(.*\)'`
  332. X        (cd $dir && . ./$file)
  333. X        ;;
  334. X    *)
  335. X        . ./$file
  336. X        ;;
  337. X    esac
  338. Xdone
  339. Xif test -f config_h.SH; then
  340. X    if test ! -f config.h; then
  341. X    : oops, they left it out of MANIFEST, probably, so do it anyway.
  342. X    . ./config_h.SH
  343. X    fi
  344. Xfi
  345. XEOS
  346. X
  347. X: produce awk script to parse command line options
  348. Xcat >options.awk <<'EOF'
  349. XBEGIN {
  350. X    optstr = "deEf:hrsSV";    # getopt-style specification
  351. X
  352. X    len = length(optstr);
  353. X    for (i = 1; i <= len; i++) {
  354. X        c = substr(optstr, i, 1);
  355. X        if (i < len) a = substr(optstr, i + 1, 1); else a = "";
  356. X        if (a == ":") {
  357. X            arg[c] = 1;
  358. X            i++;
  359. X        }
  360. X        opt[c] = 1;
  361. X    }
  362. X}
  363. X{
  364. X    expect = 0;
  365. X    str = $0;
  366. X    if (substr(str, 1, 1) != "-") {
  367. X        printf("'%s'\n", str);
  368. X        next;
  369. X    }
  370. X    len = length($0);
  371. X    for (i = 2; i <= len; i++) {
  372. X        c = substr(str, i, 1);
  373. X        if (!opt[c]) {
  374. X            printf("-%s\n", substr(str, i));
  375. X            next;
  376. X        }
  377. X        printf("-%s\n", c);
  378. X        if (arg[c]) {
  379. X            if (i < len)
  380. X                printf("'%s'\n", substr(str, i + 1));
  381. X            else
  382. X                expect = 1;
  383. X            next;
  384. X        }
  385. X    }
  386. X}
  387. XEND {
  388. X    if (expect)
  389. X        print "?";
  390. X}
  391. XEOF
  392. X
  393. X: process the command line options
  394. Xset X `for arg in "$@"; do echo $arg; done | awk -f options.awk`
  395. Xeval "set $*"
  396. Xshift
  397. Xrm -f options.awk
  398. X
  399. X: set up default values
  400. Xfastread=''
  401. Xreuseval=false
  402. Xconfig_sh=''
  403. Xalldone=''
  404. Xerror=''
  405. Xsilent=''
  406. Xextractsh=''
  407. X
  408. X: option parsing
  409. Xwhile test $# -gt 0; do
  410. X    case "$1" in
  411. X    -d) shift; fastread=yes;;
  412. X    -e) shift; alldone=cont;;
  413. X    -f)
  414. X        shift
  415. X        cd ..
  416. X        if test -r "$1"; then
  417. X            config_sh="$1"
  418. X        else
  419. X            echo "Configure: cannot read config file $1." >&2
  420. X            error=true
  421. X        fi
  422. X        cd UU
  423. X        shift;;
  424. X    -h) shift; error=true;;
  425. X    -r) shift; reuseval=true;;
  426. X    -s) shift; silent=true;;
  427. X    -E) shift; alldone=exit;;
  428. X    -S) shift; extractsh=true;;
  429. X    -V) echo "Configure generated by metaconfig 3.0 PL22." >&2
  430. X        exit 0;;
  431. X    --) break;;
  432. X    -*) echo "Configure: unknown option $1" >&2; shift; error=true;;
  433. X    *) break;;
  434. X    esac
  435. Xdone
  436. X
  437. Xcase "$error" in
  438. Xtrue)
  439. X    cat >&2 <<EOM
  440. XUsage: Configure [-dehrESV] [-f config.sh]
  441. X  -d : use defaults for all answers.
  442. X  -e : go on without questioning past the production of config.sh.
  443. X  -f : specify an alternate default configuration file.
  444. X  -h : print this help message and exit (with an error status).
  445. X  -r : reuse C symbols value if possible (skips costly nm extraction).
  446. X  -s : silent mode, only echoes questions and essential information.
  447. X  -E : stop at the end of questions, after having produced config.sh.
  448. X  -S : perform variable substitutions on all .SH files (can mix with -f)
  449. X  -V : print version number and exit (with a zero status).
  450. XEOM
  451. X    exit 1
  452. X    ;;
  453. Xesac
  454. X
  455. Xexec 4>&1
  456. Xcase "$silent" in
  457. Xtrue) exec 1>/dev/null;;
  458. Xesac
  459. X
  460. Xcase "$extractsh" in
  461. Xtrue)
  462. X    case "$config_sh" in
  463. X    '') config_sh='config.sh'; config='./config.sh';;
  464. X    /*) config="$config_sh";;
  465. X    *) config="./$config_sh";;
  466. X    esac
  467. X    echo " "
  468. X    echo "Fetching answers from $config_sh..."
  469. X    cd ..
  470. X    . $config
  471. X    echo " "
  472. X    . ./UU/extract
  473. X    rm -rf UU
  474. X    echo "Done."
  475. X    exit 0
  476. X    ;;
  477. Xesac
  478. X
  479. X: set package name
  480. Xpackage=c2man
  481. X
  482. X: Eunice requires " " instead of "", can you believe it
  483. Xecho " "
  484. X: Here we go...
  485. Xecho "Beginning of configuration questions for $package."
  486. X
  487. Xdefine='define'
  488. Xundef='undef'
  489. Xsmallmach='pdp11 i8086 z8000 i80286 iAPX286'
  490. Xrmlist=''
  491. X
  492. Xtrap 'echo " "; rm -rf $rmlist; exit 1' 1 2 3 15
  493. X
  494. X: We must find out about Eunice early
  495. Xeunicefix=':'
  496. Xif test -f /etc/unixtovms; then
  497. X    eunicefix=/etc/unixtovms
  498. Xfi
  499. Xif test -f /etc/unixtovms.exe; then
  500. X    eunicefix=/etc/unixtovms.exe
  501. Xfi
  502. X
  503. X: no include file wanted by default
  504. Xinclwanted=''
  505. X
  506. Xi_sysselct=''
  507. X: change the next line if compiling for Xenix/286 on Xenix/386
  508. Xxlibpth='/usr/lib/386 /lib/386'
  509. X
  510. X: general looking path for locating libraries
  511. Xlibpth='/usr/lib/large /lib '$xlibpth' /lib/large'
  512. Xlibpth=$libpth' /usr/lib/small /lib/small'
  513. X
  514. X: no additional library wanted by default
  515. Xlibswanted=''
  516. X
  517. Xlarge=''
  518. X: full support for void wanted by default
  519. Xdefvoidused=15
  520. X
  521. Xdefvoidused=9
  522. X
  523. X: remove obsolete files from old patchlevels and their derivatives.
  524. Xrm -f ../c2man.man ../fixpre.in ../fixpre.sed ../fixpost.in ../fixpost.sed
  525. Xrm -f ../flatten_sed.SH ../fixexample.in ../fixexample.sed
  526. Xrm -f ../eg/commentafter.c ../eg/multipledecl.c
  527. X: Some greps do not return status, grrr.
  528. Xecho "grimblepritz" >grimble
  529. Xif grep blurfldyick grimble >/dev/null 2>&1 ; then
  530. X    contains=contains
  531. Xelif grep grimblepritz grimble >/dev/null 2>&1 ; then
  532. X    contains=grep
  533. Xelse
  534. X    contains=contains
  535. Xfi
  536. Xrm -f grimble
  537. X: the following should work in any shell
  538. Xcase "$contains" in
  539. Xcontains*)
  540. X    echo " "
  541. X    echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  542. X    cat >contains <<'EOSS'
  543. Xgrep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  544. XEOSS
  545. Xchmod +x contains
  546. Xesac
  547. X
  548. X: first determine how to suppress newline on echo command
  549. Xecho " "
  550. Xecho "Checking echo to see how to suppress newlines..."
  551. X(echo "hi there\c" ; echo " ") >.echotmp
  552. Xif $contains c .echotmp >/dev/null 2>&1 ; then
  553. X    echo "...using -n."
  554. X    n='-n'
  555. X    c=''
  556. Xelse
  557. X    cat <<'EOM'
  558. X...using \c
  559. XEOM
  560. X    n=''
  561. X    c='\c'
  562. Xfi
  563. Xecho $n "The star should be here-->$c"
  564. Xecho '*'
  565. Xrm -f .echotmp
  566. X
  567. X: Now test for existence of everything in MANIFEST
  568. Xecho " "
  569. Xif test -f ../MANIFEST; then
  570. X    echo "First let's make sure your kit is complete.  Checking..." >&4
  571. X    awk '$1 !~ /PACK[A-Z]+/ {print $1}' ../MANIFEST | split -50
  572. X    rm -f missing
  573. X    for filelist in x??; do
  574. X        (cd ..; ls `cat UU/$filelist` >/dev/null 2>>UU/missing)
  575. X    done
  576. X    if test -s missing; then
  577. X        cat missing >&4
  578. X        cat >&4 <<'EOM'
  579. X
  580. XTHIS PACKAGE SEEMS TO BE INCOMPLETE.
  581. X
  582. XYou have the option of continuing the configuration process, despite the
  583. Xdistinct possibility that your kit is damaged, by typing 'y'es.  If you
  584. Xdo, don't blame me if something goes wrong.  I advise you to type 'n'o
  585. Xand contact the author (greyham@research.canon.oz.au).
  586. X
  587. XEOM
  588. X        echo $n "Continue? [n] $c" >&4
  589. X        read ans
  590. X        case "$ans" in
  591. X        y*)
  592. X            echo "Continuing..." >&4
  593. X            rm -f missing
  594. X            ;;
  595. X        *)
  596. X            echo "ABORTING..." >&4
  597. X            kill $$
  598. X            ;;
  599. X        esac
  600. X    else
  601. X        echo "Looks good..." >&4
  602. X    fi
  603. Xelse
  604. X    echo "There is no MANIFEST file.  I hope your kit is complete !"
  605. Xfi
  606. Xrm -f missing x??
  607. X
  608. X: compute the number of columns on the terminal for proper question formatting
  609. Xcase "$COLUMNS" in
  610. X'') COLUMNS='80';;
  611. Xesac
  612. X
  613. X: set up the echo used in my read
  614. Xmyecho="case \"\$xxxm\" in
  615. X'') echo $n \"\$rp $c\" >&4;;
  616. X*) case \"\$rp\" in
  617. X    '') echo $n \"[\$xxxm] $c\";;
  618. X    *)
  619. X        if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
  620. X            echo \"\$rp\" >&4
  621. X            echo $n \"[\$xxxm] $c\" >&4
  622. X        else
  623. X            echo $n \"\$rp [\$xxxm] $c\" >&4
  624. X        fi
  625. X        ;;
  626. X    esac;;
  627. Xesac"
  628. X
  629. X: now set up to do reads with possible shell escape and default assignment
  630. Xcat <<EOSC >myread
  631. Xxxxm=\$dflt
  632. X$myecho
  633. Xans='!'
  634. Xcase "\$fastread" in
  635. Xyes) case "\$dflt" in
  636. X    '') ;;
  637. X    *) ans='';
  638. X        case "\$silent-\$rp" in
  639. X        true-) ;;
  640. X        *) echo " " >&4;;
  641. X        esac;;
  642. X    esac;;
  643. X*) case "\$silent" in
  644. X    true) case "\$rp" in
  645. X        '') ans='';;
  646. X        esac;;
  647. X    esac;;
  648. Xesac
  649. Xwhile expr "X\$ans" : "X!" >/dev/null; do
  650. X    read answ
  651. X    set x \$xxxm
  652. X    shift
  653. X    aok=''; eval "ans=\"\$answ\"" && aok=y
  654. X    case  "\$answ" in
  655. X    "\$ans")
  656. X        case "\$ans" in
  657. X        "!")
  658. X            sh 1>&4
  659. X            echo " "
  660. X            $myecho
  661. X            ;;
  662. X        !*)
  663. X            set x \`expr "X\$ans" : "X!\(.*\)\$"\`
  664. X            shift
  665. X            sh 1>&4 -c "\$*"
  666. X            echo " "
  667. X            $myecho
  668. X            ;;
  669. X        esac;;
  670. X    *)
  671. X        case "\$aok" in
  672. X        y)
  673. X            echo "*** Substitution done -- please confirm."
  674. X            xxxm="\$ans"
  675. X            ans=\`echo $n "\$ans$c" | tr '\012' ' '\`
  676. X            xxxm="\$ans"
  677. X            ans=!
  678. X            ;;
  679. X        *)
  680. X            echo "*** Error -- try again."
  681. X            ans=!
  682. X            ;;
  683. X        esac
  684. X        $myecho
  685. X        ;;
  686. X    esac
  687. X    case "\$ans\$xxxm\$nostick" in
  688. X    '')
  689. X        ans=!
  690. X        $myecho
  691. X        ;;
  692. X    esac
  693. Xdone
  694. Xcase "\$ans" in
  695. X'') ans="\$xxxm";;
  696. Xesac
  697. XEOSC
  698. X
  699. X: create .config dir to save info across Configure sessions
  700. Xtest -d ../.config || mkdir ../.config
  701. Xcat >../.config/README <<EOF
  702. XThis directory created by Configure to save information that should
  703. Xpersist across sessions.
  704. X
  705. XYou may safely delete it if you wish.
  706. XEOF
  707. X
  708. X: general instructions
  709. Xneedman=true
  710. Xfirsttime=true
  711. Xuser=`( (logname) 2>/dev/null || whoami) 2>&1`
  712. Xif $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
  713. X    firsttime=false
  714. X    echo " "
  715. X    rp='Would you like to see the instructions?'
  716. X    dflt=n
  717. X    . ./myread
  718. X    case "$ans" in
  719. X    [yY]*) ;;
  720. X    *) needman=false;;
  721. X    esac
  722. Xfi
  723. Xif $needman; then
  724. X    cat <<EOH
  725. XThis installation shell script will examine your system and ask you questions
  726. Xto determine how the c2man package should be installed. If you get
  727. Xstuck on a question, you may use a ! shell escape to start a subshell or
  728. Xexecute a command.  Many of the questions will have default answers in square
  729. Xbrackets; typing carriage return will give you the default.
  730. X
  731. XOn some of the questions which ask for file or directory names you are allowed
  732. Xto use the ~name construct to specify the login directory belonging to "name",
  733. Xeven if you don't have a shell which knows about that.  Questions where this is
  734. Xallowed will be marked "(~name ok)".
  735. X
  736. XEOH
  737. X    rp=''
  738. X    dflt='Type carriage return to continue'
  739. X    . ./myread
  740. X    cat <<'EOH'
  741. X
  742. XThe prompter used in this script allows you to use shell variables and
  743. Xbackticks in your answers.  You may use $1, $2, etc...  to refer to the words
  744. Xin the default answer, as if the default line was a set of arguments given to a
  745. Xscript shell.  This means you may also use $* to repeat the whole default line,
  746. Xso you do not have to re-type everything to add something to the default.
  747. X
  748. XEverytime there is a substitution, you will have to confirm.  If there is an
  749. Xerror (e.g. an unmatched backtick), the default answer will remain unchanged
  750. Xand you will be prompted again.
  751. X
  752. XIf you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
  753. Xthe questions and use the computed defaults (or the previous answers if there
  754. Xwas already a config.sh file). Type 'Configure -h' for a list of options.
  755. X
  756. XEOH
  757. X    . ./myread
  758. X    cat <<EOH
  759. X
  760. XMuch effort has been expended to ensure that this shell script will run on any
  761. XUnix system.  If despite that it blows up on yours, your best bet is to edit
  762. XConfigure and run it again.  Also, let me (greyham@research.canon.oz.au)
  763. Xknow how I blew it.  If you can't run Configure for some reason, you'll have to
  764. Xgenerate a config.sh file by hand.
  765. X
  766. XThis installation script affects things in two ways:
  767. X
  768. X1) it may do direct variable substitutions on some of the files included
  769. X   in this kit.
  770. X2) it builds a config.h file for inclusion in C programs.  You may edit
  771. X   any of these files as the need arises after running this script.
  772. X
  773. XIf you make a mistake on a question, there is no easy way to back up to it
  774. Xcurrently.  The easiest thing to do is to edit config.sh and rerun all the SH
  775. Xfiles.  Configure will offer to let you do this before it runs the SH files.
  776. X
  777. XEOH
  778. X    dflt='Type carriage return to continue'
  779. X    . ./myread
  780. X    case "$firsttime" in
  781. X    true) echo $user >>../.config/instruct;;
  782. X    esac
  783. Xfi
  784. X
  785. X: see if sh knows # comments
  786. Xecho " "
  787. Xecho "Checking your sh to see if it knows about # comments..." >&4
  788. Xif sh -c '#' >/dev/null 2>&1 ; then
  789. X    echo "Your sh handles # comments correctly."
  790. X    shsharp=true
  791. X    spitshell=cat
  792. X    echo " "
  793. X    echo "Okay, let's see if #! works on this system..."
  794. X    echo "#!/bin/cat" >try
  795. X    $eunicefix try
  796. X    chmod +x try
  797. X    ./try > today
  798. X    if test -s today; then
  799. X        echo "It does."
  800. X        sharpbang='#!'
  801. X    else
  802. X        echo "#! /bin/cat" > try
  803. X        $eunicefix try
  804. X        chmod +x try
  805. X        ./try > today
  806. X        if test -s today; then
  807. X            echo "It does."
  808. X            sharpbang='#! '
  809. X        else
  810. X            echo "It's just a comment."
  811. X            sharpbang=': use '
  812. X        fi
  813. X    fi
  814. Xelse
  815. X    echo "Your sh doesn't grok # comments--I will strip them later on."
  816. X    shsharp=false
  817. X    echo "exec grep -v '^[     ]*#'" >spitshell
  818. X    chmod +x spitshell
  819. X    $eunicefix spitshell
  820. X    spitshell=`pwd`/spitshell
  821. X    echo "I presume that if # doesn't work, #! won't work either!"
  822. X    sharpbang=': use '
  823. Xfi
  824. Xrm -f try today
  825. X
  826. X: figure out how to guarantee sh startup
  827. Xecho " "
  828. Xecho "Checking out how to guarantee sh startup..." >&4
  829. Xcase "$SYSTYPE" in
  830. X*bsd*|sys5*) startsh=$sharpbang"/$SYSTYPE/bin/sh";;
  831. X*) startsh=$sharpbang'/bin/sh';;
  832. Xesac
  833. Xecho "Let's see if '$startsh' works..."
  834. Xcat >try <<EOSS
  835. X$startsh
  836. Xset abc
  837. Xtest "$?abc" != 1
  838. XEOSS
  839. X
  840. Xchmod +x try
  841. X$eunicefix try
  842. Xif ./try; then
  843. X    echo "Yup, it does."
  844. Xelse
  845. Xecho "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  846. Xfi
  847. Xrm -f try
  848. X
  849. X: find out where common programs are
  850. Xecho " "
  851. Xecho "Locating common programs..." >&4
  852. Xcat <<EOSC >loc
  853. X$startsh
  854. Xcase \$# in
  855. X0) exit 1;;
  856. Xesac
  857. Xthing=\$1
  858. Xshift
  859. Xdflt=\$1
  860. Xshift
  861. Xfor dir in \$*; do
  862. X    case "\$thing" in
  863. X    .)
  864. X    if test -d \$dir/\$thing; then
  865. X        echo \$dir
  866. X        exit 0
  867. X    fi
  868. X    ;;
  869. X    *)
  870. X    if test -f \$dir/\$thing; then
  871. X        echo \$dir/\$thing
  872. X        exit 0
  873. X    elif test -f \$dir/\$thing.exe; then
  874. X        : on Eunice apparently
  875. X        echo \$dir/\$thing
  876. X        exit 0
  877. X    fi
  878. X    ;;
  879. X    esac
  880. Xdone
  881. Xecho \$dflt
  882. Xexit 1
  883. XEOSC
  884. Xchmod +x loc
  885. X$eunicefix loc
  886. Xloclist="
  887. Xawk
  888. Xcat
  889. Xcp
  890. Xecho
  891. Xexpr
  892. Xgrep
  893. Xmv
  894. Xrm
  895. Xsed
  896. Xsort
  897. Xtr
  898. Xuniq
  899. X"
  900. Xtrylist="
  901. XMcc
  902. Xbison
  903. Xcpp
  904. Xdate
  905. Xflex
  906. Xmail
  907. Xnroff
  908. Xrmail
  909. Xsendmail
  910. Xsmail
  911. Xtest
  912. Xuname
  913. X"
  914. Xpth=`echo $PATH | sed -e 's/:/ /g'`
  915. Xpth="$pth /lib /usr/lib"
  916. Xfor file in $loclist; do
  917. X    xxx=`./loc $file $file $pth`
  918. X    eval $file=$xxx
  919. X    eval _$file=$xxx
  920. X    case "$xxx" in
  921. X    /*)
  922. X        echo $file is in $xxx.
  923. X        ;;
  924. X    *)
  925. X        echo "I don't know where $file is.  I hope it's in everyone's PATH."
  926. X        ;;
  927. X    esac
  928. Xdone
  929. Xecho " "
  930. Xecho "Don't worry if any of the following aren't found..."
  931. Xsay=offhand
  932. Xfor file in $trylist; do
  933. X    xxx=`./loc $file $file $pth`
  934. X    eval $file=$xxx
  935. X    eval _$file=$xxx
  936. X    case "$xxx" in
  937. X    /*)
  938. X        echo $file is in $xxx.
  939. X        ;;
  940. X    *)
  941. X        echo "I don't see $file out there, $say."
  942. X        say=either
  943. X        ;;
  944. X    esac
  945. Xdone
  946. Xcase "$egrep" in
  947. Xegrep)
  948. X    echo "Substituting grep for egrep."
  949. X    egrep=$grep
  950. X    ;;
  951. Xesac
  952. Xcase "$test" in
  953. Xtest)
  954. X    echo "Hopefully test is built into your sh."
  955. X    ;;
  956. X*)
  957. X    if sh -c "PATH= test true" >/dev/null 2>&1; then
  958. X        echo "Using the test built into your sh."
  959. X        test=test
  960. X        _test=test
  961. X    fi
  962. X    ;;
  963. Xesac
  964. Xcase "$echo" in
  965. Xecho)
  966. X    echo "Hopefully echo is built into your sh."
  967. X    ;;
  968. X'') ;;
  969. X*)
  970. X    echo " "
  971. Xecho "Checking compatibility between $echo and builtin echo (if any)..." >&4
  972. X    $echo $n "hi there$c" >foo1
  973. X    echo $n "hi there$c" >foo2
  974. X    if cmp foo1 foo2 >/dev/null 2>&1; then
  975. X        echo "They are compatible.  In fact, they may be identical."
  976. X    else
  977. X        case "$n" in
  978. X        '-n') n='' c='\c';;
  979. X        *) n='-n' c='';;
  980. X        esac
  981. X        cat <<FOO
  982. XThey are not compatible!  You are probably running ksh on a non-USG system.
  983. XI'll have to use $echo instead of the builtin, since Bourne shell doesn't
  984. Xhave echo built in and we may have to run some Bourne shell scripts.  That
  985. Xmeans I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
  986. X
  987. XFOO
  988. X        $echo $n "The star should be here-->$c"
  989. X        $echo "*"
  990. X    fi
  991. X    $rm -f foo1 foo2
  992. X    ;;
  993. Xesac
  994. X
  995. X: Try to determine whether config.sh was made on this system
  996. Xcase "$config_sh" in
  997. X'')
  998. Xmyuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
  999. Xmyuname=`echo $myuname | $sed -e 's/^[^=]*=//' | \
  1000. X    tr '[A-Z]' '[a-z]' | tr '\012' ' '`
  1001. Xdflt=n
  1002. Xif test -f ../config.sh; then
  1003. X    oldmyuname=''
  1004. X    if $contains myuname= ../config.sh >/dev/null 2>&1; then
  1005. X        eval "old`grep myuname= ../config.sh`"
  1006. X    fi
  1007. X    if test "X$myuname" = "X$oldmyuname"; then
  1008. X        dflt=y
  1009. X    fi
  1010. Xfi
  1011. X
  1012. X: Get old answers, if there is a config file out there
  1013. Xhint=default
  1014. Xif test -f ../config.sh; then
  1015. X    echo " "
  1016. X    rp="I see a config.sh file.  Shall I use it to set the defaults?"
  1017. X    . ./myread
  1018. X    case "$ans" in
  1019. X    n*|N*) echo "OK, I'll ignore it.";;
  1020. X    *)  echo "Fetching default answers from your old config.sh file..." >&4
  1021. X        tmp="$n"
  1022. X        tans="$c"
  1023. X        . ../config.sh
  1024. X        cp ../config.sh .
  1025. X        n="$tmp"
  1026. X        c="$tans"
  1027. X        hint=previous
  1028. X        ;;
  1029. X    esac
  1030. Xfi
  1031. X;;
  1032. X*)
  1033. X    echo " "
  1034. X    echo "Fetching default answers from $config_sh..." >&4
  1035. X    tmp="$n"
  1036. X    tans="$c"
  1037. X    cd ..
  1038. X    cp $config_sh config.sh 2>/dev/null
  1039. X    . ./config.sh
  1040. X    cd UU
  1041. X    cp ../config.sh .
  1042. X    n="$tmp"
  1043. X    c="$tans"
  1044. X    hint=previous
  1045. X    ;;
  1046. Xesac
  1047. X
  1048. X: Restore computed paths
  1049. Xfor file in $loclist $trylist; do
  1050. X    eval $file="\$_$file"
  1051. Xdone
  1052. X
  1053. X: who configured the system
  1054. Xcf_time=`$date 2>&1`
  1055. Xcf_by=`( (logname) 2>/dev/null || whoami) 2>&1`
  1056. X
  1057. X: determine where manual pages are on this system
  1058. Xecho " "
  1059. Xcase "$sysman" in
  1060. X'') 
  1061. X    syspath='/usr/man/man1 /usr/man/man1 /usr/man/mann'
  1062. X    syspath="$syspath /usr/man/manl /usr/man/local/man1"
  1063. X    syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
  1064. X    syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
  1065. X    syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
  1066. X    syspath="$syspath /usr/man/man.L /local/man/man1"
  1067. X    sysman=`./loc . $syspath`
  1068. X    ;;
  1069. Xesac
  1070. Xif $test -d "$sysman"; then
  1071. X    echo "System manual is in $sysman." >&4
  1072. Xelse
  1073. X    echo "Could not find manual pages in source form." >&4
  1074. Xfi
  1075. X
  1076. X: make some quick guesses about what we are up against
  1077. Xecho " "
  1078. X$echo $n "Hmm...  $c"
  1079. Xecho exit 1 >bsd
  1080. Xecho exit 1 >usg
  1081. Xecho exit 1 >v7
  1082. Xecho exit 1 >osf1
  1083. Xecho exit 1 >eunice
  1084. Xecho exit 1 >xenix
  1085. Xecho exit 1 >venix
  1086. Xd_bsd="$undef"
  1087. X$cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
  1088. Xif test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
  1089. Xthen
  1090. X    echo "Looks kind of like an OSF/1 system, but we'll see..."
  1091. X    echo exit 0 >osf1
  1092. Xelif test `echo abc | tr a-z A-Z` = Abc ; then
  1093. X    xxx=`./loc addbib blurfl $pth`
  1094. X    if $test -f $xxx; then
  1095. X    echo "Looks kind of like a USG system with BSD features, but we'll see..."
  1096. X        echo exit 0 >bsd
  1097. X        echo exit 0 >usg
  1098. X    else
  1099. X        if $contains SIGTSTP foo >/dev/null 2>&1 ; then
  1100. X            echo "Looks kind of like an extended USG system, but we'll see..."
  1101. X        else
  1102. X            echo "Looks kind of like a USG system, but we'll see..."
  1103. X        fi
  1104. X        echo exit 0 >usg
  1105. X    fi
  1106. Xelif $contains SIGTSTP foo >/dev/null 2>&1 ; then
  1107. X    echo "Looks kind of like a BSD system, but we'll see..."
  1108. X    d_bsd="$define"
  1109. X    echo exit 0 >bsd
  1110. Xelse
  1111. X    echo "Looks kind of like a Version 7 system, but we'll see..."
  1112. X    echo exit 0 >v7
  1113. Xfi
  1114. Xcase "$eunicefix" in
  1115. X*unixtovms*)
  1116. X    $cat <<'EOI'
  1117. XThere is, however, a strange, musty smell in the air that reminds me of
  1118. Xsomething...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  1119. XEOI
  1120. X    echo exit 0 >eunice
  1121. X    d_eunice="$define"
  1122. X: it so happens the Eunice I know will not run shell scripts in Unix format
  1123. X    ;;
  1124. X*)
  1125. X    echo " "
  1126. X    echo "Congratulations.  You aren't running Eunice."
  1127. X    d_eunice="$undef"
  1128. X    ;;
  1129. Xesac
  1130. Xif test -f /xenix; then
  1131. X    echo "Actually, this looks more like a XENIX system..."
  1132. X    echo exit 0 >xenix
  1133. X    d_xenix="$define"
  1134. Xelse
  1135. X    echo " "
  1136. X    echo "It's not Xenix..."
  1137. X    d_xenix="$undef"
  1138. Xfi
  1139. Xchmod +x xenix
  1140. X$eunicefix xenix
  1141. Xif test -f /venix; then
  1142. X    echo "Actually, this looks more like a VENIX system..."
  1143. X    echo exit 0 >venix
  1144. Xelse
  1145. X    echo " "
  1146. X    if xenix; then
  1147. X        : null
  1148. X    else
  1149. X        echo "Nor is it Venix..."
  1150. X    fi
  1151. Xfi
  1152. Xchmod +x bsd usg v7 osf1 eunice xenix venix
  1153. X$eunicefix bsd usg v7 osf1 eunice xenix venix
  1154. X$rm -f foo
  1155. X
  1156. X: see if we need a special compiler
  1157. Xecho " "
  1158. Xif usg; then
  1159. X    case "$cc" in
  1160. X    '') case "$Mcc" in
  1161. X        /*) dflt='Mcc';;
  1162. X        *) case "$large" in
  1163. X            -M*) dflt='cc';;
  1164. X            *)    if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
  1165. X                    if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
  1166. X                        dflt='cc'
  1167. X                    else
  1168. X                        dflt='cc -M'
  1169. X                    fi
  1170. X                else
  1171. X                    dflt='cc'
  1172. X                fi;;
  1173. X            esac;;
  1174. X        esac;;
  1175. X    *)  dflt="$cc";;
  1176. X    esac
  1177. X    $cat <<'EOM'
  1178. XOn some systems the default C compiler will not resolve multiple global
  1179. Xreferences that happen to have the same name.  On some such systems the "Mcc"
  1180. Xcommand may be used to force these to be resolved.  On other systems a "cc -M"
  1181. Xcommand is required.  (Note that the -M flag on other systems indicates a
  1182. Xmemory model to use!) If you have the Gnu C compiler, you might wish to use
  1183. Xthat instead.
  1184. X
  1185. XEOM
  1186. X    rp="What command will force resolution on this system?"
  1187. X    . ./myread
  1188. X    cc="$ans"
  1189. Xelse
  1190. X    case "$cc" in
  1191. X    '') dflt=cc;;
  1192. X    *) dflt="$cc";;
  1193. X    esac
  1194. X    rp="Use which C compiler?"
  1195. X    . ./myread
  1196. X    cc="$ans"
  1197. Xfi
  1198. Xcase "$cc" in
  1199. Xgcc*) cpp=`./loc gcc-cpp $cpp $pth`;;
  1200. Xesac
  1201. X
  1202. X: decide how portable to be
  1203. Xcase "$d_portable" in
  1204. X"$define") dflt=y;;
  1205. X*)    dflt=n;;
  1206. Xesac
  1207. X$cat <<'EOH'
  1208. XI can set things up so that your shell scripts and binaries are more portable,
  1209. Xat what may be a noticable cost in performance.  In particular, if you
  1210. Xask to be portable, the following happens:
  1211. X
  1212. X     1) Shell scripts will rely on the PATH variable rather than using
  1213. X    the paths derived above.
  1214. X     2) ~username interpretations will be done at run time rather than
  1215. X    by Configure.
  1216. X
  1217. XEOH
  1218. Xrp="Do you expect to run these scripts and binaries on multiple machines?"
  1219. X. ./myread
  1220. Xcase "$ans" in
  1221. X    y*) d_portable="$define"
  1222. X    for file in $loclist $trylist; do
  1223. X        eval $file="\$file"
  1224. X    done
  1225. X    ;;
  1226. X    *)  d_portable="$undef" ;;
  1227. Xesac
  1228. X
  1229. X: set up shell script to do ~ expansion
  1230. Xcat >filexp <<EOSS
  1231. X$startsh
  1232. X: expand filename
  1233. Xcase "\$1" in
  1234. X ~/*|~)
  1235. X    echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
  1236. X    ;;
  1237. X ~*)
  1238. X    if $test -f /bin/csh; then
  1239. X        /bin/csh -f -c "glob \$1"
  1240. X        failed=$?
  1241. X        echo ""
  1242. X        exit \$failed
  1243. X    else
  1244. X        name=\`$expr x\$1 : '..\([^/]*\)'\`
  1245. X        dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
  1246. X        if $test ! -d "\$dir"; then
  1247. X            me=\`basename \$0\`
  1248. X            echo "\$me: can't locate home directory for: \$name" >&2
  1249. X            exit 1
  1250. X        fi
  1251. X        case "\$1" in
  1252. X        */*)
  1253. X            echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
  1254. X            ;;
  1255. X        *)
  1256. X            echo \$dir
  1257. X            ;;
  1258. X        esac
  1259. X    fi
  1260. X    ;;
  1261. X*)
  1262. X    echo \$1
  1263. X    ;;
  1264. Xesac
  1265. XEOSS
  1266. Xchmod +x filexp
  1267. X$eunicefix filexp
  1268. X
  1269. X: now set up to get a file name
  1270. Xcat <<'EOSC' >getfile
  1271. Xtilde=''
  1272. Xfullpath=''
  1273. Xalready=''
  1274. Xskip=''
  1275. Xnone_ok=''
  1276. Xexp_file=''
  1277. Xorig_rp="$rp"
  1278. Xorig_dflt="$dflt"
  1279. X
  1280. Xcase "$fn" in
  1281. X*~*) tilde=true;;
  1282. Xesac
  1283. Xcase "$fn" in
  1284. X*/*) fullpath=true;;
  1285. Xesac
  1286. Xcase "$fn" in
  1287. X*+*) skip=true;;
  1288. Xesac
  1289. Xcase "$fn" in
  1290. X*n*) none_ok=true;;
  1291. Xesac
  1292. Xcase "$fn" in
  1293. X*e*) exp_file=true;;
  1294. Xesac
  1295. X
  1296. Xcase "$fn" in
  1297. X*f*) type='File';;
  1298. X*d*) type='Directory';;
  1299. X*l*) type='Locate'; fn=`expr $fn : '.*:\(.*\)'`;;
  1300. Xesac
  1301. X
  1302. Xwhat="$type"
  1303. Xcase "$what" in
  1304. XLocate) what='File';;
  1305. Xesac
  1306. X
  1307. Xcase "$exp_file" in
  1308. X'')
  1309. X    case "$d_portable" in
  1310. X    "$define") ;;
  1311. X    *) exp_file=true;;
  1312. X    esac
  1313. X    ;;
  1314. Xesac
  1315. X
  1316. Xcd ..
  1317. Xwhile test "$type"; do
  1318. X    redo=''
  1319. X    rp="$orig_rp"
  1320. X    dflt="$orig_dflt"
  1321. X    case "$tilde" in
  1322. X    true) rp="$rp (~name ok)";;
  1323. X    esac
  1324. X    . UU/myread
  1325. X    case "$ans" in
  1326. X    none)
  1327. X        value=''
  1328. X        ansexp=''
  1329. X        case "$none_ok" in
  1330. X        true) type='';;
  1331. X        esac
  1332. X        ;;
  1333. X    *)
  1334. X        case "$tilde" in
  1335. X        '') value="$ans"
  1336. X            ansexp="$ans";;
  1337. X        *)
  1338. X            value=`UU/filexp $ans`
  1339. X            case $? in
  1340. X            0)
  1341. X                if test "$ans" != "$value"; then
  1342. X                    echo "(That is $value on this particular system.)"
  1343. X                fi
  1344. X                ;;
  1345. X            *) value="$ans";;
  1346. X            esac
  1347. X            ansexp="$value"
  1348. X            case "$exp_file" in
  1349. X            '') value="$ans";;
  1350. X            esac
  1351. X            ;;
  1352. X        esac
  1353. X        case "$fullpath" in
  1354. X        true)
  1355. X            case "$ansexp" in
  1356. X            /*) value="$ansexp" ;;
  1357. X            *)
  1358. X                redo=true
  1359. X                case "$already" in
  1360. X                true)
  1361. X                echo "I shall only accept a full path name, as in /bin/ls." >&4
  1362. X                echo "Use a ! shell escape if you wish to check pathnames." >&4
  1363. X                    ;;
  1364. X                *)
  1365. X                echo "Please give a full path name, starting with slash." >&4
  1366. X                    case "$tilde" in
  1367. X                    true)
  1368. X                echo "Note that using ~name is ok provided it expands well." >&4
  1369. X                        already=true
  1370. X                        ;;
  1371. X                    esac
  1372. X                esac
  1373. X                ;;
  1374. X            esac
  1375. X            ;;
  1376. X        esac
  1377. X        case "$redo" in
  1378. X        '')
  1379. X            case "$type" in
  1380. X            File)
  1381. X                if test -f "$ansexp"; then
  1382. X                    type=''
  1383. X                elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
  1384. X                then
  1385. X                    echo "($value is not a plain file, but that's ok.)"
  1386. X                    type=''
  1387. X                fi
  1388. X                ;;
  1389. X            Directory)
  1390. X                if test -d "$ansexp"; then
  1391. X                    type=''
  1392. X                fi
  1393. X                ;;
  1394. X            Locate)
  1395. X                if test -d "$value"; then
  1396. X                    echo "(Looking for $fn in directory $value.)"
  1397. X                    value="$value/$fn"
  1398. X                fi
  1399. X                if test -f "$value"; then
  1400. X                    type=''
  1401. X                fi
  1402. X                ;;
  1403. X            esac
  1404. X
  1405. X            case "$skip" in
  1406. X            true) type='';
  1407. X            esac
  1408. X
  1409. X            case "$type" in
  1410. X            '') ;;
  1411. X            *)
  1412. X                if test "$fastread" = yes; then
  1413. X                    dflt=y
  1414. X                else
  1415. X                    dflt=n
  1416. X                fi
  1417. X                rp="$what $value doesn't exist.  Use that name anyway?"
  1418. X                . UU/myread
  1419. X                dflt=''
  1420. X                case "$ans" in
  1421. X                y*) type='';;
  1422. X                *) echo " ";;
  1423. X                esac
  1424. X                ;;
  1425. X            esac
  1426. X            ;;
  1427. X        esac
  1428. X        ;;
  1429. X    esac
  1430. Xdone
  1431. Xcd UU
  1432. Xans="$value"
  1433. Xrp="$orig_rp"
  1434. Xdflt="$orig_dflt"
  1435. XEOSC
  1436. X
  1437. X: What should the include directory be ?
  1438. Xecho " "
  1439. X$echo $n "Hmm...  $c"
  1440. Xcase "$usrinc" in
  1441. X'') dflt='/usr/include';;
  1442. X*) dflt=$usrinc;;
  1443. Xesac
  1444. Xincpath=''
  1445. Xmips_type=''
  1446. Xif $test -f /bin/mips && /bin/mips; then
  1447. X    echo "Looks like a MIPS system..."
  1448. X    $cat >usr.c <<'EOCP'
  1449. X#ifdef SYSTYPE_BSD43
  1450. X/bsd43
  1451. X#endif
  1452. XEOCP
  1453. X    if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
  1454. X        dflt='/bsd43/usr/include'
  1455. X        incpath='/bsd43'
  1456. X        mips_type='BSD 4.3'
  1457. X    else
  1458. X        mips_type='System V'
  1459. X    fi
  1460. X    $rm -f usr.c usr.out
  1461. X    echo "and you're compiling with the $mips_type compiler and libraries."
  1462. Xelse
  1463. X    echo "Doesn't look like a MIPS system."
  1464. X    echo "exit 1" >mips
  1465. X    chmod +x mips
  1466. X    $eunicefix mips
  1467. Xfi
  1468. Xecho " "
  1469. Xfn=d/
  1470. Xrp='Where are the include files you want to use?'
  1471. X. ./getfile
  1472. Xusrinc="$ans"
  1473. X
  1474. X: determine optimize, if desired, or use for debug flag also
  1475. Xcase "$optimize" in
  1476. X' ') dflt="none";;
  1477. X'') dflt="-O";;
  1478. X*) dflt="$optimize";;
  1479. Xesac
  1480. X$cat <<EOH
  1481. X
  1482. XSome C compilers have problems with their optimizers, by default, $package
  1483. Xcompiles with the -O flag to use the optimizer.  Alternately, you might want
  1484. Xto use the symbolic debugger, which uses the -g flag (on traditional Unix
  1485. Xsystems).  Either flag can be specified here.  To use neither flag, specify
  1486. Xthe word "none".
  1487. X
  1488. XEOH
  1489. Xrp="What optimizer/debugger flag should be used?"
  1490. X. ./myread
  1491. Xoptimize="$ans"
  1492. Xcase "$optimize" in
  1493. X'none') optimize=" ";;
  1494. Xesac
  1495. X
  1496. Xcase "$ccflags" in
  1497. X'')    case "$cc" in
  1498. X    *gcc*) dflt='-fpcc-struct-return';;
  1499. X    *) dflt='';;
  1500. X    esac
  1501. X    case "$optimize" in
  1502. X    *-g*) dflt="$dflt -DDEBUG";;
  1503. X    esac
  1504. X    case "$cc" in
  1505. X    *gcc*)    if test -d /etc/conf/kconfig.d &&
  1506. X          $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
  1507. X        then
  1508. X            dflt="$dflt -posix"
  1509. X        fi
  1510. X        ;;
  1511. X    esac
  1512. X    ;;
  1513. X*) dflt="$ccflags" ;;
  1514. Xesac
  1515. X
  1516. Xcase "$mips_type" in
  1517. X*BSD*) ;;
  1518. X'') ;;
  1519. X*) inclwanted="$inclwanted $usrinc/bsd";;
  1520. Xesac
  1521. Xfor thisincl in $inclwanted; do
  1522. X    if $test -d $thisincl; then
  1523. X        if $test x$thisincl != x$usrinc; then
  1524. X            case "$dflt" in
  1525. X            *$thisincl*);;
  1526. X            *) dflt="$dflt -I$thisincl";;
  1527. X            esac
  1528. X        fi
  1529. X    fi
  1530. Xdone
  1531. X
  1532. Xinctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
  1533. X    xxx=true;
  1534. Xelif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
  1535. X    xxx=true;
  1536. Xelse
  1537. X    xxx=false;
  1538. Xfi;
  1539. Xif $xxx; then
  1540. X    case "$dflt" in
  1541. X    *$2*);;
  1542. X    *) dflt="$dflt -D$2";;
  1543. X    esac;
  1544. Xfi'
  1545. X
  1546. Xif ./osf1; then
  1547. X    set signal.h __LANGUAGE_C__; eval $inctest
  1548. Xelse
  1549. X    set signal.h LANGUAGE_C; eval $inctest
  1550. Xfi
  1551. Xset signal.h NO_PROTOTYPE; eval $inctest
  1552. Xset signal.h _NO_PROTO; eval $inctest
  1553. X
  1554. Xcase "$dflt" in
  1555. X'') dflt=none;;
  1556. Xesac
  1557. X$cat <<EOH
  1558. X
  1559. XYour C compiler may want other flags.  For this question you should include
  1560. X-I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
  1561. Xbut you should NOT include libraries or ld flags like -lwhatever.  If you
  1562. Xwant $package to honor its debug switch, you should include -DDEBUG here.
  1563. XTo use no flags, specify the word "none".
  1564. X
  1565. XEOH
  1566. Xset X $dflt
  1567. Xshift
  1568. Xdflt=${1+"$@"}
  1569. Xrp="Any additional cc flags?"
  1570. X. ./myread
  1571. Xcase "$ans" in
  1572. Xnone) ccflags='';;
  1573. X*) ccflags="$ans";;
  1574. Xesac
  1575. X
  1576. X: the following weeds options from ccflags that are of no interest to cpp
  1577. Xcppflags="$ccflags"
  1578. Xcase "$cc" in
  1579. X*gcc*) cppflags="$cppflags -D__GNUC__";;
  1580. Xesac
  1581. Xcase "$mips_type" in
  1582. X'');;
  1583. X*BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
  1584. Xesac
  1585. Xcase "$cppflags" in
  1586. X'');;
  1587. X*)  set X $cppflags
  1588. X    cppflags=''
  1589. X    for flag
  1590. X    do
  1591. X        case $flag in
  1592. X        -D*|-I*|-traditional|-ansi|-nostdinc) cppflags="$cppflags $flag";;
  1593. X        esac
  1594. X    done
  1595. X    case "$cppflags" in
  1596. X    *-*)  echo "(C preprocessor flags: $cppflags)";;
  1597. X    esac
  1598. X    ;;
  1599. Xesac
  1600. X
  1601. X: flags used in final linking phase
  1602. Xcase "$ldflags" in
  1603. X'') if venix; then
  1604. X        dflt='-i -z'
  1605. X    else
  1606. X        dflt='none'
  1607. X    fi
  1608. X    ;;
  1609. X*) dflt="$ldflags";;
  1610. Xesac
  1611. Xecho " "
  1612. Xrp="Any additional ld flags (NOT including libraries)?"
  1613. X. ./myread
  1614. Xcase "$ans" in
  1615. Xnone) ldflags='';;
  1616. X*) ldflags="$ans";;
  1617. Xesac
  1618. Xrmlist="$rmlist pdp11"
  1619. X
  1620. X: Initialize h_fcntl
  1621. Xh_fcntl=false
  1622. X
  1623. X: Initialize h_sysfile
  1624. Xh_sysfile=false
  1625. X
  1626. X: Set private lib path
  1627. Xcase "$plibpth" in
  1628. X'') if mips; then
  1629. X        plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
  1630. X    else
  1631. X        plibpth="/usr/ccs/lib /usr/lib /usr/ucblib /usr/local/lib"
  1632. X    fi;;
  1633. Xesac
  1634. Xlibpth="$plibpth $libpth"
  1635. X
  1636. X: Looking for optional libraries
  1637. Xecho " "
  1638. Xecho "Checking for optional libraries..." >&4
  1639. Xcase "$libs" in
  1640. X' '|'') dflt='';;
  1641. X*) dflt="$libs";;
  1642. Xesac
  1643. Xcase "$libswanted" in
  1644. X'') libswanted='c_s';;
  1645. Xesac
  1646. Xfor thislib in $libswanted; do
  1647. X    case "$thislib" in
  1648. X    dbm) thatlib=ndbm;;
  1649. X    *_s) thatlib=NONE;;
  1650. X    *) thatlib="${thislib}_s";;
  1651. X    *) thatlib=NONE;;
  1652. X    esac
  1653. X    yyy="$incpath/usr/ccs/lib $incpath/usr/lib $incpath/usr/ucblib"
  1654. X    yyy="$yyy $incpath/usr/local/lib $incpath/lib"
  1655. X    xxx=`./loc lib$thislib.a X $yyy`
  1656. X    if $test -f $xxx; then
  1657. X        echo "Found -l$thislib."
  1658. X        case "$dflt" in
  1659. X        *-l$thislib*|*-l$thatlib*);;
  1660. X        *) dflt="$dflt -l$thislib";;
  1661. X        esac
  1662. X    else
  1663. X        xxx=`./loc lib$thislib.a X $libpth`
  1664. X        if $test -f $xxx; then
  1665. X            echo "Found $xxx."
  1666. X            case "$dflt" in
  1667. X            *$xxx*);;
  1668. X            *) dflt="$dflt $xxx";;
  1669. X            esac
  1670. X        else
  1671. X            xxx=`./loc Slib$thislib.a X $xlibpth`
  1672. X            if $test -f $xxx; then
  1673. X                echo "Found -l$thislib."
  1674. X                case "$dflt" in
  1675. X                *-l$thislib*|*-l$thatlib*);;
  1676. X                *) dflt="$dflt -l$thislib";;
  1677. X                esac
  1678. X            else
  1679. X                echo "No -l$thislib."
  1680. X            fi
  1681. X        fi
  1682. X    fi
  1683. Xdone
  1684. Xset X $dflt
  1685. Xshift
  1686. Xdflt="$*"
  1687. Xcase "$libs" in
  1688. X'') dflt="$dflt";;
  1689. X*) dflt="$libs";;
  1690. Xesac
  1691. Xcase "$dflt" in
  1692. X' '|'') dflt='none';;
  1693. Xesac
  1694. X
  1695. X$cat <<EOM
  1696. XSome versions of Unix support shared libraries, which make executables smaller
  1697. Xbut make load time slightly longer.
  1698. X
  1699. XOn some systems, mostly newer Unix System V's, the shared library is included
  1700. Xby putting the option "-lc_s" as the last thing on the cc command line when
  1701. Xlinking.  Other systems use shared libraries by default.  There may be other
  1702. Xlibraries needed to compile $package on your machine as well.  If your system
  1703. Xneeds the "-lc_s" option, include it here.  Include any other special libraries
  1704. Xhere as well.  Say "none" for none.
  1705. XEOM
  1706. X
  1707. Xecho " "
  1708. Xrp="Any additional libraries?"
  1709. X. ./myread
  1710. Xcase "$ans" in
  1711. Xnone) libs=' ';;
  1712. X*) libs="$ans";;
  1713. Xesac
  1714. X
  1715. X: see if nm is to be used to determine whether a symbol is defined or not
  1716. Xcase "$usenm" in
  1717. X'')
  1718. X    dflt=`egrep 'inlibc|csym' ../Configure | wc -l 2>/dev/null`
  1719. X    if $test $dflt -gt 20; then
  1720. X        dflt=y
  1721. X    else
  1722. X        dflt=n
  1723. X    fi
  1724. X    ;;
  1725. X*)
  1726. X    case "$usenm" in
  1727. X    true) dflt=y;;
  1728. X    *) dflt=n;;
  1729. X    esac
  1730. X    ;;
  1731. Xesac
  1732. X$cat <<EOM
  1733. X
  1734. XI can use 'nm' to extract the symbols from your C libraries. This is a time
  1735. Xconsuming task which may generate huge output on the disk (up to 3 megabytes)
  1736. Xbut that should make the symbols extraction faster. The alternative is to skip
  1737. Xthe 'nm' extraction part and to compile a small test program instead to
  1738. Xdetermine whether each symbol is present. If you have a fast C compiler and/or
  1739. Xif your 'nm' output cannot be parsed, this may be the best solution.
  1740. X
  1741. XEOM
  1742. Xrp='Shall I use nm to extract C symbols from the libraries?'
  1743. X. ./myread
  1744. Xcase "$ans" in
  1745. Xn|N) usenm=false;;
  1746. X*) usenm=true;;
  1747. Xesac
  1748. X
  1749. Xrunnm=$usenm
  1750. Xcase "$reuseval" in
  1751. Xtrue) runnm=false;;
  1752. Xesac
  1753. X
  1754. X: nm options which may be necessary
  1755. Xcase "$nm_opt" in
  1756. X'') if $test -f /mach_boot; then
  1757. X        nm_opt=''
  1758. X    elif $test -d /usr/ccs/lib; then
  1759. X        nm_opt='-p'
  1760. X    elif $test -f /dgux; then
  1761. X        nm_opt='-p'
  1762. X    else
  1763. X        nm_opt=''
  1764. X    fi;;
  1765. Xesac
  1766. X
  1767. Xcase "$runnm" in
  1768. Xtrue)
  1769. X: get list of predefined functions in a handy place
  1770. Xecho " "
  1771. Xcase "$libc" in
  1772. X'') libc=unknown
  1773. X    case "$libs" in
  1774. X    *-lc_s*) libc=`./loc libc_s.a $libc $libpth`
  1775. X    esac
  1776. X    ;;
  1777. Xesac
  1778. Xlibpth="$plibpth $libpth"
  1779. Xlibnames='';
  1780. Xcase "$libs" in
  1781. X'') ;;
  1782. X*)  for thislib in $libs; do
  1783. X    case "$thislib" in
  1784. X    -l*)
  1785. X        thislib=`expr X$thislib : 'X-l\(.*\)'`
  1786. X        try=`./loc lib$thislib.a blurfl/dyick $libpth`
  1787. X        if test ! -f $try; then
  1788. X            try=`./loc lib$thislib blurfl/dyick $libpth`
  1789. X            if test ! -f $try; then
  1790. X                try=`./loc $thislib blurfl/dyick $libpth`
  1791. X                if test ! -f $try; then
  1792. X                    try=`./loc Slib$thislib.a blurfl/dyick $xlibpth`
  1793. X                    if test ! -f $try; then
  1794. X                        try=''
  1795. X                    fi
  1796. X                fi
  1797. X            fi
  1798. X        fi
  1799. X        libnames="$libnames $try"
  1800. X        ;;
  1801. X    *) libnames="$libnames $thislib" ;;
  1802. X    esac
  1803. X    done
  1804. X    ;;
  1805. Xesac
  1806. Xxxx=normal
  1807. Xcase "$libc" in
  1808. Xunknown)
  1809. X    set /usr/ccs/lib/libc.so
  1810. X    $test -r $1 || set /usr/lib/libc.so
  1811. X    $test -r $1 || set /usr/shlib/libc.so
  1812. X    $test -r $1 || set /usr/lib/libc.so.[0-9]*
  1813. X    $test -r $1 || set /lib/libsys_s.a
  1814. X    eval set \$$#
  1815. X    ;;
  1816. X*)
  1817. X    set blurfl
  1818. X    ;;
  1819. Xesac
  1820. Xif $test -r "$1"; then
  1821. X    echo "Your (shared) C library seems to be in $1."
  1822. X    libc="$1"
  1823. Xelif $test -r /lib/libc && $test -r /lib/clib; then
  1824. X    echo "Your C library seems to be in both /lib/clib and /lib/libc."
  1825. X    xxx=apollo
  1826. X    libc='/lib/clib /lib/libc'
  1827. X    if $test -r /lib/syslib; then
  1828. X        echo "(Your math library is in /lib/syslib.)"
  1829. X        libc="$libc /lib/syslib"
  1830. X    fi
  1831. Xelif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
  1832. X    echo "Your C library seems to be in $libc, as you said before."
  1833. Xelif $test -r $incpath/usr/lib/libc.a; then
  1834. X    libc=$incpath/usr/lib/libc.a;
  1835. X    echo "Your C library seems to be in $libc.  That's fine."
  1836. Xelif $test -r /lib/libc.a; then
  1837. X    libc=/lib/libc.a;
  1838. X    echo "Your C library seems to be in $libc.  You're normal."
  1839. Xelse
  1840. X    if tans=`./loc libc.a blurfl/dyick $libpth`; $test -r "$tans"; then
  1841. X        :
  1842. X    elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
  1843. X        libnames="$libnames "`./loc clib blurfl/dyick $libpth`
  1844. X    elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
  1845. X        :
  1846. X    elif tans=`./loc Slibc.a blurfl/dyick $xlibpth`; $test -r "$tans"; then
  1847. X        :
  1848. X    elif tans=`./loc Mlibc.a blurfl/dyick $xlibpth`; $test -r "$tans"; then
  1849. X        :
  1850. X    else
  1851. X        tans=`./loc Llibc.a blurfl/dyick $xlibpth`
  1852. X    fi
  1853. X    if $test -r "$tans"; then
  1854. X        echo "Your C library seems to be in $tans, of all places."
  1855. X        libc=$tans
  1856. X    else
  1857. X        libc='blurfl'
  1858. X    fi
  1859. Xfi
  1860. Xif $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
  1861. X    dflt="$libc"
  1862. X    cat <<EOM
  1863. X
  1864. XIf the guess above is wrong (which it might be if you're using a strange
  1865. Xcompiler, or your machine supports multiple models), you can override it here.
  1866. X
  1867. XEOM
  1868. Xelse
  1869. X    dflt=''
  1870. X    echo $libpth | tr ' ' '\012' | sort | uniq > libpath
  1871. X    cat >&4 <<EOM
  1872. XI can't seem to find your C library.  I've looked in the following places:
  1873. X
  1874. XEOM
  1875. X    $sed 's/^/    /' libpath
  1876. X    cat <<EOM
  1877. X
  1878. XNone of these seems to contain your C library. I need to get its name...
  1879. X
  1880. XEOM
  1881. Xfi
  1882. Xfn=f
  1883. Xrp='Where is your C library?'
  1884. X. ./getfile
  1885. Xlibc="$ans"
  1886. X
  1887. Xecho " "
  1888. Xecho $libc $libnames | tr ' ' '\012' | sort | uniq > libnames
  1889. Xset X `cat libnames`
  1890. Xshift
  1891. Xxxx=files
  1892. Xcase $# in 1) xxx=file; esac
  1893. Xecho "Extracting names from the following $xxx for later perusal:" >&4
  1894. Xecho " "
  1895. X$sed 's/^/    /' libnames >&4
  1896. Xecho " "
  1897. X$echo $n "This may take a while...$c" >&4
  1898. X
  1899. Xnm $nm_opt $* 2>/dev/null >libc.tmp
  1900. X$echo $n ".$c"
  1901. X$grep fprintf libc.tmp > libc.ptf
  1902. Xxscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
  1903. Xxrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
  1904. Xif com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
  1905. X    eval $xscan;\
  1906. X    $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1907. X        eval $xrun
  1908. Xelif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
  1909. X    eval $xscan;\
  1910. X    $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1911. X        eval $xrun
  1912. Xelif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
  1913. X    eval $xscan;\
  1914. X    $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1915. X        eval $xrun
  1916. Xelif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
  1917. X    eval $xscan;\
  1918. X    $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1919. X        eval $xrun
  1920. Xelif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
  1921. X    eval $xscan;\
  1922. X    $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1923. X        eval $xrun
  1924. Xelif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
  1925. X    eval $xscan;\
  1926. X    $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1927. X        eval $xrun
  1928. Xelif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
  1929. X                -e '/ file/d' -e 's/^\([^     ]*\).*/\1/p'";\
  1930. X    eval $xscan;\
  1931. X    $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1932. X        eval $xrun
  1933. Xelif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
  1934. X    eval $xscan;\
  1935. X    $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1936. X        eval $xrun
  1937. Xelif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
  1938. X    eval $xscan;\
  1939. X    $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1940. X        eval $xrun
  1941. Xelse
  1942. X    nm -p $* 2>/dev/null >libc.tmp
  1943. X    com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
  1944. X    eval "<libc.tmp $com >libc.list"
  1945. X    if $contains '^fprintf$' libc.list >/dev/null 2>&1; then
  1946. X        nm_opt='-p'
  1947. X        echo "done" >&4
  1948. X    else
  1949. X        echo " "
  1950. X        echo "nm didn't seem to work right. Trying ar instead..." >&4
  1951. X        com=''
  1952. X        if ar t $libc > libc.tmp; then
  1953. X            for thisname in $libnames; do
  1954. X                ar t $thisname >>libc.tmp
  1955. X            done
  1956. X            $sed -e 's/\.o$//' < libc.tmp > libc.list
  1957. X            echo "Ok." >&4
  1958. X        else
  1959. X            echo "ar didn't seem to work right." >&4
  1960. X            echo "Maybe this is a Cray...trying bld instead..." >&4
  1961. X            if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
  1962. X                for thisname in $libnames; do
  1963. X                    bld t $libnames | \
  1964. X                    $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
  1965. X                    ar t $thisname >>libc.tmp
  1966. X                done
  1967. X                echo "Ok." >&4
  1968. X            else
  1969. X                echo "That didn't work either.  Giving up." >&4
  1970. X                exit 1
  1971. X            fi
  1972. X        fi
  1973. X    fi
  1974. Xfi
  1975. Xnm_extract="$com"
  1976. Xif $test -f /lib/syscalls.exp; then
  1977. X    echo " "
  1978. X    echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
  1979. X    $sed -n 's/^\([^     ]*\)[     ]*syscall$/\1/p' /lib/syscalls.exp >>libc.list
  1980. Xfi
  1981. X;;
  1982. Xesac
  1983. X$rm -f libnames libpath
  1984. X
  1985. X: is a C symbol defined?
  1986. Xcsym='tlook=$1;
  1987. Xcase "$3" in
  1988. X-v) tf=libc.tmp; tc=""; tdc="";;
  1989. X-a) tf=libc.tmp; tc="[0]"; tdc=[];;
  1990. X*) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
  1991. Xesac;
  1992. Xtx=yes;
  1993. Xcase "$reuseval-$4" in
  1994. Xtrue-) ;;
  1995. Xtrue-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
  1996. Xesac;
  1997. Xcase "$tx" in
  1998. Xyes)
  1999. X    case "$runnm" in
  2000. X    true)
  2001. X        if $contains $tlook $tf >/dev/null 2>&1;
  2002. X        then tval=true;
  2003. X        else tval=false;
  2004. X        fi;;
  2005. X    *)
  2006. X        echo "main() { extern int $1$tdc; printf(\"%d\", $1$tc); }" > t.c;
  2007. X        if $cc $ccflags -o t t.c $ldflags $libs >/dev/null 2>&1;
  2008. X        then tval=true;
  2009. X        else tval=false;
  2010. X        fi;
  2011. X        $rm -f t t.c;;
  2012. X    esac;;
  2013. X*)
  2014. X    case "$tval" in
  2015. X    $define) tval=true;;
  2016. X    *) tval=false;;
  2017. X    esac;;
  2018. Xesac;
  2019. Xeval "$2=$tval"'
  2020. X
  2021. X: set up the script used to warn in case of inconsistency
  2022. Xcat <<'EOSC' >whoa
  2023. Xdflt=y
  2024. Xecho " "
  2025. Xecho "*** WHOA THERE!!! ***" >&4
  2026. Xecho "    The $hint value for \$$var on this machine was \"$was\"!" >&4
  2027. Xrp="    Keep the $hint value?"
  2028. X. ./myread
  2029. Xcase "$ans" in
  2030. Xy) td=$was; tu=$was;;
  2031. Xesac
  2032. XEOSC
  2033. X
  2034. X: define an is-in-libc? function
  2035. Xinlibc='echo " "; td=$define; tu=$undef;
  2036. Xsym=$1; var=$2; eval "was=\$$2";
  2037. Xtx=yes;
  2038. Xcase "$reuseval$was" in
  2039. Xtrue) ;;
  2040. Xtrue*) tx=no;;
  2041. Xesac;
  2042. Xcase "$tx" in
  2043. Xyes)
  2044. X    set $sym tres -f;
  2045. X    eval $csym;
  2046. X    case "$tres" in
  2047. X    true)
  2048. X        echo "$sym() found." >&4;
  2049. X        case "$was" in $undef) . whoa; esac; eval "$var=\$td";;
  2050. X    *)
  2051. X        echo "$sym() NOT found." >&4;
  2052. X        case "$was" in $define) . whoa; esac; eval "$var=\$tu";;
  2053. X    esac;;
  2054. X*)
  2055. X    case "$was" in
  2056. X    $define) echo "$sym() found." >&4;;
  2057. X    *) echo "$sym() NOT found." >&4;;
  2058. X    esac;;
  2059. Xesac'
  2060. X
  2061. X: see how we invoke the C preprocessor
  2062. Xecho " "
  2063. Xecho "Now, how can we feed standard input to your C preprocessor..." >&4
  2064. Xcat <<'EOT' >testcpp.c
  2065. X#define ABC abc
  2066. X#define XYZ xyz
  2067. XABC.XYZ
  2068. XEOT
  2069. Xcd ..
  2070. Xecho 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
  2071. Xchmod 755 cppstdin
  2072. Xwrapper=`pwd`/cppstdin
  2073. Xok='false'
  2074. Xcd UU
  2075. X
  2076. Xif $test "X$cppstdin" != "X" && \
  2077. X    $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
  2078. X    $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
  2079. Xthen
  2080. X    echo "You used to use $cppstdin $cppminus so we'll use that again."
  2081. X    case "$cpprun" in
  2082. X    '') echo "But let's see if we can live without a wrapper..." ;;
  2083. X    *)
  2084. X        if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
  2085. X            $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
  2086. X        then
  2087. X            echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
  2088. X            ok='true'
  2089. X        else
  2090. X            echo "(However, $cpprun $cpplast does not work, let's see...)"
  2091. X        fi
  2092. X        ;;
  2093. X    esac
  2094. Xelse
  2095. X    case "$cppstdin" in
  2096. X    '') ;;
  2097. X    *)
  2098. X        echo "Good old $cppstdin $cppminus does not seem to be of any help..."
  2099. X        ;;
  2100. X    esac
  2101. Xfi
  2102. X
  2103. Xif $ok; then
  2104. X    : nothing
  2105. Xelif echo 'Maybe "'"$cc"' -E" will work...'; \
  2106. X    $cc -E <testcpp.c >testcpp.out 2>&1; \
  2107. X    $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2108. X    echo "Yup, it does."
  2109. X    x_cpp="$cc -E"
  2110. X    x_minus='';
  2111. Xelif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
  2112. X    $cc -E - <testcpp.c >testcpp.out 2>&1; \
  2113. X    $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2114. X    echo "Yup, it does."
  2115. X    x_cpp="$cc -E"
  2116. X    x_minus='-';
  2117. Xelif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
  2118. X    $cc -P <testcpp.c >testcpp.out 2>&1; \
  2119. X    $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2120. X    echo "Yipee, that works!"
  2121. X    x_cpp="$cc -P"
  2122. X    x_minus='';
  2123. Xelif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
  2124. X    $cc -P - <testcpp.c >testcpp.out 2>&1; \
  2125. X    $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2126. X    echo "At long last!"
  2127. X    x_cpp="$cc -P"
  2128. X    x_minus='-';
  2129. Xelif echo 'No such luck, maybe "'$cpp'" will work...'; \
  2130. X    $cpp <testcpp.c >testcpp.out 2>&1; \
  2131. X    $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2132. X    echo "It works!"
  2133. X    x_cpp="$cpp"
  2134. X    x_minus='';
  2135. Xelif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
  2136. X    $cpp - <testcpp.c >testcpp.out 2>&1; \
  2137. X    $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2138. X    echo "Hooray, it works!  I was beginning to wonder."
  2139. X    x_cpp="$cpp"
  2140. X    x_minus='-';
  2141. Xelif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
  2142. X    $wrapper <testcpp.c >testcpp.out 2>&1; \
  2143. X    $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2144. X    x_cpp="$wrapper"
  2145. X    x_minus=''
  2146. X    echo "Eureka!"
  2147. Xelse
  2148. X    dflt=''
  2149. X    rp="No dice.  I can't find a C preprocessor.  Name one:"
  2150. X    . ./myread
  2151. X    x_cpp="$ans"
  2152. X    x_minus=''
  2153. X    $x_cpp <testcpp.c >testcpp.out 2>&1
  2154. X    if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  2155. X        echo "OK, that will do." >&4
  2156. X    else
  2157. Xecho "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
  2158. X        exit 1
  2159. X    fi
  2160. Xfi
  2161. X
  2162. Xcase "$ok" in
  2163. Xfalse)
  2164. X    cppstdin="$x_cpp"
  2165. X    cppminus="$x_minus"
  2166. X    cpprun="$x_cpp"
  2167. X    cpplast="$x_minus"
  2168. X    set X $x_cpp
  2169. X    shift
  2170. X    case "$1" in
  2171. X    "$cpp")
  2172. X        echo "Perhaps can we force $cc -E using a wrapper..."
  2173. X        if $wrapper <testcpp.c >testcpp.out 2>&1; \
  2174. X            $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
  2175. X        then
  2176. X            echo "Yup, we can."
  2177. X            cppstdin="$wrapper"
  2178. X            cppminus='';
  2179. X        else
  2180. X            echo "Nope, we'll have to live without it..."
  2181. X        fi
  2182. X        ;;
  2183. X    esac
  2184. X    case "$cpprun" in
  2185. X    "$wrapper")
  2186. X        cpprun=''
  2187. X        cpplast=''
  2188. X        ;;
  2189. X    esac
  2190. X    ;;
  2191. Xesac
  2192. X
  2193. Xcase "$cppstdin" in
  2194. X"$wrapper") ;;
  2195. X*) $rm -f $wrapper;;
  2196. Xesac
  2197. X$rm -f testcpp.c testcpp.out
  2198. X
  2199. X: determine filename position in cpp output
  2200. Xecho " "
  2201. Xecho "Computing filename position in cpp output for #include directives..." >&4
  2202. Xecho '#include <stdio.h>' > foo.c
  2203. X$cat >fieldn <<EOF
  2204. X$startsh
  2205. X$cppstdin $cppminus $cppflags <foo.c 2>/dev/null | \
  2206. X$grep '^[     ]*#.*stdio\.h' | \
  2207. Xwhile read cline; do
  2208. X    pos=1
  2209. X    set \$cline
  2210. X    while $test \$# -gt 0; do
  2211. X        if $test -r \`echo \$1 | $tr -d '"'\`; then
  2212. X            echo "\$pos"
  2213. X            exit 0
  2214. X        fi
  2215. X        shift
  2216. X        pos=\`expr \$pos + 1\`
  2217. X    done
  2218. Xdone
  2219. XEOF
  2220. Xchmod +x fieldn
  2221. Xfieldn=`./fieldn`
  2222. X$rm -f foo.c fieldn
  2223. Xcase $fieldn in
  2224. X'') pos='???';;
  2225. X1) pos=first;;
  2226. X2) pos=second;;
  2227. X3) pos=third;;
  2228. X*) pos="${fieldn}th";;
  2229. Xesac
  2230. Xecho "Your cpp writes the filename in the $pos field of the line."
  2231. X
  2232. X: locate header file
  2233. X$cat >findhdr <<EOF
  2234. X$startsh
  2235. Xwanted=\$1
  2236. Xname=''
  2237. Xif test -f $usrinc/\$wanted; then
  2238. X    echo "$usrinc/\$wanted"
  2239. X    exit 0
  2240. Xfi
  2241. Xawkprg='{ print \$$fieldn }'
  2242. Xecho "#include <\$wanted>" > foo\$\$.c
  2243. X$cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
  2244. X$grep "^[     ]*#.*\$wanted" | \
  2245. Xwhile read cline; do
  2246. X    name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
  2247. X    case "\$name" in
  2248. X    */\$wanted) echo "\$name"; exit 0;;
  2249. X    *) name='';;
  2250. X    esac;
  2251. Xdone;
  2252. X$rm -f foo\$\$.c;
  2253. Xcase "\$name" in
  2254. X'') exit 1;;
  2255. Xesac
  2256. XEOF
  2257. Xchmod +x findhdr
  2258. X
  2259. X: access call always available on UNIX
  2260. !STUFFY!FUNK!
  2261. echo "End of kit 2 (of 9)"
  2262. echo " "
  2263. cat /dev/null >kit2isdone
  2264. run=''
  2265. config=''
  2266. for iskit in 1 2 3 4 5 6 7 8 9; do
  2267.     if test -f kit${iskit}isdone; then
  2268.         run="$run $iskit"
  2269.     else
  2270.         todo="$todo $iskit"
  2271.     fi
  2272. done
  2273. case $todo in
  2274.     '')
  2275.         echo "You have run all your kits."
  2276.         if test -f PACKNOTES; then
  2277.             sh PACKNOTES
  2278.         else
  2279.             echo "You have to rebuild split files by hand (see PACKLIST)."
  2280.         fi
  2281.         echo "Please read README and then type Configure."
  2282.         chmod 755 Configure
  2283.         rm -f kit*isdone
  2284.         ;;
  2285.     *)  echo "You have run$run."
  2286.         echo "You still need to run$todo."
  2287.         ;;
  2288. esac
  2289. : Someone might mail this, so exit before signature...
  2290. exit 0
  2291. -- 
  2292. Graham Stoney, Hardware/Software Engineer
  2293. Canon Information Systems Research Australia
  2294. Ph: + 61 2 805 2909    Fax: + 61 2 805 2929
  2295.  
  2296. exit 0 # Just in case...
  2297.