Fix CLEARCACHE and multiple client with the same file.
[pwmd.git] / configure.ac
blob25d98b826c6297cab192390ad7eacc6b8ce9e0e8
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
3 AC_INIT(pwmd, 3.0-dev, [Ben Kibbey bjk@luxsci.net])
4 AC_CONFIG_AUX_DIR(build)
5 AC_CANONICAL_TARGET
6 AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip])
7 AC_PROG_MAKE_SET
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.
15 AC_PROG_CC_C99
17 if test "$ac_cv_prog_cc_c99" = "no"; then
18     AC_MSG_WARN("Unable to find a C99 compatible compiler.")
21 AC_PROG_AWK
22 AC_PROG_LN_S
23 AC_PROG_INSTALL
24 AC_PROG_LN_S
25 AC_PROG_RANLIB
26 AC_PROG_CPP
27 AC_PROG_MKDIR_P
29 dnl Checks for library functions.
30 ACX_PTHREAD(, [POSIX threads are required])
31 CC="$PTHREAD_CC"
32 AM_PATH_LIBASSUAN([2.0.2],, AC_MSG_ERROR([libassuan not found]))
33 PKG_PROG_PKG_CONFIG()
34 PKG_CHECK_MODULES([LIBGTHREAD], [gthread-2.0 >= 2.16.0])
35 AM_PATH_LIBGCRYPT([1.5.0],, AC_MSG_ERROR([libgcrypt not found]))
36 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
37 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
38 dnl For data file conversion.
39 AC_CHECK_LIB(z, deflate,,
40              AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
42 dnl Checks for header files.
43 AC_HEADER_STDC
44 AC_HEADER_SYS_WAIT
45 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h libintl.h \
46                   locale.h syslog.h termios.h zlib.h getopt.h])
47 AC_CHECK_HEADER([linux/prctl.h],
48                 AC_CHECK_DECL([PR_SET_NAME],,, [[#include <linux/prctl.h>]]))
49 if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
50   AC_DEFINE(HAVE_PR_SET_NAME, 1,
51             [Defined if PR_SET_NAME is available (Linux specific)])
54 dnl Checks for typedefs, structures, and compiler characteristics.
55 AC_SYS_LARGEFILE
56 AC_C_CONST
57 AC_C_INLINE
58 AC_TYPE_MODE_T
59 AC_TYPE_SIZE_T
60 AC_STRUCT_TM
61 AC_TYPE_PID_T
62 AC_TYPE_SIGNAL
65 # Check for the getsockopt SO_PEERCRED
67 AC_MSG_CHECKING(for SO_PEERCRED)
68 AC_CACHE_VAL(pwmd_cv_sys_so_peercred,
69       [AC_TRY_COMPILE([#include <sys/socket.h>], 
70          [struct ucred cr; 
71           int cl = sizeof cr;
72           getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);],
73           pwmd_cv_sys_so_peercred=yes,
74           pwmd_cv_sys_so_peercred=no)
75        ])
76 AC_MSG_RESULT($pwmd_cv_sys_so_peercred) 
77 if test $pwmd_cv_sys_so_peercred = yes; then
78   AC_DEFINE(HAVE_SO_PEERCRED, 1,
79             [Defined if SO_PEERCRED is supported (Linux specific)])
82 dnl Checks for library functions.
83 AC_FUNC_STAT
84 AC_FUNC_FORK
85 AC_FUNC_MALLOC
86 AC_FUNC_MEMCMP
87 AC_FUNC_STRFTIME
88 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
89                 strstr strtol setrlimit mlockall getopt_long backtrace])
90 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
92 AC_DEFUN([AC_DEBUG],
94     if test "$1"; then
95         ac_cv_sys_debug=$1
96     fi
98     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
99         [ac_cv_sys_debug=no])
100     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
103 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
104     AC_DEBUG([$enableval]), AC_DEBUG)
106 AC_DEFUN([AC_MEM_DEBUG],
108     if test "$1"; then
109         ac_cv_sys_mem_debug=$1
110     fi
112     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
113         [ac_cv_sys_mem_debug=no])
114     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
117 AC_DEFUN([AC_MUTEX_DEBUG],
119     if test "$1"; then
120         ac_cv_sys_mutex_debug=$1
121     fi
123     AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
124         [ac_cv_sys_mutex_debug=no])
125     AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
128 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
129     AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
131 # Libacl support (for data files).
132 AC_ARG_ENABLE(acl, AC_HELP_STRING([--enable-acl], 
133               [Enable Access Control List support]), USE_LIBACL=yes,
134               USE_LIBACL=no)
135 if test "x$USE_LIBACL" = "xyes"; then
136     AC_CHECK_LIB(acl, acl_get_file,,
137                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
138     AC_CHECK_HEADER([sys/acl.h],,
139                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
140     AC_DEFINE(WITH_LIBACL, 1, [Define if you want libacl support.])
142 AM_CONDITIONAL(WITH_LIBACL, [test "x$USE_LIBACL" = "xyes"])
144 # Memory debugging.
145 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
146     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
147 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
149 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
150 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
151 VERSION_NUM="`printf 0x%02x%02x ${VERSION_MAJOR} ${VERSION_MINOR}`"
152 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
154 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd.1 po/Makefile.in])
155 AC_OUTPUT
156 echo
157 echo "Features:"
158 echo "    Debug: ${ac_cv_sys_debug}"
159 echo "    Memory debug: ${ac_cv_sys_mem_debug}"
160 echo "    Mutex debug: ${ac_cv_sys_mutex_debug}"
161 echo "    ACL: $USE_LIBACL"