Include all required m4 macros.
[pwmd.git] / configure.ac
blob114a925598ec0f51b8dd27c18bbc970edb57ca4d
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
3 AC_INIT(pwmd, 3.0.0-dev, [Ben Kibbey bjk@luxsci.net])
4 AC_CONFIG_MACRO_DIR([m4])
5 AC_CONFIG_AUX_DIR(build)
6 AC_CANONICAL_TARGET
7 AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip])
8 AC_PROG_MAKE_SET
9 AC_USE_SYSTEM_EXTENSIONS()
10 AC_PROG_LIBTOOL
11 AC_CONFIG_SRCDIR([src/pwmd.c])
12 AM_CONFIG_HEADER([config.h])
13 AM_GNU_GETTEXT([external])
14 AM_GNU_GETTEXT_VERSION([0.16.1])
16 dnl Checks for programs.
17 AC_PROG_CC_C99
19 if test "$ac_cv_prog_cc_c99" = "no"; then
20     AC_MSG_WARN("Unable to find a C99 compatible compiler.")
23 AC_PROG_AWK
24 AC_PROG_LN_S
25 AC_PROG_INSTALL
26 AC_PROG_LN_S
27 AC_PROG_CPP
28 AC_PROG_MKDIR_P
30 dnl Checks for library functions.
31 AX_PTHREAD(, [POSIX threads are required])
32 CC="$PTHREAD_CC"
33 save_CFLAGS="$CFLAGS"
34 save_LIBS="$LIBS"
35 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
36 LIBS="$PTHREAD_LIBS $LIBS"
38 acx_pthread_mutex_timedlock_ok=no
39 AC_MSG_CHECKING([for pthread_mutex_timedlock()])
40 AC_TRY_LINK_FUNC(pthread_mutex_timedlock, acx_pthread_mutex_timedlock_ok=yes)
41 AC_MSG_RESULT($acx_pthread_mutex_timedlock_ok)
42 if test x"$acx_pthread_mutex_timedlock_ok" = "xyes"; then
43     AC_DEFINE(HAVE_PTHREAD_MUTEX_TIMEDLOCK, 1, [Define if your OS has pthread_mutex_timedlock().])
46 acx_pthread_testcancel_ok=no
47 AC_MSG_CHECKING([for pthread_testcancel()])
48 AC_TRY_LINK_FUNC(pthread_testcancel, acx_pthread_testcancel_ok=yes)
49 AC_MSG_RESULT($acx_pthread_testcancel_ok)
50 if test x"$acx_pthread_testcancel_ok" = "xyes"; then
51     AC_DEFINE(HAVE_PTHREAD_TESTCANCEL, 1, [Define if your OS has pthread_testcancel().])
54 acx_pthread_cancel_ok=no
55 AC_MSG_CHECKING([for pthread_cancel()])
56 AC_TRY_LINK_FUNC(pthread_cancel, acx_pthread_cancel_ok=yes)
57 AC_MSG_RESULT($acx_pthread_cancel_ok)
58 if test x"$acx_pthread_cancel_ok" = "xyes"; then
59     AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if your OS has pthread_cancel().])
62 CFLAGS="$save_CFLAGS"
63 LIBS="$save_LIBS"
65 AM_PATH_LIBASSUAN([2.0.2],, AC_MSG_ERROR([libassuan not found]))
66 PKG_PROG_PKG_CONFIG()
67 AM_PATH_LIBGCRYPT([1:1.5.0],, AC_MSG_ERROR([libgcrypt not found]))
68 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
69 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
70 AC_SEARCH_LIBS([clock_gettime], [rt])
71 dnl For data file conversion.
72 AC_CHECK_LIB(z, deflate,,
73              AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
75 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls], 
76               [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
77               USE_GNUTLS=no)
78 if test "x$USE_GNUTLS" = "xyes"; then
79     PKG_CHECK_MODULES([GNUTLS], [gnutls])
80     AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
82 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
84 dnl Checks for header files.
85 AC_HEADER_STDC
86 AC_HEADER_SYS_WAIT
87 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h libintl.h \
88                   locale.h syslog.h termios.h zlib.h getopt.h limits.h \
89                   time.h])
90 AC_CHECK_HEADER([linux/prctl.h],
91                 AC_CHECK_DECL([PR_SET_NAME],,, [[#include <linux/prctl.h>]]))
92 if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
93   AC_DEFINE(HAVE_PR_SET_NAME, 1,
94             [Defined if PR_SET_NAME is available (Linux specific)])
96 AC_CHECK_HEADER([sys/socket.h], AC_CHECK_DECLS([SO_BINDTODEVICE,SO_PEERCRED],,, [[#include <sys/socket.h>]]))
98 dnl Checks for typedefs, structures, and compiler characteristics.
99 AC_SYS_LARGEFILE
100 AC_C_CONST
101 AC_C_INLINE
102 AC_TYPE_MODE_T
103 AC_TYPE_SIZE_T
104 AC_STRUCT_TM
105 AC_TYPE_PID_T
106 AC_TYPE_SIGNAL
108 dnl Checks for library functions.
109 AC_FUNC_STAT
110 AC_FUNC_FORK
111 AC_FUNC_MEMCMP
112 AC_FUNC_STRFTIME
113 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
114                 strstr strtol setrlimit mlockall getopt_long backtrace \
115                 getpwnam_r getgrnam_r])
116 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
118 AC_DEFUN([AC_DEBUG],
120     if test "$1"; then
121         ac_cv_sys_debug=$1
122     fi
124     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
125         [ac_cv_sys_debug=no])
126     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
129 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
130     AC_DEBUG([$enableval]), AC_DEBUG)
132 AC_DEFUN([AC_MEM_DEBUG],
134     if test "$1"; then
135         ac_cv_sys_mem_debug=$1
136     fi
138     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
139         [ac_cv_sys_mem_debug=no])
140     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
143 AC_DEFUN([AC_MUTEX_DEBUG],
145     if test "$1"; then
146         ac_cv_sys_mutex_debug=$1
147     fi
149     AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
150         [ac_cv_sys_mutex_debug=no])
151     AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
154 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
155     AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
157 dnl Libacl support (for data files).
158 AC_ARG_ENABLE(acl, AC_HELP_STRING([--enable-acl], 
159               [Enable Access Control List support]), USE_LIBACL=yes,
160               USE_LIBACL=no)
161 if test "x$USE_LIBACL" = "xyes"; then
162     AC_SEARCH_LIBS([acl_get_file], [acl],,
163                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
164     AC_CHECK_HEADER([sys/acl.h],,
165                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
166     AC_DEFINE(WITH_LIBACL, 1, [Define if you want libacl support.])
168 AM_CONDITIONAL(WITH_LIBACL, [test "x$USE_LIBACL" = "xyes"])
170 dnl Memory debugging.
171 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
172     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
173 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
175 # Default pwmd home directory.
176 AC_ARG_WITH(pwmd_homedir, AC_HELP_STRING([--with-pwmd-homedir=PATH],
177               [Default pwmd home directory (~/.pwmd)]),
178               pwmd_homedir="$withval", pwmd_homedir=)
179 if test x"$pwmd_homedir" != "x"; then
180    AC_DEFINE_UNQUOTED(PWMD_HOMEDIR, ["$pwmd_homedir"],
181                                     [Default pwmd home directory (~/.pwmd).])
184 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
185 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
186 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
187 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
188 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
190 dnl Disable optimizing of memset(). GCC and CLang (and others?) accept
191 dnl multiple optimization flags and use the last one specified. The
192 dnl non-optimized memset() may still use any CPU features found in the
193 dnl user specified CFLAGS (-mtune) and libc.
194 CFLAGS_ORIG="$CFLAGS"
195 CFLAGS_MEMZERO="$CFLAGS -O0"
196 CFLAGS=
197 AC_SUBST(CFLAGS_ORIG)
198 AC_SUBST(CFLAGS_MEMZERO)
200 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd.1 po/Makefile.in
201                  tests/Makefile])
202 AC_OUTPUT
203 echo
204 echo "Features:"
205 echo "    TCP (GnuTLS): $USE_GNUTLS"
206 echo "    ACL: $USE_LIBACL"
208 if test x"$pwmd_homedir" != "x"; then
209   echo "    Home directory: $pwmd_homedir"
210 else
211   echo "    Home directory: default"
214 echo "    Debug: ${ac_cv_sys_debug}"
215 echo "    Memory debug: ${ac_cv_sys_mem_debug}"
216 echo "    Mutex debug: ${ac_cv_sys_mutex_debug}"