Initialize libssh2. Now requires libssh2 1.2.5 or later.
[libpwmd.git] / configure.ac
blob2b7de017cf0d23f80b64f2bd450fdca89ed005e2
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
3 AC_INIT(libpwmd, 6.0.2, [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_DISABLE_SHARED
9 AC_USE_SYSTEM_EXTENSIONS
10 AC_PROG_LIBTOOL
11 AC_CONFIG_SRCDIR([src/libpwmd.c])
12 AM_CONFIG_HEADER([config.h])
13 AM_GNU_GETTEXT([external])
14 AM_GNU_GETTEXT_VERSION([0.16.1])
15 AC_CONFIG_SUBDIRS([assuan])
17 VER_MAJOR="`echo "$VERSION" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`"
18 VER_COMPAT="`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_COMPAT)
22 AC_SUBST(VER_PATCH)
23 VER_STRING="\"$VER_MAJOR.$VER_COMPAT.$VER_PATCH\""
24 AC_SUBST(VER_STRING)
26 case "$target_os" in
27     darwin*)
28         LDFLAGS="$LDFLAGS -flat_namespace -L/sw/lib"
29         CPPFLAGS="$CPPFLAGS -I/sw/include -L/sw/lib"
30         ;;
31     linux*)
32         case "$target_cpu" in
33             x86_64*)
34                 LDFLAGS="$LDFLAGS -lrt"
35                 ;;
36             *)
37                 ;;
38         esac
39         ;;
40     *)
41         ;;
42 esac
44 dnl Checks for programs.
45 AC_PROG_CC_C99
47 if test "$ac_cv_prog_cc_c99" = "no"; then
48     AC_MSG_ERROR("Unable to find a C99 compatible compiler.")
51 dnl Borrowed from libssh2!
52 dnl ************************************************************
53 dnl Enable hiding of internal symbols in library to reduce its size and
54 dnl speed dynamic linking of applications.  This currently is only supported
55 dnl on gcc >= 4.0 and SunPro C.
56 dnl
57 AC_MSG_CHECKING([whether to enable hidden symbols in the library])
58 AC_ARG_ENABLE(hidden-symbols,
59 AC_HELP_STRING([--enable-hidden-symbols],[Hide internal symbols in library])
60 AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibility in library]),
61 [ case "$enableval" in
62   no)
63        AC_MSG_RESULT(no)
64        ;;
65   *)
66        AC_MSG_CHECKING([whether $CC supports it])
67        if test "$GCC" = yes ; then
68          if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
69            AC_MSG_RESULT(yes)
70            AC_DEFINE(LIBPWMD_API, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
71            CFLAGS="$CFLAGS -fvisibility=hidden"
72          else
73             AC_MSG_RESULT(no)
74           fi
76        else
77          dnl Test for SunPro cc
78          if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
79            AC_MSG_RESULT(yes)
80            AC_DEFINE(LIBPWMD_API, [__global], [to make a symbol visible])
81            CFLAGS="$CFLAGS -xldscope=hidden"
82          else
83            AC_MSG_RESULT(no)
84          fi
85        fi
86        ;;
87   esac ],
88        AC_MSG_RESULT(no)
91 dnl Checks for header files.
92 AC_HEADER_STDC
93 AC_HEADER_SYS_WAIT
94 AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h unistd.h sys/socket.h \
95                   getopt.h])
97 dnl Checks for typedefs, structures, and compiler characteristics.
98 AC_C_CONST
99 AC_TYPE_SIZE_T
100 AC_STRUCT_TM
101 AC_TYPE_SSIZE_T
102 AC_TYPE_PID_T
104 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([Missing or incomplete libgpg-error installation.]))
105 AC_CHECK_PTH(, no, yes, no, have_libpth=yes, have_libpth=no)
106 AM_CONDITIONAL([WITH_LIBPTH], [test "x$have_libpth" = "xyes"])
108 AC_ARG_ENABLE(ssh, AC_HELP_STRING([--disable-ssh], [Disable SSH support.]),
109                 WITH_TCP=no, WITH_TCP=yes)
111 if test "x$WITH_TCP" = "xyes"; then
112     AC_CHECK_LIB(ssh2, libssh2_session_init_ex,,
113                       AC_MSG_ERROR([Missing or incomplete libssh2 installation.]))
114     AC_CHECK_HEADER([libssh2.h],,
115                       AC_MSG_ERROR([Missing or incomplete libssh2 installation.]))
116     AC_RUN_IFELSE([AC_LANG_PROGRAM([[
117                     #include <libssh2.h>]], [[
118                         if (LIBSSH2_VERSION_NUM < 0x010205)
119                             return 1;
120                     ]])],, AC_MSG_ERROR([Need libssh2 version 1.2.5 or later.]))
121     PKG_CHECK_MODULES(libcares, libcares,,
122                       AC_MSG_ERROR([Missing or incomplete libcares installation.]))
123     AC_DEFINE(WITH_TCP, 1, [Define if you want TCP support.])
125 AM_CONDITIONAL([WITH_TCP], [test "x$WITH_TCP" = "xyes"])
127 ACX_PTHREAD(, AC_MSG_ERROR([Missing or incomplete pthread installation]))
128 AC_SUBST(PTHREAD_LIBS)
129 AC_SUBST(PTHREAD_CFLAGS)
130 AC_SUBST(PTHREAD_CC)
132 dnl Checks for library functions.
133 AC_FUNC_MALLOC
134 AC_FUNC_REALLOC
135 AC_FUNC_STRFTIME
136 AC_FUNC_SELECT_ARGTYPES
137 AC_CHECK_FUNCS([memmove select socket strdup strerror setlocale getcwd \
138                 memset stpcpy strchr strrchr strtok_r getopt_long])
139 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
141 AC_DEFUN([AC_MEM_DEBUG],
143     if test "$1"; then
144         ac_cv_sys_mem_debug=$1
145     fi
147     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
148         [ac_cv_sys_mem_debug=no])
149     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
152 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug],
153               [Enable memory debugging.]), AC_MEM_DEBUG([$enableval]),
154               AC_MEM_DEBUG)
156 AM_CONDITIONAL(MEM_DEBUG, test "x${ac_cv_sys_mem_debug}" != "xno")
158 AC_ARG_ENABLE(pinentry, AC_HELP_STRING([--disable-pinentry], 
159               [Disable pinentry(1) support (not pwmd).]), WITH_PINENTRY=no,
160               WITH_PINENTRY=yes)
162 if test "x$WITH_PINENTRY" != "xno"; then
163     AC_CHECK_HEADERS([locale.h])
164     AC_DEFINE(WITH_PINENTRY, 1, [Define if you want local pinentry(1) support.])
167 AM_CONDITIONAL([WITH_PINENTRY], [test "x$WITH_PINENTRY" = "xyes"])
168 pinentry="/usr/bin/pinentry"
170 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
171               [Default location of the pinentry binary (/usr/bin/pinentry)]),
172               pinentry="$withval")
174 AC_SUBST(pinentry)
175 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
176                    [Default location of the pinentry binary.])
178 # Cracklib support (requires pinentry support).
179 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
180               [Enable password quality checking with cracklib.]),
181               WITH_QUALITY=$enableval, WITH_QUALITY=no)
182 if test "x$WITH_QUALITY" = "xyes"; then
183     if test "x$WITH_PINENTRY" != "xyes"; then
184         AC_MSG_ERROR([--enable-quality needs --enable-pinentry])
185     fi
187     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
188     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
189     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
191 AM_CONDITIONAL(WITH_QUALITY, [test "x$WITH_QUALITY" = "xyes"])
193 crackdict="/var/cache/cracklib/cracklib_dict"
194 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
195               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
196               crackdict="$withval")
197 AC_SUBST(crackdict)
198 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
200 AC_CONFIG_FILES([Makefile libpwmd.pc libpwmd-pth.pc doc/Makefile \
201                  doc/doxygen.conf.in doc/pwmc.1 src/Makefile \
202                  src/libpwmd.h po/Makefile.in])
203 AC_OUTPUT
204 echo
205 echo "Features:"
206 echo "    Memory debug: ${ac_cv_sys_mem_debug}"
207 echo "    Pinentry: $WITH_PINENTRY"
208 echo "    Pinentry location: $pinentry"
209 echo "    Cracklib: $WITH_QUALITY"
210 echo "    Cracklib dictionary: $crackdict"
211 echo "    Ssh support: $WITH_TCP"
212 echo "    libpth support: $have_libpth"