summaryrefslogtreecommitdiff
path: root/configure.ac
blob: c6d0856dd1f1d5e51b3a43c27526a7b7c04097b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
AC_PREREQ([2.60])

m4_define([CAC_MAJOR], 0)
m4_define([CAC_MINOR], 1)
m4_define([CAC_MICRO], 2)

AC_INIT(libcacard, [CAC_MAJOR.CAC_MINOR.CAC_MICRO], [], libcacard)

AC_CONFIG_MACRO_DIR([m4])
AM_CONFIG_HEADER([config.h])
AC_CONFIG_AUX_DIR(.)

AM_INIT_AUTOMAKE([dist-bzip2])
AM_MAINTAINER_MODE

AS_IF([test "$CFLAGS" = ""], [], [_cflags_is_set=yes])
AC_PROG_CC
AC_PROG_INSTALL
AC_CANONICAL_HOST
AC_PROG_LIBTOOL
AM_PROG_CC_C_O
AC_C_BIGENDIAN
AC_PATH_PROGS(PYTHON, python2 python)

CAC_LT_VERSION=m4_format("%d:%d:%d", 1, 0, 2)
AC_SUBST(CAC_LT_VERSION)

AC_MSG_CHECKING([for native Win32])
case "$host_os" in
     *mingw*|*cygwin*)
        os_win32=yes
        ;;
     *)
        os_win32=no
        ;;
esac
AC_MSG_RESULT([$os_win32])
AM_CONDITIONAL([OS_WIN32],[test "$os_win32" = "yes"])

dnl =========================================================================
dnl Check deps

CAC_CARD_NONPKGCONFIG_LIBS+=" -pthread"

CAC_CARD_REQUIRES=""

AC_ARG_WITH([backend],
  AS_HELP_STRING([--with-backend=@<:@nss/winscard@:>@], [Select backend @<:@default=nss@:>@]),
  [],
  [with_backend="nss"])

case "$with_backend" in
  winscard|nss*)
    ;;
  *) AC_MSG_ERROR(Unsupported backend)
esac

AS_IF([test "x$with_backend" = "xnss"],
      [PKG_CHECK_MODULES(NSS, nss, [have_nss=yes], [have_nss=no])],
      [have_nss=no])

AS_IF([test "x$have_nss" = "xyes"],
      [AC_DEFINE([WITH_NSS], 1, [Have nss?])],
      [AS_IF([test "x$with_backend" = "xnss"],
             [AC_MSG_ERROR([NSS requested but not found])
      ])
])
AM_CONDITIONAL([WITH_NSS], [test "x$have_nss" = "xyes"])
AC_SUBST(NSS_CFLAGS)
AC_SUBST(NSS_LIBS)

AS_IF([test "x$with_backend" = "xwinscard"],
      [AC_CHECK_HEADER([winscard.h], [have_winscard=yes], [have_winscard=no])],
      [have_winscard=no])

AS_IF([test "x$have_winscard" = "xyes"],
      [AC_DEFINE([WITH_WINSCARD], 1, [Have winscard?])],
      [AS_IF([test "x$with_backend" = "xwinscard"],
             [AC_MSG_ERROR([WinSCard requested but not found])
      ])
])
AM_CONDITIONAL([WITH_WINSCARD], [test "x$have_winscard" = "xyes"])


AS_IF([test "$_cflags_is_set" = "yes"], [], [
    CFLAGS="-g -O2 -Wall -Werror"
])


AS_IF([test "$_cxxflags_is_set" = "yes"], [], [
    CXXFLAGS="-g -O2 -Wall -Werror"
])

dnl Use lots of warning flags with with gcc and compatible compilers

dnl Note: if you change the following variable, the cache is automatically
dnl skipped and all flags rechecked.  So there's no need to do anything
dnl else.  If for any reason you need to force a recheck, just change
dnl MAYBE_WARN in an ignorable way (like adding whitespace)

dnl MAYBE_WARN="-Wall -Wno-sign-compare -Werror -Wno-deprecated-declarations"

MAYBE_WARN="-Wall -Wno-sign-compare -Wno-deprecated-declarations"

AC_ARG_ENABLE(werror,
AC_HELP_STRING([--enable-werror], [Use -Werror (if supported)]),
set_werror="$enableval",[
if test -f $srcdir/GITVERSION; then
	is_git_version=true
	set_werror=yes
else
	set_werror=no
fi
])

dnl handle the passthru option. passthru allows you to access the cards directly
AC_ARG_ENABLE(passthru,
AC_HELP_STRING([--enable-passthru], [allow passthru mode]),
set_passthru="$enableval",)

if test "${set_passthru}" = "yes" ; then
PKG_CHECK_MODULES(PCSC,libpcsclite)
AC_SUBST(PCSC_CFLAGS)
AC_SUBST(PCSC_LIBS)
CAC_CARD_REQUIRES+=" pcsc-lite"
USE_PASSTHRU=-DUSE_PASSTHRU
AC_SUBST(USE_PASSTHRU)
fi

AC_SUBST(CAC_COMMON_SRCDIR)
AC_SUBST(CAC_CARD_REQUIRES)
AC_SUBST(CAC_NONPKGCONFIG_CFLAGS)
AC_SUBST(CAC_CARD_NONPKGCONFIG_LIBS)

m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AC_OUTPUT([
Makefile
libcacard.pc
])

dnl ==========================================================================
echo "

        libcacard $VERSION
        ==============

        prefix:                   ${prefix}
        c compiler:               ${CC}

        Now type 'make' to build $PACKAGE
"