tests: Check for pwmc before running tests.
[pwmd.git] / configure.ac
blobf22540c352eb1d2d852a0f76afb9166dfe6da1ba
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ([2.61])
3 AC_INIT([pwmd], [3.3.0], [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 AC_CONFIG_HEADERS([config.h])
12 AM_GNU_GETTEXT([external])
13 AM_GNU_GETTEXT_VERSION([0.19.8])
15 AM_CONDITIONAL([IS_GIT_REPO], [test -f ".git/HEAD"])
16 if test -f ".git/HEAD"; then
17     GIT_BRANCH="`cut -d / -f 3 .git/HEAD`"
19 AC_SUBST([GIT_BRANCH])
21 REQUIRE_LIBGCRYPT_VERSION="1.7.0"
22 REQUIRE_LIBASSUAN_VERSION="2.5.0"
23 REQUIRE_LIBGPGERROR_VERSION="1.29"
24 REQUIRE_LIBGPGME_VERSION="1.11.0"
25 REQUIRE_GNUPG_VERSION="2.2.7"
26 REQUIRE_LIBGNUTLS_VERSION="3.3.0"
28 AC_DEFINE_UNQUOTED(REQUIRE_LIBASSUAN_VERSION, "$REQUIRE_LIBASSUAN_VERSION",
29           [Minimum libassuan version.])
30 AC_DEFINE_UNQUOTED(REQUIRE_LIBGCRYPT_VERSION, "$REQUIRE_LIBGCRYPT_VERSION",
31           [Minimum libgcrypt version.])
32 AC_DEFINE_UNQUOTED(REQUIRE_LIBGPGERROR_VERSION, "$REQUIRE_LIBGPGERROR_VERSION",
33           [Minimum libgpg-error version.])
34 AC_DEFINE_UNQUOTED(REQUIRE_LIBGPGME_VERSION, "$REQUIRE_LIBGPGME_VERSION",
35           [Minimum libgpgme version.])
36 AC_DEFINE_UNQUOTED(REQUIRE_GNUPG_VERSION, "$REQUIRE_GNUPG_VERSION",
37           [Minimum gnupg version.])
38 AC_DEFINE_UNQUOTED(REQUIRE_LIBGNUTLS_VERSION, "$REQUIRE_LIBGNUTLS_VERSION",
39           [Minimum libgnutls version.])
41 dnl Checks for programs.
42 AC_C_BIGENDIAN
43 AC_PROG_CC_C99
44 AX_CC_FOR_BUILD
46 if test "$ac_cv_prog_cc_c99" = "no"; then
47     AC_MSG_WARN([Unable to find a C99 compatible compiler.])
50 AC_PROG_AWK
51 AC_PROG_LN_S
52 AC_PROG_INSTALL
53 AC_PROG_LN_S
54 AC_PROG_CPP
55 AC_PROG_MKDIR_P
57 dnl Checks for library functions.
58 AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=2],
59                       [CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"])
60 AX_PTHREAD(, AC_MSG_ERROR([POSIX threads are required.]))
61 CC="$PTHREAD_CC"
62 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
63 LIBS="$PTHREAD_LIBS $LIBS"
65 acx_pthread_testcancel_ok=no
66 AC_MSG_CHECKING([for pthread_testcancel()])
67 AC_TRY_LINK_FUNC(pthread_testcancel, acx_pthread_testcancel_ok=yes)
68 AC_MSG_RESULT($acx_pthread_testcancel_ok)
69 if test x"$acx_pthread_testcancel_ok" = "xyes"; then
70     AC_DEFINE(HAVE_PTHREAD_TESTCANCEL, 1, [Define if your OS has pthread_testcancel().])
73 acx_pthread_cancel_ok=no
74 AC_MSG_CHECKING([for pthread_cancel()])
75 AC_TRY_LINK_FUNC(pthread_cancel, acx_pthread_cancel_ok=yes)
76 AC_MSG_RESULT($acx_pthread_cancel_ok)
77 if test x"$acx_pthread_cancel_ok" = "xyes"; then
78     AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if your OS has pthread_cancel().])
81 acx_pthread_atfork_ok=no
82 AC_MSG_CHECKING([for pthread_atfork()])
83 AC_TRY_LINK_FUNC(pthread_atfork, acx_pthread_atfork_ok=yes)
84 AC_MSG_RESULT($acx_pthread_atfork_ok)
85 if test x"$acx_pthread_atfork_ok" = "xyes"; then
86     AC_DEFINE(HAVE_PTHREAD_ATFORK, 1, [Define if your OS has pthread_atfork().])
89 dnl Checks for header files.
90 AC_HEADER_STDC
91 AC_HEADER_SYS_WAIT
93 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h strings.h sys/time.h unistd.h \
94                   libintl.h locale.h syslog.h termios.h getopt.h limits.h \
95                   time.h sys/select.h sys/file.h arpa/inet.h inttypes.h \
96                   netdb.h netinet/in.h stddef.h sys/ioctl.h sys/socket.h \
97                   wchar.h wctype.h])
99 AC_CHECK_DECLS([SO_BINDTODEVICE],,, [[#include <sys/types.h>
100                                       #include <sys/socket.h>]])
102 case "${host}" in
103     *-linux-androideabi)
104         PTHREAD_CFLAGS="-pthread"
105         PTHREAD_LIBS="-pthread"
106         ;;
107     *)
108         ;;
109 esac
111 case "$target_os" in
112      linux*)
113         AC_CHECK_HEADERS([linux/sockios.h sys/prctl.h])
114         if test "x$ac_cv_header_linux_sockios_h" = xyes; then
115                 AC_CHECK_DECL([SIOCOUTQ],,, [[#include <linux/sockios.h>]])
116                 if test "x$ac_cv_have_decl_SIOCOUTQ" = xyes; then
117                         AC_DEFINE(HAVE_DECL_SIOCOUTQ, 1,
118                                 [Defined if SIOCOUTQ is available (Linux specific)])
119                 fi
120         fi
122         if test "x$ac_cv_header_sys_prctl_h" = xyes; then
123            AC_CHECK_DECL([PR_SET_NAME],,, [[#include <sys/prctl.h>]])
124               if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
125                     AC_DEFINE(HAVE_PR_SET_NAME, 1,
126                              [Defined if PR_SET_NAME is available (Linux specific)])
127               fi
129            AC_CHECK_DECL([PR_SET_DUMPABLE],,, [[#include <sys/prctl.h>]])
130               if test "x$ac_cv_have_decl_PR_SET_DUMPABLE" = xyes; then
131                     AC_DEFINE(HAVE_PR_SET_DUMPABLE, 1,
132                              [Defined if PR_SET_DUMPABLE is available (Linux specific)])
133               fi
134         fi
135         ;;
136      openbsd*)
137         ;;
138      *bsd*)
139         AC_CHECK_HEADERS([sys/filio.h])
140         if test "x$ac_cv_header_sys_filio_h" = xyes; then
141                 AC_CHECK_DECL([FIONWRITE],,, [[#include <sys/filio.h>]])
142                 if test "x$ac_cv_have_decl_FIONWRITE" = xyes; then
143                         AC_DEFINE(HAVE_DECL_FIONWRITE, 1,
144                                 [Defined if FIONWRITE is available (*BSD specific, not OpenBSD)])
145                 fi
146         fi
147         ;;
148       *cygwin*)
149         AC_DEFINE(HAVE_WINLIKE_SYSTEM, 1, [Define if this is a Windows-like system.])
150         ;;
151      *)
152 dnl     All others use SO_SNDLOWAT.
153         ;;
154 esac
156 dnl Checks for typedefs, structures, and compiler characteristics.
157 AC_TYPE_UID_T
158 AC_C_INLINE
159 AC_TYPE_MODE_T
160 AC_TYPE_OFF_T
161 AC_TYPE_PID_T
162 AC_TYPE_SIZE_T
163 AC_TYPE_SSIZE_T
164 AC_TYPE_UINT32_T
165 AC_TYPE_UINT64_T
166 AC_TYPE_UINT8_T
167 AC_SYS_LARGEFILE
169 dnl Checks for library functions.
170 AM_GNU_GETTEXT
171 AC_FUNC_STAT
172 AC_FUNC_FORK
173 AC_FUNC_MEMCMP
174 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
175 AC_FUNC_STRFTIME
176 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
177                 strstr strtol setrlimit mlockall getopt_long backtrace \
178                 getpwnam_r getgrnam_r flock clock_gettime getcwd \
179                 isascii memchr memmove pathconf putenv select strcasecmp \
180                 strncasecmp strrchr strtoul explicit_bzero memset_s])
181 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
183 AM_PATH_LIBASSUAN($REQUIRE_LIBASSUAN_VERSION,, AC_MSG_ERROR([libassuan >= $REQUIRE_LIBASSUAN_VERSION not found]))
184 AM_PATH_LIBGCRYPT([1:$REQUIRE_LIBGCRYPT_VERSION],, AC_MSG_ERROR([libgcrypt >= $REQUIRE_LIBGCRYPT_VERSION not found]))
185 AM_PATH_GPGME_PTHREAD($REQUIRE_LIBGPGME_VERSION,, AC_MSG_ERROR([libgpgme >= $REQUIRE_LIBGPGME_VERSION not found]))
186 AM_PATH_GPG_ERROR($REQUIRE_LIBGPGERROR_VERSION,, AC_MSG_ERROR([libgpg-error >= $REQUIRE_LIBGPGERROR_VERSION not found]))
187 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
188 AC_SEARCH_LIBS([clock_gettime], [rt])
190 dnl Remote TCP/TLS connections.
191 AC_ARG_ENABLE(gnutls, AS_HELP_STRING([--enable-gnutls],
192               [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
193               USE_GNUTLS=no)
194 if test "x$USE_GNUTLS" = "xyes"; then
195     PKG_CHECK_MODULES([GNUTLS], [gnutls >= $REQUIRE_LIBGNUTLS_VERSION])
196     AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
198 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
200 dnl Libacl support (for data files).
201 AC_ARG_ENABLE(acl, AS_HELP_STRING([--enable-acl],
202               [Enable Access Control List support for data files]),
203               [USE_LIBACL=yes], [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, AS_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, AS_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, AS_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, AS_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 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd-dump.1 \
273                  po/Makefile.in tests/Makefile])
274 AC_OUTPUT
275 echo
276 echo "Features:"
277 echo "    TCP (GnuTLS)....: $USE_GNUTLS"
278 echo "    Data file ACL's.: $USE_LIBACL"
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}"