home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / utility / patch / configur < prev    next >
Encoding:
Text File  |  1988-07-20  |  16.0 KB  |  510 lines

  1. #! /bin/sh
  2. #
  3. # If these # comments don't work, trim them.  Don't worry about any other
  4. # shell scripts, Configure will trim # comments from them for you.
  5. #
  6. # Note: if you are running ksh, be sure to say "sh Configure".
  7. #
  8. # (If you are trying to port this package to a machine without sh, I would
  9. # suggest you cut out the prototypical config.h from the end of Configure
  10. # and edit it to reflect your system.  Some packages may include samples
  11. # of config.h for certain machines, so you might look for one of those.)
  12. #
  13. # $Header: Configure,v 2.0 86/09/17 15:32:58 lwall Exp $
  14. #
  15. # $Log:    Configure,v $
  16. # Revision 2.0  86/09/17  15:32:58  lwall
  17. # Baseline for netwide release.
  18. #
  19. # Yes, you may rip this off to use in other distribution packages.
  20. #
  21. # (Note: this Configure script was generated automatically.  Rather than
  22. # working with this copy of Configure, you may wish to get metaconfig.)
  23.  
  24. define='define'
  25. undef='/*undef'
  26.  
  27. d_eunice=''
  28. eunicefix=''
  29. loclist=''
  30. expr=''
  31. sed=''
  32. echo=''
  33. cat=''
  34. rm=''
  35. mv=''
  36. cp=''
  37. tail=''
  38. tr=''
  39. mkdir=''
  40. sort=''
  41. uniq=''
  42. grep=''
  43. trylist=''
  44. test=''
  45. inews=''
  46. egrep=''
  47. more=''
  48. pg=''
  49. Mcc=''
  50. vi=''
  51. mailx=''
  52. Log=''
  53. Header=''
  54. bin=''
  55. cc=''
  56. contains=''
  57. cpp=''
  58. d_index=''
  59. d_void=''
  60. iandd=''
  61. libc=''
  62. mansrc=''
  63. manext=''
  64. n=''
  65. c=''
  66. package=''
  67. registers=''
  68. reg1=''
  69. reg2=''
  70. reg3=''
  71. reg4=''
  72. reg5=''
  73. reg6=''
  74. reg7=''
  75. reg8=''
  76. reg9=''
  77. reg10=''
  78. reg11=''
  79. reg12=''
  80. reg13=''
  81. reg14=''
  82. reg15=''
  83. reg16=''
  84. spitshell=''
  85. shsharp=''
  86. sharpbang=''
  87. startsh=''
  88. CONFIG=''
  89.  
  90. package=patch
  91.  
  92. echo "Beginning of configuration questions for $package kit."
  93. : Eunice requires " " instead of "", can you believe it
  94. echo " "
  95.  
  96. : sanity checks
  97. PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc'
  98. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  99.  
  100. if test ! -t 0; then
  101.     echo "Say 'sh Configure', not 'sh <Configure'"
  102.     exit 1
  103. fi
  104.  
  105. : some greps do not return status, grrr.
  106. echo "grimblepritz" >grimble
  107. if grep blurfldyick grimble >/dev/null 2>&1 ; then
  108.     contains=contains
  109. else
  110.     if grep grimblepritz grimble >/dev/null 2>&1 ; then
  111.     contains=grep
  112.     else
  113.     contains=contains
  114.     fi
  115. fi
  116. rm -f grimble
  117. : the following should work in any shell
  118. case "$contains" in
  119. contains*)
  120.     echo " "
  121.     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  122.     cat >contains <<'EOSS'
  123. grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  124. EOSS
  125. chmod 755 contains
  126. esac
  127.  
  128. : first determine how to suppress newline on echo command
  129. echo "Checking echo to see how to suppress newlines..."
  130. (echo "hi there\c" ; echo " ") >.echotmp
  131. if $contains c .echotmp >/dev/null 2>&1 ; then
  132.     echo "...using -n."
  133.     n='-n'
  134.     c=''
  135. else
  136.     echo "...using \\\c"
  137.     echo "c."
  138.     n=''
  139.     c='\c'
  140. fi
  141. echo $n "Type carriage return to continue.  Your cursor should be here-->$c"
  142. read ans
  143. rm -f .echotmp
  144.  
  145. : now set up to do reads with possible shell escape
  146. : if this does not work on your machine, 1,$ s/. myread/read ans/
  147. cat <<EOSC >myread
  148. ans='!'
  149. while expr "X\$ans" : "X!" >/dev/null; do
  150.     read ans
  151.     case "\$ans" in
  152.     !)
  153.     sh
  154.     echo " "
  155.     echo $n "\$rp $c"
  156.     ;;
  157.     !*)
  158.     set \`expr "X\$ans" : "X!\(.*\)\$"\`
  159.     sh -c "\$*"
  160.     echo " "
  161.     echo $n "\$rp $c"
  162.     ;;
  163.     esac
  164. done
  165. rp='Your answer:'
  166. EOSC
  167.  
  168. : general instructions
  169. cat <<EOH
  170.  
  171. This installation shell script will examine your system and ask you questions
  172. to determine how $package and any auxiliary files should be installed.  If you
  173. get stuck on a question, you may use a ! shell escape to start a subshell or
  174. execute a command.  Many of the questions will have default answers in
  175. square brackets--typing carriage return will give you the default.
  176.  
  177. On some of the questions which ask for file or directory names you are
  178. allowed to use the ~name construct to specify the login directory belonging
  179. to "name", even if you don't have a shell which knows about that.  Questions
  180. where this is allowed will be marked "(~name ok)".
  181. EOH
  182. rp="[Type carriage return to continue]"
  183. echo $n "$rp $c"
  184. . myread
  185. cat <<EOH
  186. Much effort has been expended to ensure that this shell script will run
  187. on any Unix system.  If despite that it blows up on you, your best bet is
  188. to edit Configure and run it again.  (Trying to install this package
  189. without having run Configure may be well nigh impossible.)  Also, let me
  190. (lwall@sdcrdcf.UUCP) know how I blew it.
  191.  
  192. This installation script affects things in two ways: 1) it may do direct
  193. variable substitutions on some of the files included in this kit, and
  194. 2) it builds a config.h file for inclusion in C programs.  You may edit
  195. any of these files as the need arises after running this script.
  196.  
  197. EOH
  198. rp="[Type carriage return to continue]"
  199. echo $n "$rp $c"
  200. . myread
  201.  
  202. : get old answers, if there is a config file out there
  203. if test -f config.sh; then
  204.     echo " "
  205.     rp="I see a config.sh file.  Did Configure make it on THIS system? [y]"
  206.     echo $n "$rp $c"
  207.     . myread
  208.     case "$ans" in
  209.     n*) echo "OK, I'll igno≥e it.";;
  210.     *)  echo "FetcΦing default answers from your old config.sh file..."
  211.         . config.sh
  212.     ;;
  213.     esac
  214. fi
  215.  
  216. : get list of predefined functions in a handy place
  217. ecbang'/bin/sh'
  218. echo "Let's see if '$startsh' works..."
  219. cat >try <<EOSS
  220. $startsh
  221. set abc
  222. test "$?abc" != 1
  223. EOSS
  224.  
  225. chmod 755 try
  226. $eunicefix try
  227. if try; then
  228.     echo "Yup, it does."
  229. else
  230.     echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  231. fi
  232. rm -f try today
  233.  
  234. : find out where common programs are
  235. echo " "
  236. echo "Locating common programs..."
  237. pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib"
  238. cat <<EOSC >loc
  239. $startsh
  240. thing=\$1
  241. shift
  242. dflt=\$1
  243. shift
  244. for dir in \$*; do
  245.     case "\$thing" in
  246.     .)
  247.     if test -d \$dir/\$thing; then
  248.         echo \$dir
  249.         exit 0
  250.     fi
  251.     ;;
  252.     *)
  253.     if test -f \$dir/\$thing; then
  254.         echo \$dir/\$thing
  255.         exit 0
  256.     fi
  257.     ;;
  258.     esac
  259. done
  260. echo \$dflt
  261. exit 1
  262. EOSC
  263. chmod 755 loc
  264. $eunicefix loc
  265. loclist="
  266. expr
  267. sed
  268. echo
  269. cat
  270. rm
  271. grep
  272. "
  273. trylist="
  274. test
  275. Mcc
  276. "
  277. for file in $loclist; do
  278.     xxx=`loc $file $file $pth`
  279.     eval $file=$xxx
  280.     case "$xxx" in
  281.     /*)
  282.     echo $file is in $xxx.
  283.     ;;
  284.     *)
  285.     echo "I don't know where $file is.  I hope it's in everyone's PATH."
  286.     ;;
  287.     esac
  288. done
  289. echo " "
  290. echo "Don't worry if any of the following aren't found..."
  291. ans=offhand
  292. for file in $trylist; do
  293.     xxx=`loc $file $file $pth`
  294.     eval $file=$xxx
  295.     case "$xxx" in
  296.     /*)
  297.     echo $file is in $xxx.
  298.     ;;
  299.     *)
  300.     echo "I don't see $file out there, $ans."
  301.     ans=either
  302.     ;;
  303.     esac
  304. done
  305. case "$egrep" in
  306. egrep)
  307.     echo "Substituting grep for egrep."
  308.     egrep=$grep
  309.     ;;
  310. esac
  311. case "$test" in
  312. test)
  313.     echo "Hopefully test is built into your sh."
  314.     ;;
  315. /bin/test)
  316.     echo " "
  317.     echo $n 'Is your "test" built into sh? [n] (OK to guess) '"$c"
  318.     rp='test built into sh? [n]'
  319.     . myread
  320.     case "$ans" in
  321.     y*) test=test ;;
  322.     esac
  323.     ;;
  324. *)
  325.     test=test
  326.     ;;
  327. esac
  328. case "$echo" in
  329. echo)
  330.     echo "Hopefully echo is built into your sh."
  331.     ;;
  332. /bin/echo)
  333.     echo " "
  334.     echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
  335.     $echo $n "hi there$c" >foo1
  336.     echo $n "hi there$c" >foo2
  337.     if cmp foo1 foo2 >/dev/null 2>&1; then
  338.     echo "They are compatible.  In fact, they may be identical."
  339.     else
  340.     echo "They are not compatible--the echo builtin will be used."
  341.     echo=echo
  342.     fi
  343.     $rm -f foo1 foo2
  344.     ;;
  345. *)
  346.     echo=echo
  347.     ;;
  348. esac
  349.  
  350. : index or strcpy
  351. $echo " "
  352. if $contains index libc.list >/dev/null 2>&1 ; then
  353.     $echo "Your system appears to use index() and rindex() rather than strchr()"
  354.     $echo $n "and strrchr().  Is this correct? [y] $c"
  355.     rp='index() rather than strchr()? [y]'
  356.     . myread
  357.     case "$ans" in
  358.     n*|f*) d_index="$define" ;;
  359.     *)     d_index="$undef" ;;
  360.     esac
  361. else
  362.     $echo "Your system appears to use strchr() and strrchr() rather than index()"
  363.     $echo $n "and rindex().  Is this correct? [y] $c"
  364.     rp='strchr() rather than index()? [y]'
  365.     . myread
  366.     case "$ans" in
  367.     n*|f*) d_index="$undef" ;;
  368.     *)     d_index="$define" ;;
  369.     esac
  370. fi
  371.  
  372. : check for void type
  373. $echo " "
  374. $echo "Checking to see if your C compiler groks the void type..."
  375. $cat >try.c <<'EOCP'
  376. void main();
  377. EOCP
  378. if cc -c try.c >/dev/null 2>&1 ; then
  379.     d_void="$undef"
  380.     $echo "Yup, it does."
  381. else
  382.     d_void="$define"
  383.     $echo "Nope, it doesn't (boo hiss).  I will substitute int."
  384. fi
  385. $rm -f try.*
  386.  
  387. : see how we invoke the C preprocessor
  388. echo " "
  389. echo "Checking to see how your C preprocessor is invoked..."
  390. cat <<'EOT' >testcpp.c
  391. #define ABC abc
  392. #define XYZ xyz
  393. ABC.XYZ
  394. EOT
  395. echo 'Maybe "cc -E" will work...'
  396. cc -E testcpp.c >testcpp.out 2>&1
  397. if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
  398.     echo "Yup, it does."
  399.     cpp='cc -E'
  400. else
  401.     echo 'Nope...maybe "cc -P" will work...'
  402.     cc -P testcpp.c >testcpp.out 2>&1
  403.     if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
  404.     echo "Yup, that does."
  405.     cpp='cc -P'
  406.     else
  407.     echo 'Nixed again...maybe "/lib/cpp" will work...'
  408.     /lib/cpp testcpp.c >testcpp.out 2>&1
  409.     if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
  410.         echo "Hooray, it works!  I was beginning to wonder."
  411.         cpp='/lib/cpp'
  412.     else
  413.         echo 'Hmm...maybe you already told me...'
  414.         case "$cpp" in
  415.         '') ;;
  416.         *) $cpp testcpp.c >testcpp.ou component. */
  417. X    if (chdir(p) < 0 && mkdir(p, 0777) < 0 && chdir(p) < 0)
  418. X        Quit("Cannot chdir nor mkdir desired directory");
  419. X    }
  420. X    else
  421. X    cwd[0] = '\0';
  422. X
  423. X    /* No buffering. */
  424. X    (void)setbuf(stdout, (char *)NULL);
  425. X    (void)setbuf(stderr, (char *)NULL);
  426. X
  427. X    if (*av)
  428. X    /* Process filenames from command line. */
  429. X    for (; *av; av++) {
  430. X        if (cwd[0] && av[0][0] != '/') {
  431. X        (void)sprintf(buff, "%s/%s", cwd, *av);
  432. X        *av = buff;
  433. X        }
  434. X        if ((Stream = fopen(*av, "r")) == NULL)
  435. X        Fprintf(stderr, "unshar:  Can't open file '%s'.\n", *av);
  436. X        else {
  437. X        Unshar(*av, HdrFile, Stream, Saveit, Forced);
  438. X        (void)fclose(Stream);
  439. X        }
  440. X    }
  441. X    else
  442. X    /* Do standard input. */
  443. X    Unshar((char *)NULL, HdrFile, stdin, Saveit, Forced);
  444. X
  445. X    /* That's all she wrote. */
  446. X    exit(0);
  447. X}
  448. SHAR_EOF
  449. if test 8368 -ne "`wc -c < 'unshar.c'`"
  450. then
  451.     echo shar: error transmitting "'unshar.c'" '(should have been 8368 characters)'
  452. fi
  453. fi # end of overwriting check
  454. echo shar: extracting "'unshar.man'" '(2326 characters)'
  455. if test -f 'unshar.man'
  456. then
  457.     echo shar: will not over-write existing file "'unshar.man'"
  458. else
  459. sed 's/^X//' << \SHAR_EOF > 'unshar.man'
  460. X.TH UNSHAR 1l
  461. X.\" $Header: unshar.man,v 2.0 88/05/27 13:29:02 rsalz Exp $
  462. X.SH NAME
  463. Xunshar \- unpack shell archives from news, mail, notes, etc.
  464. X.SH SYNOPSIS
  465. X.B unshar
  466. X[
  467. X.BI \-c\| directory
  468. X] [
  469. X.BI \-d\| directory
  470. X] [
  471. X.BI \-h\| file
  472. X] [
  473. X.B \-f
  474. X] [
  475. X.B \-n
  476. X] [
  477. X.B \-s
  478. X] [ file... ]
  479. X.SH DESCRIPTION
  480. X.I Unshar
  481. Xremoves mail and news header lines from its input, and feeds the remainder
  482. Xto
  483. X.IR /bin/sh (1)
  484. Xso that a shell archive can be properly unpacked.
  485. XIf no files are specified,
  486. X.I unshar
  487. Xreads from standard input.
  488. XThe program is designed to be useful when unpacking archives directly
  489. Xfrom the news or mail systems (e.g., s | unshar).
  490. X.PP
  491. X.I Unshar
  492. Xnormally unpacks its files in the current directory.
  493. XUse the ``\-c'' option to have the program change to a new directory
  494. Xbefore invoking the shell.
  495. XIf the directory does not exist, it will try to create it.
  496. XIf the directory name starts with a question mark, then
  497. X.I unshar
  498. Xwill ask for t⇨غךÄQ⇧Ç0ÉI≡①ij⇧    ±æ⇧⓪æ    ±0@①    ±ij⓪@0p@①✓    ≡0p@ë≡@ë≡ÅB◆PC+3½`Rב†KúA⇨úC)⇨+søKô{sk+sí⇨ø♪ôK♪③c)⇩¬rÜB
  499. Æ*"JæpRאK1⇨úC)⇨#Kô+ú{ôח⇨s♪k)⇨¢ú♪ôúÖ⇨†KúA⇨    ⇨úKc#)a⇨úC+q⇨úC)⇨ø♪c½)⇨{1⇨úC)⇩Bzj(Rב+søKô{sk+sí⇨ø♪ôK♪③c)⇨KÖ⇨Ks¢+ôú+!⇨Kq⇨âc♪)⇨{1⇨úC♪í⇨C♪ô♪ú+æpRא3{æ⇨{sø+sK+s)a⇨úC)⇨⇨⇩βk!99⇨{âúK{q⇨KÖ⇨    ⇨¢יs{sיi⇨3{æ⇨úC)⇨⇨⇩βk⑨99⇨{âúK{qpRIJréÇRIJrI⇩½s¢C♪ÉRבs{ôk♪ccח⇨{kâc♪KsÖ⇨K1⇨úC)⇨Ksâ½í⇨c{{[Ö⇨cK[)⇨¢{k+úCKs9⇨{úC+æ⇨úC♪q⇨    ⇨¢C♪æ⇨3Kc)pRIJB♪k{s9⇨ther things, it checks for files that resemble C, and Pascal code).
  500. XIt can be fooled, however, by nonstandard versions of news, notes, etc.
  501. XThe ``\-f'' option forces
  502. X.I unshar
  503. Xto try unpacking files, even if they look like something else.
  504. X.PP
  505. XDepending on how the program is installed,
  506. X.I unshar
  507. Xmay or may not try to preserve the header part of file ``foo''
  508. Xinto the name ``foo.hdr'' (if the file is standard input, the name
  509. XwilqנîêOÅÅÇ⓪ä③ß⇦ijôÖäזHB@≡âÇ⇦⇩êOüâêOÅÅüij⇦HHOÇ◆üéנêÇ⇦î✓⇦OüâêOçäÇ✓⇦ÄOüÇOä