Fix for commit a7e15f9.
[pwmd.git] / configure.ac
blob9303cc0464022976482dd53494c3e8e9504b00b5
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.59)
3 AC_INIT(pwmd, 2.0-dev, [Ben Kibbey bjk@luxsci.net])
4 AC_CONFIG_AUX_DIR(build)
5 AC_CANONICAL_TARGET
6 AM_INIT_AUTOMAKE([foreign])
7 AC_PROG_MAKE_SET
8 AC_CONFIG_SRCDIR([src/pwmd.c])
9 AM_CONFIG_HEADER([config.h])
10 AM_GNU_GETTEXT([external])
11 AM_GNU_GETTEXT_VERSION([0.16.1])
12 AC_GNU_SOURCE
14 dnl Checks for programs.
15 AC_PROG_AWK
16 AC_PROG_LN_S
17 AC_PROG_CC
18 AC_PROG_INSTALL
19 AC_PROG_LN_S
20 AC_PROG_RANLIB
21 AC_PROG_CPP
22 AC_PROG_MKDIR_P
24 dnl Checks for library functions.
25 AM_PATH_GLIB_2_0(,, AC_MSG_ERROR([glib2 not found]))
26 AM_PATH_LIBGCRYPT(,, AC_MSG_ERROR([libgcrypt not found]))
27 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
28 AM_PATH_LIBASSUAN(1.0.5,, AC_MSG_ERROR([libassuan not found]))
29 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
30 AC_CHECK_LIB(z, deflate,,
31             AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
32 ACX_PTHREAD(, [Missing or incomplete pthread installation])
34 LIBS="$PTHREAD_LIBS $LIBS -lrt"
35 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
36 CC="$PTHREAD_CC"
38 AC_MSG_CHECKING([if zlib is >= 1.2.2.1])
39 AC_TRY_RUN([
40             #include <stdio.h>
41             #include <zlib.h>
43             int main()
44             {
45                 if (ZLIB_VERNUM < 0x1221)
46                     exit(1);
48                 exit(0);
49             }], AC_MSG_RESULT([yes]),
50             AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
52 dnl Checks for header files.
53 AC_HEADER_STDC
54 AC_HEADER_SYS_WAIT
55 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h libintl.h \
56                   locale.h syslog.h termios.h zlib.h])
58 dnl Checks for typedefs, structures, and compiler characteristics.
59 AC_C_CONST
60 AC_C_INLINE
61 AC_TYPE_MODE_T
62 AC_TYPE_SIZE_T
63 AC_STRUCT_TM
64 AC_TYPE_PID_T
65 AC_TYPE_SIGNAL
67 dnl Checks for library functions.
68 AM_GNU_GETTEXT
69 AC_FUNC_STAT
70 AC_FUNC_FORK
71 AC_FUNC_MALLOC
72 AC_FUNC_MEMCMP
73 AC_FUNC_MMAP
74 AC_FUNC_STRFTIME
75 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
76                 strstr strtol setrlimit mlockall])
78 AC_TRY_COMPILE([
79                 #include <stdio.h>
80                 #include <sys/mman.h>], [
81                 int main()
82                 {
83                     void *p = mmap(NULL, 1024, PROT_READ,
84                                    MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
85                     exit(0);
86                 }],
87                 [have_mmap_anonymous=yes], [have_mmap_anonymous=no])
89 if test "$have_mmap_anonymous" = "yes"; then
90     AC_DEFINE([MMAP_ANONYMOUS], 1, \
91               [Define if your mmap() supports the MAP_ANONYMOUS flag.])
94 AC_DEFUN([AC_DEBUG],
96     if test "$1"; then
97         ac_cv_sys_debug=$1
98     fi
100     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
101         [ac_cv_sys_debug=no])
102     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
105 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging.]),
106     AC_DEBUG([$enableval]), AC_DEBUG)
108 AC_DEFUN([AC_MEM_DEBUG],
110     if test "$1"; then
111         ac_cv_sys_mem_debug=$1
112     fi
114     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
115         [ac_cv_sys_mem_debug=no])
116     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
119 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Enable memory debugging.]),
120     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
121 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
123 AC_DEFINE([DEFAULT_RECURSION_DEPTH], 20, \
124           [Default number of target recursions before returning an error.])
126 AC_DEFINE([DEFAULT_ZLIB_BUFSIZE], 65536, \
127           [Default input and output buffer chunk sizes. Affects status messages.])
129 # GnuTLS support.
130 AC_ARG_ENABLE(tcp, AC_HELP_STRING([--enable-tcp], 
131               [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
132               USE_GNUTLS=no)
133 if test "x$USE_GNUTLS" = "xyes"; then
134     AM_PATH_LIBGNUTLS(,, AC_MSG_ERROR([libgnutls not found]))
135     AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
137 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
139 # Pinentry support.
140 AC_ARG_ENABLE(pinentry, AC_HELP_STRING([--disable-pinentry], 
141               [Disable pinentry(1) support.]), USE_PINENTRY=$enableval,
142               USE_PINENTRY=yes)
143 if test "x$USE_PINENTRY" = "xyes"; then
144     AC_DEFINE(WITH_PINENTRY, 1, [Define if you want pinentry(1) support.])
146 AM_CONDITIONAL(WITH_PINENTRY, [test "x$USE_PINENTRY" = "xyes"])
148 pinentry="/usr/bin/pinentry"
149 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
150               [Default location of the pinentry binary (/usr/bin/pinentry)]),
151               pinentry="$withval")
152 AC_SUBST(pinentry)
153 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"], [Default location of the pinentry binary.])
155 # Cracklib support (requires pinentry support).
156 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
157               [Enable password quality checking with cracklib.]),
158               CRACKLIB=$enableval, CRACKLIB=no)
159 if test "x$CRACKLIB" = "xyes"; then
160     if test "x$USE_PINENTRY" != "xyes"; then
161         AC_MSG_ERROR([--enable-quality needs --enable-pinentry])
162     fi
164     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
165     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
166     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
168 AM_CONDITIONAL(WITH_QUALITY, [test "x$USE_CRACKLIB" = "xyes"])
170 crackdict="/var/cache/cracklib/cracklib_dict"
171 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
172               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
173               crackdict="$withval")
174 AC_SUBST(crackdict)
175 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
177 VER_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
178 VER_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
179 AC_DEFINE_UNQUOTED(VERSION_HEX, 0x${VER_MAJOR}${VER_MINOR}, [For the file header.])
181 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd.1 po/Makefile.in])
182 AC_OUTPUT
183 echo
184 echo "Features:"
185 echo "    Debug: ${ac_cv_sys_debug}"
186 echo "    Memory debug: ${ac_cv_sys_mem_debug}"
187 echo "    GnuTLS: $USE_GNUTLS"
188 echo "    Pinentry: $USE_PINENTRY"
189 echo "    Pinentry location: $pinentry"
190 echo "    Cracklib: $CRACKLIB"
191 echo "    Cracklib dictionary: $crackdict"