Return an error for non-option arguments.
[pwmd.git] / configure.ac
blobd7fda2ad269d25ccbe0465c1740cbcd38d02aa8c
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
3 AC_INIT(pwmd, 3.0.16-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
18 AX_CC_FOR_BUILD
20 if test "$ac_cv_prog_cc_c99" = "no"; then
21     AC_MSG_WARN("Unable to find a C99 compatible compiler.")
24 AX_C_BIGENDIAN_CROSS
25 AC_PROG_AWK
26 AC_PROG_LN_S
27 AC_PROG_INSTALL
28 AC_PROG_LN_S
29 AC_PROG_CPP
30 AC_PROG_MKDIR_P
32 dnl Checks for library functions.
33 AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=2],
34                       [CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"])
35 AX_CHECK_COMPILE_FLAG([-fsanitize=undefined],
36                       [CFLAGS="$CFLAGS -fsanitize=undefined"])
37 AX_PTHREAD(, [POSIX threads are required])
38 CC="$PTHREAD_CC"
39 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
40 LIBS="$PTHREAD_LIBS $LIBS"
42 acx_pthread_testcancel_ok=no
43 AC_MSG_CHECKING([for pthread_testcancel()])
44 AC_TRY_LINK_FUNC(pthread_testcancel, acx_pthread_testcancel_ok=yes)
45 AC_MSG_RESULT($acx_pthread_testcancel_ok)
46 if test x"$acx_pthread_testcancel_ok" = "xyes"; then
47     AC_DEFINE(HAVE_PTHREAD_TESTCANCEL, 1, [Define if your OS has pthread_testcancel().])
50 acx_pthread_cancel_ok=no
51 AC_MSG_CHECKING([for pthread_cancel()])
52 AC_TRY_LINK_FUNC(pthread_cancel, acx_pthread_cancel_ok=yes)
53 AC_MSG_RESULT($acx_pthread_cancel_ok)
54 if test x"$acx_pthread_cancel_ok" = "xyes"; then
55     AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if your OS has pthread_cancel().])
58 acx_pthread_atfork_ok=no
59 AC_MSG_CHECKING([for pthread_atfork()])
60 AC_TRY_LINK_FUNC(pthread_atfork, acx_pthread_atfork_ok=yes)
61 AC_MSG_RESULT($acx_pthread_atfork_ok)
62 if test x"$acx_pthread_atfork_ok" = "xyes"; then
63     AC_DEFINE(HAVE_PTHREAD_ATFORK, 1, [Define if your OS has pthread_atfork().])
66 dnl Checks for header files.
67 AC_HEADER_STDC
68 AC_HEADER_SYS_WAIT
70 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h strings.h sys/time.h unistd.h \
71                   libintl.h locale.h syslog.h termios.h getopt.h limits.h \
72                   time.h sys/select.h])
74 AC_CHECK_DECLS([SO_BINDTODEVICE],,, [[#include <sys/types.h>
75                                       #include <sys/socket.h>]])
77 case "${host}" in
78     *-linux-androideabi)
79         PTHREAD_CFLAGS="-pthread"
80         PTHREAD_LIBS="-pthread"
81         ;;
82     *)
83         ;;
84 esac
86 case "$target_os" in
87      linux*)
88         AC_CHECK_HEADERS([linux/sockios.h sys/prctl.h])
89         if test "x$ac_cv_header_linux_sockios_h" = xyes; then
90                 AC_CHECK_DECL([SIOCOUTQ],,, [[#include <linux/sockios.h>]])
91                 if test "x$ac_cv_have_decl_SIOCOUTQ" = xyes; then
92                         AC_DEFINE(HAVE_DECL_SIOCOUTQ, 1,
93                                 [Defined if SIOCOUTQ is available (Linux specific)])
94                 fi
95         fi
97         if test "x$ac_cv_header_sys_prctl_h" = xyes; then
98            AC_CHECK_DECL([PR_SET_NAME],,, [[#include <sys/prctl.h>]])
99               if test "x$ac_cv_have_decl_PR_SET_NAME" = xyes; then
100                     AC_DEFINE(HAVE_PR_SET_NAME, 1,
101                              [Defined if PR_SET_NAME is available (Linux specific)])
102               fi
104            AC_CHECK_DECL([PR_SET_DUMPABLE],,, [[#include <sys/prctl.h>]])
105               if test "x$ac_cv_have_decl_PR_SET_DUMPABLE" = xyes; then
106                     AC_DEFINE(HAVE_PR_SET_DUMPABLE, 1,
107                              [Defined if PR_SET_DUMPABLE is available (Linux specific)])
108               fi
109         fi
110         ;;
111      openbsd*)
112         ;;
113      *bsd*)
114         AC_CHECK_HEADERS([sys/filio.h])
115         if test "x$ac_cv_header_sys_filio_h" = xyes; then
116                 AC_CHECK_DECL([FIONWRITE],,, [[#include <sys/filio.h>]])
117                 if test "x$ac_cv_have_decl_FIONWRITE" = xyes; then
118                         AC_DEFINE(HAVE_DECL_FIONWRITE, 1,
119                                 [Defined if FIONWRITE is available (*BSD specific, not OpenBSD)])
120                 fi
121         fi
122         ;;
123      *)
124 dnl     All others use SO_SNDLOWAT.
125         ;;
126 esac
128 dnl Checks for typedefs, structures, and compiler characteristics.
129 AC_TYPE_UID_T
130 AC_SYS_LARGEFILE
131 AC_C_CONST
132 AC_C_INLINE
133 AC_TYPE_MODE_T
134 AC_TYPE_SIZE_T
135 AC_STRUCT_TM
136 AC_TYPE_PID_T
137 AC_TYPE_SIGNAL
138 AC_TYPE_UINT8_T
139 AC_TYPE_UINT16_T
140 AC_TYPE_UINT32_T
141 AC_TYPE_UINT64_T
143 dnl Checks for library functions.
144 AC_FUNC_STAT
145 AC_FUNC_FORK
146 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
147 AC_FUNC_MEMCMP
148 AC_FUNC_STRFTIME
149 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
150                 strstr strtol setrlimit mlockall getopt_long backtrace \
151                 getpwnam_r getgrnam_r])
152 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
154 AM_PATH_LIBASSUAN([2.0.2],, AC_MSG_ERROR([libassuan not found]))
155 PKG_PROG_PKG_CONFIG()
156 AM_PATH_LIBGCRYPT([1:1.5.0],, AC_MSG_ERROR([libgcrypt not found]))
157 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
158 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
159 AC_SEARCH_LIBS([clock_gettime], [rt])
161 dnl For data file conversion.
162 AX_CHECK_ZLIB
164 dnl Remote TCP/TLS connections.
165 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls],
166               [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
167               USE_GNUTLS=no)
168 if test "x$USE_GNUTLS" = "xyes"; then
169     PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3.0])
170     AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
172 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
174 dnl Enable gpg-agent support.
175 AC_ARG_ENABLE(agent, AC_HELP_STRING([--enable-agent],
176               [Enable public key/gpg-agent support.]), WITH_AGENT=$enableval,
177               WITH_AGENT=no)
178 if test "x$WITH_AGENT" = "xyes"; then
179     AC_DEFINE(WITH_AGENT, 1, [Define if you want gpg-agent support.])
181 AM_CONDITIONAL(WITH_AGENT, [test "x$WITH_AGENT" = "xyes"])
183 pinentry="/usr/bin/pinentry"
184 dnl Default pinentry location.
185 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
186               [Default location of the pinentry binary (/usr/bin/pinentry)]),
187               pinentry="$withval")
188 AC_SUBST(pinentry)
189 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
190                    [Default location of the pinentry binary.])
192 # Cracklib support (requires pinentry support).
193 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
194               [Enable password quality checking with cracklib.]),
195               WITH_QUALITY=$enableval, WITH_QUALITY=no)
196 if test "x$WITH_QUALITY" = "xyes"; then
197     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
198     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
199     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
201 AM_CONDITIONAL(WITH_QUALITY, [test "x$WITH_QUALITY" = "xyes"])
203 crackdict="/var/cache/cracklib/cracklib_dict"
204 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
205               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
206               crackdict="$withval")
207 AC_SUBST(crackdict)
208 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
210 AC_DEFUN([AC_DEBUG],
212     if test "$1"; then
213         ac_cv_sys_debug=$1
214     fi
216     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
217         [ac_cv_sys_debug=no])
218     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
221 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging (memory de/allocations output).]),
222     AC_DEBUG([$enableval]), AC_DEBUG)
224 AC_DEFUN([AC_MEM_DEBUG],
226     if test "$1"; then
227         ac_cv_sys_mem_debug=$1
228     fi
230     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
231         [ac_cv_sys_mem_debug=no])
232     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
235 AC_DEFUN([AC_MUTEX_DEBUG],
237     if test "$1"; then
238         ac_cv_sys_mutex_debug=$1
239     fi
241     AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
242         [ac_cv_sys_mutex_debug=no])
243     AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
246 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging output.]),
247     AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
249 dnl Memory debugging.
250 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Disable internal memory manager.]),
251     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
252 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
254 # Default pwmd home directory.
255 AC_ARG_WITH(pwmd_homedir, AC_HELP_STRING([--with-pwmd-homedir=PATH],
256               [Default pwmd home directory (~/.pwmd)]),
257               pwmd_homedir="$withval", pwmd_homedir=)
258 if test x"$pwmd_homedir" != "x"; then
259    AC_DEFINE_UNQUOTED(PWMD_HOMEDIR, ["$pwmd_homedir"],
260                                     [Default pwmd home directory (~/.pwmd).])
263 VERSION_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
264 VERSION_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
265 VERSION_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
266 VERSION_NUM="`printf 0x%02x%02x%02X ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}`"
267 AC_DEFINE_UNQUOTED(VERSION_HEX, ${VERSION_NUM}, [For the file header.])
269 dnl Disable optimizing of memset(). GCC and CLang (and others?) accept
270 dnl multiple optimization flags and use the last one specified. The
271 dnl non-optimized memset() may still use any CPU features found in the
272 dnl user specified CFLAGS (-mtune) and libc.
273 CFLAGS_ORIG="$CFLAGS"
274 CFLAGS_MEMZERO="$CFLAGS -O0"
275 CFLAGS=
276 AC_SUBST(CFLAGS_ORIG)
277 AC_SUBST(CFLAGS_MEMZERO)
279 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile po/Makefile.in
280                  tests/Makefile])
281 AC_OUTPUT
282 echo
283 echo "Features:"
284 echo "    With gpg-agent..: $WITH_AGENT"
285 echo "    Pinentry binary.: $pinentry"
286 echo "    Cracklib........: $WITH_QUALITY"
287 echo "    Cracklib dict...: $crackdict"
288 echo "    TCP (GnuTLS)....: $USE_GNUTLS"
290 if test x"$pwmd_homedir" != "x"; then
291 echo "    Home directory..: $pwmd_homedir"
292 else
293 echo "    Home directory..: ~/.pwmd"
296 echo "    Debug...........: ${ac_cv_sys_debug}"
297 echo "    Memory debug....: ${ac_cv_sys_mem_debug}"
298 echo "    Mutex debug.....: ${ac_cv_sys_mutex_debug}"