1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT(pwmd, 3.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])
32 AM_PATH_LIBASSUAN([2.0.2],, AC_MSG_ERROR([libassuan not found]))
34 PKG_CHECK_MODULES([LIBGTHREAD], [gthread-2.0 >= 2.14.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.
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])
48 dnl Checks for typedefs, structures, and compiler characteristics.
59 # Check for the getsockopt SO_PEERCRED
61 AC_MSG_CHECKING(for SO_PEERCRED)
62 AC_CACHE_VAL(pwmd_cv_sys_so_peercred,
63 [AC_TRY_COMPILE([#include <sys/socket.h>],
66 getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);],
67 pwmd_cv_sys_so_peercred=yes,
68 pwmd_cv_sys_so_peercred=no)
70 AC_MSG_RESULT($pwmd_cv_sys_so_peercred)
71 if test $pwmd_cv_sys_so_peercred = yes; then
72 AC_DEFINE(HAVE_SO_PEERCRED, 1,
73 [Defined if SO_PEERCRED is supported (Linux specific)])
76 dnl Checks for library functions.
82 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
83 strstr strtol setrlimit mlockall getopt_long backtrace])
84 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
92 AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
94 AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
97 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
98 AC_DEBUG([$enableval]), AC_DEBUG)
100 AC_DEFUN([AC_MEM_DEBUG],
103 ac_cv_sys_mem_debug=$1
106 AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
107 [ac_cv_sys_mem_debug=no])
108 AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
111 AC_DEFUN([AC_MUTEX_DEBUG],
114 ac_cv_sys_mutex_debug=$1
117 AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
118 [ac_cv_sys_mutex_debug=no])
119 AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
122 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
123 AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
125 # Libacl support (for data files).
126 AC_ARG_ENABLE(acl, AC_HELP_STRING([--enable-acl],
127 [Enable Access Control List support]), USE_LIBACL=yes,
129 if test "x$USE_LIBACL" = "xyes"; then
130 AC_CHECK_LIB(acl, acl_get_file,,
131 AC_MSG_ERROR([Missing or incomplete libacl installation.]))
132 AC_CHECK_HEADER([sys/acl.h],,
133 AC_MSG_ERROR([Missing or incomplete libacl installation.]))
134 AC_DEFINE(WITH_LIBACL, 1, [Define if you want libacl support.])
136 AM_CONDITIONAL(WITH_LIBACL, [test "x$USE_LIBACL" = "xyes"])
139 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
140 AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
141 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
143 VER_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
144 VER_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
145 VER_MOD="`if test \`echo -n $VER_MINOR | wc -c\` -eq 1; then echo 0$VER_MINOR; else echo $VER_MINOR; fi`"
146 AC_DEFINE_UNQUOTED(VERSION_HEX, 0x${VER_MAJOR}${VER_MOD}, [For the file header.])
148 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd.1 po/Makefile.in])
152 echo " Debug: ${ac_cv_sys_debug}"
153 echo " Memory debug: ${ac_cv_sys_mem_debug}"
154 echo " Mutex debug: ${ac_cv_sys_mutex_debug}"
155 echo " ACL: $USE_LIBACL"