1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT(pwmd, 3.0.0-dev, [Ben Kibbey bjk@luxsci.net])
4 AC_CONFIG_AUX_DIR(build)
6 AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip])
8 AC_USE_SYSTEM_EXTENSIONS()
9 AC_CONFIG_SRCDIR([src/pwmd.c])
10 AM_CONFIG_HEADER([config.h])
11 AM_GNU_GETTEXT([external])
12 AM_GNU_GETTEXT_VERSION([0.16.1])
14 dnl Checks for programs.
17 if test "$ac_cv_prog_cc_c99" = "no"; then
18 AC_MSG_WARN("Unable to find a C99 compatible compiler.")
29 dnl Checks for library functions.
30 ACX_PTHREAD(, [POSIX threads are required])
34 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
35 LIBS="$PTHREAD_LIBS $LIBS"
36 acx_pthread_mutex_timedlock_ok=no
37 AC_MSG_CHECKING([for pthread_mutex_timedlock()])
38 AC_TRY_LINK_FUNC(pthread_mutex_timedlock, acx_pthread_mutex_timedlock_ok=yes)
39 AC_MSG_RESULT($acx_pthread_mutex_timedlock_ok)
40 if test x"$acx_pthread_mutex_timedlock_ok" = "xyes"; then
41 AC_DEFINE(HAVE_PTHREAD_MUTEX_TIMEDLOCK, 1, [Define if your OS has pthread_mutex_timedlock().])
46 AM_PATH_LIBASSUAN([2.0.2],, AC_MSG_ERROR([libassuan not found]))
48 PKG_CHECK_MODULES([LIBGTHREAD], [gthread-2.0 >= 2.16.0])
49 AM_PATH_LIBGCRYPT([1.5.0],, AC_MSG_ERROR([libgcrypt not found]))
50 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
51 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
52 dnl For data file conversion.
53 AC_CHECK_LIB(z, deflate,,
54 AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
55 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls],
56 [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
58 if test "x$USE_GNUTLS" = "xyes"; then
59 PKG_CHECK_MODULES([GNUTLS], [gnutls])
60 AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
62 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
64 dnl Checks for header files.
67 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h libintl.h \
68 locale.h syslog.h termios.h zlib.h getopt.h])
69 AC_CHECK_HEADER([linux/prctl.h],
70 AC_CHECK_DECL([PR_SET_NAME],,, [[#include <linux/prctl.h>]]))
71 if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
72 AC_DEFINE(HAVE_PR_SET_NAME, 1,
73 [Defined if PR_SET_NAME is available (Linux specific)])
75 AC_CHECK_HEADER([sys/socket.h], AC_CHECK_DECLS([SO_BINDTODEVICE,SO_PEERCRED],,, [[#include <sys/socket.h>]]))
77 dnl Checks for typedefs, structures, and compiler characteristics.
87 dnl Checks for library functions.
93 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
94 strstr strtol setrlimit mlockall getopt_long backtrace])
95 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
103 AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
104 [ac_cv_sys_debug=no])
105 AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
108 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
109 AC_DEBUG([$enableval]), AC_DEBUG)
111 AC_DEFUN([AC_MEM_DEBUG],
114 ac_cv_sys_mem_debug=$1
117 AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
118 [ac_cv_sys_mem_debug=no])
119 AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
122 AC_DEFUN([AC_MUTEX_DEBUG],
125 ac_cv_sys_mutex_debug=$1
128 AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
129 [ac_cv_sys_mutex_debug=no])
130 AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
133 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
134 AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
136 # Libacl support (for data files).
137 AC_ARG_ENABLE(acl, AC_HELP_STRING([--enable-acl],
138 [Enable Access Control List support]), USE_LIBACL=yes,
140 if test "x$USE_LIBACL" = "xyes"; then
141 AC_CHECK_LIB(acl, acl_get_file,,
142 AC_MSG_ERROR([Missing or incomplete libacl installation.]))
143 AC_CHECK_HEADER([sys/acl.h],,
144 AC_MSG_ERROR([Missing or incomplete libacl installation.]))
145 AC_DEFINE(WITH_LIBACL, 1, [Define if you want libacl support.])
147 AM_CONDITIONAL(WITH_LIBACL, [test "x$USE_LIBACL" = "xyes"])
150 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
151 AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
152 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
154 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
155 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
156 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
157 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
158 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
160 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd.1 po/Makefile.in
165 echo " Debug: ${ac_cv_sys_debug}"
166 echo " Memory debug: ${ac_cv_sys_mem_debug}"
167 echo " Mutex debug: ${ac_cv_sys_mutex_debug}"
168 echo " ACL: $USE_LIBACL"
169 echo " TCP (GnuTLS): $USE_GNUTLS"