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_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=2],
33 [CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"])
34 AX_CHECK_COMPILE_FLAG([-fsanitize=undefined],
35 [CFLAGS="$CFLAGS -fsanitize=undefined"])
36 AX_PTHREAD(, [POSIX threads are required])
38 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
39 LIBS="$PTHREAD_LIBS $LIBS"
41 acx_pthread_mutex_timedlock_ok=no
42 AC_MSG_CHECKING([for pthread_mutex_timedlock()])
43 AC_TRY_LINK_FUNC(pthread_mutex_timedlock, acx_pthread_mutex_timedlock_ok=yes)
44 AC_MSG_RESULT($acx_pthread_mutex_timedlock_ok)
45 if test x"$acx_pthread_mutex_timedlock_ok" = "xyes"; then
46 AC_DEFINE(HAVE_PTHREAD_MUTEX_TIMEDLOCK, 1, [Define if your OS has pthread_mutex_timedlock().])
49 acx_pthread_testcancel_ok=no
50 AC_MSG_CHECKING([for pthread_testcancel()])
51 AC_TRY_LINK_FUNC(pthread_testcancel, acx_pthread_testcancel_ok=yes)
52 AC_MSG_RESULT($acx_pthread_testcancel_ok)
53 if test x"$acx_pthread_testcancel_ok" = "xyes"; then
54 AC_DEFINE(HAVE_PTHREAD_TESTCANCEL, 1, [Define if your OS has pthread_testcancel().])
57 acx_pthread_cancel_ok=no
58 AC_MSG_CHECKING([for pthread_cancel()])
59 AC_TRY_LINK_FUNC(pthread_cancel, acx_pthread_cancel_ok=yes)
60 AC_MSG_RESULT($acx_pthread_cancel_ok)
61 if test x"$acx_pthread_cancel_ok" = "xyes"; then
62 AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if your OS has pthread_cancel().])
65 acx_pthread_atfork_ok=no
66 AC_MSG_CHECKING([for pthread_atfork()])
67 AC_TRY_LINK_FUNC(pthread_atfork, acx_pthread_atfork_ok=yes)
68 AC_MSG_RESULT($acx_pthread_atfork_ok)
69 if test x"$acx_pthread_atfork_ok" = "xyes"; then
70 AC_DEFINE(HAVE_PTHREAD_ATFORK, 1, [Define if your OS has pthread_atfork().])
73 dnl Checks for header files.
77 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h strings.h sys/time.h unistd.h \
78 libintl.h locale.h syslog.h termios.h getopt.h limits.h \
81 AC_CHECK_DECLS([SO_BINDTODEVICE],,, [[#include <sys/types.h>
82 #include <sys/socket.h>]])
86 AC_CHECK_HEADERS([linux/sockios.h sys/prctl.h])
87 if test "x$ac_cv_header_linux_sockios_h" = xyes; then
88 AC_CHECK_DECL([SIOCOUTQ],,, [[#include <linux/sockios.h>]])
89 if test "x$ac_cv_have_decl_SIOCOUTQ" = xyes; then
90 AC_DEFINE(HAVE_DECL_SIOCOUTQ, 1,
91 [Defined if SIOCOUTQ is available (Linux specific)])
95 if test "x$ac_cv_header_sys_prctl_h" = xyes; then
96 AC_CHECK_DECL([PR_SET_NAME],,, [[#include <sys/prctl.h>]])
97 if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
98 AC_DEFINE(HAVE_PR_SET_NAME, 1,
99 [Defined if PR_SET_NAME is available (Linux specific)])
102 AC_CHECK_DECL([PR_SET_DUMPABLE],,, [[#include <sys/prctl.h>]])
103 if test "x$ac_cv_have_decl_PR_SET_DUMPABLE" = xyes; then
104 AC_DEFINE(HAVE_PR_SET_DUMPABLE, 1,
105 [Defined if PR_SET_DUMPABLE is available (Linux specific)])
112 AC_CHECK_HEADERS([sys/filio.h])
113 if test "x$ac_cv_header_sys_filio_h" = xyes; then
114 AC_CHECK_DECL([FIONWRITE],,, [[#include <sys/filio.h>]])
115 if test "x$ac_cv_have_decl_FIONWRITE" = xyes; then
116 AC_DEFINE(HAVE_DECL_FIONWRITE, 1,
117 [Defined if FIONWRITE is available (*BSD specific, not OpenBSD)])
122 dnl All others use SO_SNDLOWAT.
126 dnl Checks for typedefs, structures, and compiler characteristics.
139 dnl Checks for library functions.
144 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
145 strstr strtol setrlimit mlockall getopt_long backtrace \
146 getpwnam_r getgrnam_r])
147 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
149 AM_PATH_LIBASSUAN([2.0.2],, AC_MSG_ERROR([libassuan not found]))
150 PKG_PROG_PKG_CONFIG()
151 AM_PATH_LIBGCRYPT([1:1.5.0],, AC_MSG_ERROR([libgcrypt not found]))
152 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
153 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
154 AC_SEARCH_LIBS([clock_gettime], [rt])
156 dnl For data file conversion.
159 dnl Remote TCP/TLS connections.
160 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls],
161 [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
163 if test "x$USE_GNUTLS" = "xyes"; then
164 PKG_CHECK_MODULES([GNUTLS], [gnutls])
165 AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
167 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
169 dnl Enable gpg-agent support.
170 AC_ARG_ENABLE(agent, AC_HELP_STRING([--enable-agent],
171 [Enable public key/gpg-agent support.]), WITH_AGENT=$enableval,
173 if test "x$WITH_AGENT" = "xyes"; then
174 AC_DEFINE(WITH_AGENT, 1, [Define if you want gpg-agent support.])
176 AM_CONDITIONAL(WITH_AGENT, [test "x$WITH_AGENT" = "xyes"])
178 pinentry="/usr/bin/pinentry"
179 dnl Default pinentry location.
180 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
181 [Default location of the pinentry binary (/usr/bin/pinentry)]),
184 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
185 [Default location of the pinentry binary.])
187 # Cracklib support (requires pinentry support).
188 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality],
189 [Enable password quality checking with cracklib.]),
190 WITH_QUALITY=$enableval, WITH_QUALITY=no)
191 if test "x$WITH_QUALITY" = "xyes"; then
192 AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
193 AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
194 AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
196 AM_CONDITIONAL(WITH_QUALITY, [test "x$WITH_QUALITY" = "xyes"])
198 crackdict="/var/cache/cracklib/cracklib_dict"
199 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
200 [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
201 crackdict="$withval")
203 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
211 AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
212 [ac_cv_sys_debug=no])
213 AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
216 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
217 AC_DEBUG([$enableval]), AC_DEBUG)
219 AC_DEFUN([AC_MEM_DEBUG],
222 ac_cv_sys_mem_debug=$1
225 AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
226 [ac_cv_sys_mem_debug=no])
227 AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
230 AC_DEFUN([AC_MUTEX_DEBUG],
233 ac_cv_sys_mutex_debug=$1
236 AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
237 [ac_cv_sys_mutex_debug=no])
238 AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
241 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
242 AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
244 dnl Memory debugging.
245 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
246 AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
247 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
249 # Default pwmd home directory.
250 AC_ARG_WITH(pwmd_homedir, AC_HELP_STRING([--with-pwmd-homedir=PATH],
251 [Default pwmd home directory (~/.pwmd)]),
252 pwmd_homedir="$withval", pwmd_homedir=)
253 if test x"$pwmd_homedir" != "x"; then
254 AC_DEFINE_UNQUOTED(PWMD_HOMEDIR, ["$pwmd_homedir"],
255 [Default pwmd home directory (~/.pwmd).])
258 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
259 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
260 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
261 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
262 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
264 dnl Disable optimizing of memset(). GCC and CLang (and others?) accept
265 dnl multiple optimization flags and use the last one specified. The
266 dnl non-optimized memset() may still use any CPU features found in the
267 dnl user specified CFLAGS (-mtune) and libc.
268 CFLAGS_ORIG="$CFLAGS"
269 CFLAGS_MEMZERO="$CFLAGS -O0"
271 AC_SUBST(CFLAGS_ORIG)
272 AC_SUBST(CFLAGS_MEMZERO)
274 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile po/Makefile.in
279 echo " With gpg-agent..: $WITH_AGENT"
280 echo " Pinentry binary.: $pinentry"
281 echo " Cracklib........: $WITH_QUALITY"
282 echo " Cracklib dict...: $crackdict"
283 echo " TCP (GnuTLS)....: $USE_GNUTLS"
285 if test x"$pwmd_homedir" != "x"; then
286 echo " Home directory..: $pwmd_homedir"
288 echo " Home directory..: ~/.pwmd"
291 echo " Debug...........: ${ac_cv_sys_debug}"
292 echo " Memory debug....: ${ac_cv_sys_mem_debug}"
293 echo " Mutex debug.....: ${ac_cv_sys_mutex_debug}"