Version 2.18.
[pwmd.git] / configure.ac
blob869db9aacb600587cdab27c6080f8349069f309a
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
3 AC_INIT(pwmd, 2.18, [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_USE_SYSTEM_EXTENSIONS()
9 AC_CONFIG_SRCDIR([src/pwmd.c])
10 AM_CONFIG_HEADER([config.h])
11 AM_GNU_GETTEXT([external])
12 AM_GNU_GETTEXT_VERSION([0.16.1])
13 AC_CONFIG_SUBDIRS([assuan])
15 dnl Checks for programs.
16 AC_PROG_CC_C99
18 if test "$ac_cv_prog_cc_c99" = "no"; then
19     AC_MSG_WARN("Unable to find a C99 compatible compiler.")
22 AC_PROG_AWK
23 AC_PROG_LN_S
24 AC_PROG_INSTALL
25 AC_PROG_LN_S
26 AC_PROG_RANLIB
27 AC_PROG_CPP
28 AC_PROG_MKDIR_P
30 dnl Checks for library functions.
31 AM_PATH_GLIB_2_0(,, AC_MSG_ERROR([glib2 not found]))
32 AM_PATH_LIBGCRYPT([1.3.1],, AC_MSG_ERROR([libgcrypt not found]))
33 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
34 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
35 AC_CHECK_LIB(z, deflate,,
36             AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
37 AC_CHECK_PTH(, yes, yes, no, ,
38              AC_MSG_ERROR([Missing or incomplete libpth installation]))
40 AC_MSG_CHECKING([if zlib is >= 1.2.2.1])
41 AC_TRY_RUN([
42             #include <stdio.h>
43             #include <zlib.h>
45             int main()
46             {
47                 if (ZLIB_VERNUM < 0x1221)
48                     exit(1);
50                 exit(0);
51             }], AC_MSG_RESULT([yes]),
52             AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
54 dnl Checks for header files.
55 AC_HEADER_STDC
56 AC_HEADER_SYS_WAIT
57 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h libintl.h \
58                   locale.h syslog.h termios.h zlib.h getopt.h])
60 dnl Checks for typedefs, structures, and compiler characteristics.
61 AC_C_CONST
62 AC_C_INLINE
63 AC_TYPE_MODE_T
64 AC_TYPE_SIZE_T
65 AC_STRUCT_TM
66 AC_TYPE_PID_T
67 AC_TYPE_SIGNAL
70 # Check for the getsockopt SO_PEERCRED
72 AC_MSG_CHECKING(for SO_PEERCRED)
73 AC_CACHE_VAL(pwmd_cv_sys_so_peercred,
74       [AC_TRY_COMPILE([#include <sys/socket.h>], 
75          [struct ucred cr; 
76           int cl = sizeof cr;
77           getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);],
78           pwmd_cv_sys_so_peercred=yes,
79           pwmd_cv_sys_so_peercred=no)
80        ])
81 AC_MSG_RESULT($pwmd_cv_sys_so_peercred) 
82 if test $pwmd_cv_sys_so_peercred = yes; then
83   AC_DEFINE(HAVE_SO_PEERCRED, 1,
84             [Defined if SO_PEERCRED is supported (Linux specific)])
87 dnl Checks for library functions.
88 AC_FUNC_STAT
89 AC_FUNC_FORK
90 AC_FUNC_MALLOC
91 AC_FUNC_MEMCMP
92 AC_FUNC_STRFTIME
93 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
94                 strstr strtol setrlimit mlockall getopt_long])
95 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
97 AC_DEFUN([AC_DEBUG],
99     if test "$1"; then
100         ac_cv_sys_debug=$1
101     fi
103     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
104         [ac_cv_sys_debug=no])
105     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
108 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging.]),
109     AC_DEBUG([$enableval]), AC_DEBUG)
111 AC_DEFUN([AC_MEM_DEBUG],
113     if test "$1"; then
114         ac_cv_sys_mem_debug=$1
115     fi
117     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
118         [ac_cv_sys_mem_debug=no])
119     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
122 AC_DEFUN([AC_MUTEX_DEBUG],
124     if test "$1"; then
125         ac_cv_sys_mutex_debug=$1
126     fi
128     AC_CACHE_CHECK([if mutex debugging is wanted], [ac_cv_sys_mutex_debug],
129         [ac_cv_sys_mutex_debug=no])
130     AM_CONDITIONAL([WITH_MUTEX_DEBUG], [test "$ac_cv_sys_mutex_debug" = "yes"])
133 AC_ARG_ENABLE(mutex_debug, AC_HELP_STRING([--enable-mutex-debug], [Enable mutex debugging.]),
134     AC_MUTEX_DEBUG([$enableval]), AC_MUTEX_DEBUG)
136 # Libacl support.
137 AC_ARG_ENABLE(acl, AC_HELP_STRING([--enable-acl], 
138               [Enable Access Control List support]), USE_LIBACL=yes,
139               USE_LIBACL=no)
140 if test "x$USE_LIBACL" = "xyes"; then
141     AC_CHECK_LIB(acl, acl_get_file,,
142                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
143     AC_CHECK_HEADER([sys/acl.h],,
144                     AC_MSG_ERROR([Missing or incomplete libacl installation.]))
145     AC_DEFINE(WITH_LIBACL, 1, [Define if you want libacl support.])
147 AM_CONDITIONAL(WITH_LIBACL, [test "x$USE_LIBACL" = "xyes"])
149 # Memory debugging.
150 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Enable memory debugging.]),
151     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
152 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
154 AC_DEFINE([DEFAULT_RECURSION_DEPTH], 20, \
155           [Default number of target recursions before returning an error.])
157 AC_DEFINE([DEFAULT_ZLIB_BUFSIZE], 65536, \
158           [Default input and output buffer chunk sizes. Affects status messages.])
160 # Pinentry support.
161 AC_ARG_ENABLE(pinentry, AC_HELP_STRING([--disable-pinentry], 
162               [Disable pinentry(1) support.]), USE_PINENTRY=$enableval,
163               USE_PINENTRY=yes)
164 if test "x$USE_PINENTRY" = "xyes"; then
165     AC_DEFINE(WITH_PINENTRY, 1, [Define if you want pinentry(1) support.])
167 AM_CONDITIONAL(WITH_PINENTRY, [test "x$USE_PINENTRY" = "xyes"])
169 pinentry="/usr/bin/pinentry"
170 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
171               [Default location of the pinentry binary (/usr/bin/pinentry)]),
172               pinentry="$withval")
173 AC_SUBST(pinentry)
174 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"], [Default location of the pinentry binary.])
176 # Cracklib support (requires pinentry support).
177 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
178               [Enable password quality checking with cracklib.]),
179               CRACKLIB=$enableval, CRACKLIB=no)
180 if test "x$CRACKLIB" = "xyes"; then
181     if test "x$USE_PINENTRY" != "xyes"; then
182         AC_MSG_ERROR([--enable-quality needs --enable-pinentry])
183     fi
185     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
186     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
187     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
189 AM_CONDITIONAL(WITH_QUALITY, [test "x$USE_CRACKLIB" = "xyes"])
191 crackdict="/var/cache/cracklib/cracklib_dict"
192 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
193               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
194               crackdict="$withval")
195 AC_SUBST(crackdict)
196 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
198 VER_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
199 VER_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
200 VER_MOD="`if test \`echo -n $VER_MINOR | wc -c\` -eq 1; then echo 0$VER_MINOR; else echo $VER_MINOR; fi`"
201 AC_DEFINE_UNQUOTED(VERSION_HEX, 0x${VER_MAJOR}${VER_MOD}, [For the file header.])
203 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd.1 po/Makefile.in])
204 AC_OUTPUT
205 echo
206 echo "Features:"
207 echo "    Debug: ${ac_cv_sys_debug}"
208 echo "    Memory debug: ${ac_cv_sys_mem_debug}"
209 echo "    Mutex debug: ${ac_cv_sys_mutex_debug}"
210 echo "    Pinentry: $USE_PINENTRY"
211 echo "    Pinentry location: $pinentry"
212 echo "    Cracklib: $CRACKLIB"
213 echo "    Cracklib dictionary: $crackdict"
214 echo "    ACL: $USE_LIBACL"