1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT([pwmd],[3.3.6],[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 AC_CONFIG_HEADERS([config.h])
12 AM_GNU_GETTEXT_VERSION([0.21])
14 AM_CONDITIONAL([IS_GIT_REPO], [test -f ".git/HEAD"])
15 if test -f ".git/HEAD"; then
16 GIT_BRANCH="`cut -d / -f 3 .git/HEAD`"
18 AC_SUBST([GIT_BRANCH])
20 REQUIRE_LIBGCRYPT_VERSION="1.7.0"
21 REQUIRE_LIBASSUAN_VERSION="2.5.0"
22 REQUIRE_LIBGPGERROR_VERSION="1.29"
23 REQUIRE_LIBGPGME_VERSION="1.11.0"
24 REQUIRE_GNUPG_VERSION="2.2.7"
25 REQUIRE_LIBGNUTLS_VERSION="3.3.0"
27 AC_DEFINE_UNQUOTED(REQUIRE_LIBASSUAN_VERSION, "$REQUIRE_LIBASSUAN_VERSION",
28 [Minimum libassuan version.])
29 AC_DEFINE_UNQUOTED(REQUIRE_LIBGCRYPT_VERSION, "$REQUIRE_LIBGCRYPT_VERSION",
30 [Minimum libgcrypt version.])
31 AC_DEFINE_UNQUOTED(REQUIRE_LIBGPGERROR_VERSION, "$REQUIRE_LIBGPGERROR_VERSION",
32 [Minimum libgpg-error version.])
33 AC_DEFINE_UNQUOTED(REQUIRE_LIBGPGME_VERSION, "$REQUIRE_LIBGPGME_VERSION",
34 [Minimum libgpgme version.])
35 AC_DEFINE_UNQUOTED(REQUIRE_GNUPG_VERSION, "$REQUIRE_GNUPG_VERSION",
36 [Minimum gnupg version.])
37 AC_DEFINE_UNQUOTED(REQUIRE_LIBGNUTLS_VERSION, "$REQUIRE_LIBGNUTLS_VERSION",
38 [Minimum libgnutls version.])
40 dnl Checks for programs.
52 dnl Checks for library functions.
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.
84 AC_CHECK_HEADERS([argz.h arpa/inet.h fcntl.h getopt.h inttypes.h langinfo.h \
85 libintl.h locale.h malloc.h netdb.h netinet/in.h stdint.h \
86 stdio_ext.h strings.h sys/acl.h sys/file.h sys/ioctl.h \
87 sys/param.h sys/socket.h sys/time.h syslog.h termios.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 AC_DEFINE(HAVE_WINLIKE_SYSTEM, 1, [Define if this is a Windows-like system.])
143 dnl All others use SO_SNDLOWAT.
147 dnl Checks for typedefs, structures, and compiler characteristics.
148 AC_CHECK_HEADER_STDBOOL
160 AC_CHECK_TYPES([ptrdiff_t])
163 dnl Checks for library functions.
164 AM_GNU_GETTEXT([external])
166 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
171 AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify backtrace \
172 clock_gettime explicit_bzero flock getcwd getgrnam_r \
173 getpwnam_r getopt_long isascii localeconv mblen mbrlen \
174 memchr memmove mempcpy memset memset_s mkdir mlockall \
175 munmap nl_langinfo putenv select setlocale setrlimit socket \
176 stpcpy strcasecmp strchr strcspn strdup strerror strncasecmp \
177 strrchr strstr strtol strtoul])
179 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
181 AM_PATH_LIBASSUAN($REQUIRE_LIBASSUAN_VERSION,, AC_MSG_ERROR([libassuan >= $REQUIRE_LIBASSUAN_VERSION not found]))
182 AM_PATH_LIBGCRYPT([1:$REQUIRE_LIBGCRYPT_VERSION],, AC_MSG_ERROR([libgcrypt >= $REQUIRE_LIBGCRYPT_VERSION not found]))
183 AM_PATH_GPGME($REQUIRE_LIBGPGME_VERSION,, AC_MSG_ERROR([libgpgme >= $REQUIRE_LIBGPGME_VERSION not found]))
184 AM_PATH_GPGRT($REQUIRE_LIBGPGERROR_VERSION,, AC_MSG_ERROR([libgpg-error >= $REQUIRE_LIBGPGERROR_VERSION not found]))
185 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
186 AC_SEARCH_LIBS([clock_gettime], [rt])
188 dnl Remote TCP/TLS connections.
189 AC_ARG_ENABLE(gnutls, AS_HELP_STRING([--enable-gnutls],
190 [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
192 if test "x$USE_GNUTLS" = "xyes"; then
193 PKG_CHECK_MODULES([GNUTLS], [gnutls >= $REQUIRE_LIBGNUTLS_VERSION])
194 AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
196 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
198 dnl Libacl support (for data files).
199 AC_ARG_ENABLE(acl, AS_HELP_STRING([--enable-acl],
200 [Enable Access Control List support for data files]),
201 [USE_LIBACL=yes], [USE_LIBACL=no])
202 if test "x$USE_LIBACL" = "xyes"; then
203 AC_SEARCH_LIBS([acl_get_file], [acl],,
204 AC_MSG_ERROR([Missing or incomplete libacl installation.]))
205 AC_CHECK_HEADER([sys/acl.h],,
206 AC_MSG_ERROR([Missing or incomplete libacl installation.]))
207 AC_DEFINE(WITH_LIBACL, 1, [Define if you want libacl support.])
209 AM_CONDITIONAL(WITH_LIBACL, [test "x$USE_LIBACL" = "xyes"])
217 AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
218 [ac_cv_sys_debug=no])
219 AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
222 AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
223 AC_DEBUG([$enableval]), AC_DEBUG)
225 AC_DEFUN([AC_MEM_DEBUG],
228 ac_cv_sys_mem_debug=$1
231 AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
232 [ac_cv_sys_mem_debug=no])
233 AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
236 AC_DEFUN([AC_MUTEX_DEBUG],
239 ac_cv_sys_mutex_debug=$1
242 AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
243 [ac_cv_sys_mutex_debug=no])
244 AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
247 AC_ARG_ENABLE(mutex_debug, AS_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
248 AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
250 dnl Memory debugging.
251 AC_ARG_ENABLE(mem_debug, AS_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
252 AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
253 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
255 # Default pwmd home directory.
256 AC_ARG_WITH(pwmd_homedir, AS_HELP_STRING([--with-pwmd-homedir=PATH],
257 [Default pwmd home directory (~/.pwmd)]),
258 pwmd_homedir="$withval", pwmd_homedir=)
259 if test x"$pwmd_homedir" != "x"; then
260 AC_DEFINE_UNQUOTED(PWMD_HOMEDIR, ["$pwmd_homedir"],
261 [Default pwmd home directory (~/.pwmd).])
264 AC_ARG_WITH(invoking_user, AS_HELP_STRING([--with-invoking-user=nobody],
265 [Default invoking_user when not specified in the configuration.
266 Setting to blank will have the user that started pwmd be the
267 invoking_user.]), invoking_user="$withval",
268 invoking_user="nobody")
269 if test x"$invoking_user" != "x"; then
270 AC_DEFINE_UNQUOTED(DEFAULT_INVOKER, ["$invoking_user"],
271 [Default invoking_user when not specified in the
272 configuration. Set to NULL to have the user that
273 started pwmd be the invoking_user.])
275 AC_DEFINE(DEFAULT_INVOKER, [NULL],
276 [Default invoking_user when not specified in the
277 configuration. Set to NULL to have the user that
278 started pwmd be the invoking_user.])
281 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
282 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
283 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
284 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
285 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
287 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd-dump.1 \
288 po/Makefile.in tests/Makefile])
292 echo " TCP (GnuTLS)....: $USE_GNUTLS"
293 echo " Data file ACL's.: $USE_LIBACL"
295 if test x"$pwmd_homedir" != "x"; then
296 echo " Home directory..: $pwmd_homedir"
298 echo " Home directory..: ~/.pwmd"
301 if test "x$invoking_user" != "x"; then
302 echo " Invoking user...: $invoking_user"
304 echo " Invoking user...: determined on start"
307 echo " Debug...........: ${ac_cv_sys_debug}"
308 echo " Memory debug....: ${ac_cv_sys_mem_debug}"
309 echo " Mutex debug.....: ${ac_cv_sys_mutex_debug}"