configure.ac 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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], 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. # Check for system extensions (_POSIX_THREAD_SEMANTICS for Solaris)
  12. AC_USE_SYSTEM_EXTENSIONS
  13. # Checks for programs.
  14. AC_PROG_CC
  15. AC_LIBTOOL_WIN32_DLL
  16. AC_PROG_LIBTOOL
  17. AC_CONFIG_HEADERS([config.h])
  18. AM_INIT_AUTOMAKE(subdir-objects)
  19. AM_PROG_CC_C_O
  20. # needed to handle 64-bit architecture
  21. AC_CHECK_SIZEOF(int)
  22. AC_CHECK_SIZEOF(long)
  23. AC_CHECK_SIZEOF(size_t)
  24. #------------------------------------------------------------------------
  25. # Handle the --prefix=... option
  26. #------------------------------------------------------------------------
  27. if test "${prefix}" = "NONE"; then
  28. prefix=/usr/local
  29. fi
  30. if test "${exec_prefix}" = "NONE"; then
  31. exec_prefix=$prefix
  32. fi
  33. # libdir must be a fully qualified path (not ${exec_prefix}/lib)
  34. eval libdir="$libdir"
  35. ################################
  36. # Deal with debugging options
  37. ################################
  38. AC_ARG_ENABLE(debug,
  39. [AS_HELP_STRING([--enable-debug],
  40. [Turn on debugging including asserts [default=no]])],
  41. [],
  42. [enable_debug=no])
  43. AM_CONDITIONAL(DEBUG,test x$enable_debug = xyes)
  44. ################################
  45. # Check for the roxml library
  46. ################################
  47. AC_ARG_WITH(roxml,
  48. [AS_HELP_STRING([--with-roxml=DIR],
  49. [Use roxml as the XML parser implementation [default=no]])],
  50. [use_roxml=$withval],
  51. [use_roxml=no])
  52. AC_ARG_WITH(libxml2,
  53. [AS_HELP_STRING([--with-libxml2=DIR],
  54. [Use libxml2 as the XML parser implementation [default=yes]])],
  55. [use_libxml2=$withval],
  56. [use_libxml2=yes])
  57. if test "x$use_roxml" = "xyes"; then
  58. if test "x$use_libxml2" = "xyes"; then
  59. AC_MSG_WARN([both roxml and libxml2 are selected. I choose roxml])
  60. use_libxml2=no
  61. fi
  62. fi
  63. XML_LDFLAGS=""
  64. XML_CFLAGS=""
  65. XML_LIBS=""
  66. AC_MSG_CHECKING([for libroxml support])
  67. case x$use_roxml in
  68. xno)
  69. AC_MSG_RESULT([no])
  70. ;;
  71. xyes)
  72. # the library is installed in the standard path
  73. XML_LDFLAGS="`pkg-config libroxml --libs-only-L`"
  74. XML_CFLAGS="`pkg-config libroxml --cflags`"
  75. XML_LIBS="`pkg-config libroxml --libs-only-l`"
  76. AC_MSG_RESULT([yes])
  77. AC_DEFINE([HAVE_LIB_ROXML],
  78. [],
  79. [Define to 1 if you want to use libroxml to parse clish XML files])
  80. ;;
  81. *)
  82. # this is very likely to be a source directory, so
  83. # let's consider that it's a valid one
  84. XML_LDFLAGS="-L${use_roxml}"
  85. XML_CFLAGS="-I${use_roxml}/inc"
  86. XML_LIBS="-lroxml"
  87. AC_MSG_RESULT([yes (lib in ${use_roxml}, includes in ${use_roxml}/inc)])
  88. AC_DEFINE([HAVE_LIB_ROXML],
  89. [],
  90. [Define to 1 if you want to use libroxml to parse clish XML files])
  91. ;;
  92. esac
  93. AC_MSG_CHECKING([for libxml2 support])
  94. case x$use_libxml2 in
  95. xno)
  96. AC_MSG_RESULT([no])
  97. ;;
  98. xyes)
  99. # the library is installed in the standard path
  100. XML_LDFLAGS="`pkg-config libxml-2.0 --libs-only-L`"
  101. XML_CFLAGS="`pkg-config libxml-2.0 --cflags`"
  102. XML_LIBS="`pkg-config libxml-2.0 --libs-only-l`"
  103. AC_MSG_RESULT([yes])
  104. AC_DEFINE([HAVE_LIB_LIBXML2],
  105. [],
  106. [Define to 1 if you want to use libxml2 to parse clish XML files])
  107. ;;
  108. *)
  109. # this is very likely to be a source directory, so
  110. # let's consider that it's a valid one
  111. XML_LDFLAGS="-L${use_libxml2}"
  112. XML_CFLAGS="-I${use_libxml2}"
  113. XML_LIBS="-lxml2"
  114. AC_MSG_RESULT([yes (lib and includes in ${use_libxml2}])
  115. AC_DEFINE([HAVE_LIB_LIBXML2],
  116. [],
  117. [Define to 1 if you want to use libxml2 to parse clish XML files])
  118. ;;
  119. esac
  120. AC_SUBST(XML_LIBS)
  121. AC_SUBST(XML_LDFLAGS)
  122. AC_SUBST(XML_CFLAGS)
  123. ################################
  124. # Check for the LUB library
  125. ################################
  126. LUB_LIBS="-llub"
  127. LUB_CFLAGS=""
  128. if test "x$LUB_LIBS" = "x"; then
  129. AC_MSG_ERROR([Cannot find the "Little Useful Bits" library])
  130. fi
  131. AC_SUBST(LUB_LIBS)
  132. AC_SUBST(LUB_CFLAGS)
  133. ################################
  134. # Check for the KONF library
  135. ################################
  136. KONF_LIBS="-lkonf"
  137. KONF_CFLAGS=""
  138. if test "x$KONF_LIBS" = "x"; then
  139. AC_MSG_ERROR([Cannot find the "CLI config" library])
  140. fi
  141. AC_SUBST(KONF_LIBS)
  142. AC_SUBST(KONF_CFLAGS)
  143. ################################
  144. # Check for the TINYRL library
  145. ################################
  146. TINYRL_LIBS="-ltinyrl"
  147. TINYRL_CFLAGS=""
  148. if test "x$TINYRL_LIBS" = "x"; then
  149. AC_MSG_ERROR([Cannot find the "Tiny Readline" library])
  150. fi
  151. AC_SUBST(TINYRL_LIBS)
  152. AC_SUBST(TINYRL_CFLAGS)
  153. ################################
  154. # Search for network functions (like connect())
  155. ################################
  156. AC_SEARCH_LIBS([socket], [socket])
  157. ################################
  158. # Check for regex.h
  159. ################################
  160. AC_CHECK_HEADERS(regex.h, [],
  161. AC_MSG_ERROR([regex.h not found: regular expressions are not supported]))
  162. ################################
  163. # Check for getopt_long()
  164. ################################
  165. AC_CHECK_HEADERS(getopt.h, [],
  166. AC_MSG_WARN([getopt.h not found: only short parameters can be used on command line]))
  167. ################################
  168. # Check for locale.h
  169. ################################
  170. AC_CHECK_HEADERS(locale.h, [],
  171. AC_MSG_WARN([locale.h not found: the locales is not supported]))
  172. ################################
  173. # Check for CODESET within nl_langinfo
  174. ################################
  175. AM_LANGINFO_CODESET
  176. ################################
  177. # Check for pwd.h and grp.h
  178. ################################
  179. AC_CHECK_HEADERS(pwd.h, [],
  180. AC_MSG_WARN([pwd.h not found: the pwd operations is not supported]))
  181. AC_CHECK_HEADERS(grp.h, [],
  182. AC_MSG_WARN([grp.h not found: the grp operations is not supported]))
  183. ################################
  184. # Check for chroot
  185. ################################
  186. AC_CHECK_FUNCS(chroot, [],
  187. AC_MSG_WARN([chroot() not found: the choot is not supported]))
  188. AC_CONFIG_FILES(Makefile)
  189. AC_OUTPUT