/contrib/ee/create.make

https://bitbucket.org/freebsd/freebsd-head/ · Shell · 292 lines · 278 code · 5 blank · 9 comment · 2 complexity · d126ecfa1493b58054dea6d932d9dba8 MD5 · raw file

  1. #!/bin/sh
  2. #
  3. # This script will determine if the system is a System V or BSD based
  4. # UNIX system and create a makefile for ee appropriate for the system.
  5. #
  6. # $Header: /home/hugh/sources/old_ae/RCS/create.make,v 1.13 2002/09/23 04:18:13 hugh Exp $
  7. #
  8. #set -x
  9. name_string="`uname`"
  10. # test for existence of termcap (exists on both BSD and SysV systems)
  11. if [ -f /etc/termcap -o -f /usr/share/lib/termcap -o -f /usr/share/misc/termcap ]
  12. then
  13. if [ -f /usr/share/lib/termcap ]
  14. then
  15. termcap_exists="-DTERMCAP=\"\\\"/usr/share/lib/termcap\\\"\""
  16. elif [ -f /usr/share/misc/termcap ]
  17. then
  18. termcap_exists="-DTERMCAP=\"\\\"/usr/share/misc/termcap\\\"\""
  19. elif [ -f /etc/termcap ]
  20. then
  21. termcap_exists="-DTERMCAP=\"\\\"/etc/termcap\\\"\""
  22. fi
  23. else
  24. termcap_exists=""
  25. fi
  26. # test for terminfo directory (exists on SysV systems)
  27. if [ -d /usr/lib/terminfo -o -d /usr/share/lib/terminfo -o -d /usr/share/terminfo ]
  28. then
  29. terminfo_exists=""
  30. else
  31. terminfo_exists="-DCAP"
  32. fi
  33. # test for existence of termio header (on SysV systems)
  34. if [ -f /usr/include/termio.h ]
  35. then
  36. termio="-DSYS5"
  37. else
  38. termio=""
  39. fi
  40. # test for sgtty header (on BSD systems)
  41. if [ -f /usr/include/sgtty.h ]
  42. then
  43. sgtty="TRUE"
  44. else
  45. sgtty=""
  46. fi
  47. # look for select call in headers, make sure headers exist
  48. HEADER_FILES=""
  49. if [ -f /usr/include/sys/time.h ]
  50. then
  51. HEADER_FILES="/usr/include/sys/time.h "
  52. fi
  53. if [ -f /usr/include/sys/types.h ]
  54. then
  55. HEADER_FILES="$HEADER_FILES /usr/include/sys/types.h"
  56. fi
  57. # check for unistd.h
  58. if [ -f /usr/include/unistd.h ]
  59. then
  60. HAS_UNISTD=-DHAS_UNISTD
  61. HEADER_FILES="$HEADER_FILES /usr/include/unistd.h"
  62. else
  63. HAS_UNISTD=""
  64. fi
  65. if [ -n "$HEADER_FILES" ]
  66. then
  67. string="`grep select $HEADER_FILES`"
  68. if [ -n "$string" ]
  69. then
  70. BSD_SELECT="-DBSD_SELECT"
  71. else
  72. BSD_SELECT=""
  73. fi
  74. fi
  75. # check for existence of select.h (on AIX)
  76. if [ -f /usr/include/sys/select.h ]
  77. then
  78. select_hdr="-DSLCT_HDR"
  79. else
  80. select_hdr=""
  81. fi
  82. # check for stdlib.h
  83. if [ -f /usr/include/stdlib.h ]
  84. then
  85. HAS_STDLIB=-DHAS_STDLIB
  86. else
  87. HAS_STDLIB=""
  88. fi
  89. # check for stdarg.h
  90. if [ -f /usr/include/stdarg.h ]
  91. then
  92. HAS_STDARG=-DHAS_STDARG
  93. else
  94. HAS_STDARG=""
  95. fi
  96. # check for ctype.h
  97. if [ -f /usr/include/ctype.h ]
  98. then
  99. HAS_CTYPE=-DHAS_CTYPE
  100. else
  101. HAS_CTYPE=""
  102. fi
  103. # check for sys/ioctl.h
  104. if [ -f /usr/include/sys/ioctl.h ]
  105. then
  106. HAS_SYS_IOCTL=-DHAS_SYS_IOCTL
  107. else
  108. HAS_SYS_IOCTL=""
  109. fi
  110. # check for sys/wait.h
  111. if [ -f /usr/include/sys/wait.h ]
  112. then
  113. HAS_SYS_WAIT=-DHAS_SYS_WAIT
  114. else
  115. HAS_SYS_WAIT=""
  116. fi
  117. # check for localization headers
  118. if [ -f /usr/include/locale.h -a -f /usr/include/nl_types.h ]
  119. then
  120. catgets=""
  121. else
  122. catgets="-DNO_CATGETS"
  123. fi
  124. # make decisions about use of new_curse.c (use of new_curse is recommended
  125. # rather than local curses)
  126. if [ -n "$terminfo_exists" -a -z "$termcap_exists" ]
  127. then
  128. echo "Neither terminfo or termcap are on this system! "
  129. if [ -f /usr/include/curses.h ]
  130. then
  131. echo "Relying on local curses implementation."
  132. else
  133. cat <<-EOF
  134. Don't know where to find curses, you'll need to modify
  135. source code to be able to build!
  136. Modify the file make.default and build ee by typing:
  137. make -f make.default
  138. EOF
  139. exit 1
  140. fi
  141. TARGET="curses"
  142. curses=""
  143. else
  144. curses="-DNCURSE"
  145. TARGET="ee"
  146. fi
  147. if [ -z "$termio" -a -z "$sgtty" ]
  148. then
  149. echo "Neither termio.h or sgtty.h are on this system! "
  150. if [ -f /usr/include/curses.h ]
  151. then
  152. echo "Relying on local curses implementation."
  153. else
  154. cat <<-EOF
  155. Don't know where to find curses, you'll need to modify
  156. source code to be able to build!
  157. Modify the file make.default and build ee by typing:
  158. make -f make.default
  159. EOF
  160. exit 1
  161. fi
  162. TARGET="curses"
  163. curses=""
  164. fi
  165. # check if this is a SunOS system
  166. if [ -d /usr/5include ]
  167. then
  168. five_include="-I/usr/5include"
  169. else
  170. five_include=""
  171. fi
  172. if [ -d /usr/5lib ]
  173. then
  174. five_lib="-L/usr/5lib"
  175. else
  176. five_lib=""
  177. fi
  178. if [ "$name_string" = "Darwin" ]
  179. then
  180. if [ -n "$CFLAGS" ]
  181. then
  182. other_cflags="${CFLAGS} -DNO_CATGETS"
  183. else
  184. other_cflags="-DNO_CATGETS"
  185. fi
  186. else
  187. if [ -n "$CFLAGS" ]
  188. then
  189. if [ -z "`echo $CFLAGS | grep '[-]g'`" ]
  190. then
  191. other_cflags="${CFLAGS} -s"
  192. else
  193. other_cflags="${CFLAGS}"
  194. fi
  195. else
  196. other_cflags="-s"
  197. fi
  198. fi
  199. # time to write the makefile
  200. echo "Generating make.local"
  201. if [ -f make.local ]
  202. then
  203. mv make.local make.lcl.old
  204. fi
  205. echo "DEFINES = $termio $terminfo_exists $BSD_SELECT $catgets $select $curses " > make.local
  206. echo "" >> make.local
  207. echo "CFLAGS = $HAS_UNISTD $HAS_STDARG $HAS_STDLIB $HAS_CTYPE $HAS_SYS_IOCTL $HAS_SYS_WAIT $five_lib $five_include $select_hdr $other_cflags $termcap_exists" >> make.local
  208. echo "" >> make.local
  209. echo "" >> make.local
  210. echo "all : $TARGET" >> make.local
  211. cat >> make.local << EOF
  212. curses : ee.c
  213. cc ee.c -o ee \$(CFLAGS) -lcurses
  214. ee : ee.o new_curse.o
  215. cc -o ee ee.o new_curse.o \$(CFLAGS)
  216. ee.o : ee.c new_curse.h
  217. cc -c ee.c \$(DEFINES) \$(CFLAGS)
  218. new_curse.o : new_curse.c new_curse.h
  219. cc new_curse.c -c \$(DEFINES) \$(CFLAGS)
  220. EOF
  221. if [ -f make.lcl.old ]
  222. then
  223. diffs="`cmp make.lcl.old make.local`"
  224. if [ -n "${diffs}" ]
  225. then
  226. rm -f ee.o new_curse.o ee
  227. fi
  228. rm -f make.lcl.old
  229. fi