add libcacard shared object target
cover add libcacard shared object target
These patches add a standalone shared object target using libtool for libcacard, see second patch for details on usage. First patch adds required --libdir customization akin to --bindir.
Alon Levy (2):
configure: add libdir and --libdir
libcacard: add libcacard.la target
Makefile | 9 +++++++++ configure | 7 ++++++- libcacard/Makefile | 30 ++++++++++++++++++++++++++---- 3 files changed, 41 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.5.1
PATCH 1/2 configure: add libdir and --libdir
--- configure | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
configure +5 -0
@@ -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
Signature · 1 line
1.7.5.1
PATCH 2/2 libcacard: add libcacard.la target
In reply to Alon LevyNo 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.
--- Makefile | 9 +++++++++ configure | 2 +- libcacard/Makefile | 30 ++++++++++++++++++++++++++---- 3 files changed, 36 insertions(+), 5 deletions(-)
Makefile +9 -0
@@ -120,6 +120,15 @@ version.o: $(SRC_PATH)/version.rc config-host.mak version-obj-$(CONFIG_WIN32) += version.o ###################################################################### +.PHONY: libcacard.la install-libcacard +libcacard.la: $(GENERATED_HEADERS) $(oslib-obj-y) qemu-malloc.o qemu-timer-common.o $(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,) + +###################################################################### + qemu-img.o: qemu-img-cmds.h qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o: $(GENERATED_HEADERS)
configure +1 -1
@@ -3595,7 +3595,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 + ln -s -f "$source_path/libcacard/Makefile" libcacard/Makefile fi d=libuser
libcacard/Makefile +26 -4
@@ -4,15 +4,37 @@ $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/libcacard) -QEMU_OBJS=$(addprefix ../, $(oslib-obj-y) $(trace-obj-y) qemu-malloc.o qemu-timer-common.o) +QEMU_TRACE_OBJS=$(addprefix ../,$(trace-obj-y)) + +QEMU_BASE_OBJS=$(addprefix ../,$(oslib-obj-y) qemu-malloc.o qemu-timer-common.o) + +# objects linked against normal qemu binaries, not compiled with libtool +QEMU_OBJS = $(QEMU_BASE_OBJS) $(QEMU_TRACE_OBJS) + +# objects linked into a shared library, built with libtool with -fPIC if required +QEMU_BASE_OBJS_LIB=$(addsuffix .lo,$(basename $(QEMU_BASE_OBJS))) + +QEMU_OBJS_LIB = $(QEMU_BASE_OBJS_LIB) $(QEMU_TRACE_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 $@") -all: vscclient +$(libcacard.lib-y) $(QEMU_BASE_OBJS_LIB) : %.lo: %.c + $(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@") + +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 $@") clean: - rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient + rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient libcacard.so *.lo .libs/* *.la + rm -Rf .libs +install-libcacard: libcacard.la + $(INSTALL_DIR) "$(DESTDIR)$(libdir)" + libtool --mode=install $(INSTALL_PROG) libcacard.la "$(DESTDIR)$(libdir)" + +all: vscclient
Signature · 1 line
1.7.5.1
Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target
configure if [ "$source_path" != `pwd` ]; then · line 3598
Quoted 2 lines · Alon Levy
configure +1
-1- ln -s "$source_path/libcacard/Makefile" libcacard/Makefile + ln -s -f "$source_path/libcacard/Makefile" libcacard/Makefile
Use the "symlink" function rather than ln -s -f for portability to broken platforms, please.
Note that this requires libtool at build time rather than only for maintainers. This is unlike all other software using it. However, I believe this is not too bad given that a special make invocation is required.
Paolo
Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target
Quoted 6 lines · Paolo Bonzini
configure if [ "$source_path" != `pwd` ]; then · line 3598
Quoted 2 lines · Alon Levy
configure +1
-1- ln -s "$source_path/libcacard/Makefile" libcacard/Makefile + ln -s -f "$source_path/libcacard/Makefile" libcacard/MakefileUse the "symlink" function rather than ln -s -f for portability to broken platforms, please.
ok.
Quoted 5 lines
Note that this requires libtool at build time rather than only for maintainers. This is unlike all other software using it. However, I believe this is not too bad given that a special make invocation is required.
I was under the impression this was the way to use libtool (I've basically followed the manual). Is there another way that is better?
Quoted 2 lines
Paolo
Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target
Quoted 7 lines · Alon Levy
Quoted 4 lines
Note that this requires libtool at build time rather than only for maintainers. This is unlike all other software using it. However, I believe this is not too bad given that a special make invocation is required.
I was under the impression this was the way to use libtool (I've basically followed the manual). Is there another way that is better?
Without using Autoconf, this is the way.
Usually programs that are fully autoconf-iscated will ship a subset of libtool sources in the tarball, build a custom version at configure time, and invoke it from the Makefile via ./libtool. This has the advantage that only the maintainer needs to have libtool installed. OTOH we do not use Autoconf and I think this contributes to 99% of the bad name for Autoconf, so it's not something we want.
Paolo
Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target
Hi,
Quoted 6 lines
Usually programs that are fully autoconf-iscated will ship a subset of libtool sources in the tarball, build a custom version at configure time, and invoke it from the
Makefilevia ./libtool. This has the advantage that only the maintainer needs to have libtool installed. OTOH we do not use Autoconf and I think this contributes to 99% of the bad name for Autoconf, so it's not something we want.
Another option would be to not use autoconf at all. Building ELF shared libs isn't that difficuilt these days. Question is whenever there is any non-ELF platform we care about (Windows maybe?).
cheers,
Gerd
Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target
Quoted 8 lines · Gerd Hoffmann
Quoted 6 lines
Usually programs that are fully autoconf-iscated will ship a subset of libtool sources in the tarball, build a custom version at configure time, and invoke it from the
Makefilevia ./libtool. This has the advantage that only the maintainer needs to have libtool installed. OTOH we do not use Autoconf and I think this contributes to 99% of the bad name for Autoconf, so it's not something we want.Another option would be to not use autoconf at all.
^^^^^^^^
You probably mean libtool?
Quoted 3 lines
Building ELF shared
libs isn't that difficuilt these days. Question is whenever there is any non-ELF platform we care about (Windows maybe?).
... and Darwin?
Paolo
Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target
Quoted 11 lines · Paolo Bonzini
Quoted 8 lines · Gerd Hoffmann
Quoted 6 lines
Usually programs that are fully autoconf-iscated will ship a subset of libtool sources in the tarball, build a custom version at configure time, and invoke it from the
Makefilevia ./libtool. This has the advantage that only the maintainer needs to have libtool installed. OTOH we do not use Autoconf and I think this contributes to 99% of the bad name for Autoconf, so it's not something we want.Another option would be to not use autoconf at all.
^^^^^^^^
Quoted 8 lines
You probably mean libtool?
Quoted 3 lines
Building ELF shared
libs isn't that difficuilt these days. Question is whenever there is any non-ELF platform we care about (Windows maybe?).... and Darwin?
For linux all that is needed is to recompile all required sources with -fPIC (doesn't make sense to force that on the objects linked to the rest of qemu), and link them with gcc -shared. Does that work on Darwin? on Windows (mingw / cygwin)?
Quoted 2 lines
Paolo
Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target
Quoted 18 lines · Alon Levy
Quoted 17 lines · Paolo Bonzini
Quoted 8 lines · Gerd Hoffmann
Quoted 6 lines
Usually programs that are fully autoconf-iscated will ship a subset of libtool sources in the tarball, build a custom version at configure time, and invoke it from the
Makefilevia ./libtool. This has the advantage that only the maintainer needs to have libtool installed. OTOH we do not use Autoconf and I think this contributes to 99% of the bad name for Autoconf, so it's not something we want.Another option would be to not use autoconf at all.
^^^^^^^^You probably mean libtool?
Quoted 3 lines
Building ELF shared
libs isn't that difficuilt these days. Question is whenever there is any non-ELF platform we care about (Windows maybe?).
Quoted 6 lines
Quoted 2 lines
... and Darwin?
For linux all that is needed is to recompile all required sources with -fPIC (doesn't make sense to force that on the objects linked to the rest of qemu), and link them with gcc -shared. Does that work on Darwin? on Windows (mingw / cygwin)?
No :(
Windows is a total mess, but Darwin is only slightly better and the naming conventions differ too (.dylib instead of .so for example).
Paolo
PATCH 1/1 libcacard: add libcacard.la target
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).
Note: please ignore the following warning message, it is harmless, and fixing it would require using libtool to build trace-dtrace.lo which, since it isn't built by gcc, I don't know how to do.
*** Warning: Linking the shared library libcacard.la against the non-libtool *** objects ../trace-dtrace.o is not portable!
--- Makefile | 17 +++++++++++++++++ configure | 12 +++++++++++- libcacard/Makefile | 38 ++++++++++++++++++++++++++++++++++---- 3 files changed, 62 insertions(+), 5 deletions(-)
Makefile +17 -0
@@ -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 + +install-libcacard: + @echo libtool is missing, please install and rerun configure +else +libcacard.la: $(GENERATED_HEADERS) $(oslib-obj-y) qemu-malloc.o qemu-timer-common.o $(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)
configure +11 -1
@@ -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
libcacard/Makefile +34 -4
@@ -4,15 +4,45 @@ $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/libcacard) -QEMU_OBJS=$(addprefix ../, $(oslib-obj-y) $(trace-obj-y) qemu-malloc.o qemu-timer-common.o) +QEMU_TRACE_OBJS=$(addprefix ../,$(trace-obj-y)) + +QEMU_BASE_OBJS=$(addprefix ../,$(oslib-obj-y) qemu-malloc.o qemu-timer-common.o) + +# objects linked against normal qemu binaries, not compiled with libtool +QEMU_OBJS = $(QEMU_BASE_OBJS) $(QEMU_TRACE_OBJS) + +# objects linked into a shared library, built with libtool with -fPIC if required +QEMU_BASE_OBJS_LIB=$(addsuffix .lo,$(basename $(QEMU_BASE_OBJS))) + +QEMU_OBJS_LIB = $(QEMU_BASE_OBJS_LIB) $(QEMU_TRACE_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 libcacard.so *.lo .libs/* *.la + rm -Rf .libs all: vscclient -clean: - rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient +ifeq ($(LIBTOOL),) +libcacard.la: + @echo libtool is missing, please install and rerun configure + +install-libcacard: + @echo libtool is missing, please install and rerun configure +else +$(libcacard.lib-y) $(QEMU_BASE_OBJS_LIB) : %.lo: %.c + $(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@") + +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
Signature · 1 line
1.7.5.1
Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target
Quoted 17 lines · Alon Levy
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-libcacardUses 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).
Quoted 6 lines
Note: please ignore the following warning message, it is harmless, and fixing it would require using libtool to build trace-dtrace.lo which, since it isn't built by gcc, I don't know how to do.
*** Warning: Linking the shared library libcacard.la against the non-libtool *** objects
../trace-dtrace.ois not portable!
I don't think slipping in libtool like this is such a good idea.
Why do you need this target?
Isn't la just a static archive compiled with -fPIC? Doesn't the whole code base need to be compiled with -fPIC then (and isn't the warning above a legitimate concern?).
Regards,
Anthony Liguori
Quoted 125 lines
--- Makefile | 17 +++++++++++++++++ configure | 12 +++++++++++- libcacard/Makefile | 38 ++++++++++++++++++++++++++++++++++---- 3 files changed, 62 insertions(+), 5 deletions(-)Makefile +17
-0@@ -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 + +install-libcacard: + @echo libtool is missing, please install and rerun configure +else +libcacard.la: $(GENERATED_HEADERS) $(oslib-obj-y) qemu-malloc.o qemu-timer-common.o $(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)configure +11
-1@@ -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=libuserlibcacard/Makefile +34
-4@@ -4,15 +4,45 @@ $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/libcacard) -QEMU_OBJS=$(addprefix ../, $(oslib-obj-y) $(trace-obj-y) qemu-malloc.o qemu-timer-common.o) +QEMU_TRACE_OBJS=$(addprefix ../,$(trace-obj-y)) + +QEMU_BASE_OBJS=$(addprefix ../,$(oslib-obj-y) qemu-malloc.o qemu-timer-common.o) + +# objects linked against normal qemu binaries, not compiled with libtool +QEMU_OBJS = $(QEMU_BASE_OBJS) $(QEMU_TRACE_OBJS) + +# objects linked into a shared library, built with libtool with -fPIC if required +QEMU_BASE_OBJS_LIB=$(addsuffix .lo,$(basename $(QEMU_BASE_OBJS))) + +QEMU_OBJS_LIB = $(QEMU_BASE_OBJS_LIB) $(QEMU_TRACE_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 libcacard.so *.lo .libs/* *.la + rm -Rf .libs all: vscclient -clean: - rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient +ifeq ($(LIBTOOL),) +libcacard.la: + @echo libtool is missing, please install and rerun configure + +install-libcacard: + @echo libtool is missing, please install and rerun configure +else +$(libcacard.lib-y) $(QEMU_BASE_OBJS_LIB) : %.lo: %.c + $(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@") + +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
Paolo Bonzini
NAKRe: [Qemu-devel] [PATCH] libcacard: add libcacard.la target
Quoted 7 lines · Anthony Liguori
Quoted 5 lines
*** Warning: Linking the shared library libcacard.la against the
non-libtool
*** objects../trace-dtrace.ois not portable!I don't think slipping in libtool like this is such a good idea.
I disagree but, the warning is indeed legitimate, so
NACK
Quoted 1 line
Isn't la just a static archive compiled with -fPIC?
No, .la is a text file pointing (most importantly) to the static library, the shared library, and the dependencies of the static library.
Alon, do you need this to comply with some packaging guidelines forbidding static libraries?
Paolo
Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target
Quoted 13 lines · Paolo Bonzini
Quoted 7 lines · Anthony Liguori
Quoted 5 lines
*** Warning: Linking the shared library libcacard.la against the
non-libtool
*** objects../trace-dtrace.ois not portable!I don't think slipping in libtool like this is such a good idea.
I disagree but, the warning is indeed legitimate, so
NACK
Quoted 9 lines
Quoted 1 line
Isn't la just a static archive compiled with -fPIC?
No, .la is a text file pointing (most importantly) to the static library, the shared library, and the dependencies of the static library.
Alon, do you need this to comply with some packaging guidelines forbidding static libraries?
<Answering both you and Anthony>
I'm basically trying to replace the current shared object built by the standalone libcacard project. Since we are deprecating that on account of not wanting to maintain two code bases, I need a replacement shared object producing something somewhere. It seems best to do it within the project and not, say, as spec file for an rpm, for obvious reasons of wanting this to be distribution agnostic. I've settled on libtool as the linker solution since it seems to be the de facto standard, please correct me on this point if I'm wrong. We are not using autoconf, so I've called it directly in it's various modes, compile, link and install.
Regarding your concerns from above:
The libcacard.la target produces a shared object with the right version symlinks (libcacard.so.0.0.0, libcacard.so.0 and libcacard.so) thanks to libtool
Legitemacy of the warning: basically libtool is concerned about linking in position dependant code. But the trace-dtrace.o contains no .rodata section and is not actually a problem for the linker, I've verfied the resulting library works fine with spicec (the spice client using it).
I'd appreciate any suggestion of a replacement for libtool if it is not appropriate. Note that this building of a shared library is not something new - we've talked about this before in relation to libcacard inclusion inside qemu git repository.
Quoted 1 line
Paolo
Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target
Quoted 4 lines · Alon Levy
I've settled on libtool
as the linker solution since it seems to be the de facto standard, please correct me on this point if I'm wrong. We are not using autoconf, so I've called it directly in it's various modes, compile, link and install.
I agree. I don't dislike this particularly :) if at all.
Quoted 4 lines
Legitemacy of the warning: basically libtool is concerned about linking in position dependant code. But the trace-dtrace.o contains no .rodata section and is not actually a problem for the linker, I've verfied the resulting library works fine with spicec (the spice client using it).
I'm not sure, however, that glibc would still keep the sharing of .text.
Quoted 3 lines
I'd appreciate any suggestion of a replacement for libtool if it is not appropriate. Note that this building of a shared library is not something new - we've talked about this before in relation to libcacard inclusion inside qemu git repository.
Do you really need tracing besides as a dependency of qemu_malloc? Perhaps you can recompile qemu-malloc.o specially for libcacard, and force usage of the nop backend.
Paolo
Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target
Quoted 6 lines · Paolo Bonzini
Quoted 4 lines · Alon Levy
I've settled on libtool
as the linker solution since it seems to be the de facto standard, please correct me on this point if I'm wrong. We are not using autoconf, so I've called it directly in it's various modes, compile, link and install.
Quoted 9 lines
I agree. I don't dislike this particularly :) if at all.
Quoted 4 lines
Legitemacy of the warning: basically libtool is concerned about linking in position dependant code. But the trace-dtrace.o contains no .rodata section and is not actually a problem for the linker, I've verfied the resulting library works fine with spicec (the spice client using it).
I'm not sure, however, that glibc would still keep the sharing of .text.
I'll check.
Quoted 7 lines
Quoted 3 lines
I'd appreciate any suggestion of a replacement for libtool if it is not appropriate. Note that this building of a shared library is not something new - we've talked about this before in relation to libcacard inclusion inside qemu git repository.
Do you really need tracing besides as a dependency of
qemu_malloc? Perhaps you can recompile qemu-malloc.o specially for libcacard, and force usage of the nop backend.
Sounds like a very good idea for short term. Otoh if I'm already building libcacard with qemu dependencies, it would be nice if I could benefit from the tracing framework.
I'll investigate building trace-dtrace.lo and if this doesn't work I'll try nop backend.
Quoted 3 lines
Paolo
Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target
In reply to Anthony LiguoriQuoted 18 lines · Anthony Liguori
Quoted 17 lines · Alon Levy
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-libcacardUses 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).
Quoted 8 lines
Quoted 6 lines
Note: please ignore the following warning message, it is harmless, and fixing it would require using libtool to build trace-dtrace.lo which, since it isn't built by gcc, I don't know how to do.
*** Warning: Linking the shared library libcacard.la against the non-libtool *** objects
../trace-dtrace.ois not portable!I don't think slipping in libtool like this is such a good idea.
Forgot from my reply to Paolo: libtool is complaining about the only object I didn't rebuild, trace-dtrace.o, the rest I've added rules specifically to rebuild into lo (-fPIC'ed) objects under libcacard (including specifically any qemu support code). I didn't do the same for trace-dtrace.o because a) I didn't find an easy way of doing it on account of it not being built by gcc b) it wasn't a real problem like I mentioned in the reply to Paolo.
Quoted 2 lines
Why do you need this target?
Answered in the reply to Paolo's email.
Quoted 135 lines
Isn't la just a static archive compiled with -fPIC? Doesn't the whole code base need to be compiled with -fPIC then (and isn't the warning above a legitimate concern?).
Regards,
Anthony Liguori
Quoted 125 lines
--- Makefile | 17 +++++++++++++++++ configure | 12 +++++++++++- libcacard/Makefile | 38 ++++++++++++++++++++++++++++++++++---- 3 files changed, 62 insertions(+), 5 deletions(-)Makefile +17
-0@@ -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 + +install-libcacard: + @echo libtool is missing, please install and rerun configure +else +libcacard.la: $(GENERATED_HEADERS) $(oslib-obj-y) qemu-malloc.o qemu-timer-common.o $(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)configure +11
-1@@ -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=libuserlibcacard/Makefile +34
-4@@ -4,15 +4,45 @@ $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/libcacard) -QEMU_OBJS=$(addprefix ../, $(oslib-obj-y) $(trace-obj-y) qemu-malloc.o qemu-timer-common.o) +QEMU_TRACE_OBJS=$(addprefix ../,$(trace-obj-y)) + +QEMU_BASE_OBJS=$(addprefix ../,$(oslib-obj-y) qemu-malloc.o qemu-timer-common.o) + +# objects linked against normal qemu binaries, not compiled with libtool +QEMU_OBJS = $(QEMU_BASE_OBJS) $(QEMU_TRACE_OBJS) + +# objects linked into a shared library, built with libtool with -fPIC if required +QEMU_BASE_OBJS_LIB=$(addsuffix .lo,$(basename $(QEMU_BASE_OBJS))) + +QEMU_OBJS_LIB = $(QEMU_BASE_OBJS_LIB) $(QEMU_TRACE_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 libcacard.so *.lo .libs/* *.la + rm -Rf .libs all: vscclient -clean: - rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient +ifeq ($(LIBTOOL),) +libcacard.la: + @echo libtool is missing, please install and rerun configure + +install-libcacard: + @echo libtool is missing, please install and rerun configure +else +$(libcacard.lib-y) $(QEMU_BASE_OBJS_LIB) : %.lo: %.c + $(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@") + +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
PATCH 1/1 libcacard: add libcacard.la target
In reply to Alon LevyNo 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).
Tested to link and load with all tracing backends except ust (no default package for my development computer for ust).
--- Makefile | 20 +++++++++++++++++++- Makefile.objs | 3 +++ configure | 12 +++++++++++- libcacard/Makefile | 32 ++++++++++++++++++++++++++++---- rules.mak | 3 +++ 5 files changed, 64 insertions(+), 6 deletions(-)
Makefile +19 -1
@@ -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 + +install-libcacard: + @echo libtool is missing, please install and rerun configure +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
Makefile.objs +3 -0
@@ -344,6 +344,9 @@ 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") +trace-dtrace.lo: trace-dtrace.dtrace + $(call quiet-command,libtool --mode=compile --tag=CC dtrace -o $@ -G -s $<, " lt GEN trace-dtrace.o") + simpletrace.o: simpletrace.c $(GENERATED_HEADERS) ifeq ($(TRACE_BACKEND),dtrace)
configure +11 -1
@@ -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
libcacard/Makefile +28 -4
@@ -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 + +install-libcacard: + @echo libtool is missing, please install and rerun configure +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
rules.mak +3 -0
@@ -17,6 +17,9 @@ 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)$@") +%.lo: %.c + $(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@") + %.o: %.S $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," AS $(TARGET_DIR)$@")
Signature · 1 line
1.7.5.1
Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target
On Tue, May 17, 2011 at 03:03:45PM +0300, Alon Levy wrote:
Forgot to mention this is the v3, with the following fixes:
* no warning, properly use libtool to wrap dtrace (which calls gcc).
* tested with all tracing backends but ust (and in the process of testing that)
* moved general rule for producing .lo to rules.mak, with the exception (trace-dtrace.lo) in Makefile.objs (same as trace-dtrace.o rule)
* fixed clean to remove the artifacts.
Quoted 192 lines
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-libcacardUses 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 systemtapb1568fd85commit the -fPIC flag isn't actually passed on. still current dtrace+libtool produced object links fine).Tested to link and load with all tracing backends except ust (no default package for my development computer for ust).
--- Makefile | 20 +++++++++++++++++++- Makefile.objs | 3 +++ configure | 12 +++++++++++- libcacard/Makefile | 32 ++++++++++++++++++++++++++++---- rules.mak | 3 +++ 5 files changed, 64 insertions(+), 6 deletions(-)Makefile +19
-1@@ -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 + +install-libcacard: + @echo libtool is missing, please install and rerun configure +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-timestampMakefile.objs +3
-0@@ -344,6 +344,9 @@ 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") +trace-dtrace.lo: trace-dtrace.dtrace + $(call quiet-command,libtool --mode=compile --tag=CC dtrace -o $@ -G -s $<, " lt GEN trace-dtrace.o") + simpletrace.o: simpletrace.c $(GENERATED_HEADERS) ifeq ($(TRACE_BACKEND),dtrace)configure +11
-1@@ -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=libuserlibcacard/Makefile +28
-4@@ -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 + +install-libcacard: + @echo libtool is missing, please install and rerun configure +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)" +endifrules.mak +3
-0@@ -17,6 +17,9 @@ 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)$@") +%.lo: %.c + $(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@") + %.o: %.S $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," AS $(TARGET_DIR)$@")Signature · 1 line
1.7.5.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target
Quoted 24 lines · Alon Levy
Quoted 24 lines
Quoted 24 lines
--- Makefile | 20 +++++++++++++++++++- Makefile.objs | 3 +++ configure | 12 +++++++++++- libcacard/Makefile | 32 ++++++++++++++++++++++++++++---- rules.mak | 3 +++ 5 files changed, 64 insertions(+), 6 deletions(-)Makefile +8
-0@@ -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 + +install-libcacard:
Quoted 8 lines
Quoted 8 lines
Makefile version.o: $(SRC_PATH)/version.rc config-host.mak · line 137
Quoted 8 lines
Makefile +8
-0+ @echo libtool is missing, please install and rerun configure +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
If you instead make the .lo rules display the error message (and add "; exit 1" after the echo), you can remove this ifeq. I'll let you decide whether to do this or not.
Otherwise looks good, thanks!
Paolo
Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target
Quoted 29 lines · Paolo Bonzini
Quoted 28 lines · Alon Levy
Quoted 28 lines
Quoted 28 lines
--- Makefile | 20 +++++++++++++++++++- Makefile.objs | 3 +++ configure | 12 +++++++++++- libcacard/Makefile | 32 ++++++++++++++++++++++++++++---- rules.mak | 3 +++ 5 files changed, 64 insertions(+), 6 deletions(-)Makefile +12
-0@@ -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 + +install-libcacard: + @echo libtool is missing, please install and rerun configure +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,)
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Makefile version.o: $(SRC_PATH)/version.rc config-host.mak · line 137
Quoted 4 lines
Makefile +4
-0+ +install-libcacard: libcacard.la + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" TARGET_DIR="$*/" install-libcacard,) +endifIf you instead make the .lo rules display the error message (and add "; exit 1" after the echo), you can remove this ifeq. I'll let you decide whether to do this or not.
The reason for doing the check at high level and not low level was to avoid building any prerequisites and then find out no libtool and bail. But I think I'll add the check at the low level too like you suggest.
Quoted 5 lines
Otherwise looks good, thanks!
Paolo