configure.ac 15 KB

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