1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT(libpwmd, 8.2.1-dev, [Ben Kibbey bjk@luxsci.net])
4 AC_CONFIG_MACRO_DIR([m4])
5 AC_CONFIG_AUX_DIR(build)
7 AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip])
10 AC_USE_SYSTEM_EXTENSIONS
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/'`"
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\""
42 LDFLAGS="$LDFLAGS -flat_namespace -L/sw/lib"
43 CPPFLAGS="$CPPFLAGS -I/sw/include -L/sw/lib"
48 LDFLAGS="$LDFLAGS -lrt"
62 AM_CONDITIONAL([WITH_MINGW32], [test x"$is_mingw32" = "x1"])
64 dnl Checks for programs.
67 if test "$ac_cv_prog_cc_c99" = "no"; then
68 AC_MSG_ERROR("Unable to find a C99 compatible compiler.")
71 dnl Borrowed from libssh2!
72 dnl ************************************************************
73 dnl Enable hiding of internal symbols in library to reduce its size and
74 dnl speed dynamic linking of applications. This currently is only supported
75 dnl on gcc >= 4.0 and SunPro C.
77 AC_MSG_CHECKING([whether to enable hidden symbols in the library])
78 AC_ARG_ENABLE(hidden-symbols,
79 AC_HELP_STRING([--enable-hidden-symbols],[Hide internal symbols in library])
80 AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibility in library]),
81 [ case "$enableval" in
86 AC_MSG_CHECKING([whether $CC supports it])
87 if test "$GCC" = yes ; then
88 if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
90 AC_DEFINE(LIBPWMD_API, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
91 CFLAGS="$CFLAGS -fvisibility=hidden"
97 dnl Test for SunPro cc
98 if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
100 AC_DEFINE(LIBPWMD_API, [__global], [to make a symbol visible])
101 CFLAGS="$CFLAGS -xldscope=hidden"
111 dnl Checks for header files.
114 AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h unistd.h sys/socket.h \
117 dnl Checks for typedefs, structures, and compiler characteristics.
124 AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=2],
125 [CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"])
126 AX_PTHREAD(, AC_MSG_ERROR([POSIX threads are required.]))
127 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
128 LIBS="$PTHREAD_LIBS $LIBS"
131 acx_pthread_cancel_ok=no
132 AC_MSG_CHECKING([for pthread_cancel()])
133 AC_TRY_LINK_FUNC(pthread_cancel, acx_pthread_cancel_ok=yes)
134 AC_MSG_RESULT($acx_pthread_cancel_ok)
135 if test x"$acx_pthread_cancel_ok" = "xyes"; then
136 AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if your OS has pthread_cancel().])
139 AC_ARG_ENABLE(interactive, AC_HELP_STRING([--disable-interactive], [Disable interactive mode in pwmc.]),
140 WITH_INTERACTIVE=no, WITH_INTERACTIVE=yes)
141 AC_MSG_CHECKING([if interactive mode is wanted])
142 AC_MSG_RESULT($WITH_INTERACTIVE)
143 if test "x$WITH_INTERACTIVE" = "xyes"; then
146 if test "x$vl_cv_lib_readline" != "xno"; then
147 READLINE_LIBS="$vl_cv_lib_readline"
148 AC_SUBST(READLINE_LIBS)
150 LIBS="$READLINE_LIBS"
151 AC_TRY_LINK_FUNC([free_history_entry], [ac_cv_free_history_entry=yes])
153 if test "x$ac_cv_free_history_entry" = "xyes"; then
154 AC_DEFINE(HAVE_FREE_HISTORY_ENTRY, 1,
155 [Define if your libreadline has free_history_entry().])
158 AC_MSG_ERROR([Missing or incomplete readline installation.])
159 WITH_INTERACTIVE="no"
162 AM_CONDITIONAL([WITH_READLINE], [test x"$vl_cv_lib_readline" != "x"])
164 AM_PATH_LIBASSUAN([2.1.0], have_libassuan_2_1_0=yes)
165 if test x"$have_libassuan_2_1_0" != x"yes";then
166 AM_PATH_LIBASSUAN([2.0.3],, AC_MSG_ERROR([libassuan 2.0.3 or later required.]))
168 AC_DEFINE(LIBASSUAN_2_1_0, 1, [Define if you have libassuan 2.1.0 or later.])
171 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([Missing or incomplete libgpg-error installation.]))
173 AC_ARG_ENABLE(ssh, AC_HELP_STRING([--enable-ssh], [Enable SSH support.]),
174 WITH_SSH=$enableval, WITH_SSH=no)
175 AC_MSG_CHECKING([if ssh support is wanted])
176 AC_MSG_RESULT($WITH_SSH)
177 if test "x$WITH_SSH" = "xyes"; then
178 AC_MSG_CHECKING([for libssh2 availability])
179 PKG_CHECK_EXISTS([libssh2], have_libssh2=1)
182 if test $have_libssh2; then
183 PKG_CHECK_MODULES([libssh2], [libssh2 >= 1.2.9])
184 AC_DEFINE(WITH_SSH, 1, [Define if you want SSH support.])
187 AC_MSG_ERROR([Missing or incomplete libssh2 installation.])
190 AM_CONDITIONAL([WITH_SSH], [test "x$WITH_SSH" = "xyes"])
192 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls],
193 [Enable GnuTLS client support.]), WITH_GNUTLS=$enableval,
195 AC_MSG_CHECKING([if gnutls support is wanted])
196 AC_MSG_RESULT($WITH_GNUTLS)
197 if test "x$WITH_GNUTLS" = "xyes"; then
198 AC_MSG_CHECKING([for libgnutls availability])
199 PKG_CHECK_EXISTS(gnutls, have_libgnutls=1, AC_MSG_ERROR([gnutls pkg-config module not found]))
202 if test $have_libgnutls; then
203 PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3.0])
204 AC_DEFINE(WITH_GNUTLS, 1, [Define if you want GnuTLS support.])
207 AC_MSG_ERROR([Missing or incomplete gnutls installation.])
210 AM_CONDITIONAL(WITH_GNUTLS, [test "x$WITH_GNUTLS" = "xyes"])
212 # Default pwmd socket.
213 AC_ARG_WITH(pwmd_socket, AC_HELP_STRING([--with-pwmd-socket=PATH],
214 [Default pwmd socket (~/.pwmd/socket)]),
215 pwmd_socket="$withval", pwmd_socket=)
216 if test x"$pwmd_socket" != "x"; then
217 AC_DEFINE_UNQUOTED(DEFAULT_PWMD_SOCKET, ["$pwmd_socket"],
218 [Default pwmd socket (~/.pwmd/socket).])
220 pwmd_socket="~/.pwmd/socket"
222 AC_SUBST(pwmd_socket)
224 dnl Checks for library functions.
226 AC_FUNC_SELECT_ARGTYPES
227 AC_CHECK_FUNCS([memmove select socket strdup strerror setlocale getcwd \
228 memset stpcpy strchr strrchr strtok_r getopt_long getpwuid_r])
229 AC_REPLACE_FUNCS([strsep err])
230 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
232 AC_DEFUN([AC_MEM_DEBUG],
235 ac_cv_sys_mem_debug=$1
238 AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
239 [ac_cv_sys_mem_debug=no])
240 AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
243 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug],
244 [Enable memory debugging.]), AC_MEM_DEBUG([$enableval]),
247 AM_CONDITIONAL(MEM_DEBUG, test "x${ac_cv_sys_mem_debug}" != "xno")
249 AC_ARG_ENABLE(pinentry, AC_HELP_STRING([--disable-pinentry],
250 [Disable pinentry(1) support (not pwmd).]), WITH_PINENTRY=no,
253 if test "x$WITH_PINENTRY" != "xno"; then
254 AC_CHECK_HEADERS([locale.h])
255 AC_DEFINE(WITH_PINENTRY, 1, [Define if you want local pinentry(1) support.])
258 AM_CONDITIONAL([WITH_PINENTRY], [test "x$WITH_PINENTRY" = "xyes"])
259 pinentry="/usr/bin/pinentry"
261 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
262 [Default location of the pinentry binary (/usr/bin/pinentry)]),
266 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
267 [Default location of the pinentry binary.])
269 # Cracklib support (requires pinentry support).
270 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality],
271 [Enable password quality checking with built-in zxcvbn.]),
272 WITH_QUALITY=$enableval, WITH_QUALITY=no)
273 if test "x$WITH_QUALITY" = "xyes"; then
274 AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
276 AM_CONDITIONAL(WITH_QUALITY, [test "x$WITH_QUALITY" = "xyes"])
278 AC_CONFIG_FILES([Makefile libpwmd-8.0.pc doc/Makefile contrib/Makefile \
279 doc/doxygen.conf.in doc/pwmc.1 src/Makefile src/libpwmd.h \
284 echo " Interactive pwmc: $WITH_INTERACTIVE"
285 echo " Ssh: $WITH_SSH"
286 echo " GnuTLS: $WITH_GNUTLS"
287 echo " Local pinentry: $WITH_PINENTRY"
288 echo " Pinentry location: $pinentry"
290 if test x"$pwmd_socket" != "x"; then
291 echo " Default pwmd socket: $pwmd_socket"
293 echo " Default pwmd socket: ~/.pwmd/socket"
296 echo " Local passphrase quality checking: $WITH_QUALITY"
297 echo " Memory debug: ${ac_cv_sys_mem_debug}"