1
0

configure.ac 17 KB

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