configure.ac 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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], 6)
  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. AC_CONFIG_MACRO_DIR([m4])
  12. # Values for SONAME. See -version-info for details.
  13. AC_SUBST(SONAME_CURRENT, 0)
  14. AC_SUBST(SONAME_REVISION, 0)
  15. AC_SUBST(SONAME_AGE, 0)
  16. # Check for system extensions (_POSIX_THREAD_SEMANTICS for Solaris)
  17. AC_USE_SYSTEM_EXTENSIONS
  18. # Checks for programs.
  19. AC_PROG_CC
  20. AC_LIBTOOL_WIN32_DLL
  21. AC_PROG_LIBTOOL
  22. AC_CONFIG_HEADERS([config.h])
  23. AM_INIT_AUTOMAKE(subdir-objects)
  24. AM_PROG_CC_C_O
  25. # needed to handle 64-bit architecture
  26. AC_CHECK_SIZEOF(int)
  27. AC_CHECK_SIZEOF(long)
  28. AC_CHECK_SIZEOF(size_t)
  29. ################################
  30. # Deal with debugging options
  31. ################################
  32. AC_ARG_ENABLE(debug,
  33. [AS_HELP_STRING([--enable-debug],
  34. [Turn on debugging including asserts [default=no]])],
  35. [],
  36. [enable_debug=no])
  37. AM_CONDITIONAL(DEBUG,test x$enable_debug = xyes)
  38. ################################
  39. # Check for the roxml library
  40. ################################
  41. AC_ARG_WITH(libroxml,
  42. [AS_HELP_STRING([--with-libroxml=DIR],
  43. [Use roxml as the XML parser implementation [default=no]])],
  44. [use_roxml=$withval],
  45. [use_roxml=no])
  46. AC_ARG_WITH(libexpat,
  47. [AS_HELP_STRING([--with-libexpat=DIR],
  48. [Use expat as the XML parser implementation [default=no]])],
  49. [use_expat=$withval],
  50. [use_expat=no])
  51. AC_ARG_WITH(libxml2,
  52. [AS_HELP_STRING([--with-libxml2=DIR],
  53. [Use libxml2 as the XML parser implementation [default=no]])],
  54. [use_libxml2=$withval],
  55. [use_libxml2=no])
  56. # select the default xml backend
  57. sel_xml_backends=""
  58. xml_backend=""
  59. found_xml_backend=""
  60. count_xml_backends=0
  61. if test "x$use_libxml2" != "xno"; then
  62. sel_xml_backends="$sel_xml_backends libxml2"
  63. xml_backend="libxml2"
  64. count_xml_backends=$((count_xml_backends + 1))
  65. fi
  66. if test "x$use_roxml" != "xno"; then
  67. sel_xml_backends="$sel_xml_backends roxml"
  68. xml_backend="roxml"
  69. count_xml_backends=$((count_xml_backends + 1))
  70. fi
  71. if test "x$use_expat" != "xno"; then
  72. sel_xml_backends="$sel_xml_backends expat"
  73. xml_backend="expat"
  74. count_xml_backends=$((count_xml_backends + 1))
  75. fi
  76. if test $count_xml_backends -gt 1; then
  77. AC_MSG_WARN([Multiple XML backend has been selected ($sel_xml_backends). I choose $xml_backend])
  78. fi
  79. if test "x$xml_backend" = "x"; then
  80. xml_backend="auto"
  81. AC_MSG_WARN([No XML backend has been selected: auto check])
  82. fi
  83. case x$xml_backend in
  84. xroxml)
  85. use_libxml2="no"
  86. use_expat="no"
  87. ;;
  88. xlibxml2)
  89. use_roxml="no"
  90. use_expat="no"
  91. ;;
  92. xexpat)
  93. use_libxml2="no"
  94. use_roxml="no"
  95. ;;
  96. esac
  97. XML_LDFLAGS=""
  98. XML_CFLAGS=""
  99. XML_LIBS=""
  100. if test "$xml_backend" = "expat" -o "$xml_backend" = "auto"; then
  101. if test "$xml_backend" = "auto"; then
  102. # on auto select, we try to detect the library
  103. use_expat="yes"
  104. fi
  105. case x$use_expat in
  106. xyes)
  107. # we choose to NOT rely on pkg-config on this one. Instead, we
  108. # check for the library and the header file - that should be
  109. # enough.
  110. AC_CHECK_HEADER([expat.h],
  111. [expat_h_found=yes],
  112. [expat_h_found=no],
  113. [/* force include check */])
  114. if test "x$expat_h_found" != "xyes"; then
  115. AC_CHECK_HEADER([bsdxml.h],
  116. [expat_h_found=yes],
  117. [expat_h_found=no],
  118. [/* force include check */])
  119. if test "x$expat_h_found" != "xyes"; then
  120. if test "$xml_backend" = "auto"; then
  121. AC_MSG_WARN([cannot find <expat.h> header file])
  122. else
  123. AC_MSG_ERROR([cannot find <expat.h> header file])
  124. fi
  125. fi
  126. fi
  127. XML_CFLAGS=""
  128. AC_CHECK_LIB([expat],
  129. [XML_ParserCreate],
  130. [expat_lib_found=yes],
  131. [expat_lib_found=no],
  132. [])
  133. if test "x$expat_lib_found" != "xyes"; then
  134. AC_CHECK_LIB([bsdxml],
  135. [XML_ParserCreate],
  136. [expat_lib_found=yes],
  137. [expat_lib_found=no],
  138. [])
  139. if test "x$expat_lib_found" != "xno"; then
  140. XML_LIBS="-lbsdxml"
  141. AC_DEFINE([HAVE_LIB_BSDXML],
  142. [],
  143. [libbsdxml-based XML backend])
  144. else
  145. if test "$xml_backend" = "auto"; then
  146. AC_MSG_WARN([cannot find expat library])
  147. else
  148. AC_MSG_ERROR([cannot find expat library])
  149. fi
  150. fi
  151. else
  152. XML_LIBS="-lexpat"
  153. fi
  154. XML_LDFLAGS=""
  155. AC_DEFINE([HAVE_LIB_EXPAT],
  156. [],
  157. [libexpat-based XML backend])
  158. xml_backend="found"
  159. found_xml_backend="expat"
  160. ;;
  161. *)
  162. # this is probably broken. We consider that the user supplied path is
  163. # a non-standard path. But we're not going to check anything.
  164. AC_MSG_WARN([--with-expat=DIR is probably broken, just trying])
  165. XML_LDFLAGS="-L${use_expat}/lib"
  166. XML_CFLAGS="-I${use_expat}/include"
  167. XML_LIBS="-lexpat"
  168. AC_MSG_CHECKING([for expat support])
  169. AC_MSG_RESULT([yes])
  170. AC_MSG_NOTICE([headers for expat hopefully in ${use_expat}/include])
  171. AC_MSG_NOTICE([library expat hopefully in ${use_expat}/lib])
  172. AC_DEFINE([HAVE_LIB_EXPAT],
  173. [],
  174. [expat-based XML backend])
  175. xml_backend="found"
  176. found_xml_backend="expat"
  177. ;;
  178. esac
  179. else
  180. AC_MSG_CHECKING([for libexpat support])
  181. AC_MSG_RESULT([no])
  182. fi
  183. if test "$xml_backend" = "roxml" -o "$xml_backend" = "auto"; then
  184. if test "$xml_backend" = "auto"; then
  185. # on auto select, we try to detect the library
  186. use_roxml="yes"
  187. fi
  188. case x$use_roxml in
  189. xyes)
  190. # we choose to NOT rely on pkg-config on this one. We may do it as
  191. # libroxml provides a .pc file but some environment (both cross-compile
  192. # or native environment) may lack this support. The good thing is that
  193. # it doesn't add much complexity to the configure.ac file (and we
  194. # may move these tests to another m4 file later).
  195. # the header is installed in the standard path
  196. AC_CHECK_HEADER([roxml.h],
  197. [roxml_h_found=yes],
  198. [roxml_h_found=no],
  199. [/* force include check */])
  200. if test "x$roxml_h_found" != "xyes"; then
  201. if test "$xml_backend" = "auto"; then
  202. AC_MSG_WARN([cannot find <roxml.h> header file])
  203. else
  204. AC_MSG_ERROR([cannot find <roxml.h> header file])
  205. fi
  206. fi
  207. XML_CFLAGS=""
  208. # the library is installed in the standard path
  209. AC_CHECK_LIB([roxml],
  210. [roxml_load_doc],
  211. [roxml_lib_found=yes],
  212. [roxml_lib_found=no],
  213. [])
  214. if test "x$roxml_lib_found" != "xyes"; then
  215. if test "$xml_backend" = "auto"; then
  216. AC_MSG_WARN([cannot find roxml library])
  217. else
  218. AC_MSG_ERROR([cannot find roxml library])
  219. fi
  220. fi
  221. XML_LDFLAGS=""
  222. XML_LIBS="-lroxml"
  223. AC_DEFINE([HAVE_LIB_ROXML],
  224. [],
  225. [libroxml-based XML backend])
  226. xml_backend="found"
  227. found_xml_backend="roxml"
  228. ;;
  229. *)
  230. # first, we check if we're not looking for an alternate include
  231. # directory -for example, if the user feeds the script with the
  232. # option --with-roxml=/usr/local
  233. # NOTE: we search for include/roxml.h and inc/roxml.h to defeat
  234. # the caching algorithm of the configure script. If someone knows
  235. # a better way, please do not hesitate
  236. roxml_CFLAGS="$CFLAGS"
  237. CFLAGS="$CFLAGS -I${use_roxml}"
  238. AC_CHECK_HEADER([include/roxml.h],
  239. [roxml_h_found=yes],
  240. [roxml_h_found=no],
  241. [/* force include check */])
  242. if test "x$roxml_h_found" = "xno"; then
  243. # the directory might be a source directory, so check
  244. # if the include file is to be found here
  245. AC_CHECK_HEADER([inc/roxml.h],
  246. [roxml_h_found=yes],
  247. [roxml_h_found=no],
  248. [/* force include check */])
  249. if test "x$roxml_h_found" = "xno"; then
  250. if test "$xml_backend" = "auto"; then
  251. AC_MSG_WARN([cannot find <roxml.h> header file])
  252. else
  253. AC_MSG_ERROR([cannot find <roxml.h> header file])
  254. fi
  255. fi
  256. XML_CFLAGS="-I${use_roxml}/inc"
  257. AC_MSG_NOTICE([header file <roxml.h> found in ${use_roxml}/inc])
  258. else
  259. XML_CFLAGS="-I${use_roxml}/include"
  260. AC_MSG_NOTICE([header file <roxml.h> found in ${use_roxml}/include])
  261. fi
  262. CFLAGS="$roxml_CFLAGS"
  263. # we're doing both previous checks, but we are trying to find a library
  264. # now, so the check themselves are a bit different
  265. # NOTE: we search for roxml_load_doc and roxml_close to defeat
  266. # the caching algorithm of the configure script. If someone knows
  267. # a better way, please do not hesitate.
  268. roxml_LDFLAGS="$LDFLAGS"
  269. LDFLAGS="$LDFLAGS -L${use_roxml}/lib"
  270. AC_CHECK_LIB([roxml],
  271. [roxml_load_doc],
  272. [roxml_lib_found=yes],
  273. [roxml_lib_found=no],
  274. [])
  275. LDFLAGS=$roxml_LDFLAGS
  276. if test "x$roxml_lib_found" = "xno"; then
  277. LDFLAGS="$LDFLAGS -L${use_roxml}"
  278. AC_CHECK_LIB([roxml],
  279. [roxml_close],
  280. [roxml_lib_found=yes],
  281. [roxml_lib_found=no],
  282. [])
  283. LDFLAGS=$roxml_LDFLAGS
  284. if test "x$roxml_lib_found" = "xno"; then
  285. if test "$xml_backend" = "auto"; then
  286. AC_MSG_WARN([cannot find roxml library])
  287. else
  288. AC_MSG_ERROR([cannot find roxml library])
  289. fi
  290. fi
  291. XML_LDFLAGS="-L${use_roxml}"
  292. XML_LIBS="-lroxml"
  293. AC_MSG_NOTICE([library libroxml found in ${use_roxml}])
  294. else
  295. XML_LDFLAGS="-L${use_roxml}/lib"
  296. XML_LIBS="-lroxml"
  297. AC_MSG_NOTICE([library libroxml found in ${use_roxml}/lib])
  298. fi
  299. AC_DEFINE([HAVE_LIB_ROXML],
  300. [],
  301. [libroxml-based XML backend])
  302. xml_backend="found"
  303. found_xml_backend="roxml"
  304. ;;
  305. esac
  306. else
  307. AC_MSG_CHECKING([for libroxml support])
  308. AC_MSG_RESULT([no])
  309. fi
  310. if test "$xml_backend" = "libxml2" -o "$xml_backend" = "auto"; then
  311. if test "$xml_backend" = "auto"; then
  312. # on auto select, we try to detect the library
  313. use_libxml2="yes"
  314. fi
  315. case x$use_libxml2 in
  316. xyes)
  317. # I would love to avoid using pkg-config (which may not be available on
  318. # some compilation environment) but doing so really add a lot of
  319. # complexity to the system, as the headers don't lie in a standard
  320. # directory (they lie in a subdirectory of a standard include directory;
  321. # not the same thing for configure scripts).
  322. XML_CFLAGS="`pkg-config libxml-2.0 --cflags`"
  323. XML_LDFLAGS="`pkg-config libxml-2.0 --libs-only-L`"
  324. XML_LIBS="`pkg-config libxml-2.0 --libs-only-l`"
  325. AC_CHECK_LIB([xml2],
  326. [xmlNewDoc],
  327. [libxml2_lib_found=yes],
  328. [libxml2_lib_found=no],
  329. [-lz])
  330. if test "x$libxml2_lib_found" != "xyes"; then
  331. if test "$xml_backend" = "auto"; then
  332. AC_MSG_WARN([cannot find libxml2 library])
  333. else
  334. AC_MSG_ERROR([cannot find libxml2 library])
  335. fi
  336. fi
  337. # the header file is installed in a subdirectory of one of the standard
  338. # include directory. This might prove to be a problem if the cross-
  339. # compile environment is not complete enough (i.e. if it misses
  340. # pkg-config, or if pkg-config returns wrong values). In most cases, the
  341. # environment is likely to be OK so we will never hit any issue.
  342. xml2_CFLAGS="$CFLAGS"
  343. CFLAGS="$CFLAGS $XML_CFLAGS"
  344. AC_CHECK_HEADER([libxml/tree.h],
  345. [libxml2_h_found=yes],
  346. [libxml2_h_found=no],
  347. [/* force include check */])
  348. CFLAGS="$xml2_CFLAGS"
  349. if test "x$libxml2_h_found" != "xyes"; then
  350. if test "$xml_backend" = "auto"; then
  351. AC_MSG_WARN([cannot find libxml2 headers])
  352. else
  353. AC_MSG_ERROR([cannot find libxml2 headers])
  354. fi
  355. fi
  356. AC_DEFINE([HAVE_LIB_LIBXML2],
  357. [],
  358. [libxml2-based XML backend])
  359. xml_backend="found"
  360. found_xml_backend="libxml2"
  361. ;;
  362. *)
  363. # this is probably broken. We consider that the user supplied path is
  364. # a non-standard path. But we're not going to check anything.
  365. AC_MSG_WARN([--with-libxml2=DIR is probably broken, just trying])
  366. XML_LDFLAGS="-L${use_libxml2}/lib"
  367. XML_CFLAGS="-I${use_libxml2}/include/libxml2"
  368. XML_LIBS="-lxml2"
  369. AC_MSG_CHECKING([for libxml2 support])
  370. AC_MSG_RESULT([yes])
  371. AC_MSG_NOTICE([headers for libxml2 hopefully in ${use_libxml2}/include/libxml2])
  372. AC_MSG_NOTICE([library libxml2 hopefully in ${use_libxml2}/lib])
  373. AC_DEFINE([HAVE_LIB_LIBXML2],
  374. [],
  375. [libxml2-based XML backend])
  376. xml_backend="found"
  377. found_xml_backend="libxml2"
  378. ;;
  379. esac
  380. else
  381. # not selected? We print a small message
  382. AC_MSG_CHECKING([for libxml2 support])
  383. AC_MSG_RESULT([no])
  384. fi
  385. if test "$xml_backend" != "found"; then
  386. AC_MSG_ERROR([Failed to find a suitable XML backend])
  387. fi
  388. if test $count_xml_backends -eq 0; then
  389. AC_MSG_NOTICE([I found a suitable XML backend: $found_xml_backend])
  390. fi
  391. AC_SUBST(XML_LIBS)
  392. AC_SUBST(XML_LDFLAGS)
  393. AC_SUBST(XML_CFLAGS)
  394. ################################
  395. # Search for network functions (like connect())
  396. ################################
  397. AC_SEARCH_LIBS([socket], [socket])
  398. ################################
  399. # Check for regex.h
  400. ################################
  401. AC_CHECK_HEADERS(regex.h, [],
  402. AC_MSG_ERROR([regex.h not found: regular expressions are not supported]))
  403. ################################
  404. # Check for getopt_long()
  405. ################################
  406. AC_CHECK_HEADERS(getopt.h, [],
  407. AC_MSG_WARN([getopt.h not found: only short parameters can be used on command line]))
  408. ################################
  409. # Check for locale.h
  410. ################################
  411. AC_CHECK_HEADERS(locale.h, [],
  412. AC_MSG_WARN([locale.h not found: the locales is not supported]))
  413. ################################
  414. # Check for CODESET within nl_langinfo
  415. ################################
  416. AC_DEFUN([AM_LANGINFO_CODESET],
  417. [
  418. AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
  419. [AC_TRY_LINK([#include <langinfo.h>],
  420. [char* cs = nl_langinfo(CODESET); return !cs;],
  421. [am_cv_langinfo_codeset=yes],
  422. [am_cv_langinfo_codeset=no])
  423. ])
  424. if test $am_cv_langinfo_codeset = yes; then
  425. AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
  426. [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
  427. fi
  428. ])
  429. AM_LANGINFO_CODESET
  430. ################################
  431. # Check for pwd.h and grp.h
  432. ################################
  433. AC_CHECK_HEADERS(pwd.h, [],
  434. AC_MSG_WARN([pwd.h not found: the pwd operations is not supported]))
  435. AC_CHECK_HEADERS(grp.h, [],
  436. AC_MSG_WARN([grp.h not found: the grp operations is not supported]))
  437. ################################
  438. # Check for chroot
  439. ################################
  440. AC_CHECK_FUNCS(chroot, [],
  441. AC_MSG_WARN([chroot() not found: the choot is not supported]))
  442. AC_CONFIG_FILES(Makefile)
  443. AC_OUTPUT