Use a pthread_mutex_t to lock and unlock the memory allocators and
[pwmd.git] / configure.ac
blob9dc65315e7fb41a48fe55a20f8f12bc3f32945ef
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.59)
3 AC_INIT(pwmd, 1.16, [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_PTH(1.0.4,, AC_MSG_ERROR([libassuan-pth not found]))
29 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
30 AC_CHECK_PTH(2.0.0,,,,, AC_MSG_ERROR([libpth not found]))
31 AC_CHECK_LIB(z, deflate,,
32             AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
33 ACX_PTHREAD(, [Missing or incomplete pthread installation])
35 LIBS="$PTHREAD_LIBS $LIBS"
36 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
37 CC="$PTHREAD_CC"
39 AC_MSG_CHECKING([if zlib is >= 1.2.2.1])
40 AC_TRY_RUN([
41             #include <stdio.h>
42             #include <zlib.h>
44             int main()
45             {
46                 if (ZLIB_VERNUM < 0x1221)
47                     exit(1);
49                 exit(0);
50             }], AC_MSG_RESULT([yes]),
51             AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
53 dnl Checks for header files.
54 AC_HEADER_STDC
55 AC_HEADER_SYS_WAIT
56 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h libintl.h \
57                   locale.h syslog.h termios.h zlib.h])
59 dnl Checks for typedefs, structures, and compiler characteristics.
60 AC_C_CONST
61 AC_C_INLINE
62 AC_TYPE_MODE_T
63 AC_TYPE_SIZE_T
64 AC_STRUCT_TM
65 AC_TYPE_PID_T
66 AC_TYPE_SIGNAL
68 dnl Checks for library functions.
69 AM_GNU_GETTEXT
70 AC_FUNC_STAT
71 AC_FUNC_FORK
72 AC_FUNC_MALLOC
73 AC_FUNC_MEMCMP
74 AC_FUNC_MMAP
75 AC_FUNC_STRFTIME
76 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
77                 strstr strtol setrlimit mlockall])
79 AC_TRY_COMPILE([
80                 #include <stdio.h>
81                 #include <sys/mman.h>], [
82                 int main()
83                 {
84                     void *p = mmap(NULL, 1024, PROT_READ,
85                                    MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
86                     exit(0);
87                 }],
88                 [have_mmap_anonymous=yes], [have_mmap_anonymous=no])
90 if test "$have_mmap_anonymous" = "yes"; then
91     AC_DEFINE([MMAP_ANONYMOUS], 1, \
92               [Define if your mmap() supports the MAP_ANONYMOUS flag.])
95 AC_DEFUN([AC_DEBUG],
97     if test "$1"; then
98         ac_cv_sys_debug=$1
99     fi
101     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
102         [ac_cv_sys_debug=no])
103     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
106 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging.]),
107     AC_DEBUG([$enableval]), AC_DEBUG)
109 AC_DEFUN([AC_MEM_DEBUG],
111     if test "$1"; then
112         ac_cv_sys_mem_debug=$1
113     fi
115     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
116         [ac_cv_sys_mem_debug=no])
117     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
120 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Enable memory debugging.]),
121     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
122 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
124 AC_DEFINE([DEFAULT_RECURSION_DEPTH], 20, \
125           [Default number of target recursions before returning an error.])
127 AC_DEFINE([DEFAULT_ZLIB_BUFSIZE], 65536, \
128           [Default input and output buffer chunk sizes. Affects status messages.])
130 # Pinentry support.
131 AC_ARG_ENABLE(pinentry, AC_HELP_STRING([--disable-pinentry], 
132               [Disable pinentry(1) support.]), USE_PINENTRY=$enableval,
133               USE_PINENTRY=yes)
134 if test "x$USE_PINENTRY" = "xyes"; then
135     AC_DEFINE(WITH_PINENTRY, 1, [Define if you want pinentry(1) support.])
137 AM_CONDITIONAL(WITH_PINENTRY, [test "x$USE_PINENTRY" = "xyes"])
139 pinentry="/usr/bin/pinentry"
140 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
141               [Default location of the pinentry binary (/usr/bin/pinentry)]),
142               pinentry="$withval")
143 AC_SUBST(pinentry)
144 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"], [Default location of the pinentry binary.])
146 # Password quality checking.
147 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
148               [Enable password quality checking with cracklib.]),
149               USE_CRACKLIB=$enableval, USE_CRACKLIB=no)
150 if test "x$USE_CRACKLIB" = "xyes"; then
151     if test "x$USE_PINENTRY" != "xyes"; then
152         AC_MSG_ERROR([--enable-quality needs --enable-pinentry])
153     fi
155     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
156     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
157     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
159 AM_CONDITIONAL(WITH_QUALITY, [test "x$USE_CRACKLIB" = "xyes"])
161 crackdict="/var/cache/cracklib/cracklib_dict"
162 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
163               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
164               crackdict="$withval")
165 AC_SUBST(crackdict)
166 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
168 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd.1 po/Makefile.in])
169 AC_OUTPUT
170 echo
171 echo "Features:"
172 echo "    Debug: ${ac_cv_sys_debug}"
173 echo "    Memory debug: ${ac_cv_sys_mem_debug}"
174 echo "    Pinentry: $USE_PINENTRY"
175 echo "    Pinentry location: $pinentry"
176 echo "    Cracklib: $USE_CRACKLIB"
177 echo "    Cracklib dictionary: $crackdict"