Parse PASSPHRASE_HINT and PASSPHRASE_INFO.
[libpwmd.git] / configure.ac
blob12d41f1bad1e76ab388b98380bb44e172a244081
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
3 AC_INIT(libpwmd, 8.0.0-dev, [Ben Kibbey bjk@luxsci.net])
4 AC_CONFIG_MACRO_DIR([m4])
5 AC_CONFIG_AUX_DIR(build)
6 AC_CANONICAL_TARGET
7 AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip])
8 AC_PROG_MAKE_SET
9 #AC_DISABLE_SHARED
10 AC_USE_SYSTEM_EXTENSIONS
11 AC_PROG_LIBTOOL
12 AC_CONFIG_SRCDIR([src/libpwmd.c])
13 AM_CONFIG_HEADER([config.h])
14 AM_GNU_GETTEXT([external])
15 AM_GNU_GETTEXT_VERSION([0.16.1])
17 VER_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
18 VER_MINOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`"
19 VER_PATCH="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`"
20 AC_SUBST(VER_MAJOR)
21 AC_SUBST(VER_MINOR)
22 AC_SUBST(VER_PATCH)
23 VER_MAJOR_HEX=`printf "%02X" $VER_MAJOR`
24 VER_MINOR_HEX=`printf "%02X" $VER_MINOR`
25 VER_PATCH_HEX=`printf "%02X" $VER_PATCH`
26 AC_SUBST(VER_MAJOR_HEX)
27 AC_SUBST(VER_MINOR_HEX)
28 AC_SUBST(VER_PATCH_HEX)
29 VER_STRING="\"$VERSION\""
30 AC_SUBST(VER_STRING)
32 case "$target_os" in
33     darwin*)
34         LDFLAGS="$LDFLAGS -flat_namespace -L/sw/lib"
35         CPPFLAGS="$CPPFLAGS -I/sw/include -L/sw/lib"
36         ;;
37     linux*)
38         case "$target_cpu" in
39             x86_64*)
40                 LDFLAGS="$LDFLAGS -lrt"
41                 ;;
42             *)
43                 ;;
44         esac
45         ;;
46     *)
47         ;;
48 esac
50 dnl Checks for programs.
51 AC_PROG_CC_C99
53 if test "$ac_cv_prog_cc_c99" = "no"; then
54     AC_MSG_ERROR("Unable to find a C99 compatible compiler.")
57 dnl Borrowed from libssh2!
58 dnl ************************************************************
59 dnl Enable hiding of internal symbols in library to reduce its size and
60 dnl speed dynamic linking of applications.  This currently is only supported
61 dnl on gcc >= 4.0 and SunPro C.
62 dnl
63 AC_MSG_CHECKING([whether to enable hidden symbols in the library])
64 AC_ARG_ENABLE(hidden-symbols,
65 AC_HELP_STRING([--enable-hidden-symbols],[Hide internal symbols in library])
66 AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibility in library]),
67 [ case "$enableval" in
68   no)
69        AC_MSG_RESULT(no)
70        ;;
71   *)
72        AC_MSG_CHECKING([whether $CC supports it])
73        if test "$GCC" = yes ; then
74          if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
75            AC_MSG_RESULT(yes)
76            AC_DEFINE(LIBPWMD_API, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
77            CFLAGS="$CFLAGS -fvisibility=hidden"
78          else
79             AC_MSG_RESULT(no)
80           fi
82        else
83          dnl Test for SunPro cc
84          if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
85            AC_MSG_RESULT(yes)
86            AC_DEFINE(LIBPWMD_API, [__global], [to make a symbol visible])
87            CFLAGS="$CFLAGS -xldscope=hidden"
88          else
89            AC_MSG_RESULT(no)
90          fi
91        fi
92        ;;
93   esac ],
94        AC_MSG_RESULT(no)
97 dnl Checks for header files.
98 AC_HEADER_STDC
99 AC_HEADER_SYS_WAIT
100 AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h unistd.h sys/socket.h \
101                   getopt.h])
103 dnl Checks for typedefs, structures, and compiler characteristics.
104 AC_C_CONST
105 AC_TYPE_SIZE_T
106 AC_STRUCT_TM
107 AC_TYPE_SSIZE_T
108 AC_TYPE_PID_T
110 ACX_PTHREAD(, AC_MSG_ERROR([Missing or incomplete pthread installation]))
111 PKG_PROG_PKG_CONFIG
113 AC_ARG_ENABLE(interactive, AC_HELP_STRING([--disable-interactive], [Disable interactive mode in pwmc.]),
114                 WITH_INTERACTIVE=no, WITH_INTERACTIVE=yes)
115 AC_MSG_CHECKING([if interactive mode is wanted])
116 AC_MSG_RESULT($WITH_INTERACTIVE)
117 if test "x$WITH_INTERACTIVE" = "xyes"; then
118     VL_LIB_READLINE
120     if test "x$vl_cv_lib_readline" != "xno"; then
121         READLINE_LIBS="$vl_cv_lib_readline"
122         AC_SUBST(READLINE_LIBS)
123     else
124         AC_MSG_ERROR([Missing or incomplete readline installation.])
125         WITH_INTERACTIVE="no"
126     fi
128 AM_CONDITIONAL([WITH_READLINE], [test x"$vl_cv_lib_readline" != "x"])
130 AM_PATH_LIBASSUAN([2.1.0], have_libassuan_2_1_0=yes)
131 if test x"$have_libassuan_2_1_0" != x"yes";then
132    AM_PATH_LIBASSUAN([2.0.3],, AC_MSG_ERROR([libassuan 2.0.3 or later required.]))
133 else
134    AC_DEFINE(LIBASSUAN_2_1_0, 1, [Define if you have libassuan 2.1.0 or later.])
136    
137 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([Missing or incomplete libgpg-error installation.]))
139 AC_ARG_ENABLE(ssh, AC_HELP_STRING([--enable-ssh], [Enable SSH support.]),
140                 WITH_SSH=$enableval, WITH_SSH=no)
141 AC_MSG_CHECKING([if ssh support is wanted])
142 AC_MSG_RESULT($WITH_SSH)
143 if test "x$WITH_SSH" = "xyes"; then
144     AC_MSG_CHECKING([for libssh2 availability])
145     PKG_CHECK_EXISTS([libssh2], have_libssh2=1)
146     WITH_SSH=no
148     if test $have_libssh2; then
149         PKG_CHECK_MODULES([libssh2], [libssh2 >= 1.2.9])
150         AC_DEFINE(WITH_SSH, 1, [Define if you want SSH support.])
151         WITH_SSH=yes
152     else
153         AC_MSG_ERROR([Missing or incomplete libssh2 installation.])
154     fi
156 AM_CONDITIONAL([WITH_SSH], [test "x$WITH_SSH" = "xyes"])
158 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls], 
159               [Enable GnuTLS client support.]), WITH_GNUTLS=$enableval,
160               WITH_GNUTLS=no)
161 AC_MSG_CHECKING([if gnutls support is wanted])
162 AC_MSG_RESULT($WITH_GNUTLS)
163 if test "x$WITH_GNUTLS" = "xyes"; then
164     AC_MSG_CHECKING([for libgnutls availability])
165     PKG_CHECK_EXISTS(gnutls, have_libgnutls=1, AC_MSG_ERROR([gnutls pkg-config module not found]))
166     WITH_GNUTLS=no
168     if test $have_libgnutls; then
169         PKG_CHECK_MODULES([GNUTLS], [gnutls])
170         AC_DEFINE(WITH_GNUTLS, 1, [Define if you want GnuTLS support.])
171         WITH_GNUTLS=yes
172     else
173         AC_MSG_ERROR([Missing or incomplete gnutls installation.])
174     fi
176 AM_CONDITIONAL(WITH_GNUTLS, [test "x$WITH_GNUTLS" = "xyes"])
178 # Default pwmd socket.
179 AC_ARG_WITH(pwmd_socket, AC_HELP_STRING([--with-pwmd-socket=PATH],
180               [Default pwmd socket (~/.pwmd/socket)]),
181               pwmd_socket="$withval", pwmd_socket=)
182 if test x"$pwmd_socket" != "x"; then
183    AC_DEFINE_UNQUOTED(DEFAULT_PWMD_SOCKET, ["$pwmd_socket"],
184                       [Default pwmd socket (~/.pwmd/socket).])
185 else
186    pwmd_socket="~/.pwmd/socket"
188 AC_SUBST(pwmd_socket)
190 dnl Checks for library functions.
191 AC_FUNC_MALLOC
192 AC_FUNC_REALLOC
193 AC_FUNC_STRFTIME
194 AC_FUNC_SELECT_ARGTYPES
195 AC_CHECK_FUNCS([memmove select socket strdup strerror setlocale getcwd \
196                 memset stpcpy strchr strrchr strtok_r getopt_long getpwuid_r])
197 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
199 AC_DEFUN([AC_MEM_DEBUG],
201     if test "$1"; then
202         ac_cv_sys_mem_debug=$1
203     fi
205     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
206         [ac_cv_sys_mem_debug=no])
207     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
210 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug],
211               [Enable memory debugging.]), AC_MEM_DEBUG([$enableval]),
212               AC_MEM_DEBUG)
214 AM_CONDITIONAL(MEM_DEBUG, test "x${ac_cv_sys_mem_debug}" != "xno")
216 AC_ARG_ENABLE(pinentry, AC_HELP_STRING([--disable-pinentry], 
217               [Disable pinentry(1) support (not pwmd).]), WITH_PINENTRY=no,
218               WITH_PINENTRY=yes)
220 if test "x$WITH_PINENTRY" != "xno"; then
221     AC_CHECK_HEADERS([locale.h])
222     AC_DEFINE(WITH_PINENTRY, 1, [Define if you want local pinentry(1) support.])
225 AM_CONDITIONAL([WITH_PINENTRY], [test "x$WITH_PINENTRY" = "xyes"])
226 pinentry="/usr/bin/pinentry"
228 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
229               [Default location of the pinentry binary (/usr/bin/pinentry)]),
230               pinentry="$withval")
232 AC_SUBST(pinentry)
233 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
234                    [Default location of the pinentry binary.])
236 # Cracklib support (requires pinentry support).
237 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
238               [Enable password quality checking with cracklib.]),
239               WITH_QUALITY=$enableval, WITH_QUALITY=no)
240 if test "x$WITH_QUALITY" = "xyes"; then
241     if test "x$WITH_PINENTRY" != "xyes"; then
242         AC_MSG_ERROR([--enable-quality needs --enable-pinentry])
243     fi
245     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
246     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
247     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
249 AM_CONDITIONAL(WITH_QUALITY, [test "x$WITH_QUALITY" = "xyes"])
251 crackdict="/var/cache/cracklib/cracklib_dict"
252 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
253               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
254               crackdict="$withval")
255 AC_SUBST(crackdict)
256 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
258 dnl Disable optimizing of memset(). GCC and CLang (and others?) accept
259 dnl multiple optimization flags and use the last one specified. The
260 dnl non-optimized memset() may still use any CPU features found in the
261 dnl user specified CFLAGS (-mtune) and libc.
262 CFLAGS_ORIG="$CFLAGS"
263 CFLAGS_MEMZERO="$CFLAGS -O0"
264 CFLAGS=
265 AC_SUBST(CFLAGS_ORIG)
266 AC_SUBST(CFLAGS_MEMZERO)
268 AC_CONFIG_FILES([Makefile libpwmd-7.0.pc doc/Makefile doc/doxygen.conf.in \
269                  doc/pwmc.1 src/Makefile src/libpwmd.h po/Makefile.in])
270 AC_OUTPUT
271 echo
272 echo "Features:"
273 echo "    Interactive pwmc: $WITH_INTERACTIVE"
274 echo "    Ssh: $WITH_SSH"
275 echo "    GnuTLS: $WITH_GNUTLS"
276 echo "    Local pinentry: $WITH_PINENTRY"
277 echo "    Pinentry location: $pinentry"
279 if test x"$pwmd_socket" != "x"; then
280 echo "    Default pwmd socket: $pwmd_socket"
281 else
282 echo "    Default pwmd socket: ~/.pwmd/socket"
285 echo "    Local passphrase quality checking: $WITH_QUALITY"
286 echo "    Crack dictionary: $crackdict"
287 echo "    Memory debug: ${ac_cv_sys_mem_debug}"