configure.in 6.3 KB

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