pcsc for platforms fixes

This commit is contained in:
Klas Lindfors
2014-02-04 17:17:31 +01:00
parent 711f24a846
commit 708a9cb5a4
3 changed files with 75 additions and 6 deletions
+3 -2
View File
@@ -25,14 +25,15 @@
# for the parts of OpenSSL used as well as that of the covered work.
AM_CFLAGS = $(WERROR_CFLAGS) $(WARN_CFLAGS)
AM_CPPFLAGS = $(PCSC_CFLAGS) $(OPENSSL_CFLAGS)
AM_CPPFLAGS = $(OPENSSL_CFLAGS) $(PCSC_CFLAGS)
ACLOCAL_AMFLAGS = -I m4
bin_PROGRAMS = yubico-piv-tool
yubico_piv_tool_SOURCES = yubico-piv-tool.c
yubico_piv_tool_SOURCES += cmdline.ggo cmdline.c cmdline.h
yubico_piv_tool_LDADD = $(PCSC_LIBS) $(OPENSSL_LIBS)
yubico_piv_tool_LDADD = $(OPENSSL_LIBS) $(PCSC_LIBS)
yubico_piv_tool_LDADD += $(LTLIBWINSCARD) $(PCSC_MACOSX_LIBS)
cmdline.c cmdline.h: cmdline.ggo Makefile.am
gengetopt --input $^
+66 -1
View File
@@ -37,9 +37,74 @@ AC_PROG_LIBTOOL
AM_MISSING_PROG(HELP2MAN, help2man, $missing_dir)
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES(PCSC, libpcsclite)
PKG_CHECK_MODULES(OPENSSL, openssl)
AC_ARG_WITH([backend],
[AS_HELP_STRING([--with-backend=ARG],
[use specific backend/linkage; 'pcsc', 'macscard' or 'winscard'])],
[],
[with_backend=check])
case "$with_backend$host" in
check*-darwin*)
AC_MSG_NOTICE([Detected Mac: selecting macscard backend])
AC_MSG_NOTICE([use --with-backend to override])
with_backend=macscard ;;
check*-mingw*)
AC_MSG_NOTICE([Detected Windows: selecting winscard backend])
AC_MSG_NOTICE([use --with-backend to override])
with_backend=winscard ;;
esac
if test "x$with_backend" = xcheck || test "x$with_backend" = xpcsc; then
PKG_CHECK_MODULES([PCSC], [libpcsclite],
[with_backend=pcsc], [:])
fi
if test "x$with_backend" = xcheck; then
AC_CHECK_HEADERS([PCSC/winscard.h])
AC_MSG_CHECKING([between Mac/Windows winscard])
if test "x$ac_cv_header_PCSC_winscard_h" = xyes; then
with_backend=macscard
AC_MSG_RESULT([Mac])
else
with_backend=winscard
AC_MSG_RESULT([Windows])
fi
fi
if test "x$with_backend" = xwinscard; then
AC_MSG_NOTICE([checking for winscard with Windows linkage])
AC_LIB_HAVE_LINKFLAGS(winscard,, [#include <winscard.h>],
[SCardBeginTransaction(0)])
if test "x$ac_cv_libwinscard" != xyes; then
AC_MSG_ERROR([cannot find Windows winscard library/headers])
fi
fi
if test "x$with_backend" = xmacscard; then
AC_MSG_NOTICE([checking for PCSC with Mac linkage])
AC_CHECK_HEADERS([PCSC/winscard.h])
PCSC_MACOSX_LIBS="-Wl,-framework -Wl,PCSC"
save_LIBS="$LIBS"
LIBS="$LIBS $PCSC_MACOSX_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <PCSC/wintypes.h>
#include <PCSC/winscard.h>]],
[[SCardBeginTransaction(0)]])],
[AC_SUBST([PCSC_MACOSX_LIBS])],
[AC_MSG_ERROR([cannot find Mac PCSC library/headers])])
LIBS="$save_LIBS"
fi
if test "x$with_backend" = xpcsc || test "x$with_backend" = xwinscard \
|| test "x$with_backend" = xmacscard; then
AC_DEFINE([BACKEND_PCSC], 1, [Define to 1 if you the PCSC backend.])
else
AC_MSG_ERROR([cannot find PCSC/winscard library/headers])
fi
AC_ARG_ENABLE([gcc-warnings],
[AS_HELP_STRING([--enable-gcc-warnings],
[turn on lots of GCC warnings (for developers)])],
+4 -1
View File
@@ -36,11 +36,14 @@
#include <openssl/pem.h>
#include <openssl/pkcs12.h>
#ifdef __APPLE__
#if BACKEND_PCSC
#if defined HAVE_PCSC_WINSCARD_H
# include <PCSC/wintypes.h>
# include <PCSC/winscard.h>
#else
# include <winscard.h>
#endif
#endif
#include "cmdline.h"