qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCHv4 0/2] libcacard.la
@ 2011-05-18 14:23 Alon Levy
  2011-05-18 14:23 ` [Qemu-devel] [PATCHv4 1/2] configure: add libdir and --libdir Alon Levy
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alon Levy @ 2011-05-18 14:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini

Allow building standalone shared (or static, whichever libtool chooses)
library out of libcacard sources, for use by ccid-card-passthru remote clients.

v4: exit (return code 1) if libtool not found at any stage (for .lo rule
and for toplevel libcacard and libcacard-install targets) per Paolo's suggestion.

Resending the whole patchset since the old thread is a little too large, no
change to the first patch, just the second changed.

Alon Levy (2):
  configure: add libdir and --libdir
  libcacard: add libcacard.la target

 Makefile           |   20 +++++++++++++++++++-
 Makefile.objs      |    8 ++++++++
 configure          |   17 ++++++++++++++++-
 libcacard/Makefile |   32 ++++++++++++++++++++++++++++----
 rules.mak          |    8 ++++++++
 5 files changed, 79 insertions(+), 6 deletions(-)

-- 
1.7.5.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCHv4 1/2] configure: add libdir and --libdir
  2011-05-18 14:23 [Qemu-devel] [PATCHv4 0/2] libcacard.la Alon Levy
@ 2011-05-18 14:23 ` Alon Levy
  2011-05-18 14:23 ` [Qemu-devel] [PATCHv4 2/2] libcacard: add libcacard.la target Alon Levy
  2011-05-23 13:12 ` [Qemu-devel] [PATCHv4 0/2] libcacard.la Alon Levy
  2 siblings, 0 replies; 5+ messages in thread
From: Alon Levy @ 2011-05-18 14:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini

---
 configure |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index d7dba5d..0627f1d 100755
--- a/configure
+++ b/configure
@@ -146,6 +146,7 @@ mandir="\${prefix}/share/man"
 datadir="\${prefix}/share/qemu"
 docdir="\${prefix}/share/doc/qemu"
 bindir="\${prefix}/bin"
+libdir="\${prefix}/lib"
 sysconfdir="\${prefix}/etc"
 confsuffix="/qemu"
 slirp="yes"
@@ -536,6 +537,8 @@ for opt do
   ;;
   --bindir=*) bindir="$optarg"
   ;;
+  --libdir=*) libdir="$optarg"
+  ;;
   --datadir=*) datadir="$optarg"
   ;;
   --docdir=*) docdir="$optarg"
@@ -2630,6 +2633,7 @@ fi
 echo "Install prefix    $prefix"
 echo "BIOS directory    `eval echo $datadir`"
 echo "binary directory  `eval echo $bindir`"
+echo "library directory `eval echo $libdir`"
 echo "config directory  `eval echo $sysconfdir`"
 if test "$mingw32" = "no" ; then
 echo "Manual directory  `eval echo $mandir`"
@@ -2722,6 +2726,7 @@ echo >> $config_host_mak
 echo all: >> $config_host_mak
 echo "prefix=$prefix" >> $config_host_mak
 echo "bindir=$bindir" >> $config_host_mak
+echo "libdir=$libdir" >> $config_host_mak
 echo "mandir=$mandir" >> $config_host_mak
 echo "datadir=$datadir" >> $config_host_mak
 echo "sysconfdir=$sysconfdir" >> $config_host_mak
-- 
1.7.5.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCHv4 2/2] libcacard: add libcacard.la target
  2011-05-18 14:23 [Qemu-devel] [PATCHv4 0/2] libcacard.la Alon Levy
  2011-05-18 14:23 ` [Qemu-devel] [PATCHv4 1/2] configure: add libdir and --libdir Alon Levy
@ 2011-05-18 14:23 ` Alon Levy
  2011-05-23 13:12 ` [Qemu-devel] [PATCHv4 0/2] libcacard.la Alon Levy
  2 siblings, 0 replies; 5+ messages in thread
From: Alon Levy @ 2011-05-18 14:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini

No flag to configure is required. Instead, added a libcacard.la target that
is not built by default, only when requested explicitly via:

mkdir build
cd build
../configure
make libcacard.la
make install-libcacard

Uses libtool to do actual linking of object files and shared library, and
installing. Tested only under linux, but supposed to work on other systems as
well.

If libtool isn't found you get a message complaining about that, only at build
time (since it is not a default target I did not add a message at configure
time).

New build artifacts:
 .libs subdirectories (at <buildroot> and <buildroot>/libcacard)
 *.lo files (at same locations as the respective o files)

Added %.lo : %.c rule that uses libtool.
Updated clean rule to clean up those artifacts.
Added specific rule to call dtrace with libtool wrapper (note that because of
a current upstream dtrace bug fixed by systemtap b1568fd85 commit the -fPIC flag
isn't actually passed on. still current dtrace+libtool produced object links fine).
If libtool is missing any of the following targets will complain and exit 1:
 any subdir: *.lo
 root and libcacard: libcacard.la, libcacard-instsall

Tested to link and load with all tracing backends.
---
 Makefile           |   20 +++++++++++++++++++-
 Makefile.objs      |    8 ++++++++
 configure          |   12 +++++++++++-
 libcacard/Makefile |   32 ++++++++++++++++++++++++++++----
 rules.mak          |    8 ++++++++
 5 files changed, 74 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 2b0438c..6d58710 100644
--- a/Makefile
+++ b/Makefile
@@ -119,6 +119,23 @@ version.o: $(SRC_PATH)/version.rc config-host.mak
 
 version-obj-$(CONFIG_WIN32) += version.o
 ######################################################################
+# Support building shared library libcacard
+
+.PHONY: libcacard.la install-libcacard
+ifeq ($(LIBTOOL),)
+libcacard.la:
+	@echo "libtool is missing, please install and rerun configure"; exit 1
+
+install-libcacard:
+	@echo "libtool is missing, please install and rerun configure"; exit 1
+else
+libcacard.la: $(GENERATED_HEADERS) $(oslib-obj-y) qemu-malloc.o qemu-timer-common.o $(addsuffix .lo, $(basename $(trace-obj-y)))
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" TARGET_DIR="$*/" libcacard.la,)
+
+install-libcacard: libcacard.la
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" TARGET_DIR="$*/" install-libcacard,)
+endif
+######################################################################
 
 qemu-img.o: qemu-img-cmds.h
 qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o: $(GENERATED_HEADERS)
@@ -149,7 +166,8 @@ 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
 	rm -f qemu-options.def
-	rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~
+	rm -f *.o *.d *.a *.lo $(TOOLS) TAGS cscope.* *.pod *~ */*~
+	rm -Rf .libs
 	rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d
 	rm -f qemu-img-cmds.h
 	rm -f trace.c trace.h trace.c-timestamp trace.h-timestamp
diff --git a/Makefile.objs b/Makefile.objs
index 4478c61..50369ab 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -344,6 +344,14 @@ trace-dtrace.dtrace-timestamp: $(SRC_PATH)/trace-events config-host.mak
 trace-dtrace.o: trace-dtrace.dtrace $(GENERATED_HEADERS)
 	$(call quiet-command,dtrace -o $@ -G -s $<, "  GEN trace-dtrace.o")
 
+ifeq ($(LIBTOOL),)
+trace-dtrace.lo: trace-dtrace.dtrace
+	@echo "missing libtool. please install and rerun configure."; exit 1
+else
+trace-dtrace.lo: trace-dtrace.dtrace
+	$(call quiet-command,libtool --mode=compile --tag=CC dtrace -o $@ -G -s $<, "  lt GEN trace-dtrace.o")
+endif
+
 simpletrace.o: simpletrace.c $(GENERATED_HEADERS)
 
 ifeq ($(TRACE_BACKEND),dtrace)
diff --git a/configure b/configure
index 0627f1d..e62841e 100755
--- a/configure
+++ b/configure
@@ -1276,6 +1276,15 @@ if ! has $pkg_config; then
 fi
 
 ##########################################
+# libtool probe
+
+if ! has libtool; then
+    libtool=
+else
+    libtool=libtool
+fi
+
+##########################################
 # Sparse probe
 if test "$sparse" != "no" ; then
   if has cgcc; then
@@ -3060,6 +3069,7 @@ echo "AR=$ar" >> $config_host_mak
 echo "OBJCOPY=$objcopy" >> $config_host_mak
 echo "LD=$ld" >> $config_host_mak
 echo "WINDRES=$windres" >> $config_host_mak
+echo "LIBTOOL=$libtool" >> $config_host_mak
 echo "CFLAGS=$CFLAGS" >> $config_host_mak
 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
@@ -3595,7 +3605,7 @@ if [ "$source_path" != `pwd` ]; then
     # out of tree build
     mkdir -p libcacard
     rm -f libcacard/Makefile
-    ln -s "$source_path/libcacard/Makefile" libcacard/Makefile
+    symlink "$source_path/libcacard/Makefile" libcacard/Makefile
 fi
 
 d=libuser
diff --git a/libcacard/Makefile b/libcacard/Makefile
index 1d34df0..9802c37 100644
--- a/libcacard/Makefile
+++ b/libcacard/Makefile
@@ -4,15 +4,39 @@
 
 $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/libcacard)
 
-QEMU_OBJS=$(addprefix ../, $(oslib-obj-y) $(trace-obj-y) qemu-malloc.o qemu-timer-common.o)
+# objects linked against normal qemu binaries, not compiled with libtool
+QEMU_OBJS=$(addprefix ../,$(oslib-obj-y) qemu-malloc.o qemu-timer-common.o $(trace-obj-y))
+
+# objects linked into a shared library, built with libtool with -fPIC if required
+QEMU_OBJS_LIB=$(addsuffix .lo,$(basename $(QEMU_OBJS)))
 
 QEMU_CFLAGS+=-I../
 
+libcacard.lib-y=$(addsuffix .lo,$(basename $(libcacard-y)))
+
 vscclient: $(libcacard-y) $(QEMU_OBJS) vscclient.o
-	$(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^,"  LINK  $(TARGET_DIR)$@")
+	$(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^,"  LINK  $@")
+
+clean:
+	rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient *.lo .libs/* *.la
+	rm -Rf .libs
 
 all: vscclient
 
-clean:
-	rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient
+#########################################################################
+# Rules for building libcacard standalone library
+
+ifeq ($(LIBTOOL),)
+libcacard.la:
+	@echo "libtool is missing, please install and rerun configure"; exit 1
+
+install-libcacard:
+	@echo "libtool is missing, please install and rerun configure"; exit 1
+else
+libcacard.la: $(libcacard.lib-y) $(QEMU_OBJS_LIB)
+	$(call quiet-command,libtool --mode=link --quiet --tag=CC $(CC) $(libcacard_libs) -lrt -rpath $(libdir) -o $@ $^,"  lt LINK $@")
 
+install-libcacard: libcacard.la
+	$(INSTALL_DIR) "$(DESTDIR)$(libdir)"
+	libtool --mode=install $(INSTALL_PROG) libcacard.la "$(DESTDIR)$(libdir)"
+endif
diff --git a/rules.mak b/rules.mak
index ed59c9e..612ae37 100644
--- a/rules.mak
+++ b/rules.mak
@@ -17,6 +17,14 @@ QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
 %.o: %.c
 	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
 
+ifeq ($(LIBTOOL),)
+%.lo: %.c
+	@echo "missing libtool. please install and rerun configure"; exit 1
+else
+%.lo: %.c
+	$(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  lt CC $@")
+endif
+
 %.o: %.S
 	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
 
-- 
1.7.5.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCHv4 0/2] libcacard.la
  2011-05-18 14:23 [Qemu-devel] [PATCHv4 0/2] libcacard.la Alon Levy
  2011-05-18 14:23 ` [Qemu-devel] [PATCHv4 1/2] configure: add libdir and --libdir Alon Levy
  2011-05-18 14:23 ` [Qemu-devel] [PATCHv4 2/2] libcacard: add libcacard.la target Alon Levy
@ 2011-05-23 13:12 ` Alon Levy
  2011-05-23 13:29   ` Paolo Bonzini
  2 siblings, 1 reply; 5+ messages in thread
From: Alon Levy @ 2011-05-23 13:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini

On Wed, May 18, 2011 at 05:23:42PM +0300, Alon Levy wrote:

Ping?

> Allow building standalone shared (or static, whichever libtool chooses)
> library out of libcacard sources, for use by ccid-card-passthru remote clients.
> 
> v4: exit (return code 1) if libtool not found at any stage (for .lo rule
> and for toplevel libcacard and libcacard-install targets) per Paolo's suggestion.
> 
> Resending the whole patchset since the old thread is a little too large, no
> change to the first patch, just the second changed.
> 
> Alon Levy (2):
>   configure: add libdir and --libdir
>   libcacard: add libcacard.la target
> 
>  Makefile           |   20 +++++++++++++++++++-
>  Makefile.objs      |    8 ++++++++
>  configure          |   17 ++++++++++++++++-
>  libcacard/Makefile |   32 ++++++++++++++++++++++++++++----
>  rules.mak          |    8 ++++++++
>  5 files changed, 79 insertions(+), 6 deletions(-)
> 
> -- 
> 1.7.5.1
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCHv4 0/2] libcacard.la
  2011-05-23 13:12 ` [Qemu-devel] [PATCHv4 0/2] libcacard.la Alon Levy
@ 2011-05-23 13:29   ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2011-05-23 13:29 UTC (permalink / raw)
  To: qemu-devel, Anthony Liguori

On 05/23/2011 03:12 PM, Alon Levy wrote:
> On Wed, May 18, 2011 at 05:23:42PM +0300, Alon Levy wrote:
>
> Ping?
>
>> Allow building standalone shared (or static, whichever libtool chooses)
>> library out of libcacard sources, for use by ccid-card-passthru remote clients.
>>
>> v4: exit (return code 1) if libtool not found at any stage (for .lo rule
>> and for toplevel libcacard and libcacard-install targets) per Paolo's suggestion.
>>
>> Resending the whole patchset since the old thread is a little too large, no
>> change to the first patch, just the second changed.
>>
>> Alon Levy (2):
>>    configure: add libdir and --libdir
>>    libcacard: add libcacard.la target
>>
>>   Makefile           |   20 +++++++++++++++++++-
>>   Makefile.objs      |    8 ++++++++
>>   configure          |   17 ++++++++++++++++-
>>   libcacard/Makefile |   32 ++++++++++++++++++++++++++++----
>>   rules.mak          |    8 ++++++++
>>   5 files changed, 79 insertions(+), 6 deletions(-)
>>
>> --
>> 1.7.5.1
>>
>>

Looks good to me.

Paolo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-05-23 13:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-18 14:23 [Qemu-devel] [PATCHv4 0/2] libcacard.la Alon Levy
2011-05-18 14:23 ` [Qemu-devel] [PATCHv4 1/2] configure: add libdir and --libdir Alon Levy
2011-05-18 14:23 ` [Qemu-devel] [PATCHv4 2/2] libcacard: add libcacard.la target Alon Levy
2011-05-23 13:12 ` [Qemu-devel] [PATCHv4 0/2] libcacard.la Alon Levy
2011-05-23 13:29   ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).