Patchwork [4/6] libcaccard: update configure to build and use internal libcaccard

login
register
mail settings
Submitter Alon Levy
Date Nov. 28, 2010, 2:46 p.m.
Message ID <1290955607-25821-5-git-send-email-alevy@redhat.com>
Download mbox | patch
Permalink /patch/73335/
State New
Headers show

Comments

Alon Levy - Nov. 28, 2010, 2:46 p.m.
Signed-off-by: Alon Levy <alevy@redhat.com>
---
 Makefile            |    6 ++++--
 Makefile.objs       |    5 +++++
 Makefile.target     |    2 ++
 configure           |   24 ++++++++++++++++++++++++
 libcaccard/Makefile |   18 ++++++++++++++++++
 5 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 libcaccard/Makefile

Patch

diff --git a/Makefile b/Makefile
index 4e120a2..e673bf1 100644
--- a/Makefile
+++ b/Makefile
@@ -172,6 +172,8 @@  check-qlist: check-qlist.o qlist.o qint.o $(CHECK_PROG_DEPS)
 check-qfloat: check-qfloat.o qfloat.o $(CHECK_PROG_DEPS)
 check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o qjson.o json-streamer.o json-lexer.o json-parser.o $(CHECK_PROG_DEPS)
 
+QEMULIBS=libhw32 libhw64 libuser libdis libdis-user libcaccard
+
 clean:
 # avoid old build problems by removing potentially incorrect old files
 	rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
@@ -183,7 +185,7 @@  clean:
 	rm -f trace-dtrace.dtrace trace-dtrace.dtrace-timestamp
 	rm -f trace-dtrace.h trace-dtrace.h-timestamp
 	$(MAKE) -C tests clean
-	for d in $(ALL_SUBDIRS) libhw32 libhw64 libuser libdis libdis-user; do \
+	for d in $(ALL_SUBDIRS) $(QEMULIBS); do \
 	if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
 	rm -f $$d/qemu-options.def; \
         done
@@ -194,7 +196,7 @@  distclean: clean
 	rm -f roms/seabios/config.mak roms/vgabios/config.mak
 	rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.dvi qemu-doc.fn qemu-doc.info qemu-doc.ky qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp qemu-doc.vr
 	rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr
-	for d in $(TARGET_DIRS) libhw32 libhw64 libuser libdis libdis-user; do \
+	for d in $(TARGET_DIRS) $(QEMULIBS); do \
 	rm -rf $$d || exit 1 ; \
         done
 
diff --git a/Makefile.objs b/Makefile.objs
index 2059e89..82691c0 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -297,6 +297,11 @@  user-obj-y += qemu-timer-common.o
 endif
 endif
 
+######################################################################
+# smartcard
+
+libcaccard-y = cac.o event.o passthru.o vcard.o vreader.o vcard_emul_nss.o vcard_emul_type.o card_7816.o
+
 vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
 
 vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
diff --git a/Makefile.target b/Makefile.target
index 2800f47..7dd6932 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -341,6 +341,8 @@  obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y))
 
 endif # CONFIG_SOFTMMU
 
+obj-y += $(addprefix $(SRC_PATH)/libcaccard/, $(libcaccard-$(CONFIG_SMARTCARD)))
+
 obj-y += $(addprefix ../, $(trace-obj-y))
 obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
 
diff --git a/configure b/configure
index fb9eac2..4b55904 100755
--- a/configure
+++ b/configure
@@ -2130,6 +2130,25 @@  EOF
   fi
 fi
 
+# check for libcaccard for smartcard support
+if test "$smartcard" != "no" ; then
+  smartcard_cflags="-I\$(SRC_PATH)/libcaccard"
+  smartcard_libs="-L\$(SRC_PATH)/libcaccard -lcaccard"
+  libcaccard_libs=$($pkgconfig --libs nss 2>/dev/null)
+  libcaccard_cflags=$($pkgconfig --cflags nss)
+  # TODO - what's the minimal nss version we support?
+  if $pkgconfig --atleast-version=3.12.8 nss; then
+    smartcard="yes"
+    QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcaccard_cflags"
+    LIBS="$libcaccard_libs $LIBS"
+  else
+    if test "smartcard" = "yes" ; then
+      feature_not_found "smartcard"
+    fi
+    smartcard="no"
+  fi
+fi
+
 ##########################################
 
 ##########################################
@@ -2956,6 +2975,11 @@  fi
 if test "$target_darwin_user" = "yes" ; then
   echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
 fi
+if test "$smartcard" = "yes" ; then
+  echo "subdir-$target: subdir-libcaccard" >> $config_host_mak
+  echo "libcaccard_libs=$libcaccard_libs" >> $config_host_mak
+  echo "libcaccard_cflags=$libcaccard_cflags" >> $config_host_mak
+fi
 list=""
 if test ! -z "$gdb_xml_files" ; then
   for x in $gdb_xml_files; do
diff --git a/libcaccard/Makefile b/libcaccard/Makefile
new file mode 100644
index 0000000..a339af1
--- /dev/null
+++ b/libcaccard/Makefile
@@ -0,0 +1,18 @@ 
+include ../Makefile.objs
+include ../config-host.mak
+include ../config-all-devices.mak
+include $(SRC_PATH)/rules.mak
+
+CFLAGS+=-fPIC
+
+libcaccard.so: $(libcaccard-y)
+	gcc -shared $(libcaccard_libs) -o $@ $^
+
+vscclient: $(libcaccard-y) vscclient.o
+	gcc $(libcaccard_libs) -o $@ $^
+
+all: libcaccard.so vscclient
+
+clean:
+	rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ libcaccard.so
+