Fix GENKEY inquire keyword to trigger NEW_PASSPHRASE.
[libpwmd.git] / configure.ac
blobfe1245518f69201cb9f8b008618b46f310e444e3
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
3 AC_INIT(libpwmd, 7.3.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)
31 LIBTOOL_CUR=1
32 LIBTOOL_REV=0
33 LIBTOOL_AGE=1
34 AC_SUBST(LIBTOOL_CUR)
35 AC_SUBST(LIBTOOL_REV)
36 AC_SUBST(LIBTOOL_AGE)
38 case "$target_os" in
39     darwin*)
40         LDFLAGS="$LDFLAGS -flat_namespace -L/sw/lib"
41         CPPFLAGS="$CPPFLAGS -I/sw/include -L/sw/lib"
42         ;;
43     linux*)
44         case "$target_cpu" in
45             x86_64*)
46                 LDFLAGS="$LDFLAGS -lrt"
47                 ;;
48             *)
49                 ;;
50         esac
51         ;;
52     *)
53         ;;
54 esac
56 dnl Checks for programs.
57 AC_PROG_CC_C99
59 if test "$ac_cv_prog_cc_c99" = "no"; then
60     AC_MSG_ERROR("Unable to find a C99 compatible compiler.")
63 dnl Borrowed from libssh2!
64 dnl ************************************************************
65 dnl Enable hiding of internal symbols in library to reduce its size and
66 dnl speed dynamic linking of applications.  This currently is only supported
67 dnl on gcc >= 4.0 and SunPro C.
68 dnl
69 AC_MSG_CHECKING([whether to enable hidden symbols in the library])
70 AC_ARG_ENABLE(hidden-symbols,
71 AC_HELP_STRING([--enable-hidden-symbols],[Hide internal symbols in library])
72 AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibility in library]),
73 [ case "$enableval" in
74   no)
75        AC_MSG_RESULT(no)
76        ;;
77   *)
78        AC_MSG_CHECKING([whether $CC supports it])
79        if test "$GCC" = yes ; then
80          if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
81            AC_MSG_RESULT(yes)
82            AC_DEFINE(LIBPWMD_API, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
83            CFLAGS="$CFLAGS -fvisibility=hidden"
84          else
85             AC_MSG_RESULT(no)
86           fi
88        else
89          dnl Test for SunPro cc
90          if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
91            AC_MSG_RESULT(yes)
92            AC_DEFINE(LIBPWMD_API, [__global], [to make a symbol visible])
93            CFLAGS="$CFLAGS -xldscope=hidden"
94          else
95            AC_MSG_RESULT(no)
96          fi
97        fi
98        ;;
99   esac ],
100        AC_MSG_RESULT(no)
103 dnl Checks for header files.
104 AC_HEADER_STDC
105 AC_HEADER_SYS_WAIT
106 AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h unistd.h sys/socket.h \
107                   getopt.h])
109 dnl Checks for typedefs, structures, and compiler characteristics.
110 AC_C_CONST
111 AC_TYPE_SIZE_T
112 AC_STRUCT_TM
113 AC_TYPE_SSIZE_T
114 AC_TYPE_PID_T
116 AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=2],
117                       [CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"])
118 ACX_PTHREAD(, AC_MSG_ERROR([Missing or incomplete pthread installation]))
119 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
120 LIBS="$PTHREAD_LIBS $LIBS"
121 PKG_PROG_PKG_CONFIG
123 AC_ARG_ENABLE(interactive, AC_HELP_STRING([--disable-interactive], [Disable interactive mode in pwmc.]),
124                 WITH_INTERACTIVE=no, WITH_INTERACTIVE=yes)
125 AC_MSG_CHECKING([if interactive mode is wanted])
126 AC_MSG_RESULT($WITH_INTERACTIVE)
127 if test "x$WITH_INTERACTIVE" = "xyes"; then
128     VL_LIB_READLINE
130     if test "x$vl_cv_lib_readline" != "xno"; then
131         READLINE_LIBS="$vl_cv_lib_readline"
132         AC_SUBST(READLINE_LIBS)
133     else
134         AC_MSG_ERROR([Missing or incomplete readline installation.])
135         WITH_INTERACTIVE="no"
136     fi
138 AM_CONDITIONAL([WITH_READLINE], [test x"$vl_cv_lib_readline" != "x"])
140 AM_PATH_LIBASSUAN([2.1.0], have_libassuan_2_1_0=yes)
141 if test x"$have_libassuan_2_1_0" != x"yes";then
142    AM_PATH_LIBASSUAN([2.0.3],, AC_MSG_ERROR([libassuan 2.0.3 or later required.]))
143 else
144    AC_DEFINE(LIBASSUAN_2_1_0, 1, [Define if you have libassuan 2.1.0 or later.])
146    
147 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([Missing or incomplete libgpg-error installation.]))
149 AC_ARG_ENABLE(ssh, AC_HELP_STRING([--enable-ssh], [Enable SSH support.]),
150                 WITH_SSH=$enableval, WITH_SSH=no)
151 AC_MSG_CHECKING([if ssh support is wanted])
152 AC_MSG_RESULT($WITH_SSH)
153 if test "x$WITH_SSH" = "xyes"; then
154     AC_MSG_CHECKING([for libssh2 availability])
155     PKG_CHECK_EXISTS([libssh2], have_libssh2=1)
156     WITH_SSH=no
158     if test $have_libssh2; then
159         PKG_CHECK_MODULES([libssh2], [libssh2 >= 1.2.9])
160         AC_DEFINE(WITH_SSH, 1, [Define if you want SSH support.])
161         WITH_SSH=yes
162     else
163         AC_MSG_ERROR([Missing or incomplete libssh2 installation.])
164     fi
166 AM_CONDITIONAL([WITH_SSH], [test "x$WITH_SSH" = "xyes"])
168 AC_ARG_ENABLE(gnutls, AC_HELP_STRING([--enable-gnutls], 
169               [Enable GnuTLS client support.]), WITH_GNUTLS=$enableval,
170               WITH_GNUTLS=no)
171 AC_MSG_CHECKING([if gnutls support is wanted])
172 AC_MSG_RESULT($WITH_GNUTLS)
173 if test "x$WITH_GNUTLS" = "xyes"; then
174     AC_MSG_CHECKING([for libgnutls availability])
175     PKG_CHECK_EXISTS(gnutls, have_libgnutls=1, AC_MSG_ERROR([gnutls pkg-config module not found]))
176     WITH_GNUTLS=no
178     if test $have_libgnutls; then
179         PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3.0])
180         AC_DEFINE(WITH_GNUTLS, 1, [Define if you want GnuTLS support.])
181         WITH_GNUTLS=yes
182     else
183         AC_MSG_ERROR([Missing or incomplete gnutls installation.])
184     fi
186 AM_CONDITIONAL(WITH_GNUTLS, [test "x$WITH_GNUTLS" = "xyes"])
188 # Default pwmd socket.
189 AC_ARG_WITH(pwmd_socket, AC_HELP_STRING([--with-pwmd-socket=PATH],
190               [Default pwmd socket (~/.pwmd/socket)]),
191               pwmd_socket="$withval", pwmd_socket=)
192 if test x"$pwmd_socket" != "x"; then
193    AC_DEFINE_UNQUOTED(DEFAULT_PWMD_SOCKET, ["$pwmd_socket"],
194                       [Default pwmd socket (~/.pwmd/socket).])
195 else
196    pwmd_socket="~/.pwmd/socket"
198 AC_SUBST(pwmd_socket)
200 dnl Checks for library functions.
201 AC_FUNC_MALLOC
202 AC_FUNC_REALLOC
203 AC_FUNC_STRFTIME
204 AC_FUNC_SELECT_ARGTYPES
205 AC_CHECK_FUNCS([memmove select socket strdup strerror setlocale getcwd \
206                 memset stpcpy strchr strrchr strtok_r getopt_long getpwuid_r])
207 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
209 AC_DEFUN([AC_MEM_DEBUG],
211     if test "$1"; then
212         ac_cv_sys_mem_debug=$1
213     fi
215     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
216         [ac_cv_sys_mem_debug=no])
217     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
220 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug],
221               [Enable memory debugging.]), AC_MEM_DEBUG([$enableval]),
222               AC_MEM_DEBUG)
224 AM_CONDITIONAL(MEM_DEBUG, test "x${ac_cv_sys_mem_debug}" != "xno")
226 AC_ARG_ENABLE(pinentry, AC_HELP_STRING([--disable-pinentry], 
227               [Disable pinentry(1) support (not pwmd).]), WITH_PINENTRY=no,
228               WITH_PINENTRY=yes)
230 if test "x$WITH_PINENTRY" != "xno"; then
231     AC_CHECK_HEADERS([locale.h])
232     AC_DEFINE(WITH_PINENTRY, 1, [Define if you want local pinentry(1) support.])
235 AM_CONDITIONAL([WITH_PINENTRY], [test "x$WITH_PINENTRY" = "xyes"])
236 pinentry="/usr/bin/pinentry"
238 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
239               [Default location of the pinentry binary (/usr/bin/pinentry)]),
240               pinentry="$withval")
242 AC_SUBST(pinentry)
243 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
244                    [Default location of the pinentry binary.])
246 # Cracklib support (requires pinentry support).
247 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
248               [Enable password quality checking with cracklib.]),
249               WITH_QUALITY=$enableval, WITH_QUALITY=no)
250 if test "x$WITH_QUALITY" = "xyes"; then
251     if test "x$WITH_PINENTRY" != "xyes"; then
252         AC_MSG_ERROR([--enable-quality needs --enable-pinentry])
253     fi
255     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
256     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
257     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
259 AM_CONDITIONAL(WITH_QUALITY, [test "x$WITH_QUALITY" = "xyes"])
261 crackdict="/var/cache/cracklib/cracklib_dict"
262 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
263               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
264               crackdict="$withval")
265 AC_SUBST(crackdict)
266 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
268 dnl Disable optimizing of memset(). GCC and CLang (and others?) accept
269 dnl multiple optimization flags and use the last one specified. The
270 dnl non-optimized memset() may still use any CPU features found in the
271 dnl user specified CFLAGS (-mtune) and libc.
272 CFLAGS_ORIG="$CFLAGS"
273 CFLAGS_MEMZERO="$CFLAGS -O0"
274 CFLAGS=
275 AC_SUBST(CFLAGS_ORIG)
276 AC_SUBST(CFLAGS_MEMZERO)
278 AC_CONFIG_FILES([Makefile libpwmd-7.0.pc doc/Makefile doc/doxygen.conf.in \
279                  doc/pwmc.1 src/Makefile src/libpwmd.h po/Makefile.in])
280 AC_OUTPUT
281 echo
282 echo "Features:"
283 echo "    Interactive pwmc: $WITH_INTERACTIVE"
284 echo "    Ssh: $WITH_SSH"
285 echo "    GnuTLS: $WITH_GNUTLS"
286 echo "    Local pinentry: $WITH_PINENTRY"
287 echo "    Pinentry location: $pinentry"
289 if test x"$pwmd_socket" != "x"; then
290 echo "    Default pwmd socket: $pwmd_socket"
291 else
292 echo "    Default pwmd socket: ~/.pwmd/socket"
295 echo "    Local passphrase quality checking: $WITH_QUALITY"
296 echo "    Crack dictionary: $crackdict"
297 echo "    Memory debug: ${ac_cv_sys_mem_debug}"