Fix OPEN when gpg-agent is not enabled.
[libpwmd.git] / configure.ac
blob94fc7362445213334f100c4d6b92b955eec32835
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
3 AC_INIT(pwmd, 3.0.13-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_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])
37 CC="$PTHREAD_CC"
38 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
39 LIBS="$PTHREAD_LIBS $LIBS"
41 acx_pthread_testcancel_ok=no
42 AC_MSG_CHECKING([for pthread_testcancel()])
43 AC_TRY_LINK_FUNC(pthread_testcancel, acx_pthread_testcancel_ok=yes)
44 AC_MSG_RESULT($acx_pthread_testcancel_ok)
45 if test x"$acx_pthread_testcancel_ok" = "xyes"; then
46     AC_DEFINE(HAVE_PTHREAD_TESTCANCEL, 1, [Define if your OS has pthread_testcancel().])
49 acx_pthread_cancel_ok=no
50 AC_MSG_CHECKING([for pthread_cancel()])
51 AC_TRY_LINK_FUNC(pthread_cancel, acx_pthread_cancel_ok=yes)
52 AC_MSG_RESULT($acx_pthread_cancel_ok)
53 if test x"$acx_pthread_cancel_ok" = "xyes"; then
54     AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if your OS has pthread_cancel().])
57 acx_pthread_atfork_ok=no
58 AC_MSG_CHECKING([for pthread_atfork()])
59 AC_TRY_LINK_FUNC(pthread_atfork, acx_pthread_atfork_ok=yes)
60 AC_MSG_RESULT($acx_pthread_atfork_ok)
61 if test x"$acx_pthread_atfork_ok" = "xyes"; then
62     AC_DEFINE(HAVE_PTHREAD_ATFORK, 1, [Define if your OS has pthread_atfork().])
65 dnl Checks for header files.
66 AC_HEADER_STDC
67 AC_HEADER_SYS_WAIT
69 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h strings.h sys/time.h unistd.h \
70                   libintl.h locale.h syslog.h termios.h getopt.h limits.h \
71                   time.h sys/select.h])
73 AC_CHECK_DECLS([SO_BINDTODEVICE],,, [[#include <sys/types.h>
74                                       #include <sys/socket.h>]])
76 case "$target_os" in
77      linux*)
78         AC_CHECK_HEADERS([linux/sockios.h sys/prctl.h])
79         if test "x$ac_cv_header_linux_sockios_h" = xyes; then
80                 AC_CHECK_DECL([SIOCOUTQ],,, [[#include <linux/sockios.h>]])
81                 if test "x$ac_cv_have_decl_SIOCOUTQ" = xyes; then
82                         AC_DEFINE(HAVE_DECL_SIOCOUTQ, 1,
83                                 [Defined if SIOCOUTQ is available (Linux specific)])
84                 fi
85         fi
87         if test "x$ac_cv_header_sys_prctl_h" = xyes; then
88            AC_CHECK_DECL([PR_SET_NAME],,, [[#include <sys/prctl.h>]])
89               if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
90                     AC_DEFINE(HAVE_PR_SET_NAME, 1,
91                              [Defined if PR_SET_NAME is available (Linux specific)])
92               fi
94            AC_CHECK_DECL([PR_SET_DUMPABLE],,, [[#include <sys/prctl.h>]])
95               if test "x$ac_cv_have_decl_PR_SET_DUMPABLE" = xyes; then
96                     AC_DEFINE(HAVE_PR_SET_DUMPABLE, 1,
97                              [Defined if PR_SET_DUMPABLE is available (Linux specific)])
98               fi
99         fi
100         ;;
101      openbsd*)
102         ;;
103      *bsd*)
104         AC_CHECK_HEADERS([sys/filio.h])
105         if test "x$ac_cv_header_sys_filio_h" = xyes; then
106                 AC_CHECK_DECL([FIONWRITE],,, [[#include <sys/filio.h>]])
107                 if test "x$ac_cv_have_decl_FIONWRITE" = xyes; then
108                         AC_DEFINE(HAVE_DECL_FIONWRITE, 1,
109                                 [Defined if FIONWRITE is available (*BSD specific, not OpenBSD)])
110                 fi
111         fi
112         ;;
113      *)
114 dnl     All others use SO_SNDLOWAT.
115         ;;
116 esac
118 dnl Checks for typedefs, structures, and compiler characteristics.
119 AC_TYPE_UID_T
120 AC_SYS_LARGEFILE
121 AC_C_CONST
122 AC_C_INLINE
123 AC_TYPE_MODE_T
124 AC_TYPE_SIZE_T
125 AC_STRUCT_TM
126 AC_TYPE_PID_T
127 AC_TYPE_SIGNAL
128 AC_TYPE_UINT8_T
129 AC_TYPE_UINT16_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_LSTAT_FOLLOWS_SLASHED_SYMLINK
137 AC_FUNC_MEMCMP
138 AC_FUNC_STRFTIME
139 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
140                 strstr strtol setrlimit mlockall getopt_long backtrace \
141                 getpwnam_r getgrnam_r])
142 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
144 AM_PATH_LIBASSUAN([2.0.2],, AC_MSG_ERROR([libassuan not found]))
145 PKG_PROG_PKG_CONFIG()
146 AM_PATH_LIBGCRYPT([1:1.5.0],, AC_MSG_ERROR([libgcrypt not found]))
147 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
148 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
149 AC_SEARCH_LIBS([clock_gettime], [rt])
151 dnl For data file conversion.
152 AX_CHECK_ZLIB
154 dnl Remote TCP/TLS connections.
155 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls],
156               [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
157               USE_GNUTLS=no)
158 if test "x$USE_GNUTLS" = "xyes"; then
159     PKG_CHECK_MODULES([GNUTLS], [gnutls])
160     AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
162 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
164 dnl Enable gpg-agent support.
165 AC_ARG_ENABLE(agent, AC_HELP_STRING([--enable-agent],
166               [Enable public key/gpg-agent support.]), WITH_AGENT=$enableval,
167               WITH_AGENT=no)
168 if test "x$WITH_AGENT" = "xyes"; then
169     AC_DEFINE(WITH_AGENT, 1, [Define if you want gpg-agent support.])
171 AM_CONDITIONAL(WITH_AGENT, [test "x$WITH_AGENT" = "xyes"])
173 pinentry="/usr/bin/pinentry"
174 dnl Default pinentry location.
175 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
176               [Default location of the pinentry binary (/usr/bin/pinentry)]),
177               pinentry="$withval")
178 AC_SUBST(pinentry)
179 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
180                    [Default location of the pinentry binary.])
182 # Cracklib support (requires pinentry support).
183 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
184               [Enable password quality checking with cracklib.]),
185               WITH_QUALITY=$enableval, WITH_QUALITY=no)
186 if test "x$WITH_QUALITY" = "xyes"; then
187     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
188     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
189     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
191 AM_CONDITIONAL(WITH_QUALITY, [test "x$WITH_QUALITY" = "xyes"])
193 crackdict="/var/cache/cracklib/cracklib_dict"
194 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
195               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
196               crackdict="$withval")
197 AC_SUBST(crackdict)
198 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
200 AC_DEFUN([AC_DEBUG],
202     if test "$1"; then
203         ac_cv_sys_debug=$1
204     fi
206     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
207         [ac_cv_sys_debug=no])
208     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
211 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
212     AC_DEBUG([$enableval]), AC_DEBUG)
214 AC_DEFUN([AC_MEM_DEBUG],
216     if test "$1"; then
217         ac_cv_sys_mem_debug=$1
218     fi
220     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
221         [ac_cv_sys_mem_debug=no])
222     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
225 AC_DEFUN([AC_MUTEX_DEBUG],
227     if test "$1"; then
228         ac_cv_sys_mutex_debug=$1
229     fi
231     AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
232         [ac_cv_sys_mutex_debug=no])
233     AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
236 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
237     AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
239 dnl Memory debugging.
240 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
241     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
242 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
244 # Default pwmd home directory.
245 AC_ARG_WITH(pwmd_homedir, AC_HELP_STRING([--with-pwmd-homedir=PATH],
246               [Default pwmd home directory (~/.pwmd)]),
247               pwmd_homedir="$withval", pwmd_homedir=)
248 if test x"$pwmd_homedir" != "x"; then
249    AC_DEFINE_UNQUOTED(PWMD_HOMEDIR, ["$pwmd_homedir"],
250                                     [Default pwmd home directory (~/.pwmd).])
253 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
254 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
255 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
256 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
257 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
259 dnl Disable optimizing of memset(). GCC and CLang (and others?) accept
260 dnl multiple optimization flags and use the last one specified. The
261 dnl non-optimized memset() may still use any CPU features found in the
262 dnl user specified CFLAGS (-mtune) and libc.
263 CFLAGS_ORIG="$CFLAGS"
264 CFLAGS_MEMZERO="$CFLAGS -O0"
265 CFLAGS=
266 AC_SUBST(CFLAGS_ORIG)
267 AC_SUBST(CFLAGS_MEMZERO)
269 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile po/Makefile.in
270                  tests/Makefile])
271 AC_OUTPUT
272 echo
273 echo "Features:"
274 echo "    With gpg-agent..: $WITH_AGENT"
275 echo "    Pinentry binary.: $pinentry"
276 echo "    Cracklib........: $WITH_QUALITY"
277 echo "    Cracklib dict...: $crackdict"
278 echo "    TCP (GnuTLS)....: $USE_GNUTLS"
280 if test x"$pwmd_homedir" != "x"; then
281 echo "    Home directory..: $pwmd_homedir"
282 else
283 echo "    Home directory..: ~/.pwmd"
286 echo "    Debug...........: ${ac_cv_sys_debug}"
287 echo "    Memory debug....: ${ac_cv_sys_mem_debug}"
288 echo "    Mutex debug.....: ${ac_cv_sys_mutex_debug}"