use a separate directory for ifd-vpcd and pcsclite-vpcd

This commit is contained in:
Frank Morgner
2014-03-31 23:35:33 +02:00
parent 0aec0e4d31
commit 8abb64e519
22 changed files with 195 additions and 55 deletions

View File

@@ -3,7 +3,7 @@
AC_PREREQ([2.64])
AC_INIT([Virtual Smart Card], [0.7], [http://sourceforge.net/projects/vsmartcard/support], [virtualsmartcard], [http://vsmartcard.sourceforge.net/virtualsmartcard/README.html])
AC_CONFIG_SRCDIR([src/vpcd/ifd-vpcd.c])
AC_CONFIG_SRCDIR([src/vpcd/vpcd.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE
@@ -47,7 +47,7 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
# --enable-libpcsclite
AC_ARG_ENABLE(libpcsclite,
AC_HELP_STRING([--enable-libpcsclite=DIR],[Build a lightweight version of
AC_HELP_STRING([--enable-libpcsclite],[Build a lightweight version of
libpcsclite, conflicts with PCSC-Lite @<:@default=no@:>@]),
[libpcsclite="${enableval}"], [libpcsclite=no])
if test "${libpcsclite}" = no ; then
@@ -102,8 +102,8 @@ if test "${libpcsclite}" = no ; then
fi
else
builddir="`pwd`"
PCSC_CFLAGS="-DNO_LOG -I${builddir}/${srcdir}/src/libpcsclite/PCSC -I${builddir}/${srcdir}/src/libpcsclite"
PCSC_LIBS="$builddir/src/libpcsclite/libpcsclite.la"
PCSC_CFLAGS="-DNO_LOG -I${builddir}/${srcdir}/src/pcsclite-vpcd/PCSC -I${builddir}/${srcdir}/src/pcsclite-vpcd"
PCSC_LIBS="$builddir/src/pcsclite-vpcd/libpcsclite.la"
AC_SUBST(PCSC_CFLAGS)
AC_SUBST(PCSC_LIBS)
fi
@@ -226,7 +226,8 @@ AC_CONFIG_FILES([Makefile
npa-example-data/dh/Makefile
npa-example-data/ecdh/Makefile
src/Makefile
src/libpcsclite/Makefile
src/pcsclite-vpcd/Makefile
src/ifd-vpcd/Makefile
src/vpcd/Makefile
src/vpicc/Makefile
])

View File

@@ -1,5 +1,5 @@
SUBDIRS = vpcd vpicc
SUBDIRS = vpcd vpicc ifd-vpcd
if BUILD_LIBPCSCLITE
SUBDIRS += libpcsclite
SUBDIRS += pcsclite-vpcd
endif

View File

@@ -0,0 +1,52 @@
IFDVPCD_LIB = $(LIB_PREFIX)ifdvpcd.$(DYN_LIB_EXT)
libifdvpcd_la_SOURCES = ifd-vpcd.c
libifdvpcd_la_LDFLAGS = -no-undefined
libifdvpcd_la_CPPFLAGS = $(PCSC_CFLAGS) -I$(srcdir)/../vpcd
libifdvpcd_la_LIBADD = $(top_builddir)/src/vpcd/libvpcd.la
noinst_HEADERS = ifd-vpcd.h
EXTRA_DIST = reader.conf.in
do_subst = $(SED) \
-e 's,[@]TARGET[@],$(serialdropdir)/$(IFDVPCD_LIB),g' \
-e 's,[@]VPCDHOST[@],$(vpcdhost),g'
if BUILD_LIBPCSCLITE
noinst_LTLIBRARIES = libifdvpcd.la
ifd-vpcd.c: pcsclite.h
.PHONY: pcsclite.h
pcsclite.h:
$(MAKE) -C $(builddir)/../pcsclite-vpcd pcsclite.h
else
libifdvpcd_la_LIBADD += $(PCSC_LIBS)
lib_LTLIBRARIES = libifdvpcd.la
install: install_libifdvpcd
install_libifdvpcd: libifdvpcd.la reader.conf.in
$(mkinstalldirs) $(DESTDIR)$(serialdropdir)
$(LIBTOOL) --mode=install cp .libs/$(IFDVPCD_LIB) $(DESTDIR)$(serialdropdir)/$(IFDVPCD_LIB).$(VERSION)
(cd $(DESTDIR)$(serialdropdir) && \
$(LN_S) -f $(IFDVPCD_LIB).$(VERSION) $(IFDVPCD_LIB))
$(mkinstalldirs) $(DESTDIR)$(serialconfdir)
$(do_subst) < $(srcdir)/reader.conf.in > $(DESTDIR)$(serialconfdir)/vpcd
uninstall: uninstall_libifdvpcd
uninstall_libifdvpcd:
rm -f $(DESTDIR)$(serialdropdir)/$(IFDVPCD_LIB).$(VERSION) \
$(DESTDIR)$(serialdropdir)/$(IFDVPCD_LIB) \
$(DESTDIR)$(serialconfdir)/vpcd
endif

View File

@@ -2,10 +2,10 @@ EXTRA_DIST = PCSC/pcsclite.h.in libpcsclite.pc.in
lib_LTLIBRARIES = libpcsclite.la
libpcsclite_la_CPPFLAGS = $(PCSC_CFLAGS) -I$(srcdir)/../vpcd
libpcsclite_la_CPPFLAGS = $(PCSC_CFLAGS) -I$(srcdir)/../ifd-vpcd -I$(srcdir)/../vpcd
libpcsclite_la_LDFLAGS = -no-undefined
libpcsclite_la_SOURCES = winscard.c debug.c strlcpy.c error.c
libpcsclite_la_LIBADD = $(top_builddir)/src/vpcd/libvpcd.la
libpcsclite_la_LIBADD = $(top_builddir)/src/ifd-vpcd/libifdvpcd.la
noinst_HEADERS = pcsclite.h strlcpycat.h misc.h

View File

@@ -0,0 +1,132 @@
/*
* MUSCLE SmartCard Development ( http://www.linuxnet.com )
*
* Copyright (C) 1999-2002
* David Corcoran <corcoran@linuxnet.com>
* Copyright (C) 2002-2011
* Ludovic Rousseau <ludovic.rousseau@free.fr>
*
* $Id: debug.c 6551 2013-03-06 13:44:17Z rousseau $
*/
/**
* @file
* @brief This handles debugging for libpcsclite.
*/
#include "config.h"
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include "debuglog.h"
#include "strlcpycat.h"
#define DEBUG_BUF_SIZE 2048
#ifdef NO_LOG
void log_msg(const int priority, const char *fmt, ...)
{
(void)priority;
(void)fmt;
}
#else
/** default level is quiet to avoid polluting fd 2 (possibly NOT stderr) */
static char LogLevel = PCSC_LOG_CRITICAL+1;
static signed char LogDoColor = 0; /**< no color by default */
static void log_init(void)
{
char *e;
#ifdef LIBPCSCLITE
e = getenv("PCSCLITE_DEBUG");
#else
e = getenv("MUSCLECARD_DEBUG");
#endif
if (e)
LogLevel = atoi(e);
/* log to stderr and stderr is a tty? */
if (isatty(fileno(stderr)))
{
char *term;
term = getenv("TERM");
if (term)
{
const char *terms[] = { "linux", "xterm", "xterm-color", "Eterm", "rxvt", "rxvt-unicode" };
unsigned int i;
/* for each known color terminal */
for (i = 0; i < sizeof(terms) / sizeof(terms[0]); i++)
{
/* we found a supported term? */
if (0 == strcmp(terms[i], term))
{
LogDoColor = 1;
break;
}
}
}
}
} /* log_init */
void log_msg(const int priority, const char *fmt, ...)
{
char DebugBuffer[DEBUG_BUF_SIZE];
va_list argptr;
static int is_initialized = 0;
if (!is_initialized)
{
log_init();
is_initialized = 1;
}
if (priority < LogLevel) /* log priority lower than threshold? */
return;
va_start(argptr, fmt);
(void)vsnprintf(DebugBuffer, DEBUG_BUF_SIZE, fmt, argptr);
va_end(argptr);
{
if (LogDoColor)
{
const char *color_pfx = "", *color_sfx = "\33[0m";
switch (priority)
{
case PCSC_LOG_CRITICAL:
color_pfx = "\33[01;31m"; /* bright + Red */
break;
case PCSC_LOG_ERROR:
color_pfx = "\33[35m"; /* Magenta */
break;
case PCSC_LOG_INFO:
color_pfx = "\33[34m"; /* Blue */
break;
case PCSC_LOG_DEBUG:
color_pfx = ""; /* normal (black) */
color_sfx = "";
break;
}
fprintf(stderr, "%s%s%s\n", color_pfx, DebugBuffer, color_sfx);
}
else
fprintf(stderr, "%s\n", DebugBuffer);
}
} /* log_msg */
#endif

View File

@@ -1,51 +1,6 @@
VPCD_LIB = $(LIB_PREFIX)vpcd.$(DYN_LIB_EXT)
libvpcd_la_SOURCES = ifd-vpcd.c vpcd.c lock.c
libvpcd_la_SOURCES = vpcd.c lock.c
libvpcd_la_LDFLAGS = -no-undefined
libvpcd_la_CFLAGS = $(PCSC_CFLAGS)
noinst_HEADERS = vpcd.h lock.h
EXTRA_DIST = reader.conf.in
do_subst = $(SED) \
-e 's,[@]TARGET[@],$(serialdropdir)/$(VPCD_LIB),g' \
-e 's,[@]VPCDHOST[@],$(vpcdhost),g'
if BUILD_LIBPCSCLITE
noinst_LTLIBRARIES = libvpcd.la
ifd-vpcd.c: pcsclite.h
.PHONY: pcsclite.h
pcsclite.h:
$(MAKE) -C $(builddir)/../libpcsclite pcsclite.h
else
libvpcd_la_LIBADD = $(PCSC_LIBS)
lib_LTLIBRARIES = libvpcd.la
install: install_libvpcd
install_libvpcd: libvpcd.la reader.conf.in
$(mkinstalldirs) $(DESTDIR)$(serialdropdir)
$(LIBTOOL) --mode=install cp .libs/$(VPCD_LIB) $(DESTDIR)$(serialdropdir)/$(VPCD_LIB).$(VERSION)
(cd $(DESTDIR)$(serialdropdir) && \
$(LN_S) -f $(VPCD_LIB).$(VERSION) $(VPCD_LIB))
$(mkinstalldirs) $(DESTDIR)$(serialconfdir)
$(do_subst) < $(srcdir)/reader.conf.in > $(DESTDIR)$(serialconfdir)/vpcd
uninstall: uninstall_libvpcd
uninstall_libvpcd:
rm -f $(DESTDIR)$(serialdropdir)/$(VPCD_LIB).$(VERSION) \
$(DESTDIR)$(serialdropdir)/$(VPCD_LIB) \
$(DESTDIR)$(serialconfdir)/vpcd
endif