1
0

configure.ac 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. m4_define([MAJOR_VERSION], 1)
  4. m4_define([MINOR_VERSION], 6)
  5. m4_define([MICRO_VERSION], 0)
  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_LIBTOOL_WIN32_DLL
  16. AC_PROG_LIBTOOL
  17. AC_CONFIG_HEADERS([config.h])
  18. AM_INIT_AUTOMAKE(subdir-objects)
  19. AM_PROG_CC_C_O
  20. # needed to handle 64-bit architecture
  21. AC_CHECK_SIZEOF(int)
  22. AC_CHECK_SIZEOF(long)
  23. AC_CHECK_SIZEOF(size_t)
  24. #------------------------------------------------------------------------
  25. # Handle the --prefix=... option
  26. #------------------------------------------------------------------------
  27. if test "${prefix}" = "NONE"; then
  28. prefix=/usr/local
  29. fi
  30. if test "${exec_prefix}" = "NONE"; then
  31. exec_prefix=$prefix
  32. fi
  33. # libdir must be a fully qualified path (not ${exec_prefix}/lib)
  34. eval libdir="$libdir"
  35. ################################
  36. # Deal with debugging options
  37. ################################
  38. AC_ARG_ENABLE(debug,
  39. [AS_HELP_STRING([--enable-debug],
  40. [Turn on debugging including asserts [default=no]])],
  41. [],
  42. [enable_debug=no])
  43. AM_CONDITIONAL(DEBUG,test x$enable_debug = xyes)
  44. ################################
  45. # Check for the roxml library
  46. ################################
  47. AC_ARG_WITH(roxml,
  48. [AS_HELP_STRING([--with-roxml=DIR],
  49. [Use roxml as the XML parser implementation [default=no]])],
  50. [use_roxml=$withval],
  51. [use_roxml=no])
  52. AC_ARG_WITH(libxml2,
  53. [AS_HELP_STRING([--with-libxml2=DIR],
  54. [Use libxml2 as the XML parser implementation [default=yes]])],
  55. [use_libxml2=$withval],
  56. [use_libxml2=yes])
  57. if test "x$use_roxml" != "xno"; then
  58. if test "x$use_libxml2" != "xno"; then
  59. AC_MSG_WARN([both roxml and libxml2 are selected. I choose roxml])
  60. use_libxml2=no
  61. fi
  62. else
  63. if test "x$use_libxml2" = "xno"; then
  64. AC_MSG_WARN([neither roxml nor libxml2 are selected. I choose libxml2])
  65. use_libxml2=yes
  66. fi
  67. fi
  68. XML_LDFLAGS=""
  69. XML_CFLAGS=""
  70. XML_LIBS=""
  71. case x$use_roxml in
  72. xno)
  73. AC_MSG_CHECKING([for libroxml support])
  74. AC_MSG_RESULT([no])
  75. ;;
  76. xyes)
  77. # we choose to NOT rely on pkg-config on this one. We may do it as
  78. # libroxml provides a .pc file but some environment (both cross-compile
  79. # or native environment) may lack this support. The good thing is that
  80. # it doesn't add much complexity to the configure.ac file (and we
  81. # may move these tests to another m4 file later).
  82. # the header is installed in the standard path
  83. AC_CHECK_HEADER([roxml.h],
  84. [roxml_h_found=yes],
  85. [roxml_h_found=no],
  86. [/* force include check */])
  87. if test "x$roxml_h_found" != "xyes"; then
  88. AC_MSG_ERROR([cannot find <roxml.h> header file])
  89. fi
  90. XML_CFLAGS=""
  91. # the library is installed in the standard path
  92. AC_CHECK_LIB([roxml],
  93. [roxml_load_doc],
  94. [roxml_lib_found=yes],
  95. [roxml_lib_found=no],
  96. [])
  97. if test "x$roxml_lib_found" != "xyes"; then
  98. AC_MSG_ERROR([cannot find roxml library])
  99. fi
  100. XML_LDFLAGS=""
  101. XML_LIBS="-lroxml"
  102. AC_DEFINE([HAVE_LIB_ROXML],
  103. [],
  104. [Define to 1 if you want to use libroxml to parse clish XML files])
  105. ;;
  106. *)
  107. # first, we check if we're not looking for an alternate include
  108. # directory -for example, if the user feeds the script with the
  109. # option --with-roxml=/usr/local
  110. # NOTE: we search for include/roxml.h and inc/roxml.h to defeat
  111. # the caching algorithm of the configure script. If someone knows
  112. # a better way, please do not hesitate
  113. roxml_CFLAGS="$CFLAGS"
  114. CFLAGS="$CFLAGS -I${use_roxml}"
  115. AC_CHECK_HEADER([include/roxml.h],
  116. [roxml_h_found=yes],
  117. [roxml_h_found=no],
  118. [/* force include check */])
  119. if test "x$roxml_h_found" = "xno"; then
  120. # the directory might be a source directory, so check
  121. # if the include file is to be found here
  122. AC_CHECK_HEADER([inc/roxml.h],
  123. [roxml_h_found=yes],
  124. [roxml_h_found=no],
  125. [/* force include check */])
  126. if test "x$roxml_h_found" = "xno"; then
  127. AC_MSG_ERROR([cannot find <roxml.h> header file])
  128. fi
  129. XML_CFLAGS="-I${use_roxml}/inc"
  130. AC_MSG_NOTICE([header file <roxml.h> found in ${use_roxml}/inc])
  131. else
  132. XML_CFLAGS="-I${use_roxml}/include"
  133. AC_MSG_NOTICE([header file <roxml.h> found in ${use_roxml}/include])
  134. fi
  135. CFLAGS="$roxml_CFLAGS"
  136. # we're doing both previous checks, but we are trying to find a library
  137. # now, so the check themselves are a bit different
  138. # NOTE: we search for roxml_load_doc and roxml_close to defeat
  139. # the caching algorithm of the configure script. If someone knows
  140. # a better way, please do not hesitate.
  141. roxml_LDFLAGS="$LDFLAGS"
  142. LDFLAGS="$LDFLAGS -L${use_roxml}/lib"
  143. AC_CHECK_LIB([roxml],
  144. [roxml_load_doc],
  145. [roxml_lib_found=yes],
  146. [roxml_lib_found=no],
  147. [])
  148. LDFLAGS=$roxml_LDFLAGS
  149. if test "x$roxml_lib_found" = "xno"; then
  150. LDFLAGS="$LDFLAGS -L${use_roxml}"
  151. AC_CHECK_LIB([roxml],
  152. [roxml_close],
  153. [roxml_lib_found=yes],
  154. [roxml_lib_found=no],
  155. [])
  156. LDFLAGS=$roxml_LDFLAGS
  157. if test "x$roxml_lib_found" = "xno"; then
  158. AC_MSG_ERROR([cannot find roxml library])
  159. fi
  160. XML_LDFLAGS="-L${use_roxml}"
  161. XML_LIBS="-lroxml"
  162. AC_MSG_NOTICE([library libroxml found in ${use_roxml}])
  163. else
  164. XML_LDFLAGS="-L${use_roxml}/lib"
  165. XML_LIBS="-lroxml"
  166. AC_MSG_NOTICE([library libroxml found in ${use_roxml}/lib])
  167. fi
  168. AC_DEFINE([HAVE_LIB_ROXML],
  169. [],
  170. [Define to 1 if you want to use libroxml to parse clish XML files])
  171. ;;
  172. esac
  173. case x$use_libxml2 in
  174. xno)
  175. AC_MSG_CHECKING([for libxml2 support])
  176. AC_MSG_RESULT([no])
  177. ;;
  178. xyes)
  179. # I would love to avoid using pkg-config (which may not be available on
  180. # some compilation environment) but doing so really add a lot of complexity
  181. # to the system, as the headers don't lie in a standard directory (they
  182. # lie in a subdirectory of a standard include directory; not the same thing
  183. # for configure scripts).
  184. XML_CFLAGS="`pkg-config libxml-2.0 --cflags`"
  185. XML_LDFLAGS="`pkg-config libxml-2.0 --libs-only-L`"
  186. XML_LIBS="`pkg-config libxml-2.0 --libs-only-l`"
  187. AC_CHECK_LIB([xml2],
  188. [xmlNewDoc],
  189. [libxml2_lib_found=yes],
  190. [libxml2_lib_found=no],
  191. [-lz])
  192. if test "x$libxml2_lib_found" != "xyes"; then
  193. AC_MSG_ERROR([cannot find libxml2 library])
  194. fi
  195. # the header file is installed in a subdirectory of one of the standard
  196. # include directory. This might prove to be a problem if the cross-compile
  197. # environment is not complete enough (i.e. if it misses pkg-config, or
  198. # if pkg-config returns wrong values). In most cases, the environment is
  199. # likely to be OK so we will never hit any issue.
  200. xml2_CFLAGS="$CFLAGS"
  201. CFLAGS="$CFLAGS $XML_CFLAGS"
  202. AC_CHECK_HEADER([libxml/tree.h],
  203. [libxml2_h_found=yes],
  204. [libxml2_h_found=no],
  205. [/* force include check */])
  206. CFLAGS="$xml2_CFLAGS"
  207. if test "x$libxml2_h_found" != "xyes"; then
  208. AC_MSG_ERROR([cannot find libxml2 headers])
  209. fi
  210. AC_DEFINE([HAVE_LIB_LIBXML2],
  211. [],
  212. [Define to 1 if you want to use libxml2 to parse clish XML files])
  213. ;;
  214. *)
  215. # this is probably broken. We consider that the user supplied path is
  216. # a non-standard path. But we're not going to check anything.
  217. AC_MSG_WARN([--with-libxml2=DIR is probably broken, but let's try])
  218. XML_LDFLAGS="-L${use_libxml2}/include/libxml2"
  219. XML_CFLAGS="-I${use_libxml2}/lib"
  220. XML_LIBS="-lxml2"
  221. AC_MSG_CHECKING([for libxml2 support])
  222. AC_MSG_RESULT([yes])
  223. AC_MSG_NOTICE([headers for libxml2 hopefully in ${use_libxml2}/include/libxml2])
  224. AC_MSG_NOTICE([library libxml2 hopefully in ${use_libxml2}/lib])
  225. AC_DEFINE([HAVE_LIB_LIBXML2],
  226. [],
  227. [Define to 1 if you want to use libxml2 to parse clish XML files])
  228. ;;
  229. esac
  230. AC_SUBST(XML_LIBS)
  231. AC_SUBST(XML_LDFLAGS)
  232. AC_SUBST(XML_CFLAGS)
  233. ################################
  234. # Check for the LUB library
  235. ################################
  236. LUB_LIBS="-llub"
  237. LUB_CFLAGS=""
  238. if test "x$LUB_LIBS" = "x"; then
  239. AC_MSG_ERROR([Cannot find the "Little Useful Bits" library])
  240. fi
  241. AC_SUBST(LUB_LIBS)
  242. AC_SUBST(LUB_CFLAGS)
  243. ################################
  244. # Check for the KONF library
  245. ################################
  246. KONF_LIBS="-lkonf"
  247. KONF_CFLAGS=""
  248. if test "x$KONF_LIBS" = "x"; then
  249. AC_MSG_ERROR([Cannot find the "CLI config" library])
  250. fi
  251. AC_SUBST(KONF_LIBS)
  252. AC_SUBST(KONF_CFLAGS)
  253. ################################
  254. # Check for the TINYRL library
  255. ################################
  256. TINYRL_LIBS="-ltinyrl"
  257. TINYRL_CFLAGS=""
  258. if test "x$TINYRL_LIBS" = "x"; then
  259. AC_MSG_ERROR([Cannot find the "Tiny Readline" library])
  260. fi
  261. AC_SUBST(TINYRL_LIBS)
  262. AC_SUBST(TINYRL_CFLAGS)
  263. ################################
  264. # Search for network functions (like connect())
  265. ################################
  266. AC_SEARCH_LIBS([socket], [socket])
  267. ################################
  268. # Check for regex.h
  269. ################################
  270. AC_CHECK_HEADERS(regex.h, [],
  271. AC_MSG_ERROR([regex.h not found: regular expressions are not supported]))
  272. ################################
  273. # Check for getopt_long()
  274. ################################
  275. AC_CHECK_HEADERS(getopt.h, [],
  276. AC_MSG_WARN([getopt.h not found: only short parameters can be used on command line]))
  277. ################################
  278. # Check for locale.h
  279. ################################
  280. AC_CHECK_HEADERS(locale.h, [],
  281. AC_MSG_WARN([locale.h not found: the locales is not supported]))
  282. ################################
  283. # Check for CODESET within nl_langinfo
  284. ################################
  285. AM_LANGINFO_CODESET
  286. ################################
  287. # Check for pwd.h and grp.h
  288. ################################
  289. AC_CHECK_HEADERS(pwd.h, [],
  290. AC_MSG_WARN([pwd.h not found: the pwd operations is not supported]))
  291. AC_CHECK_HEADERS(grp.h, [],
  292. AC_MSG_WARN([grp.h not found: the grp operations is not supported]))
  293. ################################
  294. # Check for chroot
  295. ################################
  296. AC_CHECK_FUNCS(chroot, [],
  297. AC_MSG_WARN([chroot() not found: the choot is not supported]))
  298. AC_CONFIG_FILES(Makefile)
  299. AC_OUTPUT