1
0

configure.ac 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. m4_define([MAJOR_VERSION], 1)
  4. m4_define([MINOR_VERSION], 7)
  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. 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. if test "$xml_backend" = "auto"; then
  112. AC_MSG_WARN([cannot find <expat.h> header file])
  113. else
  114. AC_MSG_ERROR([cannot find <expat.h> header file])
  115. fi
  116. fi
  117. XML_CFLAGS=""
  118. AC_CHECK_LIB([expat],
  119. [XML_ParserCreate],
  120. [expat_lib_found=yes],
  121. [expat_lib_found=no],
  122. [])
  123. if test "x$expat_lib_found" != "xyes"; then
  124. if test "$xml_backend" = "auto"; then
  125. AC_MSG_WARN([cannot find expat library])
  126. else
  127. AC_MSG_ERROR([cannot find expat library])
  128. fi
  129. fi
  130. XML_LDFLAGS=""
  131. XML_LIBS="-lexpat"
  132. AC_DEFINE([HAVE_LIB_EXPAT],
  133. [],
  134. [libexpat-based XML backend])
  135. xml_backend="found"
  136. found_xml_backend="expat"
  137. ;;
  138. *)
  139. # this is probably broken. We consider that the user supplied path is
  140. # a non-standard path. But we're not going to check anything.
  141. AC_MSG_WARN([--with-expat=DIR is probably broken, just trying])
  142. XML_LDFLAGS="-L${use_expat}/lib"
  143. XML_CFLAGS="-I${use_expat}/include"
  144. XML_LIBS="-lexpat"
  145. AC_MSG_CHECKING([for expat support])
  146. AC_MSG_RESULT([yes])
  147. AC_MSG_NOTICE([headers for expat hopefully in ${use_expat}/include])
  148. AC_MSG_NOTICE([library expat hopefully in ${use_expat}/lib])
  149. AC_DEFINE([HAVE_LIB_EXPAT],
  150. [],
  151. [expat-based XML backend])
  152. xml_backend="found"
  153. found_xml_backend="expat"
  154. ;;
  155. esac
  156. else
  157. AC_MSG_CHECKING([for libexpat support])
  158. AC_MSG_RESULT([no])
  159. fi
  160. if test "$xml_backend" = "roxml" -o "$xml_backend" = "auto"; then
  161. if test "$xml_backend" = "auto"; then
  162. # on auto select, we try to detect the library
  163. use_roxml="yes"
  164. fi
  165. case x$use_roxml in
  166. xyes)
  167. # we choose to NOT rely on pkg-config on this one. We may do it as
  168. # libroxml provides a .pc file but some environment (both cross-compile
  169. # or native environment) may lack this support. The good thing is that
  170. # it doesn't add much complexity to the configure.ac file (and we
  171. # may move these tests to another m4 file later).
  172. # the header is installed in the standard path
  173. AC_CHECK_HEADER([roxml.h],
  174. [roxml_h_found=yes],
  175. [roxml_h_found=no],
  176. [/* force include check */])
  177. if test "x$roxml_h_found" != "xyes"; then
  178. if test "$xml_backend" = "auto"; then
  179. AC_MSG_WARN([cannot find <roxml.h> header file])
  180. else
  181. AC_MSG_ERROR([cannot find <roxml.h> header file])
  182. fi
  183. fi
  184. XML_CFLAGS=""
  185. # the library is installed in the standard path
  186. AC_CHECK_LIB([roxml],
  187. [roxml_load_doc],
  188. [roxml_lib_found=yes],
  189. [roxml_lib_found=no],
  190. [])
  191. if test "x$roxml_lib_found" != "xyes"; then
  192. if test "$xml_backend" = "auto"; then
  193. AC_MSG_WARN([cannot find roxml library])
  194. else
  195. AC_MSG_ERROR([cannot find roxml library])
  196. fi
  197. fi
  198. XML_LDFLAGS=""
  199. XML_LIBS="-lroxml"
  200. AC_DEFINE([HAVE_LIB_ROXML],
  201. [],
  202. [libroxml-based XML backend])
  203. xml_backend="found"
  204. found_xml_backend="roxml"
  205. ;;
  206. *)
  207. # first, we check if we're not looking for an alternate include
  208. # directory -for example, if the user feeds the script with the
  209. # option --with-roxml=/usr/local
  210. # NOTE: we search for include/roxml.h and inc/roxml.h to defeat
  211. # the caching algorithm of the configure script. If someone knows
  212. # a better way, please do not hesitate
  213. roxml_CFLAGS="$CFLAGS"
  214. CFLAGS="$CFLAGS -I${use_roxml}"
  215. AC_CHECK_HEADER([include/roxml.h],
  216. [roxml_h_found=yes],
  217. [roxml_h_found=no],
  218. [/* force include check */])
  219. if test "x$roxml_h_found" = "xno"; then
  220. # the directory might be a source directory, so check
  221. # if the include file is to be found here
  222. AC_CHECK_HEADER([inc/roxml.h],
  223. [roxml_h_found=yes],
  224. [roxml_h_found=no],
  225. [/* force include check */])
  226. if test "x$roxml_h_found" = "xno"; then
  227. if test "$xml_backend" = "auto"; then
  228. AC_MSG_WARN([cannot find <roxml.h> header file])
  229. else
  230. AC_MSG_ERROR([cannot find <roxml.h> header file])
  231. fi
  232. fi
  233. XML_CFLAGS="-I${use_roxml}/inc"
  234. AC_MSG_NOTICE([header file <roxml.h> found in ${use_roxml}/inc])
  235. else
  236. XML_CFLAGS="-I${use_roxml}/include"
  237. AC_MSG_NOTICE([header file <roxml.h> found in ${use_roxml}/include])
  238. fi
  239. CFLAGS="$roxml_CFLAGS"
  240. # we're doing both previous checks, but we are trying to find a library
  241. # now, so the check themselves are a bit different
  242. # NOTE: we search for roxml_load_doc and roxml_close to defeat
  243. # the caching algorithm of the configure script. If someone knows
  244. # a better way, please do not hesitate.
  245. roxml_LDFLAGS="$LDFLAGS"
  246. LDFLAGS="$LDFLAGS -L${use_roxml}/lib"
  247. AC_CHECK_LIB([roxml],
  248. [roxml_load_doc],
  249. [roxml_lib_found=yes],
  250. [roxml_lib_found=no],
  251. [])
  252. LDFLAGS=$roxml_LDFLAGS
  253. if test "x$roxml_lib_found" = "xno"; then
  254. LDFLAGS="$LDFLAGS -L${use_roxml}"
  255. AC_CHECK_LIB([roxml],
  256. [roxml_close],
  257. [roxml_lib_found=yes],
  258. [roxml_lib_found=no],
  259. [])
  260. LDFLAGS=$roxml_LDFLAGS
  261. if test "x$roxml_lib_found" = "xno"; then
  262. if test "$xml_backend" = "auto"; then
  263. AC_MSG_WARN([cannot find roxml library])
  264. else
  265. AC_MSG_ERROR([cannot find roxml library])
  266. fi
  267. fi
  268. XML_LDFLAGS="-L${use_roxml}"
  269. XML_LIBS="-lroxml"
  270. AC_MSG_NOTICE([library libroxml found in ${use_roxml}])
  271. else
  272. XML_LDFLAGS="-L${use_roxml}/lib"
  273. XML_LIBS="-lroxml"
  274. AC_MSG_NOTICE([library libroxml found in ${use_roxml}/lib])
  275. fi
  276. AC_DEFINE([HAVE_LIB_ROXML],
  277. [],
  278. [libroxml-based XML backend])
  279. xml_backend="found"
  280. found_xml_backend="roxml"
  281. ;;
  282. esac
  283. else
  284. AC_MSG_CHECKING([for libroxml support])
  285. AC_MSG_RESULT([no])
  286. fi
  287. if test "$xml_backend" = "libxml2" -o "$xml_backend" = "auto"; then
  288. if test "$xml_backend" = "auto"; then
  289. # on auto select, we try to detect the library
  290. use_libxml2="yes"
  291. fi
  292. case x$use_libxml2 in
  293. xyes)
  294. # I would love to avoid using pkg-config (which may not be available on
  295. # some compilation environment) but doing so really add a lot of
  296. # complexity to the system, as the headers don't lie in a standard
  297. # directory (they lie in a subdirectory of a standard include directory;
  298. # not the same thing for configure scripts).
  299. XML_CFLAGS="`pkg-config libxml-2.0 --cflags`"
  300. XML_LDFLAGS="`pkg-config libxml-2.0 --libs-only-L`"
  301. XML_LIBS="`pkg-config libxml-2.0 --libs-only-l`"
  302. AC_CHECK_LIB([xml2],
  303. [xmlNewDoc],
  304. [libxml2_lib_found=yes],
  305. [libxml2_lib_found=no],
  306. [-lz])
  307. if test "x$libxml2_lib_found" != "xyes"; then
  308. if test "$xml_backend" = "auto"; then
  309. AC_MSG_WARN([cannot find libxml2 library])
  310. else
  311. AC_MSG_ERROR([cannot find libxml2 library])
  312. fi
  313. fi
  314. # the header file is installed in a subdirectory of one of the standard
  315. # include directory. This might prove to be a problem if the cross-
  316. # compile environment is not complete enough (i.e. if it misses
  317. # pkg-config, or if pkg-config returns wrong values). In most cases, the
  318. # environment is likely to be OK so we will never hit any issue.
  319. xml2_CFLAGS="$CFLAGS"
  320. CFLAGS="$CFLAGS $XML_CFLAGS"
  321. AC_CHECK_HEADER([libxml/tree.h],
  322. [libxml2_h_found=yes],
  323. [libxml2_h_found=no],
  324. [/* force include check */])
  325. CFLAGS="$xml2_CFLAGS"
  326. if test "x$libxml2_h_found" != "xyes"; then
  327. if test "$xml_backend" = "auto"; then
  328. AC_MSG_WARN([cannot find libxml2 headers])
  329. else
  330. AC_MSG_ERROR([cannot find libxml2 headers])
  331. fi
  332. fi
  333. AC_DEFINE([HAVE_LIB_LIBXML2],
  334. [],
  335. [libxml2-based XML backend])
  336. xml_backend="found"
  337. found_xml_backend="libxml2"
  338. ;;
  339. *)
  340. # this is probably broken. We consider that the user supplied path is
  341. # a non-standard path. But we're not going to check anything.
  342. AC_MSG_WARN([--with-libxml2=DIR is probably broken, just trying])
  343. XML_LDFLAGS="-L${use_libxml2}/lib"
  344. XML_CFLAGS="-I${use_libxml2}/include/libxml2"
  345. XML_LIBS="-lxml2"
  346. AC_MSG_CHECKING([for libxml2 support])
  347. AC_MSG_RESULT([yes])
  348. AC_MSG_NOTICE([headers for libxml2 hopefully in ${use_libxml2}/include/libxml2])
  349. AC_MSG_NOTICE([library libxml2 hopefully in ${use_libxml2}/lib])
  350. AC_DEFINE([HAVE_LIB_LIBXML2],
  351. [],
  352. [libxml2-based XML backend])
  353. xml_backend="found"
  354. found_xml_backend="libxml2"
  355. ;;
  356. esac
  357. else
  358. # not selected? We print a small message
  359. AC_MSG_CHECKING([for libxml2 support])
  360. AC_MSG_RESULT([no])
  361. fi
  362. if test "$xml_backend" != "found"; then
  363. AC_MSG_ERROR([Failed to find a suitable XML backend])
  364. fi
  365. if test $count_xml_backends -eq 0; then
  366. AC_MSG_NOTICE([I found a suitable XML backend: $found_xml_backend])
  367. fi
  368. AC_SUBST(XML_LIBS)
  369. AC_SUBST(XML_LDFLAGS)
  370. AC_SUBST(XML_CFLAGS)
  371. ################################
  372. # Search for network functions (like connect())
  373. ################################
  374. AC_SEARCH_LIBS([socket], [socket])
  375. ################################
  376. # Check for regex.h
  377. ################################
  378. AC_CHECK_HEADERS(regex.h, [],
  379. AC_MSG_ERROR([regex.h not found: regular expressions are not supported]))
  380. ################################
  381. # Check for getopt_long()
  382. ################################
  383. AC_CHECK_HEADERS(getopt.h, [],
  384. AC_MSG_WARN([getopt.h not found: only short parameters can be used on command line]))
  385. ################################
  386. # Check for locale.h
  387. ################################
  388. AC_CHECK_HEADERS(locale.h, [],
  389. AC_MSG_WARN([locale.h not found: the locales is not supported]))
  390. ################################
  391. # Check for CODESET within nl_langinfo
  392. ################################
  393. AM_LANGINFO_CODESET
  394. ################################
  395. # Check for pwd.h and grp.h
  396. ################################
  397. AC_CHECK_HEADERS(pwd.h, [],
  398. AC_MSG_WARN([pwd.h not found: the pwd operations is not supported]))
  399. AC_CHECK_HEADERS(grp.h, [],
  400. AC_MSG_WARN([grp.h not found: the grp operations is not supported]))
  401. ################################
  402. # Check for chroot
  403. ################################
  404. AC_CHECK_FUNCS(chroot, [],
  405. AC_MSG_WARN([chroot() not found: the choot is not supported]))
  406. ################################
  407. # Check for dlopen
  408. ################################
  409. AC_CHECK_HEADERS(dlfcn.h, [
  410. AC_SEARCH_LIBS([dlopen], [dl dld], [], [
  411. AC_MSG_WARN([unable to find the dlopen() function])
  412. ])
  413. ],
  414. AC_MSG_WARN([dlfcn.h not found: the dl operations is not supported]))
  415. AC_CONFIG_FILES(Makefile)
  416. AC_OUTPUT