clean up pam module
[pam_pcsc_cr.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 AC_INIT([pam_pcsc_cr], 0.0.1)
4 AC_CONFIG_SRCDIR([pam_pcsc_cr.c])
5 AC_CONFIG_MACRO_DIR([m4])
6 AM_INIT_AUTOMAKE
7 AM_CONFIG_HEADER([config.h])
8 AC_LANG_C
9 AC_PROG_CC
10
11 if test "X$CC" = "Xgcc"; then
12   CFLAGS="$CFLAGS -Wall"
13 fi
14
15 AC_PROG_MAKE_SET
16 AC_SUBST(PROGS)dnl
17 AC_SUBST(LIBPROGS)dnl
18 AC_PROG_INSTALL
19 AM_PROG_LIBTOOL
20 PKG_PROG_PKG_CONFIG
21
22 AC_CHECK_HEADERS([security/pam_appl.h], [], [
23   AC_MSG_ERROR([[PAM headers not found]])
24 ])
25 AC_CHECK_HEADERS([security/pam_modules.h security/pam_ext.h], [], [], [
26 #include <sys/types.h>
27 #include <security/pam_appl.h>
28 ])
29 AC_CHECK_LIB([pam], [pam_start])
30 AC_CHECK_FUNCS([pam_get_authtok])
31 AC_SUBST(PAMDIR, "/lib/security")
32 AC_ARG_WITH(pam-dir,
33         [  --with-pam-dir=DIR                path to install PAM module],
34         [PAMDIR="$withval"],
35         [])
36
37 PKG_CHECK_MODULES([PCSC], [libpcsclite])
38 AC_ARG_WITH(pcsclite-include-path,
39         [  --with-pcsclite-include-path=PATH path to pcsclite includes],
40         [PCSC_CFLAGS="-I $withval"],
41         [])
42 AC_ARG_WITH(pcsclite-lib-path,
43         [  --with-pcsclite-lib-path=PATH path to pcsclite libs],
44         [PCSC_LIBS="-L $withval -lpcsclite"],
45         [])
46
47 CPPFLAGS="$PCSC_CFLAGS $CPPFLAGS"
48 LIBS="$PCSC_LIBS $LIBS"
49
50 PKG_CHECK_MODULES([OPENSSL], [libcrypto], [], [:])
51 AC_ARG_WITH(openssl-include-path,
52         [  --with-openssl-include-path=PATH path to openssl includes],
53         [OPENSSL_CFLAGS="-I $withval"],
54         [])
55 AC_ARG_WITH(openssl-lib-path,
56         [  --with-openssl-lib-path=PATH path to openssl libs],
57         [OPENSSL_LIBS="-L $withval -lcrypto"],
58         [])
59 AS_IF([test "x$OPENSSL_CFLAGS" != "x" -o "x$OPENSSL_LIBS" != "x" ], [
60   use_openssl=yes
61 ])
62 CPPFLAGS="$OPENSSL_CFLAGS $CPPFLAGS"
63 LIBS="$OPENSSL_LIBS $LIBS"
64
65 AC_ARG_ENABLE(tomcrypt,
66         [  --enable-tomcrypt       use libtomcrypt even when openssl present])
67
68 AS_IF([test "x$use_openssl" != "xyes" -o "x$enable_tomcrypt" = "xyes"], [
69   PKG_CHECK_MODULES([TOMCRYPT], [libtomcrypt], [], [:])
70 ])
71 AC_ARG_WITH(libtomcrypt-include-path,
72         [  --with-libtomcrypt-include-path=PATH path to libtomcrypt includes],
73         [TOMCRYPT_CFLAGS="-I $withval"],
74         [])
75 AC_ARG_WITH(libtomcrypt-lib-path,
76         [  --with-libtomcrypt-lib-path=PATH path to libtomcrypt libs],
77         [TOMCRYPT_LIBS="-L $withval -ltomcrypt"],
78         [])
79 AS_IF([test "x$TOMCRYPT_CFLAGS" != "x" -o "x$TOMCRYPT_LIBS" != "x" ], [
80   use_tomcrypt=yes
81 ])
82 CPPFLAGS="$TOMCRYPT_CFLAGS $CPPFLAGS"
83 LIBS="$TOMCRYPT_LIBS $LIBS"
84
85 AC_ARG_ENABLE(gcrypt,
86         [  --enable-gcrypt         use libgcrypt even when openssl present])
87
88 AS_IF([test "x$use_openssl" != "xyes" && test "x$use_tomcrypt" != "xyes" || \
89         test "x$enable_tomcrypt" = "xyes"], [
90   AM_PATH_LIBGCRYPT()
91 ])
92 AC_ARG_WITH(libgcrypt-include-path,
93         [  --with-libgcrypt-include-path=PATH path to libgcrypt includes],
94         [LIBGCRYPT_CFLAGS="-I $withval"],
95         [])
96 AC_ARG_WITH(libgcrypt-lib-path,
97         [  --with-libgcrypt-lib-path=PATH path to libgcrypt libs],
98         [LIBGCRYPT_LIBS="-L $withval -lgcrypt"],
99         [])
100 AS_IF([test "x$LIBGCRYPT_CFLAGS" != "x" -o "x$LIBGCRYPT_LIBS" != "x" ], [
101   use_gcrypt=yes
102 ])
103 CPPFLAGS="$LIBGCRYPT_CFLAGS $CPPFLAGS"
104 LIBS="$LIBGCRYPT_LIBS $LIBS"
105
106 AS_IF([test "x$use_openssl" != "xyes" -a "x$use_tomcrypt" != "xyes" -a "x$use_gcrypt" != "xyes"], [
107   AC_MSG_ERROR([[Neither openssl, tomcrypt or gcrypt libraries present]])
108 ])
109
110 AS_IF([test "x$use_openssl" = "xyes"], [
111   CRYPTO_OBJS+=" ossl_crypto.lo"
112   AC_DEFINE([HAVE_OPENSSL], [1], [Use openssl libcrypto])
113 ])
114 AS_IF([test "x$use_tomcrypt" = "xyes"], [
115   CRYPTO_OBJS+=" tom_crypto.lo"
116   AC_DEFINE([HAVE_TOMCRYPT], [1], [Use libtomcrypt])
117 ])
118 AS_IF([test "x$use_gcrypt" = "xyes"], [
119   CRYPTO_OBJS+=" gnu_crypto.lo"
120   AC_DEFINE([HAVE_GCRYPT], [1], [Use libgcrypt])
121 ])
122 AC_SUBST(CRYPTO_OBJS)
123
124 dnl Checks for header files.
125 AC_HEADER_STDC
126 AC_HEADER_TIME
127
128 AC_CHECK_HEADERS([winscard.h reader.h], [],
129   [AC_MSG_ERROR([[pcsclite headers not found]])])
130 AC_CHECK_LIB([pcsclite], [SCardEstablishContext], [],
131   [AC_MSG_ERROR([[pcsclite library not useable]])])
132
133 AC_CONFIG_FILES([Makefile])
134 AC_OUTPUT