ISCACHED: don't handle unopened gpg-agent cache status.
[pwmd.git] / configure.ac
blob4ad62eb8b07b5c9d112b7f7fb15d985c4d70857d
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.61)
3 AC_INIT(pwmd, 3.1.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_CONFIG_SRCDIR([src/pwmd.c])
11 AM_CONFIG_HEADER([config.h])
12 AM_GNU_GETTEXT([external])
13 AM_GNU_GETTEXT_VERSION([0.16.1])
15 dnl Checks for programs.
16 AC_PROG_CC_C99
17 AX_CC_FOR_BUILD
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_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=2],
32                       [CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"])
33 case "${host}" in
34     *-linux-androideabi)
35         ;;
36     *)
37         AX_CHECK_COMPILE_FLAG([-fsanitize=undefined],
38                               [CFLAGS="$CFLAGS -fsanitize=undefined"])
39         ;;
40 esac
42 AX_PTHREAD(, AC_MSG_ERROR([POSIX threads are required.]))
43 CC="$PTHREAD_CC"
44 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
45 LIBS="$PTHREAD_LIBS $LIBS"
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 dnl Checks for header files.
72 AC_HEADER_STDC
73 AC_HEADER_SYS_WAIT
75 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h strings.h sys/time.h unistd.h \
76                   libintl.h locale.h syslog.h termios.h getopt.h limits.h \
77                   time.h sys/select.h sys/file.h])
79 AC_CHECK_DECLS([SO_BINDTODEVICE],,, [[#include <sys/types.h>
80                                       #include <sys/socket.h>]])
82 case "${host}" in
83     *-linux-androideabi)
84         PTHREAD_CFLAGS="-pthread"
85         PTHREAD_LIBS="-pthread"
86         ;;
87     *)
88         ;;
89 esac
91 case "$target_os" in
92      linux*)
93         AC_CHECK_HEADERS([linux/sockios.h sys/prctl.h])
94         if test "x$ac_cv_header_linux_sockios_h" = xyes; then
95                 AC_CHECK_DECL([SIOCOUTQ],,, [[#include <linux/sockios.h>]])
96                 if test "x$ac_cv_have_decl_SIOCOUTQ" = xyes; then
97                         AC_DEFINE(HAVE_DECL_SIOCOUTQ, 1,
98                                 [Defined if SIOCOUTQ is available (Linux specific)])
99                 fi
100         fi
102         if test "x$ac_cv_header_sys_prctl_h" = xyes; then
103            AC_CHECK_DECL([PR_SET_NAME],,, [[#include <sys/prctl.h>]])
104               if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
105                     AC_DEFINE(HAVE_PR_SET_NAME, 1,
106                              [Defined if PR_SET_NAME is available (Linux specific)])
107               fi
109            AC_CHECK_DECL([PR_SET_DUMPABLE],,, [[#include <sys/prctl.h>]])
110               if test "x$ac_cv_have_decl_PR_SET_DUMPABLE" = xyes; then
111                     AC_DEFINE(HAVE_PR_SET_DUMPABLE, 1,
112                              [Defined if PR_SET_DUMPABLE is available (Linux specific)])
113               fi
114         fi
115         ;;
116      openbsd*)
117         ;;
118      *bsd*)
119         AC_CHECK_HEADERS([sys/filio.h])
120         if test "x$ac_cv_header_sys_filio_h" = xyes; then
121                 AC_CHECK_DECL([FIONWRITE],,, [[#include <sys/filio.h>]])
122                 if test "x$ac_cv_have_decl_FIONWRITE" = xyes; then
123                         AC_DEFINE(HAVE_DECL_FIONWRITE, 1,
124                                 [Defined if FIONWRITE is available (*BSD specific, not OpenBSD)])
125                 fi
126         fi
127         ;;
128      *)
129 dnl     All others use SO_SNDLOWAT.
130         ;;
131 esac
133 dnl Checks for typedefs, structures, and compiler characteristics.
134 AC_SYS_LARGEFILE
135 AC_C_CONST
136 AC_C_INLINE
137 AC_TYPE_MODE_T
138 AC_TYPE_SIZE_T
139 AC_STRUCT_TM
140 AC_TYPE_PID_T
141 AC_TYPE_SIGNAL
142 AC_TYPE_UINT8_T
143 AC_TYPE_UINT32_T
144 AC_TYPE_UINT64_T
146 dnl Checks for library functions.
147 AC_FUNC_STAT
148 AC_FUNC_FORK
149 AC_FUNC_MEMCMP
150 AC_FUNC_STRFTIME
151 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
152                 strstr strtol setrlimit mlockall getopt_long backtrace \
153                 getpwnam_r getgrnam_r flock])
154 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
156 AM_PATH_LIBASSUAN([2.3.0],, AC_MSG_ERROR([libassuan >= 2.3.0 not found]))
157 AM_PATH_LIBGCRYPT([1:1.5.0],, AC_MSG_ERROR([libgcrypt >= 1.5.0 not found]))
158 AM_PATH_GPGME_PTHREAD([1.7.0],, AC_MSG_ERROR([gpgme >= 1.7.0 not found]))
159 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
160 AM_PATH_GPG_ERROR([1.18],, AC_MSG_ERROR([libgpg-error not found]))
161 AC_SEARCH_LIBS([clock_gettime], [rt])
163 dnl Remote TCP/TLS connections.
164 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls],
165               [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
166               USE_GNUTLS=no)
167 if test "x$USE_GNUTLS" = "xyes"; then
168     PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3.0])
169     AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
171 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
173 dnl Libacl support (for data files).
174 AC_ARG_ENABLE(acl, AC_HELP_STRING([--enable-acl],
175               [Enable Access Control List support for data files]),
176               [USE_LIBACL=yes], [USE_LIBACL=no])
177 if test "x$USE_LIBACL" = "xyes"; then
178     AC_SEARCH_LIBS([acl_get_file], [acl],,
179                    AC_MSG_ERROR([Missing or incomplete libacl installation.]))
180     AC_CHECK_HEADER([sys/acl.h],,
181                    AC_MSG_ERROR([Missing or incomplete libacl installation.]))
182     AC_DEFINE(WITH_LIBACL, 1, [Define if you want libacl support.])
184 AM_CONDITIONAL(WITH_LIBACL, [test "x$USE_LIBACL" = "xyes"])
186 AC_DEFUN([AC_DEBUG],
188     if test "$1"; then
189         ac_cv_sys_debug=$1
190     fi
192     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
193         [ac_cv_sys_debug=no])
194     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
197 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
198     AC_DEBUG([$enableval]), AC_DEBUG)
200 AC_DEFUN([AC_MEM_DEBUG],
202     if test "$1"; then
203         ac_cv_sys_mem_debug=$1
204     fi
206     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
207         [ac_cv_sys_mem_debug=no])
208     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
211 AC_DEFUN([AC_MUTEX_DEBUG],
213     if test "$1"; then
214         ac_cv_sys_mutex_debug=$1
215     fi
217     AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
218         [ac_cv_sys_mutex_debug=no])
219     AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
222 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
223     AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
225 dnl Memory debugging.
226 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
227     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
228 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
230 # Default pwmd home directory.
231 AC_ARG_WITH(pwmd_homedir, AC_HELP_STRING([--with-pwmd-homedir=PATH],
232               [Default pwmd home directory (~/.pwmd)]),
233               pwmd_homedir="$withval", pwmd_homedir=)
234 if test x"$pwmd_homedir" != "x"; then
235    AC_DEFINE_UNQUOTED(PWMD_HOMEDIR, ["$pwmd_homedir"],
236                                     [Default pwmd home directory (~/.pwmd).])
239 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
240 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
241 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
242 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
243 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
245 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd-dump.1
246                  po/Makefile.in tests/Makefile])
247 AC_OUTPUT
248 echo
249 echo "Features:"
250 echo "    TCP (GnuTLS)....: $USE_GNUTLS"
251 echo "    Data file ACL's.: $USE_LIBACL"
253 if test x"$pwmd_homedir" != "x"; then
254 echo "    Home directory..: $pwmd_homedir"
255 else
256 echo "    Home directory..: ~/.pwmd"
259 echo "    Debug...........: ${ac_cv_sys_debug}"
260 echo "    Memory debug....: ${ac_cv_sys_mem_debug}"
261 echo "    Mutex debug.....: ${ac_cv_sys_mutex_debug}"