Olaf Hering
2012-Mar-28  18:56 UTC
[PATCH] tools/configure: add options to pass EXTRA_CLFAGS
config/Tools.mk.in                  |  4 ++++
 tools/Makefile                      |  2 ++
 tools/blktap/drivers/Makefile       |  2 ++
 tools/blktap/lib/Makefile           |  2 ++
 tools/blktap2/Makefile              |  2 ++
 tools/blktap2/control/Makefile      |  2 ++
 tools/blktap2/drivers/Makefile      |  2 ++
 tools/blktap2/lvm/Makefile          |  2 ++
 tools/blktap2/vhd/Makefile          |  2 ++
 tools/blktap2/vhd/lib/Makefile      |  2 ++
 tools/configure.ac                  |  6 ++++++
 tools/console/Makefile              |  3 +++
 tools/debugger/kdd/Makefile         |  3 +++
 tools/debugger/xenitp/Makefile      |  2 ++
 tools/flask/utils/Makefile          |  2 ++
 tools/libaio/src/Makefile           |  3 +++
 tools/libfsimage/Makefile           |  2 ++
 tools/libvchan/Makefile             |  2 ++
 tools/libxc/Makefile                |  2 ++
 tools/libxen/Makefile               |  2 ++
 tools/libxl/Makefile                |  2 ++
 tools/memshr/Makefile               |  2 ++
 tools/misc/Makefile                 |  2 ++
 tools/misc/lomount/Makefile         |  4 +++-
 tools/misc/nsplitd/Makefile         |  2 ++
 tools/pygrub/Makefile               |  2 ++
 tools/python/Makefile               |  2 ++
 tools/tests/Makefile                |  3 +++
 tools/tests/mce-test/tools/Makefile |  2 ++
 tools/tests/mem-sharing/Makefile    |  2 ++
 tools/tests/xen-access/Makefile     |  2 ++
 tools/xcutils/Makefile              |  2 ++
 tools/xenbackendd/Makefile          |  3 +++
 tools/xenmon/Makefile               |  3 +++
 tools/xenpaging/Makefile            |  2 ++
 tools/xenpmd/Makefile               |  2 ++
 tools/xenstat/Makefile              |  2 ++
 tools/xenstat/libxenstat/Makefile   |  2 ++
 tools/xenstat/xentop/Makefile       |  2 ++
 tools/xenstore/Makefile             |  2 ++
 tools/xentrace/Makefile             |  3 +++
 41 files changed, 96 insertions(+), 1 deletions(-)
# HG changeset patch
# User Olaf Hering <olaf@aepfle.de>
# Date 1332960970 -7200
# Node ID bb6c07589982cd206f7397d58cc73ac2cdb00fd0
# Parent  1821c05638dfe76f36625f3555c8b3e9108180e0
tools/configure: add options to pass EXTRA_CLFAGS
Currently qemu-xen will be compiled with CFLAGS only if CFLAGS was
already in the environment during make invocation. If CFLAGS is in
environment then make will append all of the various flags specified in
xen Makefiles to this environment variable, which is then used in qemu
configure. Since qemu-xen is not ready for compiler flags like
"-std=gnu99" compilation will fail. If CFLAGS is not in environment,
then configure will use just "-O2 -g" because make does not export its
own CFLAGS variable.
From a distro perspective, it is required to build libraries and
binaries with certain global cflags (arbitrary gcc options). Up to the
point when qemu-xen was imported it worked as expected by exporting
CFLAGS before ''make tools''.  Now qemu-upstream reuses these
CFLAGS, but
it cant deal with the result.
This patch extends configure to recognize three environment variables
which will be written to config/Tools.mk so they will be reused with
each make invocation:
  EXTRA_CFLAGS_XEN_TOOLS= specifies CFLAGS for the tools build.
  EXTRA_CFLAGS_QEMU_TRADITIONAL= specifies CFLAGS for old qemu.
  EXTRA_CFLAGS_QEMU_XEN= specifies CFLAGS for new qemu.
The new feature can be used like this in a rpm xen.spec file:
   env \
   EXTRA_CFLAGS_XEN_TOOLS="${RPM_OPT_FLAGS}" \
   EXTRA_CFLAGS_QEMU_TRADITIONAL="${RPM_OPT_FLAGS}" \
   EXTRA_CFLAGS_QEMU_XEN="${RPM_OPT_FLAGS}" \
   ./configure \
   	--libdir=%{_libdir} \
   	--prefix=/usr
   make
v3:
 - move EXTRA_CFLAGS_XEN_TOOLS from rules in tools/Rules.mk to every
   Makefile except firmware because it runs in guest context and can not
   deal with gcc options like -fstack-protector. This turns
   EXTRA_CFLAGS_XEN_TOOLS into a HOST_CFLAGS kind of thing.
v2:
 - add new EXTRA_CFLAGS_XEN_TOOLS variable to config/Tools.mk.in instead
   of modifying CFLAGS in this file. Also remove include order change in
   tools/Rules.mk since its now not needed anymore
 - add EXTRA_CFLAGS_XEN_TOOLS to all rules in tools/Rules.mk
 - update help output in tools/configure.ac
Signed-off-by: Olaf Hering <olaf@aepfle.de>
diff -r 1821c05638df -r bb6c07589982 config/Tools.mk.in
--- a/config/Tools.mk.in
+++ b/config/Tools.mk.in
@@ -22,6 +22,10 @@ PREPEND_LIB         := @PREPEND_LIB@
 APPEND_INCLUDES     := @APPEND_INCLUDES@
 APPEND_LIB          := @APPEND_LIB@
 
+EXTRA_CFLAGS_XEN_TOOLS        := @EXTRA_CFLAGS_XEN_TOOLS@
+EXTRA_CFLAGS_QEMU_TRADITIONAL := @EXTRA_CFLAGS_QEMU_TRADITIONAL@
+EXTRA_CFLAGS_QEMU_XEN         := @EXTRA_CFLAGS_QEMU_XEN@
+
 # Download GIT repositories via HTTP or GIT''s own protocol?
 # GIT''s protocol is faster and more robust, when it works at all
(firewalls
 # may block it). We make it the default, but if your GIT repository downloads
diff -r 1821c05638df -r bb6c07589982 tools/Makefile
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -122,6 +122,7 @@ subdir-all-qemu-xen-traditional-dir subd
 	set -e; \
 		$(buildmakevars2shellvars); \
 		cd qemu-xen-traditional-dir; \
+		env CFLAGS="$(EXTRA_CFLAGS_QEMU_TRADITIONAL)" \
 		$(QEMU_ROOT)/xen-setup $(IOEMU_CONFIGURE_CROSS); \
 		$(MAKE) install
 
@@ -146,6 +147,7 @@ subdir-all-qemu-xen-dir subdir-install-q
 		source=.; \
 	fi; \
 	cd qemu-xen-dir; \
+	env CFLAGS="$(EXTRA_CFLAGS_QEMU_XEN)" \
 	$$source/configure --enable-xen --target-list=i386-softmmu \
 		--source-path=$$source \
 		--extra-cflags="-I$(XEN_ROOT)/tools/include \
diff -r 1821c05638df -r bb6c07589982 tools/blktap/drivers/Makefile
--- a/tools/blktap/drivers/Makefile
+++ b/tools/blktap/drivers/Makefile
@@ -35,6 +35,8 @@ else
 AIOLIBS     := -laio
 endif
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LDLIBS_blktapctrl := $(MEMSHRLIBS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore)
-L../lib -lblktap -lrt -lm -lpthread
 LDLIBS_img := $(AIOLIBS) $(CRYPT_LIB) -lpthread -lz
 
diff -r 1821c05638df -r bb6c07589982 tools/blktap/lib/Makefile
--- a/tools/blktap/lib/Makefile
+++ b/tools/blktap/lib/Makefile
@@ -19,6 +19,8 @@ CFLAGS   += -fPIC
 # get asprintf():
 CFLAGS   += -D _GNU_SOURCE
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 OBJS     = $(SRCS:.c=.o)
 OBJS_PIC = $(SRCS:.c=.opic)
 IBINS   :diff -r 1821c05638df -r bb6c07589982 tools/blktap2/Makefile
--- a/tools/blktap2/Makefile
+++ b/tools/blktap2/Makefile
@@ -2,6 +2,8 @@ XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS  += $(CFLAGS_libxenctrl)
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LDLIBS += $(LDLIBS_libxenctrl)
 
 SUBDIRS-y :diff -r 1821c05638df -r bb6c07589982 tools/blktap2/control/Makefile
--- a/tools/blktap2/control/Makefile
+++ b/tools/blktap2/control/Makefile
@@ -16,6 +16,8 @@ CFLAGS            += $(CFLAGS_libxenctrl
 CFLAGS            += -D_GNU_SOURCE
 CFLAGS            += -DTAPCTL
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 CTL_OBJS  := tap-ctl-ipc.o
 CTL_OBJS  += tap-ctl-list.o
 CTL_OBJS  += tap-ctl-allocate.o
diff -r 1821c05638df -r bb6c07589982 tools/blktap2/drivers/Makefile
--- a/tools/blktap2/drivers/Makefile
+++ b/tools/blktap2/drivers/Makefile
@@ -49,6 +49,8 @@ ifeq ($(VHD_STATIC),y)
 td-util: CFLAGS += -static
 endif
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 PORTABLE-OBJS-y : PORTABLE-OBJS-$(CONFIG_Linux)  += blk_linux.o
 PORTABLE-OBJS-$(CONFIG_NetBSD) += blk_netbsd.o
diff -r 1821c05638df -r bb6c07589982 tools/blktap2/lvm/Makefile
--- a/tools/blktap2/lvm/Makefile
+++ b/tools/blktap2/lvm/Makefile
@@ -15,6 +15,8 @@ ifeq ($(CONFIG_X86_64),y)
 CFLAGS            += -fPIC
 endif
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LVM-OBJS          := lvm-util.o
 
 all: build
diff -r 1821c05638df -r bb6c07589982 tools/blktap2/vhd/Makefile
--- a/tools/blktap2/vhd/Makefile
+++ b/tools/blktap2/vhd/Makefile
@@ -21,6 +21,8 @@ ifeq ($(VHD_STATIC),y)
 CFLAGS            += -static
 endif
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LIBS              := -Llib -lvhd
 
 all: subdirs-all build
diff -r 1821c05638df -r bb6c07589982 tools/blktap2/vhd/lib/Makefile
--- a/tools/blktap2/vhd/lib/Makefile
+++ b/tools/blktap2/vhd/lib/Makefile
@@ -19,6 +19,8 @@ CFLAGS          += -D_GNU_SOURCE
 CFLAGS          += -fPIC
 CFLAGS          += -g
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 ifeq ($(CONFIG_Linux),y)
 LIBS            := -luuid
 endif
diff -r 1821c05638df -r bb6c07589982 tools/configure.ac
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -55,6 +55,12 @@ AC_ARG_VAR([APPEND_INCLUDES],
     [List of include folders to append to CFLAGS (without -I)])
 AC_ARG_VAR([APPEND_LIB],
     [List of library folders to append to LDFLAGS (without -L)])
+AC_ARG_VAR([EXTRA_CFLAGS_XEN_TOOLS],
+    [Extra CFLAGS to build Xen tools])
+AC_ARG_VAR([EXTRA_CFLAGS_QEMU_TRADITIONAL],
+    [Extra CFLAGS to build qemu-xen-traditional])
+AC_ARG_VAR([EXTRA_CFLAGS_QEMU_XEN],
+    [Extra CFLAGS to build qemu-xen-upstream])
 
 AX_SET_FLAGS
 
diff -r 1821c05638df -r bb6c07589982 tools/console/Makefile
--- a/tools/console/Makefile
+++ b/tools/console/Makefile
@@ -5,6 +5,9 @@ CFLAGS  += -Werror
 
 CFLAGS  += $(CFLAGS_libxenctrl)
 CFLAGS  += $(CFLAGS_libxenstore)
+
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LDLIBS += $(LDLIBS_libxenctrl)
 LDLIBS += $(LDLIBS_libxenstore)
 LDLIBS += $(SOCKET_LIBS)
diff -r 1821c05638df -r bb6c07589982 tools/debugger/kdd/Makefile
--- a/tools/debugger/kdd/Makefile
+++ b/tools/debugger/kdd/Makefile
@@ -2,6 +2,9 @@ XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS  += $(CFLAGS_libxenctrl)
+
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LDLIBS  += $(LDLIBS_libxenctrl)
 
 CFILES  := kdd.c kdd-xen.c
diff -r 1821c05638df -r bb6c07589982 tools/debugger/xenitp/Makefile
--- a/tools/debugger/xenitp/Makefile
+++ b/tools/debugger/xenitp/Makefile
@@ -5,6 +5,8 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS  += $(CFLAGS_libxenctrl)
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LIBBIN   = 
 
 ifeq ($(XEN_TARGET_ARCH),ia64)
diff -r 1821c05638df -r bb6c07589982 tools/flask/utils/Makefile
--- a/tools/flask/utils/Makefile
+++ b/tools/flask/utils/Makefile
@@ -4,6 +4,8 @@ include $(XEN_ROOT)/tools/Rules.mk
 CFLAGS += -Wall -g -Werror
 CFLAGS += $(CFLAGS_libxenctrl)
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 TESTDIR  = testsuite/tmp
 TESTFLAGS= -DTESTING
 TESTENV  = XENSTORED_ROOTDIR=$(TESTDIR) XENSTORED_RUNDIR=$(TESTDIR)
diff -r 1821c05638df -r bb6c07589982 tools/libaio/src/Makefile
--- a/tools/libaio/src/Makefile
+++ b/tools/libaio/src/Makefile
@@ -7,6 +7,9 @@ libdir=$(prefix)/lib
 
 ARCH := $(shell uname -m | sed -e s/i.86/i386/)
 CFLAGS = -nostdlib -nostartfiles -Wall -I. -g -fomit-frame-pointer -O2 -fPIC
+
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 SO_CFLAGS=-shared $(CFLAGS)
 L_CFLAGS=$(CFLAGS)
 LINK_FLAGSdiff -r 1821c05638df -r bb6c07589982 tools/libfsimage/Makefile
--- a/tools/libfsimage/Makefile
+++ b/tools/libfsimage/Makefile
@@ -1,6 +1,8 @@
 XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 SUBDIRS-y = common ufs reiserfs iso9660 fat zfs
 SUBDIRS-$(CONFIG_X86) += xfs
 ifeq ($(CONFIG_EXT2FS), y)
diff -r 1821c05638df -r bb6c07589982 tools/libvchan/Makefile
--- a/tools/libvchan/Makefile
+++ b/tools/libvchan/Makefile
@@ -19,6 +19,8 @@ MINOR = 0
 
 CFLAGS += -I../include -I.
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 .PHONY: all
 all: libxenvchan.so vchan-node1 vchan-node2 libxenvchan.a
 
diff -r 1821c05638df -r bb6c07589982 tools/libxc/Makefile
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -73,6 +73,8 @@ CFLAGS   += -I. $(CFLAGS_xeninclude)
 # Needed for posix_fadvise64() in xc_linux.c
 CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 # Define this to make it possible to run valgrind on code linked with these
 # libraries.
 #CFLAGS   += -DVALGRIND -O0 -ggdb3
diff -r 1821c05638df -r bb6c07589982 tools/libxen/Makefile
--- a/tools/libxen/Makefile
+++ b/tools/libxen/Makefile
@@ -26,6 +26,8 @@ CFLAGS += -Iinclude                     
           $(shell $(CURL_CONFIG) --cflags) \
           -fPIC
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LDFLAGS += $(shell $(XML2_CONFIG) --libs) \
            $(shell $(CURL_CONFIG) --libs)
 
diff -r 1821c05638df -r bb6c07589982 tools/libxl/Makefile
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -72,6 +72,8 @@ testidl.c: libxl_types.idl gentest.py li
 	$(PYTHON) gentest.py libxl_types.idl testidl.c.new
 	mv testidl.c.new testidl.c
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 .PHONY: all
 all: $(CLIENTS) libxenlight.so libxenlight.a libxlutil.so libxlutil.a \
 	$(AUTOSRCS) $(AUTOINCS)
diff -r 1821c05638df -r bb6c07589982 tools/memshr/Makefile
--- a/tools/memshr/Makefile
+++ b/tools/memshr/Makefile
@@ -11,6 +11,8 @@ CFLAGS          += -D_GNU_SOURCE
 CFLAGS          += -fPIC
 CFLAGS          += -g
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LIB-SRCS        := interface.c
 LIB-SRCS        += shm.c
 LIB-SRCS        += bidir-daemon.c
diff -r 1821c05638df -r bb6c07589982 tools/misc/Makefile
--- a/tools/misc/Makefile
+++ b/tools/misc/Makefile
@@ -30,6 +30,8 @@ INSTALL_SBIN := $(INSTALL_SBIN-y)
 # Include configure output (config.h) to headers search path
 CFLAGS += -I$(XEN_ROOT)/tools
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 .PHONY: all
 all: build
 
diff -r 1821c05638df -r bb6c07589982 tools/misc/lomount/Makefile
--- a/tools/misc/lomount/Makefile
+++ b/tools/misc/lomount/Makefile
@@ -3,6 +3,8 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS  += -Werror
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 .PHONY: all
 all: build
 
@@ -20,4 +22,4 @@ clean:
 lomount: lomount.o
 	$(CC) $(CFLAGS) -o $@ $< 
 
--include $(DEPS)
\ No newline at end of file
+-include $(DEPS)
diff -r 1821c05638df -r bb6c07589982 tools/misc/nsplitd/Makefile
--- a/tools/misc/nsplitd/Makefile
+++ b/tools/misc/nsplitd/Makefile
@@ -1,6 +1,8 @@
 XEN_ROOT := $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 CFILES = $(wildcard *.c)
 
 HDRS     = $(wildcard *.h)
diff -r 1821c05638df -r bb6c07589982 tools/pygrub/Makefile
--- a/tools/pygrub/Makefile
+++ b/tools/pygrub/Makefile
@@ -2,6 +2,8 @@
 XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 .PHONY: all
 all: build
 .PHONY: build
diff -r 1821c05638df -r bb6c07589982 tools/python/Makefile
--- a/tools/python/Makefile
+++ b/tools/python/Makefile
@@ -1,6 +1,8 @@
 XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 .PHONY: all
 all: build
 
diff -r 1821c05638df -r bb6c07589982 tools/tests/Makefile
--- a/tools/tests/Makefile
+++ b/tools/tests/Makefile
@@ -2,6 +2,9 @@ XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS  += $(CFLAGS_libxenctrl)
+
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LDLIBS += $(LDLIBS_libxenctrl)
 
 SUBDIRS-y :diff -r 1821c05638df -r bb6c07589982
tools/tests/mce-test/tools/Makefile
--- a/tools/tests/mce-test/tools/Makefile
+++ b/tools/tests/mce-test/tools/Makefile
@@ -7,6 +7,8 @@ CFLAGS += $(CFLAGS_libxenguest)
 CFLAGS += $(CFLAGS_libxenstore) 
 CFLAGS += $(CFLAGS_xeninclude) 
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 .PHONY: all
 all: xen-mceinj
 
diff -r 1821c05638df -r bb6c07589982 tools/tests/mem-sharing/Makefile
--- a/tools/tests/mem-sharing/Makefile
+++ b/tools/tests/mem-sharing/Makefile
@@ -6,6 +6,8 @@ CFLAGS += -Werror
 CFLAGS += $(CFLAGS_libxenctrl)
 CFLAGS += $(CFLAGS_xeninclude)
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 TARGETS-y := 
 TARGETS-$(CONFIG_X86) += memshrtool
 TARGETS := $(TARGETS-y)
diff -r 1821c05638df -r bb6c07589982 tools/tests/xen-access/Makefile
--- a/tools/tests/xen-access/Makefile
+++ b/tools/tests/xen-access/Makefile
@@ -7,6 +7,8 @@ CFLAGS += $(CFLAGS_libxenctrl)
 CFLAGS += $(CFLAGS_libxenguest)
 CFLAGS += $(CFLAGS_xeninclude)
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 TARGETS-y := 
 TARGETS-$(CONFIG_X86) += xen-access
 TARGETS := $(TARGETS-y)
diff -r 1821c05638df -r bb6c07589982 tools/xcutils/Makefile
--- a/tools/xcutils/Makefile
+++ b/tools/xcutils/Makefile
@@ -15,6 +15,8 @@ PROGRAMS = xc_restore xc_save readnotes 
 
 CFLAGS += -Werror
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 CFLAGS_xc_restore.o := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
 CFLAGS_xc_save.o    := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
$(CFLAGS_libxenstore)
 CFLAGS_readnotes.o  := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
diff -r 1821c05638df -r bb6c07589982 tools/xenbackendd/Makefile
--- a/tools/xenbackendd/Makefile
+++ b/tools/xenbackendd/Makefile
@@ -14,6 +14,9 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS  += -Werror
 CFLAGS  += $(CFLAGS_libxenstore)
+
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 CPPFLAGS += -DXEN_SCRIPT_DIR="\"$(XEN_SCRIPT_DIR)\""
 LDLIBS  += $(LDLIBS_libxenstore)
 
diff -r 1821c05638df -r bb6c07589982 tools/xenmon/Makefile
--- a/tools/xenmon/Makefile
+++ b/tools/xenmon/Makefile
@@ -15,6 +15,9 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS  += -Werror
 CFLAGS  += $(CFLAGS_libxenctrl)
+
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LDLIBS  += $(LDLIBS_libxenctrl)
 
 SCRIPTS = xenmon.py
diff -r 1821c05638df -r bb6c07589982 tools/xenpaging/Makefile
--- a/tools/xenpaging/Makefile
+++ b/tools/xenpaging/Makefile
@@ -14,6 +14,8 @@ CFLAGS   += -Werror
 CFLAGS   += -Wno-unused
 CFLAGS   += -g
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 OBJS     = $(SRCS:.c=.o)
 IBINS    = xenpaging
 
diff -r 1821c05638df -r bb6c07589982 tools/xenpmd/Makefile
--- a/tools/xenpmd/Makefile
+++ b/tools/xenpmd/Makefile
@@ -4,6 +4,8 @@ include $(XEN_ROOT)/tools/Rules.mk
 CFLAGS += -Werror
 CFLAGS += $(CFLAGS_libxenstore)
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LDLIBS += $(LDLIBS_libxenstore)
 
 .PHONY: all
diff -r 1821c05638df -r bb6c07589982 tools/xenstat/Makefile
--- a/tools/xenstat/Makefile
+++ b/tools/xenstat/Makefile
@@ -1,6 +1,8 @@
 XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 SUBDIRS : SUBDIRS += libxenstat
 
diff -r 1821c05638df -r bb6c07589982 tools/xenstat/libxenstat/Makefile
--- a/tools/xenstat/libxenstat/Makefile
+++ b/tools/xenstat/libxenstat/Makefile
@@ -39,6 +39,8 @@ WARN_FLAGS=-Wall -Werror
 CFLAGS+=-fPIC
 CFLAGS+=-Isrc $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(CFLAGS_xeninclude)
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LDLIBS-y = $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl)
 LDLIBS-$(CONFIG_SunOS) += -lkstat
 
diff -r 1821c05638df -r bb6c07589982 tools/xenstat/xentop/Makefile
--- a/tools/xenstat/xentop/Makefile
+++ b/tools/xenstat/xentop/Makefile
@@ -25,6 +25,8 @@ CFLAGS += -DHOST_$(XEN_OS)
 # Include configure output (config.h) to headers search path
 CFLAGS += -I$(XEN_ROOT)/tools
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 .PHONY: all
 all: xentop
 
diff -r 1821c05638df -r bb6c07589982 tools/xenstore/Makefile
--- a/tools/xenstore/Makefile
+++ b/tools/xenstore/Makefile
@@ -52,6 +52,8 @@ xenstored_probes.o: xenstored_solaris.o
 CFLAGS += -DHAVE_DTRACE=1
 endif
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 init-xenstore-domain.o: CFLAGS += $(CFLAGS_libxenguest)
 
 init-xenstore-domain: init-xenstore-domain.o $(LIBXENSTORE)
diff -r 1821c05638df -r bb6c07589982 tools/xentrace/Makefile
--- a/tools/xentrace/Makefile
+++ b/tools/xentrace/Makefile
@@ -4,6 +4,9 @@ include $(XEN_ROOT)/tools/Rules.mk
 CFLAGS += -Werror
 
 CFLAGS += $(CFLAGS_libxenctrl)
+
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 LDLIBS += $(LDLIBS_libxenctrl)
 
 BIN      = xentrace xentrace_setsize
Ian Jackson
2012-Apr-03  17:13 UTC
[PATCH] tools/configure: add options to pass EXTRA_CLFAGS
Olaf Hering writes ("[Xen-devel] [PATCH] tools/configure: add options to
pass EXTRA_CLFAGS"):> tools/configure: add options to pass EXTRA_CLFAGS
Much of this looks good to me.  (Although you need to fix the typo
CLFLAGS in the subject...)
I''m happy with the changes to all the tools/*/Makefile.
> This patch extends configure to recognize three environment variables
> which will be written to config/Tools.mk so they will be reused with
> each make invocation:
>   EXTRA_CFLAGS_XEN_TOOLS= specifies CFLAGS for the tools build.
>   EXTRA_CFLAGS_QEMU_TRADITIONAL= specifies CFLAGS for old qemu.
>   EXTRA_CFLAGS_QEMU_XEN= specifies CFLAGS for new qemu.
> The new feature can be used like this in a rpm xen.spec file:
I''m not sure why it is necessary to plumb these through our configure
and Tools.mk.  Why can''t we just take them from the environment (or
the make command line) ?
However, 
>  		cd qemu-xen-traditional-dir; \
> +		env CFLAGS="$(EXTRA_CFLAGS_QEMU_TRADITIONAL)" \
>  		$(QEMU_ROOT)/xen-setup $(IOEMU_CONFIGURE_CROSS); \
>  		$(MAKE) install
I''m not really sure that this is a good idea.  Note that the xen-setup
script in qemu-xen-traditional already imports many of the settings
from the Xen tree.  I think this would be a better approach than a
blanket export of CFLAGS.
> @@ -146,6 +147,7 @@ subdir-all-qemu-xen-dir subdir-install-q
>  		source=.; \
>  	fi; \
>  	cd qemu-xen-dir; \
> +	env CFLAGS="$(EXTRA_CFLAGS_QEMU_XEN)" \
>  	$$source/configure --enable-xen --target-list=i386-softmmu \
>  		--source-path=$$source \
>  		--extra-cflags="-I$(XEN_ROOT)/tools/include \
And this definitely isn''t a good idea, unless you can find me some
documentation from qemu upstream which says that it is a supported
approach.
Thanks,
Ian.