Skip to contentSkip to conversation

build: pending fixes and improvements

PATCH In review Paolo Bonzini 2 participants 14 messages May 8, 2014 Kbuild

lore
Share & tools
lore
#0 lore raw

cover build: pending fixes and improvements

This is the overall set of changes to:

- do various cleanups in Makefile.target

- fix rough edges around -cflags and -libs variables, and use it more widely.

Michael Tokarev (6):
build: simplify Makefile.target a bit, use just one rule for softmmu
Makefile: strip tools and modules too
Makefile.target: use $(INSTALL_PROG) for installing, not $(INSTALL)
Makefile: use $(INSTALL_LIB) for modules not $(INSTALL_PROG)
build: convert some obj-specific CFLAGS to use new foo.o-cflags syntax
libcacard: remove libcacard-specific CFLAGS and LIBS from global vars

Paolo Bonzini (4):
build: Fix per-object variables for Makefile.target
build: simplify Makefile.target around unnest-vars invocations
build: add support for per-object -cflags and -libs to all rules
build: simplify and fix fix-obj-vars

 Makefile               | 22 ++++++++++++----------
 Makefile.objs          |  4 ++++
 Makefile.target        | 41 +++++++++++++++--------------------------
 audio/Makefile.objs    |  2 +-
 backends/Makefile.objs |  2 +-
 configure              | 17 +++++++----------
 disas/Makefile.objs    |  2 +-
 hw/usb/Makefile.objs   |  1 +
 libcacard/Makefile     |  1 -
 rules.mak              | 24 +++++++++++++-----------
 ui/Makefile.objs       |  2 +-
 11 files changed, 56 insertions(+), 62 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/10 build: Fix per-object variables for Makefile.target

The compiling is done in a subdir, so the extraction of per-object libs and cflags are referencing objects with ../ prefixed. So prefix the per-object variables "foo.o-cflags" and "foo.o-libs" to "../foo.o-cflags" and "../foo.o-libs".

---
 rules.mak | 1 +
 1 file changed, 1 insertion(+)
rules.mak +1 -0
index 5c454d8..7038576 100644
@@ -228,6 +228,7 @@ endef
 define unnest-vars
 $(eval obj := $1)
 $(eval nested-vars := $2)
+$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(if $(obj),$(obj)/)))
 $(eval old-nested-dirs := )
 $(call unnest-vars-1)
 $(if $1,$(foreach v,$(nested-vars),$(eval \
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/10 build: simplify Makefile.target a bit, use just one rule for softmmu

In reply to Paolo Bonzini

From: Michael Tokarev <[email protected]>

On win*, we build QEMU_PROGW (GUI) and create a console app QEMU_PROG from it, while on non-win*, we make only QEMU_PROG using the same rules as used for QEMU_PROGW on win*. Make just one rule for building main executable, and an additional rule for win* to make console app from it. Also consolidate tests for $(QEMU_PROGW).

[Fix user-mode compilation. - Paolo]
---
 Makefile.target | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)
Makefile.target +11 -15
index 6d8fde8..2726b74 100644
@@ -16,19 +16,22 @@ QEMU_CFLAGS+=-I$(SRC_PATH)/include
 ifdef CONFIG_USER_ONLY
 # user emulator name
 QEMU_PROG=qemu-$(TARGET_NAME)
+QEMU_PROG_BUILD = $(QEMU_PROG)
 else
 # system emulator name
+QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF)
 ifneq (,$(findstring -mwindows,$(libs_softmmu)))
 # Terminate program name with a 'w' because the linker builds a windows executable.
 QEMU_PROGW=qemu-system-$(TARGET_NAME)w$(EXESUF)
-endif # windows executable
-QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF)
+$(QEMU_PROG): $(QEMU_PROGW)
+	$(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG),"  GEN   $(TARGET_DIR)$(QEMU_PROG)")
+QEMU_PROG_BUILD = $(QEMU_PROGW)
+else
+QEMU_PROG_BUILD = $(QEMU_PROG)
 endif
-
-PROGS=$(QEMU_PROG)
-ifdef QEMU_PROGW
-PROGS+=$(QEMU_PROGW)
 endif
+
+PROGS=$(QEMU_PROG) $(QEMU_PROGW)
 STPFILES=
 
 config-target.h: config-target.h-timestamp
@@ -164,16 +167,9 @@ ifndef CONFIG_HAIKU
 LIBS+=-lm
 endif
 
-ifdef QEMU_PROGW
-# The linker builds a windows executable. Make also a console executable.
-$(QEMU_PROGW): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
-	$(call LINK,$^)
-$(QEMU_PROG): $(QEMU_PROGW)
-	$(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG),"  GEN   $(TARGET_DIR)$(QEMU_PROG)")
-else
-$(QEMU_PROG): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
+# build either PROG or PROGW
+$(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
 	$(call LINK,$^)
-endif
 
 gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
 	$(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES),"  GEN   $(TARGET_DIR)$@")
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/10 build: simplify Makefile.target around unnest-vars invocations

In reply to Paolo Bonzini

No need to save/restore obj-y, we can just build all-obj-y incrementally.

---
 Makefile.target | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
Makefile.target +2 -9
index 2726b74..261de9e 100644
@@ -143,10 +143,7 @@ endif # CONFIG_SOFTMMU
 %/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
 
 dummy := $(call unnest-vars,,obj-y)
-
-# we are making another call to unnest-vars with different vars, protect obj-y,
-# it can be overriden in subdir Makefile.objs
-obj-y-save := $(obj-y)
+all-obj-y := $(obj-y)
 
 block-obj-y :=
 common-obj-y :=
@@ -156,11 +153,7 @@ dummy := $(call unnest-vars,.., \
                block-obj-m \
                common-obj-y \
                common-obj-m)
-
-# Now restore obj-y
-obj-y := $(obj-y-save)
-
-all-obj-y = $(obj-y) $(common-obj-y)
+all-obj-y += $(common-obj-y)
 all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
 
 ifndef CONFIG_HAIKU
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 4/10 Makefile: strip tools and modules too

In reply to Paolo Bonzini

From: Michael Tokarev <[email protected]>

Commit 52ba784d3 replaced $(STRIP_OPT) with $(STRIP) in some places (for example, Makefile.target), but not all of them. There are a few places remain in main Makefile which still uses $(STRIP_OPT). Replace these places with $(STRIP) too.

While at it, simplify variable pattern substitution of the surrounding places, change $(patsubst pat,rep,$(var)) into $(var:pat=rep) which is much easier to read (this is probably a good idea to do everywhere).

---
 Makefile        | 16 ++++++++++++----
 Makefile.target |  2 +-
 2 files changed, 13 insertions(+), 5 deletions(-)
Makefile +12 -4
index 423e373..23ca444 100644
@@ -372,17 +372,25 @@ install: all $(if $(BUILD_DOCS),install-doc) install-sysconfig \
 install-datadir install-localstatedir
 	$(INSTALL_DIR) "$(DESTDIR)$(bindir)"
 ifneq ($(TOOLS),)
-	$(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) "$(DESTDIR)$(bindir)"
+	$(INSTALL_PROG) $(TOOLS) "$(DESTDIR)$(bindir)"
+ifneq ($(STRIP),)
+	$(STRIP) $(TOOLS:%="$(DESTDIR)$(bindir)/%")
+endif
 endif
 ifneq ($(CONFIG_MODULES),)
 	$(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
-	for s in $(patsubst %.mo,%$(DSOSUF),$(modules-m)); do \
-		$(INSTALL_PROG) $(STRIP_OPT) $$s "$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
+	for s in $(modules-m:.mo=$(DSOSUF)); do \
+		t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
+		$(INSTALL_PROG) $$s "$$t"; \
+		test -z "$(STRIP)" || $(STRIP) "$$t"; \
 	done
 endif
 ifneq ($(HELPERS-y),)
 	$(INSTALL_DIR) "$(DESTDIR)$(libexecdir)"
-	$(INSTALL_PROG) $(STRIP_OPT) $(HELPERS-y) "$(DESTDIR)$(libexecdir)"
+	$(INSTALL_PROG) $(HELPERS-y) "$(DESTDIR)$(libexecdir)"
+ifneq ($(STRIP),)
+	$(STRIP) $(HELPERS-y:%="$(DESTDIR)$(libexecdir)/%")
+endif
 endif
 ifneq ($(BLOBS),)
 	set -e; for x in $(BLOBS); do \
Makefile.target +1 -1
index 261de9e..8fc606f 100644
@@ -185,7 +185,7 @@ install: all
 ifneq ($(PROGS),)
 	$(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)"
 ifneq ($(STRIP),)
-	$(STRIP) $(patsubst %,"$(DESTDIR)$(bindir)/%",$(PROGS))
+	$(STRIP) $(PROGS:%="$(DESTDIR)$(bindir)/%")
 endif
 endif
 ifdef CONFIG_TRACE_SYSTEMTAP
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 5/10 Makefile.target: use $(INSTALL_PROG) for installing, not $(INSTALL)

In reply to Paolo Bonzini

From: Michael Tokarev <[email protected]>

$(INSTALL_PROG) is evaluated to libtool if using libtool, while $(INSTALL) is not. Use $(INSTALL_PROG) so that libtool is used with target too when necessary. This allows, for example, to link qemu with shared libcacard.

--
This is done on top of previous patch (using $(STRIP)), but it can be used by its own.

---
 Makefile.target | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile.target +1 -1
index 8fc606f..9986047 100644
@@ -183,7 +183,7 @@ endif
 
 install: all
 ifneq ($(PROGS),)
-	$(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)"
+	$(INSTALL_PROG) $(PROGS) "$(DESTDIR)$(bindir)"
 ifneq ($(STRIP),)
 	$(STRIP) $(PROGS:%="$(DESTDIR)$(bindir)/%")
 endif
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 6/10 Makefile: use $(INSTALL_LIB) for modules not $(INSTALL_PROG)

In reply to Paolo Bonzini

From: Michael Tokarev <[email protected]>

We have $(INSTALL_LIB) which is the same as $(INSTALL_PROG) but uses correct permissions. Loadable objects (modules) are like shared libraries, not like programs.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 23ca444..12ea464 100644
@@ -381,7 +381,7 @@ ifneq ($(CONFIG_MODULES),)
 	$(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
 	for s in $(modules-m:.mo=$(DSOSUF)); do \
 		t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
-		$(INSTALL_PROG) $$s "$$t"; \
+		$(INSTALL_LIB) $$s "$$t"; \
 		test -z "$(STRIP)" || $(STRIP) "$$t"; \
 	done
 endif
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH 7/10 build: add support for per-object -cflags and -libs to all rules

In reply to Paolo Bonzini

This is needed in order to use per-object flags variables.

---
 rules.mak | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
rules.mak +5 -5
index 7038576..73efafe 100644
@@ -45,7 +45,7 @@ LINK = $(call quiet-command,$(LINKPROG) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $
 else
 LIBTOOL += $(if $(V),,--quiet)
 %.lo: %.c
-	$(call quiet-command,$(LIBTOOL) --mode=compile --tag=CC $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  lt CC $@")
+	$(call quiet-command,$(LIBTOOL) --mode=compile --tag=CC $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($*.o-cflags) -c -o $@ $<,"  lt CC $@")
 %.lo: %.rc
 	$(call quiet-command,$(LIBTOOL) --mode=compile --tag=RC $(WINDRES) -I. -o $@ $<,"lt RC   $(TARGET_DIR)$@")
 %.lo: %.dtrace
@@ -57,7 +57,7 @@ LINK = $(call quiet-command,\
        $(call expand-objs,$1) \
        $(if $(filter %.lo %.la,$1),$(version-lobj-y),$(version-obj-y)) \
        $(if $(filter %.lo %.la,$1),$(LIBTOOLFLAGS)) \
-       $(call extract-libs,$1) $(LIBS),$(if $(filter %.lo %.la,$1),"lt LINK ", "  LINK  ")"$(TARGET_DIR)$@")
+       $(call extract-libs,$(1:.lo=.o)) $(LIBS),$(if $(filter %.lo %.la,$1),"lt LINK ", "  LINK  ")"$(TARGET_DIR)$@")
 endif
 
 %.asm: %.S
@@ -67,13 +67,13 @@ endif
 	$(call quiet-command,$(AS) $(ASFLAGS) -o $@ $<,"  AS    $(TARGET_DIR)$@")
 
 %.o: %.cc
-	$(call quiet-command,$(CXX) $(QEMU_INCLUDES) $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CXX   $(TARGET_DIR)$@")
+	$(call quiet-command,$(CXX) $(QEMU_INCLUDES) $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) -c -o $@ $<,"  CXX   $(TARGET_DIR)$@")
 
 %.o: %.cpp
-	$(call quiet-command,$(CXX) $(QEMU_INCLUDES) $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CXX   $(TARGET_DIR)$@")
+	$(call quiet-command,$(CXX) $(QEMU_INCLUDES) $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) -c -o $@ $<,"  CXX   $(TARGET_DIR)$@")
 
 %.o: %.m
-	$(call quiet-command,$(OBJCC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
+	$(call quiet-command,$(OBJCC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
 
 %.o: %.dtrace
 	$(call quiet-command,dtrace -o $@ -G -s $<, "  GEN   $(TARGET_DIR)$@")
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH 8/10 build: convert some obj-specific CFLAGS to use new foo.o-cflags syntax

In reply to Paolo Bonzini

From: Michael Tokarev <[email protected]>

Current Makefile system allows using foo.o-cflags variables to store object-specific CFLAGS. Convert some usages of old syntax (using QEMU_CFLAGS += construct) to the new syntax.

Do not touch multifile modules for now, as build system isn't ready for this.

---
 Makefile               | 6 ------
 Makefile.objs          | 2 ++
 audio/Makefile.objs    | 2 +-
 backends/Makefile.objs | 2 +-
 disas/Makefile.objs    | 2 +-
 ui/Makefile.objs       | 2 +-
 6 files changed, 6 insertions(+), 10 deletions(-)
Makefile +0 -6
index 12ea464..52442bf 100644
@@ -148,10 +148,6 @@ endif
 
 all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
 
-vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
-
-vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
-
 config-host.h: config-host.h-timestamp
 config-host.h-timestamp: config-host.mak
 qemu-options.def: $(SRC_PATH)/qemu-options.hx
@@ -195,8 +191,6 @@ ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
 
 recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
 
-bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
-
 $(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc $(BUILD_DIR)/config-host.h | $(BUILD_DIR)/version.lo
 	$(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"  RC    version.o")
 $(BUILD_DIR)/version.lo: $(SRC_PATH)/version.rc $(BUILD_DIR)/config-host.h
Makefile.objs +2 -0
index a6e0e2a..f0069ba 100644
@@ -64,9 +64,11 @@ common-obj-y += hw/
 
 common-obj-y += ui/
 common-obj-y += bt-host.o bt-vhci.o
+bt-host.o-cflags := $(BLUEZ_CFLAGS)
 
 common-obj-y += dma-helpers.o
 common-obj-y += vl.o
+vl.o-cflags := $(GPROF_CFLAGS) $(SDL_CFLAGS)
 common-obj-y += tpm.o
 
 common-obj-$(CONFIG_SLIRP) += slirp/
audio/Makefile.objs +1 -1
index d71a877..26a0ac9 100644
@@ -14,4 +14,4 @@ common-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
 common-obj-y += wavcapture.o
 
 $(obj)/audio.o $(obj)/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS)
-$(obj)/sdlaudio.o: QEMU_CFLAGS += $(SDL_CFLAGS)
+sdlaudio.o-cflags := $(SDL_CFLAGS)
backends/Makefile.objs +1 -1
index 42557d5..591ddcf 100644
@@ -3,6 +3,6 @@ common-obj-$(CONFIG_POSIX) += rng-random.o
 
 common-obj-y += msmouse.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
-$(obj)/baum.o: QEMU_CFLAGS += $(SDL_CFLAGS) 
+baum.o-cflags := $(SDL_CFLAGS)
 
 common-obj-$(CONFIG_TPM) += tpm.o
disas/Makefile.objs +1 -1
index 41c2374..8dae4da 100644
@@ -4,7 +4,7 @@ common-obj-$(CONFIG_ARM_DIS) += arm.o
 common-obj-$(CONFIG_ARM_A64_DIS) += arm-a64.o
 common-obj-$(CONFIG_ARM_A64_DIS) += libvixl/
 libvixldir = $(SRC_PATH)/disas/libvixl
-$(obj)/arm-a64.o: QEMU_CFLAGS += -I$(libvixldir)
+arm-a64.o-cflags := -I$(libvixldir)
 common-obj-$(CONFIG_CRIS_DIS) += cris.o
 common-obj-$(CONFIG_HPPA_DIS) += hppa.o
 common-obj-$(CONFIG_I386_DIS) += i386.o
ui/Makefile.objs +1 -1
index 6f2294e..4af420b 100644
@@ -17,4 +17,4 @@ common-obj-$(CONFIG_GTK) += gtk.o x_keymap.o
 
 $(obj)/sdl.o $(obj)/sdl_zoom.o $(obj)/sdl2.o: QEMU_CFLAGS += $(SDL_CFLAGS)
 
-$(obj)/gtk.o: QEMU_CFLAGS += $(GTK_CFLAGS) $(VTE_CFLAGS)
+gtk.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS)
Signature · 1 line
1.8.3.1
#9 lore raw

PATCH 9/10 build: simplify and fix fix-obj-vars

In reply to Paolo Bonzini

fix-obj-vars has the undesired side effect of breaking -cflags -objs and -libs variables in the toplevel Makefile.objs. The variables in the toplevel Makefile.objs do not need any fix, so fix-obj-vars need not do anything.

Since we are touching it, remove the now unnecessary $(if) in the callers.

---
 rules.mak | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
rules.mak +8 -7
index 73efafe..0157bc4 100644
@@ -175,16 +175,17 @@ $(eval save-$2-$1 :=)
 endef
 
 define fix-obj-vars
-$(foreach v,$($1), \
+$(if $2,
+  $(foreach v,$($1), \
 	$(if $($v-cflags), \
-		$(eval $2$v-cflags := $($v-cflags)) \
+		$(eval $2/$v-cflags := $($v-cflags)) \
 		$(eval $v-cflags := )) \
 	$(if $($v-libs), \
-		$(eval $2$v-libs := $($v-libs)) \
+		$(eval $2/$v-libs := $($v-libs)) \
 		$(eval $v-libs := )) \
 	$(if $($v-objs), \
-		$(eval $2$v-objs := $(addprefix $2,$($v-objs))) \
-		$(eval $v-objs := )))
+		$(eval $2/$v-objs := $(addprefix $2/,$($v-objs))) \
+		$(eval $v-objs := ))))
 endef
 
 define unnest-dir
@@ -192,7 +193,7 @@ $(foreach var,$(nested-vars),$(call push-var,$(var),$1/))
 $(eval obj-parent-$1 := $(obj))
 $(eval obj := $(if $(obj),$(obj)/$1,$1))
 $(eval include $(SRC_PATH)/$1/Makefile.objs)
-$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(if $(obj),$(obj)/)))
+$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(obj)))
 $(eval obj := $(obj-parent-$1))
 $(eval obj-parent-$1 := )
 $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/))
@@ -228,7 +229,7 @@ endef
 define unnest-vars
 $(eval obj := $1)
 $(eval nested-vars := $2)
-$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(if $(obj),$(obj)/)))
+$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(obj)))
 $(eval old-nested-dirs := )
 $(call unnest-vars-1)
 $(if $1,$(foreach v,$(nested-vars),$(eval \
Signature · 1 line
1.8.3.1
#10 lore raw

Re: [Qemu-devel] [PATCH 09/10] build: simplify and fix fix-obj-vars

Quoted 5 lines · Paolo Bonzini

fix-obj-vars has the undesired side effect of breaking -cflags -objs and -libs variables in the toplevel Makefile.objs. The variables in the toplevel Makefile.objs do not need any fix, so fix-obj-vars need not do anything.

[]

rules.mak endef · line 235

Quoted 9 lines
rules.mak +1 -1
@@ -228,7 +229,7 @@ endef
 define unnest-vars
 $(eval obj := $1)
 $(eval nested-vars := $2)
-$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(if $(obj),$(obj)/)))
+$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(obj)))
 $(eval old-nested-dirs := )
 $(call unnest-vars-1)
 $(if $1,$(foreach v,$(nested-vars),$(eval \

How about ditching 01/10 and replacing it with this 09/10 ?

Thanks,

/mjt

#11 lore raw

Re: [Qemu-devel] [PATCH 09/10] build: simplify and fix fix-obj-vars

Il 08/05/2014 15:53, Michael Tokarev ha scritto:

Quoted 7 lines
Quoted 5 lines · Paolo Bonzini

fix-obj-vars has the undesired side effect of breaking -cflags -objs and -libs variables in the toplevel Makefile.objs. The variables in the toplevel Makefile.objs do not need any fix, so fix-obj-vars need not do anything.

[]

Quoted 11 lines

rules.mak endef · line 235

Quoted 9 lines
rules.mak +1 -1
@@ -228,7 +229,7 @@ endef
 define unnest-vars
 $(eval obj := $1)
 $(eval nested-vars := $2)
-$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(if $(obj),$(obj)/)))
+$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(obj)))
 $(eval old-nested-dirs := )
 $(call unnest-vars-1)
 $(if $1,$(foreach v,$(nested-vars),$(eval \

How about ditching 01/10 and replacing it with this 09/10 ?

I was thinking about that, but in the end the two fixes are different, and given the code is tricky, small patches are preferrable.

Paolo

#12 lore raw

PATCH 10/10 libcacard: remove libcacard-specific CFLAGS and LIBS from global vars

In reply to Paolo Bonzini

From: Michael Tokarev <[email protected]>

Currently all what's needed for single file libcacard/vcard_emul_nss.c (libnss cflags) and hw/usb/ccid-card-emulated.c (libcacard includes) together with the libs is added to global QEMU_CFLAGS and libs_softmmu.

Use the cflags only where really used (for two mentioned files), and libs only where needed.

While at it, rename variables to better reflect reality: libcacard_* is really nss_*.

This needs a bit more tweaking: $(NSS_LIBS) should not contain $glib_libs (ditto for _cflags). But in order to fix it, some more preparations should be made first. So add a FIXME comment.

---
 Makefile.objs        |  2 ++
 configure            | 17 +++++++----------
 hw/usb/Makefile.objs |  1 +
 libcacard/Makefile   |  1 -
 4 files changed, 10 insertions(+), 11 deletions(-)
Makefile.objs +2 -0
index f0069ba..b897e1d 100644
@@ -31,6 +31,8 @@ libcacard-y += libcacard/vcard_emul_nss.o
 libcacard-y += libcacard/vcard_emul_type.o
 libcacard-y += libcacard/card_7816.o
 libcacard-y += libcacard/vcardt.o
+libcacard/vcard_emul_nss.o-cflags := $(NSS_CFLAGS)
+libcacard/vcard_emul_nss.o-libs := $(NSS_LIBS)
 
 ######################################################################
 # Target independent part of system emulation. The long term path is to
configure +7 -10
index ac2fa15..25d59f9 100755
@@ -3470,10 +3470,10 @@ if test "$smartcard_nss" != "no"; then
 #include <pk11pub.h>
 int main(void) { PK11_FreeSlot(0); return 0; }
 EOF
-    smartcard_includes="-I\$(SRC_PATH)/libcacard"
-    libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
-    libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
-    test_cflags="$libcacard_cflags"
+    # FIXME: do not include $glib_* in here
+    nss_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
+    nss_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
+    test_cflags="$nss_cflags"
     # The header files in nss < 3.13.3 have a bug which causes them to
     # emit a warning. If we're going to compile QEMU with -Werror, then
     # test that the headers don't have this bug. Otherwise we would pass
@@ -3483,11 +3483,8 @@ EOF
     fi
     if test -n "$libtool" &&
        $pkg_config --atleast-version=3.12.8 nss && \
-      compile_prog "$test_cflags" "$libcacard_libs"; then
+      compile_prog "$test_cflags" "$nss_libs"; then
         smartcard_nss="yes"
-        QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
-        QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
-        libs_softmmu="$libcacard_libs $libs_softmmu"
     else
         if test "$smartcard_nss" = "yes"; then
             feature_not_found "nss"
@@ -4499,8 +4496,8 @@ fi
 
 if test "$smartcard_nss" = "yes" ; then
   echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
-  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
-  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
+  echo "NSS_LIBS=$nss_libs" >> $config_host_mak
+  echo "NSS_CFLAGS=$nss_cflags" >> $config_host_mak
 fi
 
 if test "$libusb" = "yes" ; then
hw/usb/Makefile.objs +1 -0
index 17d460c..3fe4dff 100644
@@ -24,6 +24,7 @@ ifeq ($(CONFIG_USB_SMARTCARD),y)
 common-obj-y                          += dev-smartcard-reader.o
 common-obj-y                          += ccid-card-passthru.o
 common-obj-$(CONFIG_SMARTCARD_NSS)    += ccid-card-emulated.o
+ccid-card-emulated.o-cflags := -I$(SRC_PATH)/libcacard
 endif
 
 ifeq ($(CONFIG_POSIX),y)
libcacard/Makefile +0 -1
index 6b06448..881b222 100644
@@ -25,7 +25,6 @@ vscclient$(EXESUF): libcacard/vscclient.o libcacard.la
 
 libcacard.la: LDFLAGS += -rpath $(libdir) -no-undefined \
 	-export-syms $(SRC_PATH)/libcacard/libcacard.syms
-libcacard.la: LIBS = $(libcacard_libs)
 libcacard.la: $(libcacard-lobj-y)
 	$(call LINK,$^)
 
Signature · 1 line
1.8.3.1
#13 lore raw

Re: [Qemu-devel] [PATCH 10/10] libcacard: remove libcacard-specific CFLAGS and LIBS from global vars

Quoted 9 lines · Paolo Bonzini

From: Michael Tokarev <[email protected]>

Currently all what's needed for single file libcacard/vcard_emul_nss.c (libnss cflags) and hw/usb/ccid-card-emulated.c (libcacard includes) together with the libs is added to global QEMU_CFLAGS and libs_softmmu.

Use the cflags only where really used (for two mentioned files), and libs only where needed.

Quoted 6 lines

While at it, rename variables to better reflect reality: libcacard_* is really nss_*.

This needs a bit more tweaking: $(NSS_LIBS) should not contain $glib_libs (ditto for _cflags). But in order to fix it, some more preparations should be made first. So add a FIXME comment.

[]

Quoted 5 lines
configure +0 -0
index ac2fa15..25d59f9 100755

configure if test "$smartcard_nss" != "no"; then · line 3475

Quoted 10 lines
configure +3 -4
@@ -3470,10 +3470,10 @@ if test "$smartcard_nss" != "no"; then
 #include <pk11pub.h>
 int main(void) { PK11_FreeSlot(0); return 0; }
 EOF
-    smartcard_includes="-I\$(SRC_PATH)/libcacard"
-    libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
-    libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
-    test_cflags="$libcacard_cflags"
+    # FIXME: do not include $glib_* in here
+    nss_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
+    nss_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"

glib_cflags isn't needed here, only glib_libs. Or else glib_cflags is added twice (doen't hurt, just bigger command line)

FWIW.

Thanks,

/mjt