Version 1.17.
[pwmd.git] / configure.ac
blob77bf039c865307b64c5ab6db7a91835738408e92
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.59)
3 AC_INIT(pwmd, 1.17, [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]))
34 AC_MSG_CHECKING([if zlib is >= 1.2.2.1])
35 AC_TRY_RUN([
36             #include <stdio.h>
37             #include <zlib.h>
39             int main()
40             {
41                 if (ZLIB_VERNUM < 0x1221)
42                     exit(1);
44                 exit(0);
45             }], AC_MSG_RESULT([yes]),
46             AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
48 dnl Checks for header files.
49 AC_HEADER_STDC
50 AC_HEADER_SYS_WAIT
51 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h libintl.h \
52                   locale.h syslog.h termios.h zlib.h])
54 dnl Checks for typedefs, structures, and compiler characteristics.
55 AC_C_CONST
56 AC_C_INLINE
57 AC_TYPE_MODE_T
58 AC_TYPE_SIZE_T
59 AC_STRUCT_TM
60 AC_TYPE_PID_T
61 AC_TYPE_SIGNAL
63 dnl Checks for library functions.
64 AM_GNU_GETTEXT
65 AC_FUNC_STAT
66 AC_FUNC_FORK
67 AC_FUNC_MALLOC
68 AC_FUNC_MEMCMP
69 AC_FUNC_MMAP
70 AC_FUNC_STRFTIME
71 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
72                 strstr strtol setrlimit mlockall])
74 AC_TRY_COMPILE([
75                 #include <stdio.h>
76                 #include <sys/mman.h>], [
77                 int main()
78                 {
79                     void *p = mmap(NULL, 1024, PROT_READ,
80                                    MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
81                     exit(0);
82                 }],
83                 [have_mmap_anonymous=yes], [have_mmap_anonymous=no])
85 if test "$have_mmap_anonymous" = "yes"; then
86     AC_DEFINE([MMAP_ANONYMOUS], 1, \
87               [Define if your mmap() supports the MAP_ANONYMOUS flag.])
90 AC_DEFUN([AC_DEBUG],
92     if test "$1"; then
93         ac_cv_sys_debug=$1
94     fi
96     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
97         [ac_cv_sys_debug=no])
98     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
101 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging.]),
102     AC_DEBUG([$enableval]), AC_DEBUG)
104 AC_DEFUN([AC_MEM_DEBUG],
106     if test "$1"; then
107         ac_cv_sys_mem_debug=$1
108     fi
110     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
111         [ac_cv_sys_mem_debug=no])
112     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
115 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Enable memory debugging.]),
116     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
117 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
119 AC_DEFINE([DEFAULT_RECURSION_DEPTH], 20, \
120           [Default number of target recursions before returning an error.])
122 AC_DEFINE([DEFAULT_ZLIB_BUFSIZE], 65536, \
123           [Default input and output buffer chunk sizes. Affects status messages.])
125 # Pinentry support.
126 AC_ARG_ENABLE(pinentry, AC_HELP_STRING([--disable-pinentry], 
127               [Disable pinentry(1) support.]), USE_PINENTRY=$enableval,
128               USE_PINENTRY=yes)
129 if test "x$USE_PINENTRY" = "xyes"; then
130     AC_DEFINE(WITH_PINENTRY, 1, [Define if you want pinentry(1) support.])
132 AM_CONDITIONAL(WITH_PINENTRY, [test "x$USE_PINENTRY" = "xyes"])
134 pinentry="/usr/bin/pinentry"
135 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
136               [Default location of the pinentry binary (/usr/bin/pinentry)]),
137               pinentry="$withval")
138 AC_SUBST(pinentry)
139 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"], [Default location of the pinentry binary.])
141 # Password quality checking.
142 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
143               [Enable password quality checking with cracklib.]),
144               USE_CRACKLIB=$enableval, USE_CRACKLIB=no)
145 if test "x$USE_CRACKLIB" = "xyes"; then
146     if test "x$USE_PINENTRY" != "xyes"; then
147         AC_MSG_ERROR([--enable-quality needs --enable-pinentry])
148     fi
150     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
151     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
152     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
154 AM_CONDITIONAL(WITH_QUALITY, [test "x$USE_CRACKLIB" = "xyes"])
156 crackdict="/var/cache/cracklib/cracklib_dict"
157 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
158               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
159               crackdict="$withval")
160 AC_SUBST(crackdict)
161 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
163 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd.1 po/Makefile.in])
164 AC_OUTPUT
165 echo
166 echo "Features:"
167 echo "    Debug: ${ac_cv_sys_debug}"
168 echo "    Memory debug: ${ac_cv_sys_mem_debug}"
169 echo "    Pinentry: $USE_PINENTRY"
170 echo "    Pinentry location: $pinentry"
171 echo "    Cracklib: $USE_CRACKLIB"
172 echo "    Cracklib dictionary: $crackdict"