Created status.c.
[pwmd.git] / configure.ac
blobaae778e5ea2d4902f8e98cb235a47a328eef34e8
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 System specific settings.
15 case "$target_os" in
16     linux*)
17         LIBS="$LIBS -lrt"
18         ;;
19     *)
20         ;;
21 esac
23 dnl Checks for programs.
24 AC_PROG_AWK
25 AC_PROG_LN_S
26 AC_PROG_CC
27 AC_PROG_INSTALL
28 AC_PROG_LN_S
29 AC_PROG_RANLIB
30 AC_PROG_CPP
31 AC_PROG_MKDIR_P
33 dnl Checks for library functions.
34 AM_PATH_GLIB_2_0(,, AC_MSG_ERROR([glib2 not found]))
35 AM_PATH_LIBGCRYPT(,, AC_MSG_ERROR([libgcrypt not found]))
36 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
37 AM_PATH_LIBASSUAN(1.0.5,, AC_MSG_ERROR([libassuan not found]))
38 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
39 AC_CHECK_LIB(z, deflate,,
40             AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
41 ACX_PTHREAD(, [Missing or incomplete pthread installation])
43 LIBS="$PTHREAD_LIBS $LIBS"
44 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
45 CC="$PTHREAD_CC"
47 AC_MSG_CHECKING([if zlib is >= 1.2.2.1])
48 AC_TRY_RUN([
49             #include <stdio.h>
50             #include <zlib.h>
52             int main()
53             {
54                 if (ZLIB_VERNUM < 0x1221)
55                     exit(1);
57                 exit(0);
58             }], AC_MSG_RESULT([yes]),
59             AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
61 dnl Checks for header files.
62 AC_HEADER_STDC
63 AC_HEADER_SYS_WAIT
64 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h libintl.h \
65                   locale.h syslog.h termios.h zlib.h])
67 dnl Checks for typedefs, structures, and compiler characteristics.
68 AC_C_CONST
69 AC_C_INLINE
70 AC_TYPE_MODE_T
71 AC_TYPE_SIZE_T
72 AC_STRUCT_TM
73 AC_TYPE_PID_T
74 AC_TYPE_SIGNAL
76 dnl Checks for library functions.
77 AM_GNU_GETTEXT
78 AC_FUNC_STAT
79 AC_FUNC_FORK
80 AC_FUNC_MALLOC
81 AC_FUNC_MEMCMP
82 AC_FUNC_MMAP
83 AC_FUNC_STRFTIME
84 AC_CHECK_FUNCS([memset mkdir munmap setlocale socket strchr strerror strrchr \
85                 strstr strtol setrlimit mlockall])
87 AC_TRY_COMPILE([
88                 #include <stdio.h>
89                 #include <sys/mman.h>], [
90                 int main()
91                 {
92                     void *p = mmap(NULL, 1024, PROT_READ,
93                                    MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
94                     exit(0);
95                 }],
96                 [have_mmap_anonymous=yes], [have_mmap_anonymous=no])
98 if test "$have_mmap_anonymous" = "yes"; then
99     AC_DEFINE([MMAP_ANONYMOUS], 1, \
100               [Define if your mmap() supports the MAP_ANONYMOUS flag.])
103 AC_DEFUN([AC_DEBUG],
105     if test "$1"; then
106         ac_cv_sys_debug=$1
107     fi
109     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
110         [ac_cv_sys_debug=no])
111     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
114 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging.]),
115     AC_DEBUG([$enableval]), AC_DEBUG)
117 AC_DEFUN([AC_MEM_DEBUG],
119     if test "$1"; then
120         ac_cv_sys_mem_debug=$1
121     fi
123     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
124         [ac_cv_sys_mem_debug=no])
125     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
128 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Enable memory debugging.]),
129     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
130 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
132 AC_DEFINE([DEFAULT_RECURSION_DEPTH], 20, \
133           [Default number of target recursions before returning an error.])
135 AC_DEFINE([DEFAULT_ZLIB_BUFSIZE], 65536, \
136           [Default input and output buffer chunk sizes. Affects status messages.])
138 # GnuTLS support.
139 AC_ARG_ENABLE(tcp, AC_HELP_STRING([--enable-tcp], 
140               [Enable TCP (GnuTLS) server support.]), USE_GNUTLS=$enableval,
141               USE_GNUTLS=no)
142 if test "x$USE_GNUTLS" = "xyes"; then
143     AM_PATH_LIBGNUTLS(,, AC_MSG_ERROR([libgnutls not found]))
144     AC_DEFINE(WITH_GNUTLS, 1, [Define if you want TCP (GnuTLS) support.])
146 AM_CONDITIONAL(WITH_GNUTLS, [test "x$USE_GNUTLS" = "xyes"])
148 # Pinentry support.
149 AC_ARG_ENABLE(pinentry, AC_HELP_STRING([--disable-pinentry], 
150               [Disable pinentry(1) support.]), USE_PINENTRY=$enableval,
151               USE_PINENTRY=yes)
152 if test "x$USE_PINENTRY" = "xyes"; then
153     AC_DEFINE(WITH_PINENTRY, 1, [Define if you want pinentry(1) support.])
155 AM_CONDITIONAL(WITH_PINENTRY, [test "x$USE_PINENTRY" = "xyes"])
157 pinentry="/usr/bin/pinentry"
158 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
159               [Default location of the pinentry binary (/usr/bin/pinentry)]),
160               pinentry="$withval")
161 AC_SUBST(pinentry)
162 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"], [Default location of the pinentry binary.])
164 # Cracklib support (requires pinentry support).
165 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
166               [Enable password quality checking with cracklib.]),
167               CRACKLIB=$enableval, CRACKLIB=no)
168 if test "x$CRACKLIB" = "xyes"; then
169     if test "x$USE_PINENTRY" != "xyes"; then
170         AC_MSG_ERROR([--enable-quality needs --enable-pinentry])
171     fi
173     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
174     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
175     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
177 AM_CONDITIONAL(WITH_QUALITY, [test "x$USE_CRACKLIB" = "xyes"])
179 crackdict="/var/cache/cracklib/cracklib_dict"
180 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
181               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
182               crackdict="$withval")
183 AC_SUBST(crackdict)
184 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
186 VER_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
187 VER_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
188 AC_DEFINE_UNQUOTED(VERSION_HEX, 0x${VER_MAJOR}${VER_MINOR}, [For the file header.])
190 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/pwmd.1 po/Makefile.in])
191 AC_OUTPUT
192 echo
193 echo "Features:"
194 echo "    Debug: ${ac_cv_sys_debug}"
195 echo "    Memory debug: ${ac_cv_sys_mem_debug}"
196 echo "    GnuTLS: $USE_GNUTLS"
197 echo "    Pinentry: $USE_PINENTRY"
198 echo "    Pinentry location: $pinentry"
199 echo "    Cracklib: $CRACKLIB"
200 echo "    Cracklib dictionary: $crackdict"