Fixed 'make install' to not create the pkgconfig directory if it already
[libpwmd.git] / configure.ac
blob3d61b3d11e636b06ee08657f673c669b96bff442
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
3 AC_INIT(libpwmd, 7.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_STRING="\"$VERSION\""
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 ACX_PTHREAD(, AC_MSG_ERROR([Missing or incomplete pthread installation]))
105 VL_LIB_READLINE
107 if test "x$vl_cv_lib_readline" != "xno"; then
108     READLINE_LIBS="$vl_cv_lib_readline"
109     AC_SUBST(READLINE_LIBS)
111 AM_CONDITIONAL([WITH_READLINE], [test "x$vl_cv_lib_readline" != "xno"])
113 AM_PATH_LIBASSUAN([2.0.0],, AC_MSG_ERROR([libassuan not found]))
114 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([Missing or incomplete libgpg-error installation.]))
116 AC_ARG_ENABLE(ssh, AC_HELP_STRING([--disable-ssh], [Disable SSH support.]),
117                 WITH_TCP=no, WITH_TCP=yes)
119 AC_MSG_CHECKING([if ssh support is wanted])
120 AC_MSG_RESULT($WITH_TCP)
122 if test "x$WITH_TCP" = "xyes"; then
123     AC_MSG_CHECKING([for libssh2 availability])
124     PKG_CHECK_EXISTS([libssh2], have_libssh2=1)
125     WITH_TCP=no
127     if test $have_libssh2; then
128         PKG_CHECK_MODULES([libssh2], [libssh2 >= 1.2.8])
129         AC_DEFINE(WITH_TCP, 1, [Define if you want TCP support.])
130         WITH_TCP=yes
131     fi
133 AM_CONDITIONAL([WITH_TCP], [test "x$WITH_TCP" = "xyes"])
135 dnl Checks for library functions.
136 AC_FUNC_MALLOC
137 AC_FUNC_REALLOC
138 AC_FUNC_STRFTIME
139 AC_FUNC_SELECT_ARGTYPES
140 AC_CHECK_FUNCS([memmove select socket strdup strerror setlocale getcwd \
141                 memset stpcpy strchr strrchr strtok_r getopt_long])
142 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
144 AC_DEFUN([AC_MEM_DEBUG],
146     if test "$1"; then
147         ac_cv_sys_mem_debug=$1
148     fi
150     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
151         [ac_cv_sys_mem_debug=no])
152     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
155 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug],
156               [Enable memory debugging.]), AC_MEM_DEBUG([$enableval]),
157               AC_MEM_DEBUG)
159 AM_CONDITIONAL(MEM_DEBUG, test "x${ac_cv_sys_mem_debug}" != "xno")
161 AC_ARG_ENABLE(pinentry, AC_HELP_STRING([--disable-pinentry], 
162               [Disable pinentry(1) support (not pwmd).]), WITH_PINENTRY=no,
163               WITH_PINENTRY=yes)
165 if test "x$WITH_PINENTRY" != "xno"; then
166     AC_CHECK_HEADERS([locale.h])
167     AC_DEFINE(WITH_PINENTRY, 1, [Define if you want local pinentry(1) support.])
170 AM_CONDITIONAL([WITH_PINENTRY], [test "x$WITH_PINENTRY" = "xyes"])
171 pinentry="/usr/bin/pinentry"
173 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
174               [Default location of the pinentry binary (/usr/bin/pinentry)]),
175               pinentry="$withval")
177 AC_SUBST(pinentry)
178 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
179                    [Default location of the pinentry binary.])
181 # Cracklib support (requires pinentry support).
182 AC_ARG_ENABLE(quality, AC_HELP_STRING([--enable-quality], 
183               [Enable password quality checking with cracklib.]),
184               WITH_QUALITY=$enableval, WITH_QUALITY=no)
185 if test "x$WITH_QUALITY" = "xyes"; then
186     if test "x$WITH_PINENTRY" != "xyes"; then
187         AC_MSG_ERROR([--enable-quality needs --enable-pinentry])
188     fi
190     AC_CHECK_HEADER([crack.h],, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
191     AC_CHECK_LIB([crack], FascistCheck,, AC_MSG_ERROR([Missing or invalid cracklib installation.]))
192     AC_DEFINE(WITH_QUALITY, 1, [Define if you want password quality checking.])
194 AM_CONDITIONAL(WITH_QUALITY, [test "x$WITH_QUALITY" = "xyes"])
196 crackdict="/var/cache/cracklib/cracklib_dict"
197 AC_ARG_WITH(crackdict, AC_HELP_STRING([--with-crack-dict=PATH],
198               [Location of the cracklib dictionary (/var/cache/cracklib/cracklib_dict).]),
199               crackdict="$withval")
200 AC_SUBST(crackdict)
201 AC_DEFINE_UNQUOTED(CRACKLIB_DICT, ["$crackdict"], [The location of the cracklib dictionary.])
203 AC_CONFIG_FILES([Makefile libpwmd-7.0.pc doc/Makefile doc/doxygen.conf.in \
204                  doc/pwmc.1 src/Makefile src/libpwmd.h po/Makefile.in])
205 AC_OUTPUT
206 echo
207 echo "Features:"
208 echo "    Memory debug: ${ac_cv_sys_mem_debug}"
209 echo "    Pinentry: $WITH_PINENTRY"
210 echo "    Pinentry location: $pinentry"
211 echo "    Cracklib: $WITH_QUALITY"
212 echo "    Cracklib dictionary: $crackdict"
213 echo "    Ssh support: $WITH_TCP"
214 echo "    Interactive pwmc: ${vl_cv_lib_readline}"