configure.in 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. dnl
  2. dnl Process this file with autoconf to produce a configure script.
  3. dnl
  4. AC_INIT(Makefile.in)
  5. dnl If CFLAGS isn't defined and using gcc, set CFLAGS to something reasonable.
  6. dnl Otherwise, just prevent autoconf from molesting CFLAGS.
  7. CFLAGS=$CFLAGS
  8. AC_PROG_CC
  9. if test "x$CFLAGS" = "x" ; then
  10. no_CFLAGS="yes"
  11. fi
  12. if test "x$no_CFLAGS" = "xyes" -a "x$GCC" = "xyes" ; then
  13. CFLAGS="-Wall -pipe -g3"
  14. fi
  15. A_CFLAGS=""
  16. AC_SUBST(A_CFLAGS)
  17. S_CFLAGS="-fPIC -DPIC"
  18. AC_SUBST(S_CFLAGS)
  19. AC_PROG_CPP
  20. AC_PROG_AWK
  21. dnl Platform-specific settings. The ABI can probably be determined
  22. dnl programmatically, but doing so is error-prone, which makes it generally
  23. dnl not worth the trouble.
  24. AC_CANONICAL_HOST
  25. case "${host}" in
  26. *-*-darwin*)
  27. CFLAGS="$CFLAGS -fno-common -no-cpp-precomp"
  28. ABI="macho"
  29. ;;
  30. *-*-freebsd*)
  31. ABI="elf"
  32. ;;
  33. *-*-linux* | *cygwin*)
  34. if echo ${host} | grep -q cygwin ; then \
  35. echo "cygwin detected"; \
  36. S_CFLAGS=""; \
  37. echo "/* cygdef.h. Generated automatically by configure. */
  38. #ifndef _CYGDEF_H_
  39. #define _CYGDEF_H_ 1
  40. #include <sys/ioctl.h>
  41. #define __linux__ 1
  42. typedef void (*sig_t)(int);
  43. #endif /* _CYGDEF_H_ */" > cygdef.h; \
  44. echo "
  45. #define CYGWIN 1
  46. " > confdefs.h; \
  47. fi
  48. ABI="elf"
  49. ;;
  50. *-*-netbsd*)
  51. AC_MSG_CHECKING(ABI)
  52. AC_EGREP_CPP(yes,
  53. [#ifdef __ELF__
  54. yes
  55. #endif
  56. ],
  57. ABI="elf",
  58. ABI="aout")
  59. AC_MSG_RESULT($ABI)
  60. ;;
  61. *-*-solaris2*)
  62. ABI="elf"
  63. AC_DEFINE(SUNOS)
  64. ;;
  65. *)
  66. AC_MSG_RESULT(Unsupported operating system: ${host})
  67. ABI="elf"
  68. ;;
  69. esac
  70. AC_PROG_INSTALL
  71. AC_PROG_RANLIB
  72. AC_PATH_PROGS(AR, ar gar, , $PATH)
  73. dnl Search for termcap access routines in termcap, tinfo, curses, and ncurses.
  74. AC_CHECK_LIB(termcap, tgetent, , \
  75. AC_CHECK_LIB(tinfo, tgetent, , \
  76. AC_CHECK_LIB(curses, tgetent, , \
  77. AC_CHECK_LIB(ncurses, tgetent, , \
  78. AC_MSG_ERROR(termcap support not found)))))
  79. dnl Use termcap.h if it exists; otherwise we need both term.h and [n]curses.h.
  80. AC_CHECK_HEADERS(termcap.h, , \
  81. AC_CHECK_HEADERS(term.h, , \
  82. AC_MSG_RESULT(Need term.h since termcap.h is missing))
  83. AC_CHECK_HEADERS(curses.h, , \
  84. AC_CHECK_HEADERS(ncurses.h, , \
  85. AC_MSG_RESULT(Need curses.h or ncurses.h))))
  86. AC_CHECK_HEADERS(sys/cdefs.h vis.h)
  87. AC_CHECK_FUNCS(issetugid)
  88. AC_CHECK_FUNCS(fgetln, , CCSRCS="$CCSRCS np/fgetln.c")
  89. AC_CHECK_FUNCS(strvis, , CCSRCS="$CCSRCS np/vis.c")
  90. AC_CHECK_FUNCS(strunvis, , CCSRCS="$CCSRCS np/unvis.c")
  91. AC_CHECK_FUNCS(strlcpy, , CCSRCS="$CCSRCS np/strlcpy.c")
  92. AC_CHECK_FUNCS(strlcat, , CCSRCS="$CCSRCS np/strlcat.c")
  93. AC_EGREP_CPP(yes,
  94. [#include <sys/cdefs.h>
  95. #ifdef __RCSID
  96. yes
  97. #endif
  98. ], , [CPPFLAGS="$CPPFLAGS '-D__RCSID(x)='"])
  99. AC_EGREP_CPP(yes,
  100. [#include <sys/cdefs.h>
  101. #ifdef __COPYRIGHT
  102. yes
  103. #endif
  104. ], , [CPPFLAGS="$CPPFLAGS '-D__COPYRIGHT(x)='"])
  105. AC_EGREP_CPP(yes,
  106. [#include <sys/cdefs.h>
  107. #ifdef __RENAME
  108. yes
  109. #endif
  110. ], , [CPPFLAGS="$CPPFLAGS '-D__RENAME(x)='"])
  111. AC_EGREP_CPP(yes,
  112. [#include <sys/cdefs.h>
  113. #ifdef _DIAGASSERT
  114. yes
  115. #endif
  116. ], , [CPPFLAGS="$CPPFLAGS '-D_DIAGASSERT(x)='"])
  117. dnl Enable readline compatibility by default.
  118. AC_ARG_ENABLE(readline, [ --disable-readline Disable readline compatibility],
  119. if test "x$enable_readline" != "xyes" ; then
  120. enable_readline="no"
  121. fi
  122. ,
  123. enable_readline="yes"
  124. )
  125. dnl Optionally enable debugging.
  126. AC_ARG_ENABLE(debug, [ --enable-debug Enable debugging code],
  127. if test "x$enable_debug" != "xyes" ; then
  128. enable_debug="no"
  129. fi
  130. ,
  131. enable_debug="no"
  132. )
  133. if test "x$enable_debug" = "xyes" ; then
  134. CPPFLAGS="$CPPFLAGS -DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG"
  135. CPPFLAGS="$CPPFLAGS -DDEBUG_REFRESH -DDEBUG_PASTE"
  136. else
  137. CFLAGS="$CFLAGS -O"
  138. fi
  139. dnl
  140. dnl File lists. This is done here instead of in the Makefile in order to avoid
  141. dnl the need for conditionals.
  142. dnl
  143. dnl .c files.
  144. ACSRCS="common.c emacs.c vi.c"
  145. BCSRCS="chared.c el.c hist.c key.c map.c parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c"
  146. CCSRCS="$CCSRCS history.c tokenizer.c"
  147. dnl Generated .c files.
  148. AGCSRCS="fcns.c help.c"
  149. BGCSRCS="editline.c"
  150. dnl .h files.
  151. HDRS="chared.h el.h hist.h key.h map.h parse.h prompt.h refresh.h search.h sig.h sys.h term.h tokenizer.h tty.h"
  152. dnl Installed .h files.
  153. IHDRS="histedit.h"
  154. dnl Installed headers for readline compatibility.
  155. IHDR_LINKS=
  156. dnl Generated .h files.
  157. AGHDRS="common.h emacs.h vi.h"
  158. BGHDRS="fcns.h help.h"
  159. dnl Header installation directories.
  160. HDR_DIRS="include"
  161. dnl Man pages.
  162. MAN3="editline.3"
  163. MAN5="editrc.5"
  164. MAN3_LINKS=
  165. for i in el_init.3 el_end.3 el_reset.3 el_gets.3 el_getc.3 el_push.3 \
  166. el_parse.3 el_set.3 el_get.3 el_source.3 el_resize.3 el_line.3 \
  167. el_insertstr.3 el_deletestr.3 history_init.3 history_end.3 \
  168. history.3 ; do
  169. MAN3_LINKS="$MAN3_LINKS editline.3 $i"
  170. done
  171. dnl Man page installation directories.
  172. MAN_DIRS="man/man3 man/man5"
  173. dnl Library settings.
  174. LIB_DIRS="lib"
  175. LIB_MAJOR="2"
  176. LIB_MINOR="6"
  177. LIB_A="libedit.a"
  178. LIB_A_LINKS=
  179. if test "x$ABI" = "xelf" ; then
  180. LIB_S="libedit.so.$LIB_MAJOR"
  181. LIB_S_LINK="libedit.so"
  182. LIB_S_LINKS="$LIB_S $LIB_S_LINK"
  183. S_LDFLAGS="-shared"
  184. elif test "x$ABI" = "xaout" ; then
  185. LIB_S="libedit.so.$LIB_MAJOR.$LIB_MINOR"
  186. LIB_S_LINKS=
  187. S_LDFLAGS="-shared"
  188. elif test "x$ABI" = "xmacho" ; then
  189. S_LDFLAGS="-shared"
  190. LIB_S="libedit.$LIB_MAJOR.dylib"
  191. LIB_S_LINK="libedit.dylib"
  192. LIB_S_LINKS="$LIB_S $LIB_S_LINK"
  193. if test "x$prefix" = "xNONE" ; then
  194. S_LDFLAGS="-undefined suppress -flat_namespace -dynamiclib -compatibility_version $LIB_MAJOR -current_version $LIB_MAJOR -install_name /usr/local/lib/$LIB_S"
  195. else
  196. S_LDFLAGS="-undefined suppress -flat_namespace -dynamiclib -compatibility_version $LIB_MAJOR -current_version $LIB_MAJOR -install_name $prefix/lib/$LIB_S"
  197. fi
  198. fi
  199. dnl Test program.
  200. TEST="TEST/test"
  201. TCSRCS="TEST/test.c"
  202. dnl Add files to the lists if readline compatibility is enabled.
  203. if test "x$enable_readline" = "xyes" ; then
  204. CCSRCS="$CCSRCS readline.c"
  205. IHDRS="$IHDRS readline.h"
  206. IHDR_LINKS="readline.h readline/history.h"
  207. HDR_DIRS="$HDR_DIRS include/readline"
  208. LIB_A_LINKS="$LIB_A_LINKS libedit.a libreadline.a"
  209. if test "x$ABI" = "xelf" ; then
  210. LIB_S_LINKS="$LIB_S_LINKS $LIB_S_LINK libreadline.so"
  211. elif test "x$ABI" = "xaout" ; then
  212. LIB_S_LINKS="$LIB_S_LINKS $LIB_S libreadline.so.$LIB_MAJOR.$LIB_MINOR"
  213. elif test "x$ABI" = "xmacho" ; then
  214. LIB_S_LINKS="$LIB_S_LINKS $LIB_S_LINK libreadline.dylib"
  215. fi
  216. fi
  217. AC_SUBST(ACSRCS)
  218. AC_SUBST(BCSRCS)
  219. AC_SUBST(CCSRCS)
  220. AC_SUBST(AGCSRCS)
  221. AC_SUBST(BGCSRCS)
  222. AC_SUBST(HDRS)
  223. AC_SUBST(IHDRS)
  224. AC_SUBST(IHDR_LINKS)
  225. AC_SUBST(AGHDRS)
  226. AC_SUBST(BGHDRS)
  227. AC_SUBST(HDR_DIRS)
  228. AC_SUBST(MAN3)
  229. AC_SUBST(MAN5)
  230. AC_SUBST(MAN3_LINKS)
  231. AC_SUBST(MAN_DIRS)
  232. AC_SUBST(LIB_DIRS)
  233. AC_SUBST(LIB_VER)
  234. AC_SUBST(LIB_A)
  235. AC_SUBST(LIB_A_LINKS)
  236. AC_SUBST(LIB_S)
  237. AC_SUBST(LIB_S_LINKS)
  238. AC_SUBST(S_LDFLAGS)
  239. AC_SUBST(TEST)
  240. AC_SUBST(TCSRCS)
  241. AC_CONFIG_HEADER(config.h)
  242. AC_OUTPUT([Makefile makelist])