Created src/misc.[ch],ssh.[ch],pinentry.[ch].
[libpwmd.git] / configure.ac
blobba272b0e7b0c98cd097110faa91ebf9890c3c140
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
3 AC_INIT(libpwmd, 6.0.0-dev, [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)
24 case "$target_os" in
25     darwin*)
26         LDFLAGS="$LDFLAGS -flat_namespace -L/sw/lib"
27         CPPFLAGS="$CPPFLAGS -I/sw/include -L/sw/lib"
28         ;;
29     linux*)
30         case "$target_cpu" in
31             x86_64*)
32                 LDFLAGS="$LDFLAGS -lrt"
33                 ;;
34             *)
35                 ;;
36         esac
37         ;;
38     *)
39         ;;
40 esac
42 dnl Checks for programs.
43 AC_PROG_CC_C99
45 if test "$ac_cv_prog_cc_c99" = "no"; then
46     AC_MSG_ERROR("Unable to find a C99 compatible compiler.")
49 dnl Checks for header files.
50 AC_HEADER_STDC
51 AC_HEADER_SYS_WAIT
52 AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h unistd.h sys/socket.h \
53                   getopt.h])
55 dnl Checks for typedefs, structures, and compiler characteristics.
56 AC_C_CONST
57 AC_TYPE_SIZE_T
58 AC_STRUCT_TM
59 AC_TYPE_SSIZE_T
60 AC_TYPE_PID_T
62 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([Missing or incomplete libgpg-error installation.]))
63 AC_CHECK_PTH(, yes, yes, no, have_libpth=yes, have_libpth=no)
64 AM_CONDITIONAL([WITH_LIBPTH], [test "x$have_libpth" = "xyes"])
66 AC_ARG_ENABLE(ssh, AC_HELP_STRING([--disable-ssh], [Disable SSH support.]),
67                 WITH_TCP=no, WITH_TCP=yes)
69 if test "x$WITH_TCP" = "xyes"; then
70     AC_CHECK_LIB(ssh2, libssh2_session_init_ex,,
71                       AC_MSG_ERROR([Missing or incomplete libssh2 installation.]))
72     PKG_CHECK_MODULES(libcares, libcares,,
73                       AC_MSG_ERROR([Missing or incomplete libcares installation.]))
74     AC_DEFINE(WITH_TCP, 1, [Define if you want TCP support.])
76 AM_CONDITIONAL([WITH_TCP], [test "x$WITH_TCP" = "xyes"])
78 ACX_PTHREAD(, [Missing or incomplete pthread installation])
79 AC_SUBST(PTHREAD_LIBS)
80 AC_SUBST(PTHREAD_CFLAGS)
81 AC_SUBST(PTHREAD_CC)
83 dnl Checks for library functions.
84 AC_FUNC_MALLOC
85 AC_FUNC_REALLOC
86 AC_FUNC_STRFTIME
87 AC_FUNC_SELECT_ARGTYPES
88 AC_CHECK_FUNCS([memmove select socket strdup strerror setlocale getcwd \
89                 memset stpcpy strchr strrchr strtok_r getopt_long])
90 AM_CONDITIONAL([NEED_GETOPT_LONG], [test "$ac_cv_func_getopt_long" != "yes"])
92 AC_DEFUN([AC_MEM_DEBUG],
94     if test "$1"; then
95         ac_cv_sys_mem_debug=$1
96     fi
98     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
99         [ac_cv_sys_mem_debug=no])
100     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
103 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug],
104               [Enable memory debugging.]), AC_MEM_DEBUG([$enableval]),
105               AC_MEM_DEBUG)
107 AM_CONDITIONAL(MEM_DEBUG, test "x${ac_cv_sys_mem_debug}" != "xno")
109 AC_ARG_ENABLE(pinentry, AC_HELP_STRING([--disable-pinentry], 
110               [Disable pinentry(1) support (not pwmd).]), WITH_PINENTRY=no,
111               WITH_PINENTRY=yes)
113 if test "x$WITH_PINENTRY" != "xno"; then
114     AC_CHECK_HEADERS([locale.h])
115     AC_DEFINE(WITH_PINENTRY, 1, [Define if you want local pinentry(1) support.])
118 AM_CONDITIONAL([WITH_PINENTRY], [test "x$WITH_PINENTRY" = "xyes"])
119 pinentry="/usr/bin/pinentry"
121 AC_ARG_WITH(pinentry, AC_HELP_STRING([--with-pinentry=PATH],
122               [Default location of the pinentry binary (/usr/bin/pinentry)]),
123               pinentry="$withval")
125 AC_SUBST(pinentry)
126 AC_DEFINE_UNQUOTED(PINENTRY_PATH, ["$pinentry"],
127                    [Default location of the pinentry binary.])
129 AC_CONFIG_FILES([Makefile libpwmd.pc libpwmd-pth.pc doc/Makefile \
130                  doc/doxygen.conf.in doc/pwmc.1 src/Makefile \
131                  src/libpwmd.h po/Makefile.in])
132 AC_OUTPUT
133 echo
134 echo "Features:"
135 echo "    Memory debug: ${ac_cv_sys_mem_debug}"
136 echo "    Pinentry: $WITH_PINENTRY"
137 echo "    Pinentry location: $pinentry"
138 echo "    Ssh support: $WITH_TCP"
139 echo "    libpth support: $have_libpth"