home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / z / zsh220.zip / zsh2.2 / src / buildzsh next >
Text File  |  1992-05-02  |  12KB  |  431 lines

  1. #! /bin/sh
  2. echo
  3. echo 'Building config.h...
  4. '
  5. exec >config.h
  6. cat <<'foo'
  7. /* this file is created automatically by buildzsh */
  8.  
  9. /* define this if you are sysvish */
  10. foo
  11. if test -f /usr/include/sys/resource.h
  12. then echo '/* #define SYSV */'; echo 'looks like a BSDish system...' >&2
  13. else echo '#define SYSV'; echo 'looks like a SYSVish system...' >&2
  14. fi
  15. echo
  16. if grep ULTRIX /usr/include/stdio.h >/dev/null 2>&1
  17. then echo '/* ULTRIX termios is weird... */
  18. /* #define TERMIOS */'; echo 'using sgttyb...' >&2
  19. else
  20. if test -f /usr/include/termios.h && test ! -f /hp-ux
  21. then echo '#define TERMIOS
  22. /* #define TTY_NEEDS_DRAINING */
  23. /* #define CLOBBERS_TYPEAHEAD */'
  24. echo 'using termios...' >&2
  25. else
  26. if grep sgttyb /usr/include/sys/ioctl.h >/dev/null 2>&1
  27. then echo '/* #define TERMIO */'
  28. else echo '#define TERMIO'
  29. echo 'using termio...' >&2
  30. fi
  31. echo '#define TTY_NEEDS_DRAINING
  32. #define CLOBBERS_TYPEAHEAD'
  33. echo 'using sgttyb...' >&2
  34. fi
  35. fi
  36. echo
  37. if test -f /usr/include/stdlib.h
  38. then echo '#define HAS_STDLIB'; echo 'using <stdlib.h>...' >&2
  39. else echo '/*#define HAS_STDLIB*/'; echo 'not using <stdlib.h>...' >&2
  40. fi
  41. echo
  42. if test -f /usr/include/string.h
  43. then echo '#define HAS_STRING'; echo 'using <string.h>...' >&2
  44. else echo '/*#define HAS_STRING*/'; echo 'using <strings.h>...' >&2
  45. echo '#define strchr    index
  46. #define strrchr    rindex
  47. #define memcpy(dst, src, n)    bcopy(src, dst, n)
  48. #define memset(dst, ch, n)    bfill(dst, n, ch)
  49. #define memcmp(s1, s2, n)    bcopy(s1, s2, n)'
  50. fi
  51. echo
  52. if test -f /usr/include/locale.h
  53. then echo '#define HAS_LOCALE'; echo 'using <locale.h>...' >&2
  54. else echo '/*#define HAS_LOCALE*/'; echo 'not using <locale.h>...' >&2
  55. fi
  56. echo
  57. echo '/* define this if you have a host field in utmp */'
  58. if grep ut_host /usr/include/utmp.h >/dev/null
  59. then echo '#define UTMP_HOST'; echo 'host field in utmp...' >&2
  60. else echo '/* #define UTMP_HOST */'; echo 'no host field in utmp...' >&2
  61. fi
  62. echo
  63. echo '/* define this if you have WAITPID */'
  64. if man 2 wait 2>/dev/null | sed 's/_.//g' | grep waitpid >/dev/null
  65. then echo '#define WAITPID'; echo 'using waitpid()...' >&2
  66. else echo '/* #define WAITPID */'; echo 'not using waitpid()...' >&2
  67. fi
  68. echo
  69. echo '/* define this if you have SELECT */'
  70. if grep FD_SET /usr/include/sys/types.h >/dev/null ||
  71.     test -f /usr/include/sys/select.h
  72. then echo '#define HAS_SELECT'; echo 'using select()...' >&2
  73. else echo '/* #define HAS_SELECT */'; echo 'not using select()...' >&2
  74. fi
  75. echo
  76. echo '/* define this if you have <sys/select.h> */'
  77. if test -f /usr/include/sys/select.h
  78. then echo '#define HAS_SYS_SELECT'
  79. else echo '/* #define HAS_SYS_SELECT */'
  80. fi
  81. echo "
  82. /* we can't just test for S_IFIFO or check to see if the mknod worked,
  83.    because the NeXTs sold by a vendor which will remain nameless will
  84.    happily create the FIFO for you, and then panic when you try to do
  85.     something weird with them, because they aren't supported by the OS. */
  86. "
  87. if test -f /mach
  88. then echo '#define NO_FIFOS'; echo 'no FIFOs...' >&2
  89. else echo '/* #define NO_FIFOS */'; echo 'using FIFOs...' >&2
  90. fi
  91. echo
  92. echo '/* define this if you have strftime() */'
  93. if man 3 strftime 2>/dev/null | grep return >/dev/null
  94. then echo '#define HAS_STRFTIME'; echo 'using strftime()...' >&2
  95. else echo '/* #define HAS_STRFTIME */'; echo 'not using strftime()...' >&2
  96. fi
  97. echo
  98. if man tcsetpgrp 2>/dev/null | grep process >/dev/null
  99. then echo '#define HAS_TCSETPGRP'; echo 'using tcsetpgrp()...' >&2
  100. else echo '/* #define HAS_TCSETPGRP */'; echo 'not using tcsetpgrp()...' >&2
  101. fi
  102. echo
  103. if grep tcgetattr /usr/include/termios.h >/dev/null 2>/dev/null ||
  104.     grep tcgetattr /usr/include/sys/termios.h >/dev/null 2>/dev/null ||
  105.     grep tcgetattr /usr/include/sys/termio.h >/dev/null 2>/dev/null
  106. then echo '#define HAS_TCCRAP'; echo 'using tcgetattr() and friends...' >&2
  107. else echo '/* #define HAS_TCCRAP */'; echo 'not using tcgetattr()...' >&2
  108. fi
  109. echo
  110. if test -f /bin/hinv
  111. then echo '/* SGI setpgid() is weird...  setpgrp() is better anyway */
  112. /* #define HAS_SETPGID */'; echo 'using setpgrp()...' >&2
  113. elif man setpgid 2>/dev/null | grep process >/dev/null
  114. then echo '#define HAS_SETPGID'; echo 'using setpgid()...' >&2
  115. else echo '/* #define HAS_SETPGID */'; echo 'using setpgrp()...' >&2
  116. fi
  117. echo
  118. if test ! -f /hp-ux && man sigrelse 2>/dev/null | grep signal >/dev/null
  119. then echo '#define HAS_SIGRELSE'; echo 'using sigrelse()...' >&2
  120. else echo '/* #define HAS_SIGRELSE */'; echo 'using sigblock()...' >&2
  121. fi
  122. echo
  123. echo '/* define this if you have RFS */'
  124. if test -d /../.CONTROL
  125. then echo '#define HAS_RFS'; echo 'you seem to have RFS...' >&2
  126. else echo '/* #define HAS_RFS */'; echo 'no RFS, it seems...' >&2
  127. fi
  128. echo
  129. echo '/* define this if you have a working getrusage and wait3 */'
  130. if test -f /hp-ux
  131. then echo '/* #define HAS_RUSAGE */'; echo 'no getrusage...' >&2
  132. elif test -f /usr/include/sys/resource.h
  133. then echo '#define HAS_RUSAGE'; echo 'has getrusage...' >&2
  134. else echo '/* #define HAS_RUSAGE */'; echo 'no getrusage...' >&2
  135. fi
  136. echo '
  137. /* define this if your signal handlers return void */'
  138. if grep SIG_DFL /usr/include/signal.h /usr/include/sys/signal.h |
  139.     grep void >/dev/null
  140. then echo '#define SIGVOID'; echo 'signal handlers return void...' >&2
  141. else echo '/* #define SIGVOID */'; echo 'signal handlers return int...' >&2
  142. fi
  143. cat <<'foo'
  144. #ifdef sgi
  145. #undef SIGVOID
  146. #endif
  147. foo
  148. echo
  149. echo '/* define this if signal handlers need to be reset each time */'
  150. if grep SIGTSTP /usr/include/signal.h /usr/include/sys/signal.h >/dev/null
  151. then echo '/* #define RESETHANDNEEDED */'
  152. echo 'signal handlers need no resetting...' >&2
  153. else echo '#define RESETHANDNEEDED'
  154. echo 'signal handlers need to be reset...' >&2
  155. fi
  156. echo
  157. cat <<'foo'
  158. #ifdef SIGVOID
  159. #define HANDTYPE void
  160. #else
  161. #define HANDTYPE int
  162. #define INTHANDTYPE
  163. #endif
  164.  
  165. /* a string corresponding to the host type */
  166. foo
  167. echo '#define HOSTTYPE "' | tr -d '\012'
  168. host=`(tcsh -fc 'echo $HOSTTYPE' || arch) 2>/dev/null`
  169. case $host in
  170. '') if grep ULTRIX /usr/include/stdio.h >/dev/null 2>&1
  171.     then host=ultrix
  172.      elif test -f /bin/hinv
  173.      then host=iris
  174.      elif test -d /NextApps
  175.      then host=next
  176.      elif test $machine
  177.      then host=$machine
  178.      else
  179.      echo 1>&2 '
  180.  
  181. I cannot figure out what sort of host this is.  Please enter one
  182. short alphanumeric string describing this host.  (This will be used
  183. to set the $HOSTTYPE variable, so '"you don't have to be very
  184. accurate if you're not in a multivendor environment.)
  185. "
  186.      echo "? " | tr -d '\012' 1>&2
  187.      read host
  188.      echo ' ' 1>&2
  189.      fi
  190.   ;;
  191. esac
  192. echo $host'"'
  193. echo "using host type $host..." >&2
  194. echo
  195. echo '/* the default editor for the fc builtin */'
  196. echo '#define DEFFCEDIT "vi"'
  197. echo
  198. if grep UTMP_FILE /usr/include/utmp.h >/dev/null
  199. then :
  200. else 
  201. echo '/* the path of wtmp */'
  202. echo '#define WTMP_FILE "' | tr -d '\012'
  203. if test -f /etc/wtmp
  204. then echo /etc/wtmp
  205. elif test -f /usr/etc/wtmp
  206. then echo /usr/etc/wtmp
  207. elif test -f /var/adm/wtmp
  208. then echo /var/adm/wtmp
  209. elif test -f /usr/adm/wtmp
  210. then echo /usr/adm/wtmp
  211. else echo /dev/null
  212. fi | tr -d '\012'
  213. echo '"
  214.  
  215. /* the path of utmp */
  216. #define UTMP_FILE "/etc/utmp"
  217. '
  218. fi
  219. cat <<'foo'
  220. /* default prefix for temporary files */
  221. #define DEFTMPPREFIX "/tmp/zsh"
  222.  
  223. /* define if you prefer "suspended" to "stopped" */
  224. #define USE_SUSPENDED
  225.  
  226. /* the file to source whenever zsh is run; if undefined, don't source
  227.     anything */
  228. #define GLOBALZSHRC "/etc/zshrc"
  229.  
  230. /* the file to source whenever zsh is run as a login shell; if
  231.     undefined, don't source anything */
  232. #define GLOBALZLOGIN "/etc/zlogin"
  233.  
  234. /* the file to source whenever zsh is run as a login shell, before
  235.     zshrc is read; if undefined, don't source anything */
  236. #define GLOBALZPROFILE "/etc/zprofile"
  237.  
  238. /* the default HISTSIZE */
  239. #define DEFAULT_HISTSIZE 30
  240.  
  241. #define _BSD_SIGNALS   /* this could be an iris, you never know */
  242. #define _BSD           /* this could be HP-UX, you never know */
  243. #define _BSD_INCLUDES  /* this could be AIX, you never know */
  244.  
  245. /* if your compiler doesn't like void *, change this to char *
  246.     and ignore all the warnings.
  247. */
  248.  
  249. typedef void *vptr;
  250.  
  251. #define JOB_CONTROL
  252. foo
  253. exec 1>&2
  254. echo
  255. echo 'Building signals.h...' | tr -d '\012'
  256. echo `csh -fc 'kill -l'` | tr ' ' '\012' >signals.h
  257. lct=`wc -l < signals.h`
  258. cp signals.h signams.h
  259. (
  260. echo '/* this file is created automatically by buildzsh */
  261. /* if all this is wrong, blame csh ;-) */
  262.  
  263. #define SIGCOUNT '"$lct"'
  264.  
  265. #ifdef GLOBALS
  266.  
  267. char *sigmsg[SIGCOUNT+2] = {
  268.     "done",'
  269. sed -e 's/^/SIG/' -e '/SIGHUP/s//hangup/
  270. /SIGINT/s//interrupt/
  271. /SIGQUIT/s//quit/
  272. /SIGILL/s//illegal instruction/
  273. /SIGTRAP/s//trace trap/
  274. /SIGIOT/s//IOT instruction/
  275. /SIGABRT/s//abort/
  276. /SIGEMT/s//EMT instruction/
  277. /SIGFPE/s//floating point exception/
  278. /SIGKILL/s//killed/
  279. /SIGBUS/s//bus error/
  280. /SIGSEGV/s//segmentation fault/
  281. /SIGSYS/s//bad system call/
  282. /SIGPIPE/s//broken pipe/
  283. /SIGTERM/s//terminated/
  284. /SIGPWR/s//power fail/
  285. /SIGVTALRM/s//virtual time alarm/
  286. /SIGCONT/s//continued/
  287. /SIGXCPU/s//cpu limit exceeded/
  288. /SIGXFSZ/s//filesize limit exceeded/' -e 's/.*/    "&",/' signals.h
  289. echo '    NULL
  290. };
  291.  
  292. char *sigs[SIGCOUNT+4] = {
  293.     "EXIT",' ) >sigtmp.h
  294. mv sigtmp.h signals.h
  295. if grep SIGSTOP signals.h >/dev/null
  296. then ed signals.h <<'foo' >/dev/null 2>&1
  297. /SIGSTOP/c
  298. #ifdef USE_SUSPENDED
  299.     "suspended (signal)",
  300. #else
  301.     "stopped (signal)",
  302. #endif
  303. .
  304. /SIGTSTP/c
  305. #ifdef USE_SUSPENDED
  306.     "suspended",
  307. #else
  308.     "stopped",
  309. #endif
  310. .
  311. /SIGTTIN/c
  312. #ifdef USE_SUSPENDED
  313.     "suspended (tty input)",
  314. #else
  315.     "stopped (tty input)",
  316. #endif
  317. .
  318. /SIGTTOU/c
  319. #ifdef USE_SUSPENDED
  320.     "suspended (tty output)",
  321. #else
  322.     "stopped (tty output)",
  323. #endif
  324. .
  325. w
  326. q
  327. foo
  328. fi
  329. (sed 's/.*/    "&",/' signams.h
  330. echo '    "ERR",
  331.     "DEBUG",
  332.     NULL
  333. };
  334.  
  335. #else
  336.  
  337. extern char *sigs[SIGCOUNT+4],*sigmsg[SIGCOUNT+2];
  338.  
  339. #endif') >>signals.h
  340. rm signams.h
  341. echo done
  342. echo 'Building Makefile...' | tr -d '\012'
  343. exec >Makefile
  344. cat <<'foo'
  345. #! /bin/make -f
  346. # Makefile for zsh
  347. # generated by buildzsh
  348.  
  349. OBJS=builtin.o cond.o exec.o glob.o hist.o init.o jobs.o lex.o loop.o \
  350. math.o mem.o params.o parse.o subst.o table.o text.o utils.o watch.o \
  351. zle_bindings.o zle_hist.o zle_main.o zle_misc.o zle_move.o zle_refresh.o \
  352. zle_tricky.o zle_utils.o zle_vi.o zle_word.o
  353.  
  354. BINDIR=/usr/local/bin
  355. MANDIR=/usr/local/man/man1
  356.  
  357. # debugging flags
  358. #CFLAGS=-g -Wreturn-type -Wunused -Wpointer-arith -DQDEBUG
  359. #CC=gcc -traditional
  360.  
  361. CC=cc
  362. foo
  363. if test -f /usr/include/ndir.h -a ! -f /usr/lib/libBSD.a
  364. then echo 'CFLAGS= -O -Aa'
  365. elif strings /usr/bin/cc 2>/dev/null | grep cckr >/dev/null 2>&1
  366. then echo 'CFLAGS= -O -cckr'
  367. else echo 'CFLAGS= -O'
  368. fi
  369. if test -f /bin/hinv
  370. then
  371. if grep '^\+' /etc/passwd >/dev/null
  372. then echo 'LIBS= -lcurses -lmalloc -lbsd -lsun'
  373. else echo 'LIBS= -lcurses -lmalloc -lbsd'
  374. fi
  375. elif test -f /usr/lib/libcposix.a
  376. then echo 'LIBS= -lcposix -ltermcap'
  377. elif test -f /usr/lib/libBSD.a
  378. then echo 'LIBS= -ltermcap -lBSD'
  379. elif test -f /usr/lib/libtermcap.a || test -f /usr/ucblib/libtermcap.a
  380. then
  381.     if grep 'Property of IBM' /usr/include/stdio.h >/dev/null 2>&1
  382.     then echo 'LIBS= -lcurses'
  383.     else echo 'LIBS= -ltermcap'
  384.     fi
  385. else echo 'LIBS= -lcurses'
  386. fi
  387. cat <<'foo'
  388.  
  389. ZSHPATH=zsh
  390.  
  391. .c.o:
  392.     $(CC) $(CFLAGS) -c $<
  393.  
  394. all: $(ZSHPATH)
  395.  
  396. $(ZSHPATH): $(OBJS)
  397.     $(CC) -o $(ZSHPATH) $(OBJS) $(LIBS) $(LFLAGS)
  398.     
  399. tags: /tmp
  400.     ctags *.[cy]
  401.  
  402. # I hate this next line
  403. $(OBJS): config.h zsh.h zle.h signals.h ztype.h funcs.h
  404.  
  405. clean:
  406.     rm -f *.o zsh core 
  407.  
  408. cleanall:
  409.     rm -f *.o zsh core Makefile signals.h config.h
  410.  
  411. install: zsh
  412.     install -s -m 755 zsh $(BINDIR)
  413.     install -m 444 ../man/man1/zsh.1 $(MANDIR)
  414. foo
  415. exec 1>&2
  416. cat <<'foo'
  417. done
  418.  
  419. You may want to look at the files I just created (config.h, Makefile,
  420. and signals.h) to make sure they are correct.  Or you may just want
  421. to go ahead and try running make now to see what happens.
  422.  
  423. foo
  424. echo 'Shall I execute make now?' | tr -d '\012' 
  425. read reply
  426. echo
  427. case "$reply" in
  428. [yY]*) exec make ;;
  429. esac
  430.  
  431.