Fix PASSWD to allow changing to an empty passphrase for PKI files.
[pwmd.git] / configure.ac
blobdf0659941b155d0e6ff4353be358f8d97b33721c
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 AX_C_BIGENDIAN_CROSS
24 AC_PROG_AWK
25 AC_PROG_LN_S
26 AC_PROG_INSTALL
27 AC_PROG_LN_S
28 AC_PROG_CPP
29 AC_PROG_MKDIR_P
31 dnl Checks for library functions.
32 AX_PTHREAD(, [POSIX threads are required])
33 CC="$PTHREAD_CC"
34 save_CFLAGS="$CFLAGS"
35 save_LIBS="$LIBS"
36 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
37 LIBS="$PTHREAD_LIBS $LIBS"
39 acx_pthread_mutex_timedlock_ok=no
40 AC_MSG_CHECKING([for pthread_mutex_timedlock()])
41 AC_TRY_LINK_FUNC(pthread_mutex_timedlock, acx_pthread_mutex_timedlock_ok=yes)
42 AC_MSG_RESULT($acx_pthread_mutex_timedlock_ok)
43 if test x"$acx_pthread_mutex_timedlock_ok" = "xyes"; then
44     AC_DEFINE(HAVE_PTHREAD_MUTEX_TIMEDLOCK, 1, [Define if your OS has pthread_mutex_timedlock().])
47 acx_pthread_testcancel_ok=no
48 AC_MSG_CHECKING([for pthread_testcancel()])
49 AC_TRY_LINK_FUNC(pthread_testcancel, acx_pthread_testcancel_ok=yes)
50 AC_MSG_RESULT($acx_pthread_testcancel_ok)
51 if test x"$acx_pthread_testcancel_ok" = "xyes"; then
52     AC_DEFINE(HAVE_PTHREAD_TESTCANCEL, 1, [Define if your OS has pthread_testcancel().])
55 acx_pthread_cancel_ok=no
56 AC_MSG_CHECKING([for pthread_cancel()])
57 AC_TRY_LINK_FUNC(pthread_cancel, acx_pthread_cancel_ok=yes)
58 AC_MSG_RESULT($acx_pthread_cancel_ok)
59 if test x"$acx_pthread_cancel_ok" = "xyes"; then
60     AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if your OS has pthread_cancel().])
63 acx_pthread_atfork_ok=no
64 AC_MSG_CHECKING([for pthread_atfork()])
65 AC_TRY_LINK_FUNC(pthread_atfork, acx_pthread_atfork_ok=yes)
66 AC_MSG_RESULT($acx_pthread_atfork_ok)
67 if test x"$acx_pthread_atfork_ok" = "xyes"; then
68     AC_DEFINE(HAVE_PTHREAD_ATFORK, 1, [Define if your OS has pthread_atfork().])
71 CFLAGS="$save_CFLAGS"
72 LIBS="$save_LIBS"
74 dnl Checks for header files.
75 AC_HEADER_STDC
76 AC_HEADER_SYS_WAIT
78 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h libintl.h \
79                   locale.h syslog.h termios.h getopt.h limits.h time.h])
81 AC_CHECK_DECLS([SO_BINDTODEVICE],,, [[#include <sys/types.h>
82                                       #include <sys/socket.h>]])
84 case "$target_os" in
85      linux*)
86         AC_CHECK_HEADERS([linux/sockios.h linux/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)])
92                 fi
93         fi
95         if test "x$ac_cv_header_linux_prctl_h" = xyes; then
96            AC_CHECK_DECL([PR_SET_NAME],,, [[#include <linux/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)])
100               fi
101         fi
102         ;;
103      openbsd*)
104         ;;
105      *bsd*)
106         AC_CHECK_HEADERS([sys/filio.h])
107         if test "x$ac_cv_header_sys_filio_h" = xyes; then
108                 AC_CHECK_DECL([FIONWRITE],,, [[#include <sys/filio.h>]])
109                 if test "x$ac_cv_have_decl_FIONWRITE" = xyes; then
110                         AC_DEFINE(HAVE_DECL_FIONWRITE, 1,
111                                 [Defined if FIONWRITE is available (*BSD specific, not OpenBSD)])
112                 fi
113         fi
114         ;;
115      *)
116 dnl     All others use SO_SNDLOWAT.
117         ;;
118 esac
120 dnl Checks for typedefs, structures, and compiler characteristics.
121 AC_SYS_LARGEFILE
122 AC_C_CONST
123 AC_C_INLINE
124 AC_TYPE_MODE_T
125 AC_TYPE_SIZE_T
126 AC_STRUCT_TM
127 AC_TYPE_PID_T
128 AC_TYPE_SIGNAL
129 AC_TYPE_UINT8_T
130 AC_TYPE_UINT32_T
131 AC_TYPE_UINT64_T
133 dnl Checks for library functions.
134 AC_FUNC_STAT
135 AC_FUNC_FORK
136 AC_FUNC_MEMCMP
137 AC_FUNC_STRFTIME
138 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
139                 strstr strtol setrlimit mlockall getopt_long backtrace \
140                 getpwnam_r getgrnam_r])
141 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
143 AM_PATH_LIBASSUAN([2.0.2],, AC_MSG_ERROR([libassuan not found]))
144 PKG_PROG_PKG_CONFIG()
145 AM_PATH_LIBGCRYPT([1:1.5.0],, AC_MSG_ERROR([libgcrypt not found]))
146 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
147 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
148 AC_SEARCH_LIBS([clock_gettime], [rt])
150 dnl For data file conversion.
151 AX_CHECK_ZLIB
153 dnl Remote TCP/TLS connections.
154 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls],
155               [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
156               USE_GNUTLS=no)
157 if test "x$USE_GNUTLS" = "xyes"; then
158     PKG_CHECK_MODULES([GNUTLS], [gnutls])
159     AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
161 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
163 dnl Enable gpg-agent support.
164 AC_ARG_ENABLE(agent, AC_HELP_STRING([--enable-agent],
165               [Enable public key/gpg-agent support.]), WITH_AGENT=$enableval,
166               WITH_AGENT=no)
167 if test "x$WITH_AGENT" = "xyes"; then
168     AC_DEFINE(WITH_AGENT, 1, [Define if you want gpg-agent support.])
170 AM_CONDITIONAL(WITH_AGENT, [test "x$WITH_AGENT" = "xyes"])
172 pinentry="/usr/bin/pinentry"
173 dnl Default pinentry location.
174 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
175               [Default location of the pinentry binary (/usr/bin/pinentry)]),
176               pinentry="$withval")
177 AC_SUBST(pinentry)
178 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
179                    [Default location of the pinentry binary.])
181 # Cracklib support (requires pinentry support).
182 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
183               [Enable password quality checking with cracklib.]),
184               WITH_QUALITY=$enableval, WITH_QUALITY=no)
185 if test "x$WITH_QUALITY" = "xyes"; then
186     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
187     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
188     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
190 AM_CONDITIONAL(WITH_QUALITY, [test "x$WITH_QUALITY" = "xyes"])
192 crackdict="/var/cache/cracklib/cracklib_dict"
193 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
194               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
195               crackdict="$withval")
196 AC_SUBST(crackdict)
197 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
200 dnl Libacl support (for data files).
201 AC_ARG_ENABLE(acl, AC_HELP_STRING([--enable-acl],
202               [Enable Access Control List support]), USE_LIBACL=yes,
203               USE_LIBACL=no)
204 if test "x$USE_LIBACL" = "xyes"; then
205     AC_SEARCH_LIBS([acl_get_file], [acl],,
206                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
207     AC_CHECK_HEADER([sys/acl.h],,
208                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
209     AC_DEFINE(WITH_LIBACL, 1, [Define if you want libacl support.])
211 AM_CONDITIONAL(WITH_LIBACL, [test "x$USE_LIBACL" = "xyes"])
213 AC_DEFUN([AC_DEBUG],
215     if test "$1"; then
216         ac_cv_sys_debug=$1
217     fi
219     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
220         [ac_cv_sys_debug=no])
221     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
224 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
225     AC_DEBUG([$enableval]), AC_DEBUG)
227 AC_DEFUN([AC_MEM_DEBUG],
229     if test "$1"; then
230         ac_cv_sys_mem_debug=$1
231     fi
233     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
234         [ac_cv_sys_mem_debug=no])
235     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
238 AC_DEFUN([AC_MUTEX_DEBUG],
240     if test "$1"; then
241         ac_cv_sys_mutex_debug=$1
242     fi
244     AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
245         [ac_cv_sys_mutex_debug=no])
246     AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
249 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
250     AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
252 dnl Memory debugging.
253 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
254     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
255 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
257 # Default pwmd home directory.
258 AC_ARG_WITH(pwmd_homedir, AC_HELP_STRING([--with-pwmd-homedir=PATH],
259               [Default pwmd home directory (~/.pwmd)]),
260               pwmd_homedir="$withval", pwmd_homedir=)
261 if test x"$pwmd_homedir" != "x"; then
262    AC_DEFINE_UNQUOTED(PWMD_HOMEDIR, ["$pwmd_homedir"],
263                                     [Default pwmd home directory (~/.pwmd).])
266 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
267 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
268 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
269 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
270 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
272 dnl Disable optimizing of memset(). GCC and CLang (and others?) accept
273 dnl multiple optimization flags and use the last one specified. The
274 dnl non-optimized memset() may still use any CPU features found in the
275 dnl user specified CFLAGS (-mtune) and libc.
276 CFLAGS_ORIG="$CFLAGS"
277 CFLAGS_MEMZERO="$CFLAGS -O0"
278 CFLAGS=
279 AC_SUBST(CFLAGS_ORIG)
280 AC_SUBST(CFLAGS_MEMZERO)
282 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile po/Makefile.in
283                  tests/Makefile])
284 AC_OUTPUT
285 echo
286 echo "Features:"
287 echo "    With gpg-agent..: $WITH_AGENT"
288 echo "    Pinentry binary.: $pinentry"
289 echo "    Cracklib........: $WITH_QUALITY"
290 echo "    Cracklib dict...: $crackdict"
291 echo "    TCP (GnuTLS)....: $USE_GNUTLS"
292 echo "    ACL.............: $USE_LIBACL"
294 if test x"$pwmd_homedir" != "x"; then
295 echo "    Home directory..: $pwmd_homedir"
296 else
297 echo "    Home directory..: ~/.pwmd"
300 echo "    Debug...........: ${ac_cv_sys_debug}"
301 echo "    Memory debug....: ${ac_cv_sys_mem_debug}"
302 echo "    Mutex debug.....: ${ac_cv_sys_mutex_debug}"