Add configure --with-extra-cflags-*
PATCH 1/1 Add configure --with-extra-cflags-*
Since commit 338c4375153e39b95ddc82f2ed95f85dd73e0245 ("tools: pass EXTRA_CFLAGS via environment") it was possible to specify additional CFLAGS in the environment. That commit gives a good explanation how that is useful.
Now that we have configure move the knobs from the middle of the source code to a more prominent place. If the variables are set once via configure it is possible to rerun make from another shell which may not have these environment variables. That can happen if one tries to resume a failed build with either doing chroot into a rpmbuild tree or from another xterm.
This change adds the configure options --with-extra-cflags-tools=, --with-extra-cflags-qemu-traditional= and --with-extra-cflags-qemu-upstream= which will assign their values to the existing make variables.
It is now required to use configure instead of environment variables to have a consistent set of CFLAGS across make invocations.
A new knob "skip_extra_cflags" in Rules.mk is recognized to turn off the assignment to CFLAGS. This is required to build the firmware.
Please rerun autogen.sh after applying this patch.
--- config/Tools.mk.in | 3 +++ tools/Rules.mk | 2 ++ tools/configure.ac | 21 +++++++++++++++++++++ tools/firmware/Rules.mk | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-)
config/Tools.mk.in +3 -0
@@ -59,6 +59,9 @@ CONFIG_QEMU_TRAD := @qemu_traditional@ CONFIG_QEMU_XEN := @qemu_xen@ CONFIG_BLKTAP1 := @blktap1@ CONFIG_BLKTAP2 := @blktap2@ +EXTRA_CFLAGS_XEN_TOOLS := @EXTRA_CFLAGS_XEN_TOOLS@ +EXTRA_CFLAGS_QEMU_TRADITIONAL := @EXTRA_CFLAGS_QEMU_TRADITIONAL@ +EXTRA_CFLAGS_QEMU_XEN := @EXTRA_CFLAGS_QEMU_XEN@ CONFIG_QEMUU_EXTRA_ARGS:= @EXTRA_QEMUU_CONFIGURE_ARGS@ CONFIG_REMUS_NETBUF := @remus_netbuf@
tools/Rules.mk +2 -0
@@ -88,7 +88,9 @@ endif CFLAGS-$(CONFIG_X86_32) += $(call cc-option,$(CC),-mno-tls-direct-seg-refs) CFLAGS += $(CFLAGS-y) +ifneq ($(skip_extra_cflags),y) CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS) +endif INSTALL_PYTHON_PROG = \ $(XEN_ROOT)/tools/python/install-wrap "$(PYTHON_PATH)" $(INSTALL_PROG)
tools/configure.ac +21 -0
@@ -223,6 +223,27 @@ AC_ARG_WITH([system-ovmf], ],[]) AC_SUBST(ovmf_path) +AC_ARG_WITH([extra-cflags-tools], + AS_HELP_STRING([--with-extra-cflags-tools="EXTRA_CFLAGS"], + [Additional CFLAGS to be used to build tools.]), + [EXTRA_CFLAGS_XEN_TOOLS=$withval], + [EXTRA_CFLAGS_XEN_TOOLS=]) +AC_SUBST(EXTRA_CFLAGS_XEN_TOOLS) + +AC_ARG_WITH([extra-cflags-qemu-traditional], + AS_HELP_STRING([--with-extra-cflags-qemu-traditional="EXTRA_CFLAGS"], + [Additional CFLAGS to be used to build qemu-traditional.]), + [EXTRA_CFLAGS_QEMU_TRADITIONAL=$withval], + [EXTRA_CFLAGS_QEMU_TRADITIONAL=]) +AC_SUBST(EXTRA_CFLAGS_QEMU_TRADITIONAL) + +AC_ARG_WITH([extra-cflags-qemu-upstream], + AS_HELP_STRING([--with-extra-cflags-qemu-upstream="EXTRA_CFLAGS"], + [Additional CFLAGS to be used to build qemu-upstream.]), + [EXTRA_CFLAGS_QEMU_XEN=$withval], + [EXTRA_CFLAGS_QEMU_XEN=]) +AC_SUBST(EXTRA_CFLAGS_QEMU_XEN) + AC_ARG_WITH([extra-qemuu-configure-args], AS_HELP_STRING([--with-extra-qemuu-configure-args@<:@="--ARG1 ..."@:>@], [List of additional configure options for upstream qemu]),[
tools/firmware/Rules.mk +1 -1
@@ -3,7 +3,7 @@ override XEN_TARGET_ARCH = x86_32 # User-supplied CFLAGS are not useful here. CFLAGS = -EXTRA_CFLAGS_XEN_TOOLS = +skip_extra_cflags := y include $(XEN_ROOT)/tools/Rules.mk
tools/configure.ac AC_ARG_WITH([system-ovmf], · line 231
Quoted 6 lines · Olaf Hering
tools/configure.ac +6
-0+AC_ARG_WITH([extra-cflags-tools], + AS_HELP_STRING([--with-extra-cflags-tools="EXTRA_CFLAGS"], + [Additional CFLAGS to be used to build tools.]), + [EXTRA_CFLAGS_XEN_TOOLS=$withval], + [EXTRA_CFLAGS_XEN_TOOLS=]) +AC_SUBST(EXTRA_CFLAGS_XEN_TOOLS)
I wonder why all the other --with-foo are not done that way as well. It looks like they would take the variable from the environment and do AC_SUBST(). IMO private variables like seabios_path, ovmf_path, EXTRA_QEMUU_CONFIGURE_ARGS should not be passed via environment. I also question if --with-foo=no is useful at all. My suggestion is to convert these three to the style quoted above: a --with-foo=val assigns $val to the given private variable, otherwise the private variable is initialized empty.
What do you think?
Olaf
Quoted 13 lines · Olaf Hering
tools/configure.ac AC_ARG_WITH([system-ovmf], · line 231
Quoted 6 lines · Olaf Hering
tools/configure.ac +6
-0+AC_ARG_WITH([extra-cflags-tools], + AS_HELP_STRING([--with-extra-cflags-tools="EXTRA_CFLAGS"], + [Additional CFLAGS to be used to build tools.]), + [EXTRA_CFLAGS_XEN_TOOLS=$withval], + [EXTRA_CFLAGS_XEN_TOOLS=]) +AC_SUBST(EXTRA_CFLAGS_XEN_TOOLS)I wonder why all the other --with-foo are not done that way as well. It looks like they would take the variable from the environment and do
AC_SUBST(). IMO private variables likeseabios_path,ovmf_path,EXTRA_QEMUU_CONFIGURE_ARGSshould not be passed via environment.
It looks to me like seabios_path isn't, so I'm confused about what you are trying to suggest:
AC_ARG_WITH([system-seabios],
AS_HELP_STRING([--with-system-seabios@<:@=PATH@:>@],
[Use system supplied seabios PATH instead of building and installing
our own version]),[
case $withval in
no) seabios_path= ;;
*) seabios_path=$withval ;;
esac
],[])AC_SUBST(seabios_path)
Doesn't take anything fro the env, does it?
Quoted 2 lines
I also
question if --with-foo=no is useful at all.
Isn't $withval=no the result of passing --without-foo?
Quoted 6 lines
My suggestion is to convert
these three to the style quoted above: a --with-foo=val assigns $val to the given private variable, otherwise the private variable is initialized empty.What do you think?
I have no real opinion one way or the other, since I'm not really sure what the practical implication of what you are suggesting is.
But it certainly doesn't sound like 4.5 material at this point.
Ian.
Quoted 14 lines · Ian Campbell
It looks to me like
seabios_pathisn't, so I'm confused about what you are trying to suggest:AC_ARG_WITH([system-seabios],
AS_HELP_STRING([--with-system-seabios@<:@=PATH@:>@],
[Use system supplied seabios PATH instead of building and installing
our own version]),[
case $withval in
no) seabios_path= ;;
*) seabios_path=$withval ;;
esac
],[])AC_SUBST(seabios_path)
Quoted 1 line
Doesn't take anything fro the env, does it?
I just tried today:
# git clean -dfx # env EXTRA_QEMUU_CONFIGURE_ARGS=XXXXXXXXXXXXXXXX ./configure &>/dev/null # grep XXXXXXXXXXXXXXXX config/Tools.mk CONFIG_QEMUU_EXTRA_ARGS:= XXXXXXXXXXXXXXXX
The empty [] in AC_ARG_WITH() is what is supposed to be executed if --with*-foo was not specified. In this case nothing will be done with EXTRA_QEMUU_CONFIGURE_ARGS. Later AC_SUBST() takes the environment variable and does the substitution. And the same happens if I replace "EXTRA_QEMUU_CONFIGURE_ARGS" with "seabios_path" in my example.
I think this should not happen. To fix it the empty [] should be filled with "variable=", like "seabios_path=".
What do you think?
Quoted 4 lines
Quoted 2 lines
I also
question if --with-foo=no is useful at all.Isn't $withval=no the result of passing --without-foo?
Yes, looks like it. I will update my patch to handle also the "no" due to --without-extra-cflags-*.
Olaf
On Thu, 2014-10-09 at 11:43 +0200, Olaf Hering wrote:
Please do not use the "for-xen-4.5" without making some sort of argument as to why it should be acceptable for 4.5, usually after the --- separator.
To me this looks like a feature, but in any case neither Konrad nor I should be expected to make the argument for you.
Ian.
Quoted 8 lines · Ian Campbell
On Thu, 2014-10-09 at 11:43 +0200, Olaf Hering wrote:
Please do not use the "for-xen-4.5" without making some sort of argument as to why it should be acceptable for 4.5, usually after the --- separator.
To me this looks like a feature, but in any case neither Konrad nor I should be expected to make the argument for you.
The point is that the build system should not take "random" environment variables. Instead such things should be passed in via configure. Now that configure does already most of the settings it should do also this.
Olaf