configure.ac 16 KB

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