1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT(pwmd, 3.1.0-beta3, [Ben Kibbey bjk@luxsci.net])
4 AC_CONFIG_MACRO_DIR([m4])
5 AC_CONFIG_AUX_DIR(build)
7 AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip])
9 AC_USE_SYSTEM_EXTENSIONS()
10 AC_CONFIG_SRCDIR([src/pwmd.c])
11 AM_CONFIG_HEADER([config.h])
12 AM_GNU_GETTEXT([external])
13 AM_GNU_GETTEXT_VERSION([0.16.1])
15 REQUIRE_LIBGCRYPT_VERSION="1.5.0"
16 REQUIRE_LIBASSUAN_VERSION="2.3.0"
17 REQUIRE_LIBGPGERROR_VERSION="1.18"
18 REQUIRE_LIBGPGME_VERSION="1.7.0"
19 REQUIRE_GNUPG_VERSION="2.1.15"
20 REQUIRE_LIBGNUTLS_VERSION="3.3.0"
22 AC_DEFINE_UNQUOTED(REQUIRE_LIBASSUAN_VERSION, "$REQUIRE_LIBASSUAN_VERSION",
23 [Minimum libassuan version.])
24 AC_DEFINE_UNQUOTED(REQUIRE_LIBGCRYPT_VERSION, "$REQUIRE_LIBGCRYPT_VERSION",
25 [Minimum libgcrypt version.])
26 AC_DEFINE_UNQUOTED(REQUIRE_LIBGPGERROR_VERSION, "$REQUIRE_LIBGPGERROR_VERSION",
27 [Minimum libgpg-error version.])
28 AC_DEFINE_UNQUOTED(REQUIRE_LIBGPGME_VERSION, "$REQUIRE_LIBGPGME_VERSION",
29 [Minimum libgpgme version.])
30 AC_DEFINE_UNQUOTED(REQUIRE_GNUPG_VERSION, "$REQUIRE_GNUPG_VERSION",
31 [Minimum gnupg version.])
32 AC_DEFINE_UNQUOTED(REQUIRE_LIBGNUTLS_VERSION, "$REQUIRE_LIBGNUTLS_VERSION",
33 [Minimum libgnutls version.])
35 dnl Checks for programs.
39 if test "$ac_cv_prog_cc_c99" = "no"; then
40 AC_MSG_WARN([Unable to find a C99 compatible compiler.])
50 dnl Checks for library functions.
51 AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=2],
52 [CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"])
53 AX_PTHREAD(, AC_MSG_ERROR([POSIX threads are required.]))
55 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
56 LIBS="$PTHREAD_LIBS $LIBS"
58 acx_pthread_testcancel_ok=no
59 AC_MSG_CHECKING([for pthread_testcancel()])
60 AC_TRY_LINK_FUNC(pthread_testcancel, acx_pthread_testcancel_ok=yes)
61 AC_MSG_RESULT($acx_pthread_testcancel_ok)
62 if test x"$acx_pthread_testcancel_ok" = "xyes"; then
63 AC_DEFINE(HAVE_PTHREAD_TESTCANCEL, 1, [Define if your OS has pthread_testcancel().])
66 acx_pthread_cancel_ok=no
67 AC_MSG_CHECKING([for pthread_cancel()])
68 AC_TRY_LINK_FUNC(pthread_cancel, acx_pthread_cancel_ok=yes)
69 AC_MSG_RESULT($acx_pthread_cancel_ok)
70 if test x"$acx_pthread_cancel_ok" = "xyes"; then
71 AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if your OS has pthread_cancel().])
74 acx_pthread_atfork_ok=no
75 AC_MSG_CHECKING([for pthread_atfork()])
76 AC_TRY_LINK_FUNC(pthread_atfork, acx_pthread_atfork_ok=yes)
77 AC_MSG_RESULT($acx_pthread_atfork_ok)
78 if test x"$acx_pthread_atfork_ok" = "xyes"; then
79 AC_DEFINE(HAVE_PTHREAD_ATFORK, 1, [Define if your OS has pthread_atfork().])
82 dnl Checks for header files.
86 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h strings.h sys/time.h unistd.h \
87 libintl.h locale.h syslog.h termios.h getopt.h limits.h \
88 time.h sys/select.h sys/file.h])
90 AC_CHECK_DECLS([SO_BINDTODEVICE],,, [[#include <sys/types.h>
91 #include <sys/socket.h>]])
95 PTHREAD_CFLAGS="-pthread"
96 PTHREAD_LIBS="-pthread"
104 AC_CHECK_HEADERS([linux/sockios.h sys/prctl.h])
105 if test "x$ac_cv_header_linux_sockios_h" = xyes; then
106 AC_CHECK_DECL([SIOCOUTQ],,, [[#include <linux/sockios.h>]])
107 if test "x$ac_cv_have_decl_SIOCOUTQ" = xyes; then
108 AC_DEFINE(HAVE_DECL_SIOCOUTQ, 1,
109 [Defined if SIOCOUTQ is available (Linux specific)])
113 if test "x$ac_cv_header_sys_prctl_h" = xyes; then
114 AC_CHECK_DECL([PR_SET_NAME],,, [[#include <sys/prctl.h>]])
115 if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
116 AC_DEFINE(HAVE_PR_SET_NAME, 1,
117 [Defined if PR_SET_NAME is available (Linux specific)])
120 AC_CHECK_DECL([PR_SET_DUMPABLE],,, [[#include <sys/prctl.h>]])
121 if test "x$ac_cv_have_decl_PR_SET_DUMPABLE" = xyes; then
122 AC_DEFINE(HAVE_PR_SET_DUMPABLE, 1,
123 [Defined if PR_SET_DUMPABLE is available (Linux specific)])
130 AC_CHECK_HEADERS([sys/filio.h])
131 if test "x$ac_cv_header_sys_filio_h" = xyes; then
132 AC_CHECK_DECL([FIONWRITE],,, [[#include <sys/filio.h>]])
133 if test "x$ac_cv_have_decl_FIONWRITE" = xyes; then
134 AC_DEFINE(HAVE_DECL_FIONWRITE, 1,
135 [Defined if FIONWRITE is available (*BSD specific, not OpenBSD)])
140 dnl All others use SO_SNDLOWAT.
144 dnl Checks for typedefs, structures, and compiler characteristics.
157 dnl Checks for library functions.
162 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
163 strstr strtol setrlimit mlockall getopt_long backtrace \
164 getpwnam_r getgrnam_r flock readdir_r])
165 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
167 AM_PATH_GPG_ERROR($REQUIRE_LIBGPGERROR_VERSION,, AC_MSG_ERROR([libgpg-error >= $REQUIRE_LIBGPGERROR_VERSION not found]))
168 AM_PATH_LIBASSUAN($REQUIRE_LIBASSUAN_VERSION,, AC_MSG_ERROR([libassuan >= $REQUIRE_LIBASSUAN_VERSION not found]))
169 AM_PATH_LIBGCRYPT([1:$REQUIRE_LIBGCRYPT_VERSION],, AC_MSG_ERROR([libgcrypt >= $REQUIRE_LIBGCRYPT_VERSION not found]))
170 AM_PATH_GPGME_PTHREAD($REQUIRE_LIBGPGME_VERSION,, AC_MSG_ERROR([libgpgme >= $REQUIRE_LIBGPGME_VERSION not found]))
171 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
172 AC_SEARCH_LIBS([clock_gettime], [rt])
174 dnl Remote TCP/TLS connections.
175 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls],
176 [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
178 if test "x$USE_GNUTLS" = "xyes"; then
179 PKG_CHECK_MODULES([GNUTLS], [gnutls >= $REQUIRE_LIBGNUTLS_VERSION])
180 AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
182 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
184 dnl Libacl support (for data files).
185 AC_ARG_ENABLE(acl, AC_HELP_STRING([--enable-acl],
186 [Enable Access Control List support for data files]),
187 [USE_LIBACL=yes], [USE_LIBACL=no])
188 if test "x$USE_LIBACL" = "xyes"; then
189 AC_SEARCH_LIBS([acl_get_file], [acl],,
190 AC_MSG_ERROR([Missing or incomplete libacl installation.]))
191 AC_CHECK_HEADER([sys/acl.h],,
192 AC_MSG_ERROR([Missing or incomplete libacl installation.]))
193 AC_DEFINE(WITH_LIBACL, 1, [Define if you want libacl support.])
195 AM_CONDITIONAL(WITH_LIBACL, [test "x$USE_LIBACL" = "xyes"])
203 AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
204 [ac_cv_sys_debug=no])
205 AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
208 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
209 AC_DEBUG([$enableval]), AC_DEBUG)
211 AC_DEFUN([AC_MEM_DEBUG],
214 ac_cv_sys_mem_debug=$1
217 AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
218 [ac_cv_sys_mem_debug=no])
219 AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
222 AC_DEFUN([AC_MUTEX_DEBUG],
225 ac_cv_sys_mutex_debug=$1
228 AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
229 [ac_cv_sys_mutex_debug=no])
230 AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
233 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
234 AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
236 dnl Memory debugging.
237 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
238 AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
239 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
241 # Default pwmd home directory.
242 AC_ARG_WITH(pwmd_homedir, AC_HELP_STRING([--with-pwmd-homedir=PATH],
243 [Default pwmd home directory (~/.pwmd)]),
244 pwmd_homedir="$withval", pwmd_homedir=)
245 if test x"$pwmd_homedir" != "x"; then
246 AC_DEFINE_UNQUOTED(PWMD_HOMEDIR, ["$pwmd_homedir"],
247 [Default pwmd home directory (~/.pwmd).])
250 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
251 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
252 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
253 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
254 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
256 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd-dump.1
257 po/Makefile.in tests/Makefile])
261 echo " TCP (GnuTLS)....: $USE_GNUTLS"
262 echo " Data file ACL's.: $USE_LIBACL"
264 if test x"$pwmd_homedir" != "x"; then
265 echo " Home directory..: $pwmd_homedir"
267 echo " Home directory..: ~/.pwmd"
270 echo " Debug...........: ${ac_cv_sys_debug}"
271 echo " Memory debug....: ${ac_cv_sys_mem_debug}"
272 echo " Mutex debug.....: ${ac_cv_sys_mutex_debug}"