1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT(pwmd, 3.0.12, [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()
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.
19 if test "$ac_cv_prog_cc_c99" = "no"; then
20 AC_MSG_WARN("Unable to find a C99 compatible compiler.")
31 dnl Checks for library functions.
32 AX_PTHREAD(, [POSIX threads are required])
34 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
35 LIBS="$PTHREAD_LIBS $LIBS"
37 acx_pthread_mutex_timedlock_ok=no
38 AC_MSG_CHECKING([for pthread_mutex_timedlock()])
39 AC_TRY_LINK_FUNC(pthread_mutex_timedlock, acx_pthread_mutex_timedlock_ok=yes)
40 AC_MSG_RESULT($acx_pthread_mutex_timedlock_ok)
41 if test x"$acx_pthread_mutex_timedlock_ok" = "xyes"; then
42 AC_DEFINE(HAVE_PTHREAD_MUTEX_TIMEDLOCK, 1, [Define if your OS has pthread_mutex_timedlock().])
45 acx_pthread_testcancel_ok=no
46 AC_MSG_CHECKING([for pthread_testcancel()])
47 AC_TRY_LINK_FUNC(pthread_testcancel, acx_pthread_testcancel_ok=yes)
48 AC_MSG_RESULT($acx_pthread_testcancel_ok)
49 if test x"$acx_pthread_testcancel_ok" = "xyes"; then
50 AC_DEFINE(HAVE_PTHREAD_TESTCANCEL, 1, [Define if your OS has pthread_testcancel().])
53 acx_pthread_cancel_ok=no
54 AC_MSG_CHECKING([for pthread_cancel()])
55 AC_TRY_LINK_FUNC(pthread_cancel, acx_pthread_cancel_ok=yes)
56 AC_MSG_RESULT($acx_pthread_cancel_ok)
57 if test x"$acx_pthread_cancel_ok" = "xyes"; then
58 AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if your OS has pthread_cancel().])
61 acx_pthread_atfork_ok=no
62 AC_MSG_CHECKING([for pthread_atfork()])
63 AC_TRY_LINK_FUNC(pthread_atfork, acx_pthread_atfork_ok=yes)
64 AC_MSG_RESULT($acx_pthread_atfork_ok)
65 if test x"$acx_pthread_atfork_ok" = "xyes"; then
66 AC_DEFINE(HAVE_PTHREAD_ATFORK, 1, [Define if your OS has pthread_atfork().])
69 dnl Checks for header files.
73 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h strings.h sys/time.h unistd.h \
74 libintl.h locale.h syslog.h termios.h getopt.h limits.h \
77 AC_CHECK_DECLS([SO_BINDTODEVICE],,, [[#include <sys/types.h>
78 #include <sys/socket.h>]])
82 AC_CHECK_HEADERS([linux/sockios.h sys/prctl.h])
83 if test "x$ac_cv_header_linux_sockios_h" = xyes; then
84 AC_CHECK_DECL([SIOCOUTQ],,, [[#include <linux/sockios.h>]])
85 if test "x$ac_cv_have_decl_SIOCOUTQ" = xyes; then
86 AC_DEFINE(HAVE_DECL_SIOCOUTQ, 1,
87 [Defined if SIOCOUTQ is available (Linux specific)])
91 if test "x$ac_cv_header_sys_prctl_h" = xyes; then
92 AC_CHECK_DECL([PR_SET_NAME],,, [[#include <sys/prctl.h>]])
93 if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
94 AC_DEFINE(HAVE_PR_SET_NAME, 1,
95 [Defined if PR_SET_NAME is available (Linux specific)])
98 AC_CHECK_DECL([PR_SET_DUMPABLE],,, [[#include <sys/prctl.h>]])
99 if test "x$ac_cv_have_decl_PR_SET_DUMPABLE" = xyes; then
100 AC_DEFINE(HAVE_PR_SET_DUMPABLE, 1,
101 [Defined if PR_SET_DUMPABLE is available (Linux specific)])
108 AC_CHECK_HEADERS([sys/filio.h])
109 if test "x$ac_cv_header_sys_filio_h" = xyes; then
110 AC_CHECK_DECL([FIONWRITE],,, [[#include <sys/filio.h>]])
111 if test "x$ac_cv_have_decl_FIONWRITE" = xyes; then
112 AC_DEFINE(HAVE_DECL_FIONWRITE, 1,
113 [Defined if FIONWRITE is available (*BSD specific, not OpenBSD)])
118 dnl All others use SO_SNDLOWAT.
122 dnl Checks for typedefs, structures, and compiler characteristics.
135 dnl Checks for library functions.
140 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
141 strstr strtol setrlimit mlockall getopt_long backtrace \
142 getpwnam_r getgrnam_r])
143 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
145 AM_PATH_LIBASSUAN([2.0.2],, AC_MSG_ERROR([libassuan not found]))
146 PKG_PROG_PKG_CONFIG()
147 AM_PATH_LIBGCRYPT([1:1.5.0],, AC_MSG_ERROR([libgcrypt not found]))
148 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
149 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
150 AC_SEARCH_LIBS([clock_gettime], [rt])
152 dnl For data file conversion.
155 dnl Remote TCP/TLS connections.
156 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls],
157 [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
159 if test "x$USE_GNUTLS" = "xyes"; then
160 PKG_CHECK_MODULES([GNUTLS], [gnutls])
161 AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
163 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
165 dnl Enable gpg-agent support.
166 AC_ARG_ENABLE(agent, AC_HELP_STRING([--enable-agent],
167 [Enable public key/gpg-agent support.]), WITH_AGENT=$enableval,
169 if test "x$WITH_AGENT" = "xyes"; then
170 AC_DEFINE(WITH_AGENT, 1, [Define if you want gpg-agent support.])
172 AM_CONDITIONAL(WITH_AGENT, [test "x$WITH_AGENT" = "xyes"])
174 pinentry="/usr/bin/pinentry"
175 dnl Default pinentry location.
176 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
177 [Default location of the pinentry binary (/usr/bin/pinentry)]),
180 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
181 [Default location of the pinentry binary.])
183 # Cracklib support (requires pinentry support).
184 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality],
185 [Enable password quality checking with cracklib.]),
186 WITH_QUALITY=$enableval, WITH_QUALITY=no)
187 if test "x$WITH_QUALITY" = "xyes"; then
188 AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
189 AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
190 AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
192 AM_CONDITIONAL(WITH_QUALITY, [test "x$WITH_QUALITY" = "xyes"])
194 crackdict="/var/cache/cracklib/cracklib_dict"
195 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
196 [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
197 crackdict="$withval")
199 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
207 AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
208 [ac_cv_sys_debug=no])
209 AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
212 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
213 AC_DEBUG([$enableval]), AC_DEBUG)
215 AC_DEFUN([AC_MEM_DEBUG],
218 ac_cv_sys_mem_debug=$1
221 AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
222 [ac_cv_sys_mem_debug=no])
223 AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
226 AC_DEFUN([AC_MUTEX_DEBUG],
229 ac_cv_sys_mutex_debug=$1
232 AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
233 [ac_cv_sys_mutex_debug=no])
234 AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
237 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
238 AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
240 dnl Memory debugging.
241 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
242 AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
243 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
245 # Default pwmd home directory.
246 AC_ARG_WITH(pwmd_homedir, AC_HELP_STRING([--with-pwmd-homedir=PATH],
247 [Default pwmd home directory (~/.pwmd)]),
248 pwmd_homedir="$withval", pwmd_homedir=)
249 if test x"$pwmd_homedir" != "x"; then
250 AC_DEFINE_UNQUOTED(PWMD_HOMEDIR, ["$pwmd_homedir"],
251 [Default pwmd home directory (~/.pwmd).])
254 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
255 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
256 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
257 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
258 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
260 dnl Disable optimizing of memset(). GCC and CLang (and others?) accept
261 dnl multiple optimization flags and use the last one specified. The
262 dnl non-optimized memset() may still use any CPU features found in the
263 dnl user specified CFLAGS (-mtune) and libc.
264 CFLAGS_ORIG="$CFLAGS"
265 CFLAGS_MEMZERO="$CFLAGS -O0"
267 AC_SUBST(CFLAGS_ORIG)
268 AC_SUBST(CFLAGS_MEMZERO)
270 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile po/Makefile.in
275 echo " With gpg-agent..: $WITH_AGENT"
276 echo " Pinentry binary.: $pinentry"
277 echo " Cracklib........: $WITH_QUALITY"
278 echo " Cracklib dict...: $crackdict"
279 echo " TCP (GnuTLS)....: $USE_GNUTLS"
281 if test x"$pwmd_homedir" != "x"; then
282 echo " Home directory..: $pwmd_homedir"
284 echo " Home directory..: ~/.pwmd"
287 echo " Debug...........: ${ac_cv_sys_debug}"
288 echo " Memory debug....: ${ac_cv_sys_mem_debug}"
289 echo " Mutex debug.....: ${ac_cv_sys_mutex_debug}"