configure.ac 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. m4_define([MAJOR_VERSION], 3)
  4. m4_define([MINOR_VERSION], 0)
  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. case x$use_libxml2 in
  201. xno)
  202. /bin/true
  203. ;;
  204. xyes)
  205. # I would love to avoid using pkg-config (which may not be available on
  206. # some compilation environment) but doing so really add a lot of
  207. # complexity to the system, as the headers don't lie in a standard
  208. # directory (they lie in a subdirectory of a standard include directory;
  209. # not the same thing for configure scripts).
  210. LIBXML2_CFLAGS="`pkg-config libxml-2.0 --cflags`"
  211. LIBXML2_LDFLAGS="`pkg-config libxml-2.0 --libs-only-L`"
  212. LIBXML2_LIBS="`pkg-config libxml-2.0 --libs-only-l`"
  213. AC_CHECK_LIB([xml2],
  214. [xmlNewDoc],
  215. [],
  216. [AC_MSG_ERROR([cannot find libxml2 headers])],
  217. [])
  218. # the header file is installed in a subdirectory of one of the standard
  219. # include directory. This might prove to be a problem if the cross-
  220. # compile environment is not complete enough (i.e. if it misses
  221. # pkg-config, or if pkg-config returns wrong values). In most cases, the
  222. # environment is likely to be OK so we will never hit any issue.
  223. saved_CFLAGS="$CFLAGS"
  224. CFLAGS="$CFLAGS $LIBXML2_CFLAGS"
  225. AC_CHECK_HEADER([libxml/tree.h],
  226. [],
  227. [AC_MSG_ERROR([cannot find libxml2 headers])],
  228. [/* */])
  229. CFLAGS="$saved_CFLAGS"
  230. AC_DEFINE([HAVE_LIB_LIBXML2],
  231. [],
  232. [libxml2-based XML backend])
  233. ;;
  234. *)
  235. # this is probably broken. We consider that the user supplied path is
  236. # a non-standard path. But we're not going to check anything.
  237. AC_MSG_WARN([--with-libxml2=DIR is probably broken, just trying])
  238. LIBXML2_LDFLAGS="-L${use_libxml2}/lib"
  239. LIBXML2_CFLAGS="-I${use_libxml2}/include/libxml2"
  240. LIBXML2_LIBS="-lxml2"
  241. AC_MSG_CHECKING([for libxml2 support])
  242. AC_MSG_RESULT([yes])
  243. AC_MSG_NOTICE([headers for libxml2 hopefully in ${use_libxml2}/include/libxml2])
  244. AC_MSG_NOTICE([library libxml2 hopefully in ${use_libxml2}/lib])
  245. AC_DEFINE([HAVE_LIB_LIBXML2],
  246. [],
  247. [libxml2-based XML backend])
  248. ;;
  249. esac
  250. AC_SUBST(LIBXML2_LIBS)
  251. AC_SUBST(LIBXML2_LDFLAGS)
  252. AC_SUBST(LIBXML2_CFLAGS)
  253. ################################
  254. # Check for the roxml library
  255. ################################
  256. AC_ARG_WITH(roxml,
  257. [AS_HELP_STRING([--with-roxml=DIR],
  258. [Use roxml as the XML parser implementation [default=no]])],
  259. [use_roxml=$withval],
  260. [use_roxml=no])
  261. case x$use_roxml in
  262. xno)
  263. /bin/true
  264. ;;
  265. xyes)
  266. # we choose to NOT rely on pkg-config on this one. We may do it as
  267. # roxml provides a .pc file but some environment (both cross-compile
  268. # or native environment) may lack this support. The good thing is that
  269. # it doesn't add much complexity to the configure.ac file (and we
  270. # may move these tests to another m4 file later).
  271. # The header is installed in the standard path
  272. AC_CHECK_HEADER([roxml.h],
  273. [],
  274. [AC_MSG_ERROR([cannot find <roxml.h> header file])],
  275. [/* */])
  276. # The library is installed in the standard path
  277. AC_CHECK_LIB([roxml],
  278. [roxml_load_doc],
  279. [],
  280. [AC_MSG_ERROR([cannot find roxml library])],
  281. [])
  282. ROXML_CFLAGS=""
  283. ROXML_LDFLAGS=""
  284. ROXML_LIBS="-lroxml"
  285. AC_DEFINE([HAVE_LIB_ROXML],
  286. [],
  287. [roxml-based XML backend])
  288. ;;
  289. *)
  290. # first, we check if we're not looking for an alternate include
  291. # directory -for example, if the user feeds the script with the
  292. # option --with-roxml=/usr/local
  293. # NOTE: we search for include/roxml.h and inc/roxml.h to defeat
  294. # the caching algorithm of the configure script. If someone knows
  295. # a better way, please do not hesitate
  296. saved_CFLAGS="$CFLAGS"
  297. CFLAGS="$CFLAGS -I${use_roxml}"
  298. AC_CHECK_HEADER([include/roxml.h],
  299. [roxml_h_found=yes],
  300. [roxml_h_found=no],
  301. [/* */])
  302. if test "x$roxml_h_found" = "xno"; then
  303. # the directory might be a source directory, so check
  304. # if the include file is to be found here
  305. AC_CHECK_HEADER([inc/roxml.h],
  306. [roxml_h_found=yes],
  307. [roxml_h_found=no],
  308. [/* */])
  309. if test "x$roxml_h_found" = "xno"; then
  310. AC_MSG_ERROR([cannot find <roxml.h> header file])
  311. fi
  312. ROXML_CFLAGS="-I${use_roxml}/inc"
  313. AC_MSG_NOTICE([header file <roxml.h> found in ${use_roxml}/inc])
  314. else
  315. ROXML_CFLAGS="-I${use_roxml}/include"
  316. AC_MSG_NOTICE([header file <roxml.h> found in ${use_roxml}/include])
  317. fi
  318. CFLAGS="$saved_CFLAGS"
  319. # we're doing both previous checks, but we are trying to find a library
  320. # now, so the check themselves are a bit different
  321. # NOTE: we search for roxml_load_doc and roxml_close to defeat
  322. # the caching algorithm of the configure script. If someone knows
  323. # a better way, please do not hesitate.
  324. saved_LDFLAGS="$LDFLAGS"
  325. LDFLAGS="$LDFLAGS -L${use_roxml}/lib"
  326. AC_CHECK_LIB([roxml],
  327. [roxml_load_doc],
  328. [roxml_lib_found=yes],
  329. [roxml_lib_found=no],
  330. [])
  331. LDFLAGS="$saved_LDFLAGS"
  332. if test "x$roxml_lib_found" = "xno"; then
  333. LDFLAGS="$LDFLAGS -L${use_roxml}"
  334. AC_CHECK_LIB([roxml],
  335. [roxml_close],
  336. [],
  337. [AC_MSG_ERROR([cannot find roxml library])],
  338. [])
  339. LDFLAGS=$saved_LDFLAGS
  340. ROXML_LDFLAGS="-L${use_roxml}"
  341. ROXML_LIBS="-lroxml"
  342. AC_MSG_NOTICE([library roxml found in ${use_roxml}])
  343. else
  344. ROXML_LDFLAGS="-L${use_roxml}/lib"
  345. ROXML_LIBS="-lroxml"
  346. AC_MSG_NOTICE([library roxml found in ${use_roxml}/lib])
  347. fi
  348. AC_DEFINE([HAVE_LIB_ROXML],
  349. [],
  350. [roxml-based XML backend])
  351. ;;
  352. esac
  353. AC_SUBST(ROXML_LIBS)
  354. AC_SUBST(ROXML_LDFLAGS)
  355. AC_SUBST(ROXML_CFLAGS)
  356. ################################
  357. # Check for the expat library
  358. ################################
  359. AC_ARG_WITH(expat,
  360. [AS_HELP_STRING([--with-expat=DIR],
  361. [Use expat as the XML parser implementation [default=no]])],
  362. [use_expat=$withval],
  363. [use_expat=no])
  364. case x$use_expat in
  365. xno)
  366. /bin/true
  367. ;;
  368. xyes)
  369. # we choose to NOT rely on pkg-config on this one. Instead, we
  370. # check for the library and the header file - that should be
  371. # enough.
  372. AC_CHECK_HEADER([expat.h],
  373. [expat_h_found=yes],
  374. [expat_h_found=no],
  375. [/* */])
  376. if test "x$expat_h_found" != "xyes"; then
  377. AC_CHECK_HEADER([bsdxml.h],
  378. [expat_h_found=yes],
  379. [expat_h_found=no],
  380. [/* */])
  381. if test "x$expat_h_found" != "xyes"; then
  382. AC_MSG_ERROR([cannot find <expat.h> header file])
  383. fi
  384. fi
  385. EXPAT_CFLAGS=""
  386. AC_CHECK_LIB([expat],
  387. [XML_ParserCreate],
  388. [expat_lib_found=yes],
  389. [expat_lib_found=no],
  390. [])
  391. if test "x$expat_lib_found" != "xyes"; then
  392. AC_CHECK_LIB([bsdxml],
  393. [XML_ParserCreate],
  394. [],
  395. [AC_MSG_ERROR([cannot find expat library])],
  396. [])
  397. EXPAT_LIBS="-lbsdxml"
  398. AC_DEFINE([HAVE_LIB_BSDXML],
  399. [],
  400. [libbsdxml-based XML backend])
  401. else
  402. EXPAT_LIBS="-lexpat"
  403. fi
  404. EXPAT_LDFLAGS=""
  405. AC_DEFINE([HAVE_LIB_EXPAT],
  406. [],
  407. [expat-based XML backend])
  408. ;;
  409. *)
  410. # this is probably broken. We consider that the user supplied path is
  411. # a non-standard path. But we're not going to check anything.
  412. AC_MSG_WARN([--with-expat=DIR is probably broken, just trying])
  413. EXPAT_LDFLAGS="-L${use_expat}/lib"
  414. EXPAT_CFLAGS="-I${use_expat}/include"
  415. EXPAT_LIBS="-lexpat"
  416. AC_MSG_CHECKING([for expat support])
  417. AC_MSG_RESULT([yes])
  418. AC_MSG_NOTICE([headers for expat hopefully in ${use_expat}/include])
  419. AC_MSG_NOTICE([library expat hopefully in ${use_expat}/lib])
  420. AC_DEFINE([HAVE_LIB_EXPAT],
  421. [],
  422. [expat-based XML backend])
  423. ;;
  424. esac
  425. AC_SUBST(EXPAT_LIBS)
  426. AC_SUBST(EXPAT_LDFLAGS)
  427. AC_SUBST(EXPAT_CFLAGS)
  428. ################################
  429. # Check for Lua support
  430. ################################
  431. AC_ARG_WITH(lua,
  432. [AS_HELP_STRING([--with-lua=DIR],
  433. [Build Lua ACTION plugin [default=no]])],
  434. [use_lua=$withval],
  435. [use_lua=no])
  436. AM_CONDITIONAL(WITH_LUA,test x$use_lua != xno)
  437. if test x$use_lua != xno; then
  438. if test x$use_lua != xyes; then
  439. CPPFLAGS="${CPPFLAGS} -I$use_lua/include"
  440. LDFLAGS="${LDFLAGS} -L$use_lua/lib"
  441. fi
  442. LUA_VERSION="5.1"
  443. AX_LUA_HEADERS()
  444. AX_LUA_LIBS()
  445. fi
  446. AC_CONFIG_FILES([Makefile])
  447. AC_OUTPUT