1
0

configure.ac 15 KB

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