autotools tuning
[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 -g"
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 PKG_CHECK_MODULES([PCSC], [libpcsclite])
23 AC_ARG_WITH(pcsclite-include-path,
24         [  --with-pcsclite-include-path=PATH path to pcsclite includes],
25         [PCSC_CFLAGS="-I $withval"],
26         [])
27 AC_ARG_WITH(pcsclite-lib-path,
28         [  --with-pcsclite-lib-path=PATH path to pcsclite libs],
29         [PCSC_LIBS="-L $withval -lpcsclite"],
30         [])
31
32 CPPFLAGS="$PCSC_CFLAGS $CPPFLAGS"
33 LIBS="$PCSC_LIBS $LIBS"
34
35 PKG_CHECK_MODULES([OPENSSL], [libcrypto], [], [:])
36 AC_ARG_WITH(openssl-include-path,
37         [  --with-openssl-include-path=PATH path to openssl includes],
38         [OPENSSL_CFLAGS="-I $withval"],
39         [])
40 AC_ARG_WITH(openssl-lib-path,
41         [  --with-openssl-lib-path=PATH path to openssl libs],
42         [OPENSSL_LIBS="-L $withval -lcrypto"],
43         [])
44 AS_IF([test "x$OPENSSL_CFLAGS" != "x" -o "x$OPENSSL_LIBS" != "x" ], [
45   use_openssl=yes
46 ])
47 CPPFLAGS="$OPENSSL_CFLAGS $CPPFLAGS"
48 LIBS="$OPENSSL_LIBS $LIBS"
49
50 AS_IF([test "x$use_openssl" != "xyes"], [
51   PKG_CHECK_MODULES([TOMCRYPT], [libtomcrypt], [], [:])
52 ])
53 AC_ARG_WITH(libtomcrypt-include-path,
54         [  --with-libtomcrypt-include-path=PATH path to libtomcrypt includes],
55         [TOMCRYPT_CFLAGS="-I $withval"],
56         [])
57 AC_ARG_WITH(libtomcrypt-lib-path,
58         [  --with-libtomcrypt-lib-path=PATH path to libtomcrypt libs],
59         [TOMCRYPT_LIBS="-L $withval -ltomcrypt"],
60         [])
61 AS_IF([test "x$TOMCRYPT_CFLAGS" != "x" -o "x$TOMCRYPT_LIBS" != "x" ], [
62   use_tomcrypt=yes
63 ])
64 CPPFLAGS="$TOMCRYPT_CFLAGS $CPPFLAGS"
65 LIBS="$TOMCRYPT_LIBS $LIBS"
66
67 AS_IF([test "x$use_openssl" != "xyes" -a "x$use_tomcrypt" != "xyes"], [
68   AC_MSG_ERROR([[Neither openssl nor tomcrypt libraries present]])
69 ])
70
71 AS_IF([test "x$use_openssl" = "xyes"], [
72   CRYPTO_OBJS+=ossl_crypto.lo
73 ])
74 AS_IF([test "x$use_tomcrypt" = "xyes"], [
75   CRYPTO_OBJS+=tom_crypto.lo
76 ])
77 AC_SUBST(CRYPTO_OBJS)
78
79 dnl Checks for header files.
80 AC_HEADER_STDC
81 AC_HEADER_TIME
82
83 AC_CHECK_HEADERS([winscard.h reader.h], [],
84   [AC_MSG_ERROR([[pcsclite headers not found]])])
85 AC_CHECK_LIB([pcsclite], [SCardEstablishContext], [],
86   [AC_MSG_ERROR([[pcsclite library not useable]])])
87
88 AC_CONFIG_FILES([Makefile])
89 AC_OUTPUT