Add #include's for ntohl().
[pwmd.git] / configure.ac
blob22723c110d6d426b7b9420d3eec61b3f5330f4d6
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 zlib.h getopt.h limits.h \
80                   time.h])
82 AC_CHECK_DECLS([SO_BINDTODEVICE],,, [[#include <sys/types.h>
83                                       #include <sys/socket.h>]])
85 case "$target_os" in
86      linux*)
87         AC_CHECK_HEADERS([linux/sockios.h linux/prctl.h])
88         if test "x$ac_cv_header_linux_sockios_h" = xyes; then
89                 AC_CHECK_DECL([SIOCOUTQ],,, [[#include <linux/sockios.h>]])
90                 if test "x$ac_cv_have_decl_SIOCOUTQ" = xyes; then
91                         AC_DEFINE(HAVE_DECL_SIOCOUTQ, 1,
92                                 [Defined if SIOCOUTQ is available (Linux specific)])
93                 fi
94         fi
96         if test "x$ac_cv_header_linux_prctl_h" = xyes; then
97            AC_CHECK_DECL([PR_SET_NAME],,, [[#include <linux/prctl.h>]])
98               if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
99                     AC_DEFINE(HAVE_PR_SET_NAME, 1,
100                              [Defined if PR_SET_NAME is available (Linux specific)])
101               fi
102         fi
103         ;;
104      openbsd*)
105         ;;
106      *bsd*)
107         AC_CHECK_HEADERS([sys/filio.h])
108         if test "x$ac_cv_header_sys_filio_h" = xyes; then
109                 AC_CHECK_DECL([FIONWRITE],,, [[#include <sys/filio.h>]])
110                 if test "x$ac_cv_have_decl_FIONWRITE" = xyes; then
111                         AC_DEFINE(HAVE_DECL_FIONWRITE, 1,
112                                 [Defined if FIONWRITE is available (*BSD specific, not OpenBSD)])
113                 fi
114         fi
115         ;;
116      *)
117 dnl     All others use SO_SNDLOWAT.
118         ;;
119 esac
121 dnl Checks for typedefs, structures, and compiler characteristics.
122 AC_SYS_LARGEFILE
123 AC_C_CONST
124 AC_C_INLINE
125 AC_TYPE_MODE_T
126 AC_TYPE_SIZE_T
127 AC_STRUCT_TM
128 AC_TYPE_PID_T
129 AC_TYPE_SIGNAL
130 AC_TYPE_UINT8_T
131 AC_TYPE_UINT32_T
132 AC_TYPE_UINT64_T
134 dnl Checks for library functions.
135 AC_FUNC_STAT
136 AC_FUNC_FORK
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 AC_CHECK_LIB(z, deflate,,
153              AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
155 dnl Remote TCP/TLS connections.
156 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls],
157               [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
158               USE_GNUTLS=no)
159 if test "x$USE_GNUTLS" = "xyes"; then
160     PKG_CHECK_MODULES([GNUTLS], [gnutls])
161     AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
163 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
165 dnl Disable gpg-agent.
166 AC_ARG_ENABLE(agent, AC_HELP_STRING([--disable-agent],
167               [Disable public key/gpg-agent support.]), WITH_AGENT=$enableval,
168               WITH_AGENT=yes)
169 if test "x$WITH_AGENT" = "xyes"; then
170     AC_DEFINE(WITH_AGENT, 1, [Define if you want gpg-agent support.])
172 AM_CONDITIONAL(WITH_AGENT, [test "x$WITH_AGENT" = "xyes"])
174 pinentry="/usr/bin/pinentry"
175 dnl Default pinentry location.
176 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
177               [Default location of the pinentry binary (/usr/bin/pinentry)]),
178               pinentry="$withval")
179 AC_SUBST(pinentry)
180 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
181                    [Default location of the pinentry binary.])
183 # Cracklib support (requires pinentry support).
184 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
185               [Enable password quality checking with cracklib.]),
186               WITH_QUALITY=$enableval, WITH_QUALITY=no)
187 if test "x$WITH_QUALITY" = "xyes"; then
188     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
189     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
190     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
192 AM_CONDITIONAL(WITH_QUALITY, [test "x$WITH_QUALITY" = "xyes"])
194 crackdict="/var/cache/cracklib/cracklib_dict"
195 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
196               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
197               crackdict="$withval")
198 AC_SUBST(crackdict)
199 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
202 dnl Libacl support (for data files).
203 AC_ARG_ENABLE(acl, AC_HELP_STRING([--enable-acl],
204               [Enable Access Control List support]), USE_LIBACL=yes,
205               USE_LIBACL=no)
206 if test "x$USE_LIBACL" = "xyes"; then
207     AC_SEARCH_LIBS([acl_get_file], [acl],,
208                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
209     AC_CHECK_HEADER([sys/acl.h],,
210                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
211     AC_DEFINE(WITH_LIBACL, 1, [Define if you want libacl support.])
213 AM_CONDITIONAL(WITH_LIBACL, [test "x$USE_LIBACL" = "xyes"])
215 AC_DEFUN([AC_DEBUG],
217     if test "$1"; then
218         ac_cv_sys_debug=$1
219     fi
221     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
222         [ac_cv_sys_debug=no])
223     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
226 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
227     AC_DEBUG([$enableval]), AC_DEBUG)
229 AC_DEFUN([AC_MEM_DEBUG],
231     if test "$1"; then
232         ac_cv_sys_mem_debug=$1
233     fi
235     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
236         [ac_cv_sys_mem_debug=no])
237     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
240 AC_DEFUN([AC_MUTEX_DEBUG],
242     if test "$1"; then
243         ac_cv_sys_mutex_debug=$1
244     fi
246     AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
247         [ac_cv_sys_mutex_debug=no])
248     AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
251 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
252     AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
254 dnl Memory debugging.
255 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
256     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
257 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
259 # Default pwmd home directory.
260 AC_ARG_WITH(pwmd_homedir, AC_HELP_STRING([--with-pwmd-homedir=PATH],
261               [Default pwmd home directory (~/.pwmd)]),
262               pwmd_homedir="$withval", pwmd_homedir=)
263 if test x"$pwmd_homedir" != "x"; then
264    AC_DEFINE_UNQUOTED(PWMD_HOMEDIR, ["$pwmd_homedir"],
265                                     [Default pwmd home directory (~/.pwmd).])
268 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
269 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
270 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
271 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
272 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
274 dnl Disable optimizing of memset(). GCC and CLang (and others?) accept
275 dnl multiple optimization flags and use the last one specified. The
276 dnl non-optimized memset() may still use any CPU features found in the
277 dnl user specified CFLAGS (-mtune) and libc.
278 CFLAGS_ORIG="$CFLAGS"
279 CFLAGS_MEMZERO="$CFLAGS -O0"
280 CFLAGS=
281 AC_SUBST(CFLAGS_ORIG)
282 AC_SUBST(CFLAGS_MEMZERO)
284 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd.1 po/Makefile.in
285                  tests/Makefile])
286 AC_OUTPUT
287 echo
288 echo "Features:"
289 echo "    With gpg-agent..: $WITH_AGENT"
290 echo "    Pinentry binary.: $pinentry"
291 echo "    Cracklib........: $WITH_QUALITY"
292 echo "    Cracklib dict...: $crackdict"
293 echo "    TCP (GnuTLS)....: $USE_GNUTLS"
294 echo "    ACL.............: $USE_LIBACL"
296 if test x"$pwmd_homedir" != "x"; then
297 echo "    Home directory..: $pwmd_homedir"
298 else
299 echo "    Home directory..: ~/.pwmd"
302 echo "    Debug...........: ${ac_cv_sys_debug}"
303 echo "    Memory debug....: ${ac_cv_sys_mem_debug}"
304 echo "    Mutex debug.....: ${ac_cv_sys_mutex_debug}"