From 521a3c21c7fafb8bc08713749336c72e28f3c8e9 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 14 Oct 2006 18:53:50 +0000 Subject: [PATCH] redesign autoconf/automake infrastructure to support - building of CM5121 driver (and backends) optional - building of librfid for in-firmware-use git-svn-id: https://svn.gnumonks.org/trunk/librfid@1906 e0336214-984f-0b4b-a45f-81c69e1f0ede --- README | 18 ++++++++++++++---- configure.in | 35 +++++++++++++++++++++++++++++++---- include/librfid/rfid_system.h | 6 +----- src/Makefile.am | 29 +++++++++++++++++++++++------ src/rfid_reader.c | 2 +- src/rfid_reader_openpcd.c | 2 +- 6 files changed, 71 insertions(+), 21 deletions(-) diff --git a/README b/README index b15ef9e..c495d11 100644 --- a/README +++ b/README @@ -41,6 +41,7 @@ everything. This reader is not yet supported. + 2.x Further Readers Support for more devices shouldn't be too difficult to add, provided the @@ -54,14 +55,19 @@ based on Philips CL RC622, RC531 and RC632, adding support should be very straightforward. If you want to contract me for implementing a driver backend, don't hesitate to contact me. -3. Installation -In order to run librfid, you need a reader transport backend that provides a -PC_to_RDR_Escape function. The current version of this library offers two backends +3. Building / Installing + +In the default configuration, librfid only includes the driver for the OpenPCD +dumbreader firmware. + +If you want support for Omnikey Cardman 5121/5321, you have to add +'--enable-reader-cm5x21' to the './configure' comannd, _and_ choose the backend +you want to use, either: 3.1 (new) native CCID backend -If you add the '--with-ccid' option to the './configure' command, then the new +If you add the '--enable-ccid' option to the './configure' command, then the new native CCID driver (courtesy of Werner Koch) will be linked into the library. This requires a working libusb with development headers. @@ -85,6 +91,10 @@ lower-layer transport interface, it doesn't actually provide a virtual reader interface to it, i.e. you can't use CT-API/OpenCT/PCSC API's to access RFID transponders. +In order to use this backend, you need to use the +'--with-openct=/path/to/openct' option. + + 4. Testing In the 'utils' directory, you will get a 'librfid-tool' binary. It is very diff --git a/configure.in b/configure.in index c141be0..d047682 100644 --- a/configure.in +++ b/configure.in @@ -11,13 +11,40 @@ AC_EXEEXT AM_PROG_LIBTOOL AC_SUBST(LIBTOOL_DEPS) -AC_ARG_WITH(ccid, - [ --with-ccid Include internal CCID driver], +AC_ARG_ENABLE(ccid, + [ --enable-ccid Include internal CCID driver for CM5121], [MY_CCID=1], [MY_CCID=0]) - # AC_SUBST(MY_CCID) -AM_CONDITIONAL(MY_CCID, test "$MY_CCID" == "1") +AM_CONDITIONAL(ENABLE_CCID, test "$MY_CCID" == "1") + +AC_ARG_WITH(openct, + [ --with-openct Use (patched) OpenCT for CM5121 CCID access], + [OPENCT_PATH="$withval"], [OPENCT_PATH=""]) +AC_SUBST(OPENCT_PATH) +AM_CONDITIONAL(ENABLE_OPENCT, test "$OPENCT_PATH" != "") + +AC_ARG_WITH(firmware, + [ --with-firmware=PATH Compile for running inside firmware], + [FIRMWARE_PATH="$withval"], [FIRMWARE_PATH=""]) +AC_SUBST(FIRMWARE_PATH) + +AC_ARG_ENABLE(static, + [ --enable-static Don't use dynamic allocations at all], + [ENABLE_STATIC=1], [ENABLE_STATIC=0]) +AM_CONDITIONAL(ENABLE_STATIC, test "$ENABLE_STATIC" == "1") + +AC_ARG_ENABLE(firmware, + [ --enable-firmware Don't use dynamic allocations at all], + [ENABLE_FIRMWARE=1], [ENABLE_FIRMWARE=0]) +AM_CONDITIONAL(ENABLE_FIRMWARE, test "$ENABLE_FIRMWARE" == "1") + +AC_ARG_ENABLE(reader-cm5x21, + [ --enable-reader-cm5x21 Support for Omnikey Cardman 5121/5321], + [ENABLE_CM5121=1], [ENABLE_CM5121=0]) +AM_CONDITIONAL(ENABLE_CM5121, test "$ENABLE_CM5121" == "1") + +AC_ARG_WITH() #AC_CHECK_HEADERS(usb.h, [have_libusb="yes"], [ AC_MSG_WARN([usb.h not found, use --enable-libusb=PATH. Otherwise, INDI will compile without Apogee USB support.]) ]) AC_CHECK_LIB(usb, usb_close,,) diff --git a/include/librfid/rfid_system.h b/include/librfid/rfid_system.h index 7f9c1b3..9b6ffb7 100644 --- a/include/librfid/rfid_system.h +++ b/include/librfid/rfid_system.h @@ -1,14 +1,10 @@ /* system / environment specific defines */ /* build for openpcd firmware */ -#define LIBRFID_FIRMWARE +//#define LIBRFID_FIRMWARE /* build without dynamic allocations */ //#define LIBRFID_STATIC -// -#ifdef LIBRFID_FIRMWARE -#define LIBRFID_STATIC -#endif #ifdef __LIBRFID__ diff --git a/src/Makefile.am b/src/Makefile.am index c0cbfbe..0c4be7c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,21 +1,38 @@ LIBVERSION= 0:0:0 -INCLUDES = $(all_includes) -I$(top_srcdir)/include -D__LIBRFID__ +INCLUDES = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS = -std=gnu99 -D__LIBRFID__ -AM_CFLAGS = -std=gnu99 +if ENABLE_FIRMWARE +INCLUDES += -I$(FIRMWARE_PATH)/include -I$(GNUARM_PATH)/arm-elf/include +AM_CFLAGS += -DLIBRFID_FIRMWARE -DLIBRFID_STATIC -D__MS_types__ +endif + +if ENABLE_STATIC +AM_CFLAGS += -DLIBRFID_STATIC +endif lib_LTLIBRARIES = librfid.la CORE=rfid.c rfid_layer2.c rfid_protocol.c rfid_reader.c rfid_scan.c L2=rfid_layer2_iso14443a.c rfid_layer2_iso14443b.c rfid_layer2_iso15693.c rfid_iso14443_common.c PROTO=rfid_proto_tcl.c rfid_proto_mifare_ul.c rfid_proto_mifare_classic.c -READER=rfid_reader_cm5121.c rfid_asic_rc632.c rfid_reader_openpcd.c +ASIC=rfid_asic_rc632.c +READER=rfid_reader_openpcd.c + +if ENABLE_CM5121 +READER += rfid_reader_cm5121.c +AM_CFLAGS += -DENABLE_CM5121 -if MY_CCID +if ENABLE_CCID READER_LOW=ccid/rfid_reader_cm5121_ccid_direct.c ccid/ccid-driver.c -else +endif + +if ENABLE_OPENCT READER_LOW=rfid_reader_cm5121_openct.c endif +endif + librfid_la_LDFLAGS = -Wc,-nostartfiles -version-info $(LIBVERSION) -lopenct -librfid_la_SOURCES = $(CORE) $(L2) $(PROTO) $(READER) $(READER_LOW) +librfid_la_SOURCES = $(CORE) $(L2) $(PROTO) $(READER) $(READER_LOW) $(ASIC) diff --git a/src/rfid_reader.c b/src/rfid_reader.c index a5dbeb2..af947ac 100644 --- a/src/rfid_reader.c +++ b/src/rfid_reader.c @@ -26,7 +26,7 @@ #include static const struct rfid_reader *rfid_readers[] = { -#ifndef LIBRFID_FIRMWARE +#ifdef ENABLE_CM5121 [RFID_READER_CM5121] = &rfid_reader_cm5121, #endif [RFID_READER_OPENPCD] = &rfid_reader_openpcd, diff --git a/src/rfid_reader_openpcd.c b/src/rfid_reader_openpcd.c index aee3d18..9397cb0 100644 --- a/src/rfid_reader_openpcd.c +++ b/src/rfid_reader_openpcd.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -57,6 +56,7 @@ static struct openpcd_hdr *rcv_hdr; #ifndef LIBRFID_FIRMWARE +#include static struct usb_device *dev; static struct usb_dev_handle *hdl; -- 2.20.1