Rework str_vasprintf().
[libpwmd.git] / configure.ac
blob595660cef5f768d6259d7ef658804b6ffa0d1910
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
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)
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=3
32 LIBTOOL_REV=0
33 LIBTOOL_AGE=2
34 AC_SUBST(LIBTOOL_CUR)
35 AC_SUBST(LIBTOOL_REV)
36 AC_SUBST(LIBTOOL_AGE)
38 is_mingw32=0
40 case "$target_os" in
41     darwin*)
42         LDFLAGS="$LDFLAGS -flat_namespace -L/sw/lib"
43         CPPFLAGS="$CPPFLAGS -I/sw/include -L/sw/lib"
44         ;;
45     linux*)
46         case "$target_cpu" in
47             x86_64*)
48                 LDFLAGS="$LDFLAGS -lrt"
49                 ;;
50             *)
51                 ;;
52         esac
53         ;;
54     mingw32*)
55         LT_INIT([win32-dll])
56         is_mingw32=1
57         ;;
58     *)
59         ;;
60 esac
62 AM_CONDITIONAL([WITH_MINGW32], [test x"$is_mingw32" = "x1"])
64 dnl Checks for programs.
65 AC_PROG_CC_C99
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.
76 dnl
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
82   no)
83        AC_MSG_RESULT(no)
84        ;;
85   *)
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
89            AC_MSG_RESULT(yes)
90            AC_DEFINE(LIBPWMD_API, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
91            CFLAGS="$CFLAGS -fvisibility=hidden"
92          else
93             AC_MSG_RESULT(no)
94           fi
96        else
97          dnl Test for SunPro cc
98          if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
99            AC_MSG_RESULT(yes)
100            AC_DEFINE(LIBPWMD_API, [__global], [to make a symbol visible])
101            CFLAGS="$CFLAGS -xldscope=hidden"
102          else
103            AC_MSG_RESULT(no)
104          fi
105        fi
106        ;;
107   esac ],
108        AC_MSG_RESULT(no)
111 dnl Checks for header files.
112 AC_HEADER_STDC
113 AC_HEADER_SYS_WAIT
114 AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h unistd.h sys/socket.h \
115                   getopt.h])
117 dnl Checks for typedefs, structures, and compiler characteristics.
118 AC_C_CONST
119 AC_TYPE_SIZE_T
120 AC_STRUCT_TM
121 AC_TYPE_SSIZE_T
122 AC_TYPE_PID_T
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"
129 PKG_PROG_PKG_CONFIG
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
144     VL_LIB_READLINE
146     if test "x$vl_cv_lib_readline" != "xno"; then
147         READLINE_LIBS="$vl_cv_lib_readline"
148         AC_SUBST(READLINE_LIBS)
149         ORIG_LIBS="$LIBS"
150         LIBS="$READLINE_LIBS"
151         AC_TRY_LINK_FUNC([free_history_entry], [ac_cv_free_history_entry=yes])
152         LIBS="$ORIG_LIBS"
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().])
156         fi
157     else
158         AC_MSG_ERROR([Missing or incomplete readline installation.])
159         WITH_INTERACTIVE="no"
160     fi
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.]))
167 else
168    AC_DEFINE(LIBASSUAN_2_1_0, 1, [Define if you have libassuan 2.1.0 or later.])
170    
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)
180     WITH_SSH=no
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.])
185         WITH_SSH=yes
186     else
187         AC_MSG_ERROR([Missing or incomplete libssh2 installation.])
188     fi
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,
194               WITH_GNUTLS=no)
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]))
200     WITH_GNUTLS=no
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.])
205         WITH_GNUTLS=yes
206     else
207         AC_MSG_ERROR([Missing or incomplete gnutls installation.])
208     fi
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).])
219 else
220    pwmd_socket="~/.pwmd/socket"
222 AC_SUBST(pwmd_socket)
224 dnl Checks for library functions.
225 AC_FUNC_STRFTIME
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],
234     if test "$1"; then
235         ac_cv_sys_mem_debug=$1
236     fi
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]),
245               AC_MEM_DEBUG)
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,
251               WITH_PINENTRY=yes)
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)]),
263               pinentry="$withval")
265 AC_SUBST(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 \
280                  po/Makefile.in])
281 AC_OUTPUT
282 echo
283 echo "Features:"
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"
292 else
293 echo "    Default pwmd socket: ~/.pwmd/socket"
296 echo "    Local passphrase quality checking: $WITH_QUALITY"
297 echo "    Memory debug: ${ac_cv_sys_mem_debug}"