configure.ac 18 KB

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