configure.ac 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. m4_define([MAJOR_VERSION], 1)
  4. m4_define([MINOR_VERSION], 5)
  5. m4_define([MICRO_VERSION], 3)
  6. AC_PREREQ(2.59)
  7. AC_INIT([klish],
  8. [MAJOR_VERSION.MINOR_VERSION.MICRO_VERSION],
  9. [serj.kalichev at gmail dot com])
  10. AC_CONFIG_AUX_DIR(aux_scripts)
  11. # Check for system extensions (_POSIX_THREAD_SEMANTICS for Solaris)
  12. AC_USE_SYSTEM_EXTENSIONS
  13. # Checks for programs.
  14. AC_PROG_CC
  15. AC_PROG_CXX
  16. AC_LIBTOOL_WIN32_DLL
  17. AC_PROG_LIBTOOL
  18. AC_CONFIG_HEADERS([config.h])
  19. AM_INIT_AUTOMAKE(subdir-objects)
  20. AM_PROG_CC_C_O
  21. # needed to handle 64-bit architecture
  22. AC_CHECK_SIZEOF(int)
  23. AC_CHECK_SIZEOF(long)
  24. AC_CHECK_SIZEOF(size_t)
  25. #------------------------------------------------------------------------
  26. # Handle the --prefix=... option
  27. #------------------------------------------------------------------------
  28. if test "${prefix}" = "NONE"; then
  29. prefix=/usr/local
  30. fi
  31. if test "${exec_prefix}" = "NONE"; then
  32. exec_prefix=$prefix
  33. fi
  34. # libdir must be a fully qualified path (not ${exec_prefix}/lib)
  35. eval libdir="$libdir"
  36. ################################
  37. # Deal with debugging options
  38. ################################
  39. AC_ARG_ENABLE(debug,
  40. [AS_HELP_STRING([--enable-debug],
  41. [Turn on debugging including asserts [default=no]])],
  42. [],
  43. [enable_debug=no])
  44. AM_CONDITIONAL(DEBUG,test x$enable_debug = xyes)
  45. ################################
  46. # Check for the LUB library
  47. ################################
  48. LUB_LIBS="-llub"
  49. LUB_CFLAGS=""
  50. if test "x$LUB_LIBS" = "x"; then
  51. AC_MSG_ERROR([Cannot find the "Little Useful Bits" library])
  52. fi
  53. AC_SUBST(LUB_LIBS)
  54. AC_SUBST(LUB_CFLAGS)
  55. ################################
  56. # Check for the KONF library
  57. ################################
  58. KONF_LIBS="-lkonf"
  59. KONF_CFLAGS=""
  60. if test "x$KONF_LIBS" = "x"; then
  61. AC_MSG_ERROR([Cannot find the "CLI config" library])
  62. fi
  63. AC_SUBST(KONF_LIBS)
  64. AC_SUBST(KONF_CFLAGS)
  65. ################################
  66. # Check for the TINYRL library
  67. ################################
  68. TINYRL_LIBS="-ltinyrl"
  69. TINYRL_CFLAGS=""
  70. if test "x$TINYRL_LIBS" = "x"; then
  71. AC_MSG_ERROR([Cannot find the "Tiny Readline" library])
  72. fi
  73. AC_SUBST(TINYRL_LIBS)
  74. AC_SUBST(TINYRL_CFLAGS)
  75. ################################
  76. # Check for the TINYXML library
  77. ################################
  78. TINYXML_LIBS="-ltinyxml"
  79. TINYXML_CXXFLAGS="-std=gnu++98"
  80. if test "x$TINYXML_LIBS" = "x"; then
  81. AC_MSG_ERROR([Cannot find the "Tiny XML" library])
  82. fi
  83. AC_SUBST(TINYXML_LIBS)
  84. AC_SUBST(TINYXML_CXXFLAGS)
  85. ################################
  86. # Check for the PTHREAD library
  87. ################################
  88. AC_ARG_WITH(pthread,
  89. [AS_HELP_STRING([--with-pthread=DIR],
  90. [Use POSIX threads library distribution in DIR])
  91. ])
  92. AC_CHECK_HEADERS(pthread.h,
  93. [AC_CHECK_LIB(pthread,
  94. pthread_create,
  95. [AC_DEFINE([HAVE_LIBPTHREAD], [], [Have POSIX threads library])
  96. if test "x$with_pthread" = "x"; then
  97. PTHREAD_LIBS="-lpthread"
  98. else
  99. PTHREAD_CFLAGS="-I$with_pthread/include"
  100. PTHREAD_LIBS="-L$with_pthread/lib -lpthread"
  101. fi
  102. AC_SUBST(PTHREAD_LIBS)
  103. AC_SUBST(PTHREAD_CFLAGS)
  104. ])
  105. ])
  106. if test "x$PTHREAD_LIBS" = "x"; then
  107. AC_MSG_ERROR([Cannot find the POSIX threads library])
  108. fi
  109. ################################
  110. # Check for the RT library
  111. ################################
  112. AC_ARG_WITH(rt,
  113. [AS_HELP_STRING([--with-rt=DIR],
  114. [Use POSIX real time library distribution in DIR])])
  115. AC_CHECK_LIB(rt,
  116. clock_gettime,
  117. [
  118. AC_DEFINE([HAVE_LIBRT], [], [Have POSIX real time library])
  119. if test "x$with_rt" = "x"; then
  120. RT_LIBS="-lrt"
  121. else
  122. RT_CFLAGS="-I$with_rt/include"
  123. RT_LIBS="-L$with_rt/lib -lrt"
  124. fi
  125. AC_SUBST(RT_LIBS)
  126. AC_SUBST(RT_CFLAGS)
  127. ])
  128. ################################
  129. # Check for the TCL library
  130. ################################
  131. TCL_CONFIG=${libdir}/tclConfig.sh
  132. AC_ARG_WITH(tcl,
  133. [AS_HELP_STRING([--with-tcl=DIR],
  134. [Use TCL library distribution in DIR])],
  135. if test -e $TCL_CONFIG; then
  136. source ${TCL_CONFIG} # get TCL_VERSION
  137. if test "${with_tcl}" = "yes"; then
  138. TCL_CFLAGS="${TCL_INCLUDE_SPEC}"
  139. TCL_LIBS="${TCL_LIB_SPEC}"
  140. else
  141. TCL_CFLAGS="-I${with_tcl}/include"
  142. TCL_LIBS="-L${with_tcl}/lib -ltcl"
  143. fi
  144. CPPFLAGS="$CPPFLAGS $TCL_CFLAGS"
  145. AC_CHECK_HEADERS(tcl.h,
  146. AC_CHECK_LIB(tcl${TCL_VERSION}, Tcl_CreateInterp, [
  147. AC_DEFINE([HAVE_LIBTCL], [], [Have TCL library])
  148. AC_SUBST(TCL_CFLAGS)
  149. AC_SUBST(TCL_LIBS)
  150. AC_SUBST(TCL_VERSION)
  151. have_tcl="yes"
  152. ])
  153. )
  154. fi
  155. )
  156. AM_CONDITIONAL(TCL,test "x${have_tcl}" = "xyes")
  157. ################################
  158. # Check for inclusion of lub_heap
  159. ################################
  160. AC_ARG_ENABLE(lubheap,
  161. [AS_HELP_STRING([--enable-lubheap],
  162. [Replace standard memory libaries with lubheap (EXPERIMENTAL) [default=no]])],
  163. [],
  164. [enable_lubheap=no])
  165. AM_CONDITIONAL(LUBHEAP,test "x$enable_lubheap" = "xyes")
  166. if test "x$enable_lubheap" = "xyes"; then
  167. AC_MSG_WARN([Replacing standard memory libraries with lubheap])
  168. LUBHEAP_LIBS="-llubheap"
  169. LUBHEAP_CFLAGS=""
  170. if test "x$LUBHEAP_LIBS" = "x"; then
  171. AC_MSG_ERROR([Cannot find the "Little Useful Bits Heap" library])
  172. fi
  173. AC_SUBST(LUBHEAP_LIBS)
  174. AC_SUBST(LUBHEAP_CFLAGS)
  175. fi
  176. ################################
  177. # Check for linkage with GPL libraries
  178. ################################
  179. AC_ARG_ENABLE(gpl,
  180. [AS_HELP_STRING([--enable-gpl],
  181. [Link with GPL licenced libraries [default=yes]])],
  182. [],
  183. [enable_gpl=yes])
  184. if test "x$enable_gpl" = "xyes"; then
  185. ################################
  186. # Check for BFD library
  187. ################################
  188. AC_MSG_WARN([Linking with GPL licence libraries])
  189. AC_CHECK_HEADERS(bfd.h,
  190. [AC_CHECK_LIB(bfd,
  191. bfd_init,
  192. [AC_DEFINE([HAVE_LIBBFD],
  193. [],
  194. [Have Binary File Decription library])
  195. BFD_LIBS="-lbfd -liberty"
  196. AC_CHECK_LIB(intl,
  197. libintl_dgettext,
  198. [AC_DEFINE([HAVE_LIBINTL],
  199. [],
  200. [Have native langauage support library])
  201. BFD_LIBS="$BFD_LIBS -lintl"
  202. ])
  203. AC_SUBST(BFD_LIBS)
  204. ])
  205. ])
  206. else
  207. AC_MSG_WARN([Skipping BFD library checks because of GPL Licence])
  208. fi
  209. ################################
  210. # Search for network functions (like connect())
  211. ################################
  212. AC_SEARCH_LIBS([socket], [socket])
  213. ################################
  214. # Check for regex.h
  215. ################################
  216. AC_CHECK_HEADERS(regex.h, [],
  217. AC_MSG_ERROR([regex.h not found: regular expressions are not supported]))
  218. ################################
  219. # Check for getopt_long()
  220. ################################
  221. AC_CHECK_HEADERS(getopt.h, [],
  222. AC_MSG_WARN([getopt.h not found: only short parameters can be used on command line]))
  223. ################################
  224. # Check for locale.h
  225. ################################
  226. AC_CHECK_HEADERS(locale.h, [],
  227. AC_MSG_WARN([locale.h not found: the locales is not supported]))
  228. ################################
  229. # Check for CODESET within nl_langinfo
  230. ################################
  231. AM_LANGINFO_CODESET
  232. ################################
  233. # Check for pwd.h and grp.h
  234. ################################
  235. AC_CHECK_HEADERS(pwd.h, [],
  236. AC_MSG_WARN([pwd.h not found: the pwd operations is not supported]))
  237. AC_CHECK_HEADERS(grp.h, [],
  238. AC_MSG_WARN([grp.h not found: the grp operations is not supported]))
  239. ################################
  240. # Check for chroot
  241. ################################
  242. AC_CHECK_FUNCS(chroot, [],
  243. AC_MSG_WARN([chroot() not found: the choot is not supported]))
  244. AC_CONFIG_FILES(Makefile)
  245. AC_OUTPUT