configure.ac 15 KB

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