Add pinentry configure options.
[libpwmd.git] / configure.ac
bloba424d18bc5052d1b6583305cca959f17af05cb7e
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 dnl Checks for header files.
66 AC_HEADER_STDC
67 AC_HEADER_SYS_WAIT
69 AC_CHECK_DECLS([SO_BINDTODEVICE],,, [[#include <sys/types.h>
70                                         #include <sys/socket.h>]])
72 AC_CHECK_HEADER([linux/prctl.h],
73                 AC_CHECK_DECL([PR_SET_NAME],,, [[#include <linux/prctl.h>]]))
74 if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
75    AC_DEFINE(HAVE_PR_SET_NAME, 1,
76              [Defined if PR_SET_NAME is available (Linux specific)])
79 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h libintl.h \
80                   locale.h syslog.h termios.h zlib.h getopt.h limits.h \
81                   time.h])
83 dnl Checks for typedefs, structures, and compiler characteristics.
84 AC_SYS_LARGEFILE
85 AC_C_CONST
86 AC_C_INLINE
87 AC_TYPE_MODE_T
88 AC_TYPE_SIZE_T
89 AC_STRUCT_TM
90 AC_TYPE_PID_T
91 AC_TYPE_SIGNAL
93 dnl Checks for library functions.
94 AC_FUNC_STAT
95 AC_FUNC_FORK
96 AC_FUNC_MEMCMP
97 AC_FUNC_STRFTIME
98 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
99                 strstr strtol setrlimit mlockall getopt_long backtrace \
100                 getpwnam_r getgrnam_r])
101 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
103 AM_PATH_LIBASSUAN([2.0.2],, AC_MSG_ERROR([libassuan not found]))
104 PKG_PROG_PKG_CONFIG()
105 AM_PATH_LIBGCRYPT([1:1.5.0],, AC_MSG_ERROR([libgcrypt not found]))
106 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
107 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
108 AC_SEARCH_LIBS([clock_gettime], [rt])
110 dnl For data file conversion.
111 AC_CHECK_LIB(z, deflate,,
112              AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
114 dnl Remote TCP/TLS connections.
115 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls],
116               [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
117               USE_GNUTLS=no)
118 if test "x$USE_GNUTLS" = "xyes"; then
119     PKG_CHECK_MODULES([GNUTLS], [gnutls])
120     AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
122 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
124 dnl Disable gpg-agent.
125 AC_ARG_ENABLE(agent, AC_HELP_STRING([--disable-agent],
126               [Disable public key/gpg-agent support.]), WITH_AGENT=$enableval,
127               WITH_AGENT=yes)
128 if test "x$WITH_AGENT" = "xyes"; then
129     AC_DEFINE(WITH_AGENT, 1, [Define if you want gpg-agent support.])
131 AM_CONDITIONAL(WITH_AGENT, [test "x$WITH_AGENT" = "xyes"])
133 pinentry="/usr/bin/pinentry"
134 dnl Default pinentry location.
135 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
136               [Default location of the pinentry binary (/usr/bin/pinentry)]),
137               pinentry="$withval")
138 AC_SUBST(pinentry)
139 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
140                    [Default location of the pinentry binary.])
142 # Cracklib support (requires pinentry support).
143 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
144               [Enable password quality checking with cracklib.]),
145               WITH_QUALITY=$enableval, WITH_QUALITY=no)
146 if test "x$WITH_QUALITY" = "xyes"; then
147     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
148     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
149     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
151 AM_CONDITIONAL(WITH_QUALITY, [test "x$WITH_QUALITY" = "xyes"])
153 crackdict="/var/cache/cracklib/cracklib_dict"
154 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
155               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
156               crackdict="$withval")
157 AC_SUBST(crackdict)
158 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
161 dnl Libacl support (for data files).
162 AC_ARG_ENABLE(acl, AC_HELP_STRING([--enable-acl],
163               [Enable Access Control List support]), USE_LIBACL=yes,
164               USE_LIBACL=no)
165 if test "x$USE_LIBACL" = "xyes"; then
166     AC_SEARCH_LIBS([acl_get_file], [acl],,
167                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
168     AC_CHECK_HEADER([sys/acl.h],,
169                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
170     AC_DEFINE(WITH_LIBACL, 1, [Define if you want libacl support.])
172 AM_CONDITIONAL(WITH_LIBACL, [test "x$USE_LIBACL" = "xyes"])
174 AC_DEFUN([AC_DEBUG],
176     if test "$1"; then
177         ac_cv_sys_debug=$1
178     fi
180     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
181         [ac_cv_sys_debug=no])
182     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
185 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
186     AC_DEBUG([$enableval]), AC_DEBUG)
188 AC_DEFUN([AC_MEM_DEBUG],
190     if test "$1"; then
191         ac_cv_sys_mem_debug=$1
192     fi
194     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
195         [ac_cv_sys_mem_debug=no])
196     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
199 AC_DEFUN([AC_MUTEX_DEBUG],
201     if test "$1"; then
202         ac_cv_sys_mutex_debug=$1
203     fi
205     AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
206         [ac_cv_sys_mutex_debug=no])
207     AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
210 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
211     AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
213 dnl Memory debugging.
214 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
215     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
216 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
218 # Default pwmd home directory.
219 AC_ARG_WITH(pwmd_homedir, AC_HELP_STRING([--with-pwmd-homedir=PATH],
220               [Default pwmd home directory (~/.pwmd)]),
221               pwmd_homedir="$withval", pwmd_homedir=)
222 if test x"$pwmd_homedir" != "x"; then
223    AC_DEFINE_UNQUOTED(PWMD_HOMEDIR, ["$pwmd_homedir"],
224                                     [Default pwmd home directory (~/.pwmd).])
227 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
228 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
229 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
230 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
231 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
233 dnl Disable optimizing of memset(). GCC and CLang (and others?) accept
234 dnl multiple optimization flags and use the last one specified. The
235 dnl non-optimized memset() may still use any CPU features found in the
236 dnl user specified CFLAGS (-mtune) and libc.
237 CFLAGS_ORIG="$CFLAGS"
238 CFLAGS_MEMZERO="$CFLAGS -O0"
239 CFLAGS=
240 AC_SUBST(CFLAGS_ORIG)
241 AC_SUBST(CFLAGS_MEMZERO)
243 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd.1 po/Makefile.in
244                  tests/Makefile])
245 AC_OUTPUT
246 echo
247 echo "Features:"
248 echo "    With gpg-agent..: $WITH_AGENT"
249 echo "    Pinentry binary.: $pinentry"
250 echo "    Cracklib........: $WITH_QUALITY"
251 echo "    Cracklib dict...: $crackdict"
252 echo "    TCP (GnuTLS)....: $USE_GNUTLS"
253 echo "    ACL.............: $USE_LIBACL"
255 if test x"$pwmd_homedir" != "x"; then
256 echo "    Home directory..: $pwmd_homedir"
257 else
258 echo "    Home directory..: ~/.pwmd"
261 echo "    Debug...........: ${ac_cv_sys_debug}"
262 echo "    Memory debug....: ${ac_cv_sys_mem_debug}"
263 echo "    Mutex debug.....: ${ac_cv_sys_mutex_debug}"