Portability fixes. Mostly for Android.
[pwmd.git] / configure.ac
blob2ab09b44b46a92ad223c0b0e04e30951e3c07f0c
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_AUX_DIR(build)
5 AC_CANONICAL_TARGET
6 AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip])
7 AC_PROG_MAKE_SET
8 AC_USE_SYSTEM_EXTENSIONS()
9 AC_CONFIG_SRCDIR([src/pwmd.c])
10 AM_CONFIG_HEADER([config.h])
11 AM_GNU_GETTEXT([external])
12 AM_GNU_GETTEXT_VERSION([0.16.1])
14 dnl Checks for programs.
15 AC_PROG_CC_C99
17 if test "$ac_cv_prog_cc_c99" = "no"; then
18     AC_MSG_WARN("Unable to find a C99 compatible compiler.")
21 AC_PROG_AWK
22 AC_PROG_LN_S
23 AC_PROG_INSTALL
24 AC_PROG_LN_S
25 AC_PROG_RANLIB
26 AC_PROG_CPP
27 AC_PROG_MKDIR_P
29 dnl Checks for library functions.
30 AX_PTHREAD(, [POSIX threads are required])
31 CC="$PTHREAD_CC"
32 save_CFLAGS="$CFLAGS"
33 save_LIBS="$LIBS"
34 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
35 LIBS="$PTHREAD_LIBS $LIBS"
37 acx_pthread_mutex_timedlock_ok=no
38 AC_MSG_CHECKING([for pthread_mutex_timedlock()])
39 AC_TRY_LINK_FUNC(pthread_mutex_timedlock, acx_pthread_mutex_timedlock_ok=yes)
40 AC_MSG_RESULT($acx_pthread_mutex_timedlock_ok)
41 if test x"$acx_pthread_mutex_timedlock_ok" = "xyes"; then
42     AC_DEFINE(HAVE_PTHREAD_MUTEX_TIMEDLOCK, 1, [Define if your OS has pthread_mutex_timedlock().])
45 acx_pthread_testcancel_ok=no
46 AC_MSG_CHECKING([for pthread_testcancel()])
47 AC_TRY_LINK_FUNC(pthread_testcancel, acx_pthread_testcancel_ok=yes)
48 AC_MSG_RESULT($acx_pthread_testcancel_ok)
49 if test x"$acx_pthread_testcancel_ok" = "xyes"; then
50     AC_DEFINE(HAVE_PTHREAD_TESTCANCEL, 1, [Define if your OS has pthread_testcancel().])
53 CFLAGS="$save_CFLAGS"
54 LIBS="$save_LIBS"
56 AM_PATH_LIBASSUAN([2.0.2],, AC_MSG_ERROR([libassuan not found]))
57 PKG_PROG_PKG_CONFIG()
58 AM_PATH_LIBGCRYPT([1:1.5.0],, AC_MSG_ERROR([libgcrypt not found]))
59 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
60 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
61 AC_SEARCH_LIBS([clock_gettime], [rt])
62 dnl For data file conversion.
63 AC_CHECK_LIB(z, deflate,,
64              AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
66 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls], 
67               [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
68               USE_GNUTLS=no)
69 if test "x$USE_GNUTLS" = "xyes"; then
70     PKG_CHECK_MODULES([GNUTLS], [gnutls])
71     AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
73 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
75 dnl Checks for header files.
76 AC_HEADER_STDC
77 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 zlib.h getopt.h limits.h \
80                   time.h])
81 AC_CHECK_HEADER([linux/prctl.h],
82                 AC_CHECK_DECL([PR_SET_NAME],,, [[#include <linux/prctl.h>]]))
83 if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
84   AC_DEFINE(HAVE_PR_SET_NAME, 1,
85             [Defined if PR_SET_NAME is available (Linux specific)])
87 AC_CHECK_HEADER([sys/socket.h], AC_CHECK_DECLS([SO_BINDTODEVICE,SO_PEERCRED],,, [[#include <sys/socket.h>]]))
89 dnl Checks for typedefs, structures, and compiler characteristics.
90 AC_SYS_LARGEFILE
91 AC_C_CONST
92 AC_C_INLINE
93 AC_TYPE_MODE_T
94 AC_TYPE_SIZE_T
95 AC_STRUCT_TM
96 AC_TYPE_PID_T
97 AC_TYPE_SIGNAL
99 dnl Checks for library functions.
100 AC_FUNC_STAT
101 AC_FUNC_FORK
102 AC_FUNC_MEMCMP
103 AC_FUNC_STRFTIME
104 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
105                 strstr strtol setrlimit mlockall getopt_long backtrace \
106                 sigtimedwait getpwnam_r getgrnam_r])
107 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
109 AC_DEFUN([AC_DEBUG],
111     if test "$1"; then
112         ac_cv_sys_debug=$1
113     fi
115     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
116         [ac_cv_sys_debug=no])
117     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
120 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
121     AC_DEBUG([$enableval]), AC_DEBUG)
123 AC_DEFUN([AC_MEM_DEBUG],
125     if test "$1"; then
126         ac_cv_sys_mem_debug=$1
127     fi
129     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
130         [ac_cv_sys_mem_debug=no])
131     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
134 AC_DEFUN([AC_MUTEX_DEBUG],
136     if test "$1"; then
137         ac_cv_sys_mutex_debug=$1
138     fi
140     AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
141         [ac_cv_sys_mutex_debug=no])
142     AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
145 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
146     AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
148 # Libacl support (for data files).
149 AC_ARG_ENABLE(acl, AC_HELP_STRING([--enable-acl], 
150               [Enable Access Control List support]), USE_LIBACL=yes,
151               USE_LIBACL=no)
152 if test "x$USE_LIBACL" = "xyes"; then
153     AC_CHECK_LIB(acl, acl_get_file,,
154                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
155     AC_CHECK_HEADER([sys/acl.h],,
156                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
157     AC_DEFINE(WITH_LIBACL, 1, [Define if you want libacl support.])
159 AM_CONDITIONAL(WITH_LIBACL, [test "x$USE_LIBACL" = "xyes"])
161 # Memory debugging.
162 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
163     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
164 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
166 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
167 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
168 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
169 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
170 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
172 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd.1 po/Makefile.in
173                  tests/Makefile])
174 AC_OUTPUT
175 echo
176 echo "Features:"
177 echo "    TCP (GnuTLS): $USE_GNUTLS"
178 echo "    ACL: $USE_LIBACL"
179 echo "    Debug: ${ac_cv_sys_debug}"
180 echo "    Memory debug: ${ac_cv_sys_mem_debug}"
181 echo "    Mutex debug: ${ac_cv_sys_mutex_debug}"