[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v4 11/15] autoconf: xen: move standard variables to a generic place



From: "Luis R. Rodriguez" <mcgrof@xxxxxxxx>

This moves all generic variables to the top level makefile,
tons of files use these so just make them general enough. This
also paves the way to let us easily dynamically configure these
with autoconf, for now we leave the same presets as was present
before.

This work was prompted by looking for an autoconf way to do
replacements for the hotplug global file, while at it I realized
that a few other files use the same variables and have in places
around the tree the same constructs for generating their own
files. This replaces all that with a two central files, one for
shell scripts and another for C header files. We should later
optimize this further by only having one target file and
generating the two needed from that.

Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Keir Fraser <keir@xxxxxxx>
Cc: Tim Deegan <tim@xxxxxxx>
Signed-off-by: Luis R. Rodriguez <mcgrof@xxxxxxxx>
---
 .gitignore                        |  2 ++
 Config.mk                         | 13 ---------
 config/StdGNU.mk                  | 19 ++----------
 config/Toplevel.mk.in             | 24 +++++++++++++++
 config/xen-environment-header.in  | 13 +++++++++
 config/xen-environment-scripts.in | 15 ++++++++++
 configure.ac                      |  9 +++++-
 m4/expand_config.m4               | 61 +++++++++++++++++++++++++++++++++++++++
 stubdom/Makefile                  | 17 ++++++-----
 stubdom/configure.ac              |  3 ++
 tools/configure.ac                |  3 ++
 tools/hotplug/common/Makefile     |  6 ++--
 tools/libxl/Makefile              | 11 ++-----
 tools/python/Makefile             |  6 ++--
 14 files changed, 149 insertions(+), 53 deletions(-)
 create mode 100644 config/xen-environment-header.in
 create mode 100644 config/xen-environment-scripts.in
 create mode 100644 m4/expand_config.m4

diff --git a/.gitignore b/.gitignore
index 562c262..fd1b627 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,6 +36,8 @@ config.log
 config.status
 config.cache
 config/Toplevel.mk
+config/xen-environment-scripts
+config/xen-environment-header
 
 build-*
 dist/*
diff --git a/Config.mk b/Config.mk
index 6a93533..84f79a0 100644
--- a/Config.mk
+++ b/Config.mk
@@ -166,19 +166,6 @@ define move-if-changed
        if ! cmp -s $(1) $(2); then mv -f $(1) $(2); else rm -f $(1); fi
 endef
 
-buildmakevars2file = $(eval $(call buildmakevars2file-closure,$(1)))
-define buildmakevars2file-closure
-    .PHONY: genpath
-    genpath:
-       rm -f $(1).tmp;                                                     \
-       $(foreach var,                                                      \
-                 SBINDIR BINDIR LIBEXEC LIBDIR SHAREDIR PRIVATE_BINDIR     \
-                 XENFIRMWAREDIR XEN_CONFIG_DIR XEN_SCRIPT_DIR XEN_LOCK_DIR \
-                 XEN_RUN_DIR XEN_PAGING_DIR,                               \
-                 echo "$(var)=\"$($(var))\"" >>$(1).tmp;)        \
-       $(call move-if-changed,$(1).tmp,$(1))
-endef
-
 ifeq ($(debug_symbols),y)
 CFLAGS += -g
 endif
diff --git a/config/StdGNU.mk b/config/StdGNU.mk
index 25fc594..00b47de 100644
--- a/config/StdGNU.mk
+++ b/config/StdGNU.mk
@@ -1,3 +1,5 @@
+include $(XEN_ROOT)/config/Toplevel.mk
+
 AS         = $(CROSS_COMPILE)as
 LD         = $(CROSS_COMPILE)ld
 ifeq ($(clang),y)
@@ -27,30 +29,13 @@ INSTALL_DIR  = $(INSTALL) -d -m0755 -p
 INSTALL_DATA = $(INSTALL) -m0644 -p
 INSTALL_PROG = $(INSTALL) -m0755 -p
 
-PREFIX ?= /usr
-BINDIR = $(PREFIX)/bin
 INCLUDEDIR = $(PREFIX)/include
-LIBEXEC = $(PREFIX)/lib/xen/bin
-SHAREDIR = $(PREFIX)/share
 MANDIR = $(SHAREDIR)/man
 MAN1DIR = $(MANDIR)/man1
 MAN8DIR = $(MANDIR)/man8
-SBINDIR = $(PREFIX)/sbin
-XENFIRMWAREDIR = $(PREFIX)/lib/xen/boot
-
-PRIVATE_PREFIX = $(LIBDIR)/xen
-PRIVATE_BINDIR = $(PRIVATE_PREFIX)/bin
-
-CONFIG_DIR = /etc
-XEN_LOCK_DIR = /var/lock
-XEN_RUN_DIR = /var/run/xen
-XEN_PAGING_DIR = /var/lib/xen/xenpaging
 
 SYSCONFIG_DIR = $(CONFIG_DIR)/$(CONFIG_LEAF_DIR)
 
-XEN_CONFIG_DIR = $(CONFIG_DIR)/xen
-XEN_SCRIPT_DIR = $(XEN_CONFIG_DIR)/scripts
-
 SOCKET_LIBS =
 UTIL_LIBS = -lutil
 DLOPEN_LIBS = -ldl
diff --git a/config/Toplevel.mk.in b/config/Toplevel.mk.in
index 4db7eaf..fc2754c 100644
--- a/config/Toplevel.mk.in
+++ b/config/Toplevel.mk.in
@@ -1 +1,25 @@
 SUBSYSTEMS               := @SUBSYSTEMS@
+
+SBINDIR                  := @SBINDIR@
+BINDIR                   := @BINDIR@
+LIBEXEC                  := @LIBEXEC@
+
+SHAREDIR                 := @SHAREDIR@
+LIBDIR                   := @LIBDIR@
+
+XEN_RUN_DIR              := @XEN_RUN_DIR@
+XEN_LOG_DIR              := @XEN_LOG_DIR@
+XEN_LIB_STORED           := @XEN_LIB_STORED@
+
+CONFIG_DIR               := @CONFIG_DIR@
+XEN_LOCK_DIR             := @XEN_LOCK_DIR@
+XEN_PAGING_DIR           := @XEN_PAGING_DIR@
+
+PRIVATE_PREFIX           := @PRIVATE_PREFIX@
+PRIVATE_PREFIX           := @PKG_XEN_PREFIX@
+PRIVATE_BINDIR           := @PRIVATE_BINDIR@
+
+XENFIRMWAREDIR           := @XENFIRMWAREDIR@
+
+XEN_CONFIG_DIR           := @XEN_CONFIG_DIR@
+XEN_SCRIPT_DIR           := @XEN_SCRIPT_DIR@
diff --git a/config/xen-environment-header.in b/config/xen-environment-header.in
new file mode 100644
index 0000000..7dd7a53
--- /dev/null
+++ b/config/xen-environment-header.in
@@ -0,0 +1,13 @@
+#define SBINDIR "@SBINDIR@"
+#define BINDIR "@BINDIR@"
+#define LIBEXEC "@LIBEXEC@"
+#define LIBDIR "@LIBDIR@"
+#define SHAREDIR "@SHAREDIR@"
+
+#define PRIVATE_BINDIR "@PRIVATE_BINDIR@"
+#define XENFIRMWAREDIR "@XENFIRMWAREDIR@"
+#define XEN_CONFIG_DIR "@XEN_CONFIG_DIR@"
+#define XEN_SCRIPT_DIR "@XEN_SCRIPT_DIR@"
+#define XEN_LOCK_DIR "@XEN_LOCK_DIR@"
+#define XEN_RUN_DIR "@XEN_RUN_DIR@"
+#define XEN_PAGING_DIR "@XEN_PAGING_DIR@"
diff --git a/config/xen-environment-scripts.in 
b/config/xen-environment-scripts.in
new file mode 100644
index 0000000..9623231
--- /dev/null
+++ b/config/xen-environment-scripts.in
@@ -0,0 +1,15 @@
+SBINDIR="@SBINDIR@"
+BINDIR="@BINDIR@"
+LIBEXEC="@LIBEXEC@"
+LIBDIR="@LIBDIR@"
+SHAREDIR="@SHAREDIR@"
+
+PRIVATE_BINDIR="@PRIVATE_BINDIR@"
+XENFIRMWAREDIR="@XENFIRMWAREDIR@"
+XEN_CONFIG_DIR="@XEN_CONFIG_DIR@"
+XEN_SCRIPT_DIR="@XEN_SCRIPT_DIR@"
+XEN_LOCK_DIR="@XEN_LOCK_DIR@"
+XEN_LOG_DIR="@XEN_LOG_DIR@"
+XEN_LIB_STORED="@XEN_LIB_STORED@"
+XEN_RUN_DIR="@XEN_RUN_DIR@"
+XEN_PAGING_DIR="@XEN_PAGING_DIR@"
diff --git a/configure.ac b/configure.ac
index 6c14524..3f26a39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,12 +5,19 @@ AC_PREREQ([2.67])
 AC_INIT([Xen Hypervisor], m4_esyscmd([./version.sh ./xen/Makefile]),
     [xen-devel@xxxxxxxxxxxxx], [xen], [http://www.xen.org/])
 AC_CONFIG_SRCDIR([./xen/common/kernel.c])
-AC_CONFIG_FILES([./config/Toplevel.mk])
+AC_CONFIG_FILES([
+       config/Toplevel.mk
+       config/xen-environment-scripts
+       config/xen-environment-header
+])
 
 AC_CANONICAL_HOST
 
 m4_include([m4/features.m4])
 m4_include([m4/subsystem.m4])
+m4_include([m4/expand_config.m4])
+
+AX_XEN_EXPAND_CONFIG()
 
 dnl mini-os is only ported to certain platforms
 case "$host_cpu" in
diff --git a/m4/expand_config.m4 b/m4/expand_config.m4
new file mode 100644
index 0000000..717fcd1
--- /dev/null
+++ b/m4/expand_config.m4
@@ -0,0 +1,61 @@
+AC_DEFUN([AX_XEN_EXPAND_CONFIG], [
+dnl expand these early so we can use this for substitutions
+test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
+test "x$exec_prefix" = "xNONE" && exec_prefix=$ac_default_prefix
+
+BINDIR=$prefix/bin
+AC_SUBST(BINDIR)
+
+SBINDIR=$prefix/sbin
+AC_SUBST(SBINDIR)
+
+dnl XXX: this should be changed to use the passed $libexec
+dnl but can be done as a second step
+LIBEXEC=$prefix/lib/xen/bin
+AC_SUBST(LIBEXEC)
+
+LIBDIR=`eval echo $libdir`
+AC_SUBST(LIBDIR)
+
+XEN_RUN_DIR=/var/run/xen
+AC_SUBST(XEN_RUN_DIR)
+
+XEN_LOG_DIR=/var/log/xen
+AC_SUBST(XEN_LOG_DIR)
+
+XEN_LIB_STORED=/var/lib/xenstored
+AC_SUBST(XEN_LIB_STORED)
+
+SHAREDIR=$prefix/share
+AC_SUBST(SHAREDIR)
+
+PRIVATE_PREFIX=$LIBDIR/xen
+AC_SUBST(PRIVATE_PREFIX)
+
+PKG_XEN_PREFIX=$LIBDIR/xen
+AC_SUBST(PKG_XEN_PREFIX)
+
+PRIVATE_BINDIR=$PRIVATE_PREFIX/bin
+AC_SUBST(PRIVATE_BINDIR)
+
+XENFIRMWAREDIR=$prefix/lib/xen/boot
+AC_SUBST(XENFIRMWAREDIR)
+
+CONFIG_DIR=/etc
+AC_SUBST(CONFIG_DIR)
+
+XEN_CONFIG_DIR=$CONFIG_DIR/xen
+AC_SUBST(XEN_CONFIG_DIR)
+
+XEN_SCRIPT_DIR=$XEN_CONFIG_DIR/scripts
+AC_SUBST(XEN_SCRIPT_DIR)
+
+XEN_LOCK_DIR=/var/lock
+AC_SUBST(XEN_LOCK_DIR)
+
+XEN_RUN_DIR=/var/run/xen
+AC_SUBST(XEN_RUN_DIR)
+
+XEN_PAGING_DIR=/var/lib/xen/xenpaging
+AC_SUBST(XEN_PAGING_DIR)
+])
diff --git a/stubdom/Makefile b/stubdom/Makefile
index b1822b7..bf2ee1d 100644
--- a/stubdom/Makefile
+++ b/stubdom/Makefile
@@ -48,18 +48,19 @@ TARGET_LDFLAGS += -nostdlib 
-L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
 
 TARGETS=$(STUBDOM_TARGETS)
 
+STUBDOMPATH="stubdompath.sh"
+
+$(STUBDOMPATH): $(XEN_ROOT)/config/xen-environment-scripts
+       @cp $(XEN_ROOT)/config/xen-environment-scripts $@
+
 .PHONY: all
 all: build
 ifeq ($(STUBDOM_SUPPORTED),1)
-build: genpath $(STUBDOM_BUILD)
+build: $(STUBDOMPATH) $(STUBDOM_BUILD)
 else
-build: genpath
+build: $(STUBDOMPATH)
 endif
 
-STUBDOMPATH="stubdompath.sh"
-genpath-target = $(call buildmakevars2file,$(STUBDOMPATH))
-$(eval $(genpath-target))
-
 ##############
 # Cross-newlib
 ##############
@@ -446,9 +447,9 @@ xenstore-stubdom: mini-os-$(XEN_TARGET_ARCH)-xenstore libxc 
xenstore
 #########
 
 ifeq ($(STUBDOM_SUPPORTED),1)
-install: genpath install-readme $(STUBDOM_INSTALL)
+install: $(STUBDOMPATH) install-readme $(STUBDOM_INSTALL)
 else
-install: genpath
+install: $(STUBDOMPATH)
 endif
 
 install-readme:
diff --git a/stubdom/configure.ac b/stubdom/configure.ac
index 6468203..d6b0fbf 100644
--- a/stubdom/configure.ac
+++ b/stubdom/configure.ac
@@ -16,6 +16,9 @@ m4_include([../m4/features.m4])
 m4_include([../m4/path_or_fail.m4])
 m4_include([../m4/depends.m4])
 m4_include([../m4/fetcher.m4])
+m4_include([../m4/expand_config.m4])
+
+AX_XEN_EXPAND_CONFIG()
 
 # Enable/disable stub domains
 AX_STUBDOM_CONDITIONAL([ioemu-stubdom], [ioemu])
diff --git a/tools/configure.ac b/tools/configure.ac
index 00fb47b..c7674a0 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -47,6 +47,9 @@ m4_include([../m4/ptyfuncs.m4])
 m4_include([../m4/extfs.m4])
 m4_include([../m4/fetcher.m4])
 m4_include([../m4/ax_compare_version.m4])
+m4_include([../m4/expand_config.m4])
+
+AX_XEN_EXPAND_CONFIG()
 
 # Enable/disable options
 AX_ARG_DEFAULT_DISABLE([githttp], [Download GIT repositories via HTTP])
diff --git a/tools/hotplug/common/Makefile b/tools/hotplug/common/Makefile
index 18d87aa..4a63f40 100644
--- a/tools/hotplug/common/Makefile
+++ b/tools/hotplug/common/Makefile
@@ -9,14 +9,14 @@ HOTPLUGPATH="hotplugpath.sh"
 XEN_SCRIPTS =
 XEN_SCRIPT_DATA = $(HOTPLUGPATH)
 
-genpath-target = $(call buildmakevars2file,$(HOTPLUGPATH))
-$(eval $(genpath-target))
+$(HOTPLUGPATH): $(XEN_ROOT)/config/xen-environment-scripts
+       @cp $(XEN_ROOT)/config/xen-environment-scripts $@
 
 .PHONY: all
 all: build
 
 .PHONY: build
-build: genpath
+build: $(HOTPLUGPATH)
 
 .PHONY: install
 install: all install-scripts
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 755b666..1b8852c 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -97,6 +97,9 @@ TEST_PROGS += $(foreach t, $(LIBXL_TESTS),test_$t)
 
 $(LIBXL_OBJS) $(LIBXL_TEST_OBJS): CFLAGS += $(CFLAGS_LIBXL) -include 
$(XEN_ROOT)/tools/config.h
 
+_paths.h: $(XEN_ROOT)/config/xen-environment-header
+       @cp $(XEN_ROOT)/config/xen-environment-header $@
+
 AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h _libxl_list.h _paths.h \
        libxlu_disk_l.h _libxl_save_msgs_callout.h _libxl_save_msgs_helper.h
 AUTOSRCS= libxlu_cfg_y.c libxlu_cfg_l.c
@@ -141,9 +144,6 @@ $(LIBXL_OBJS) $(LIBXLU_OBJS) $(XL_OBJS) $(SAVE_HELPER_OBJS) 
\
        @rm -f $*.[ch]
        $(FLEX) --header-file=$*.h --outfile=$*.c $<
 
-genpath-target = $(call buildmakevars2file,_paths.h.tmp)
-$(eval $(genpath-target))
-
 libxl.api-ok: check-libxl-api-rules _libxl.api-for-check
        $(PERL) $^
        touch $@
@@ -154,11 +154,6 @@ _%.api-for-check: %.h $(AUTOINCS)
                >$@.new
        mv -f $@.new $@
 
-_paths.h: genpath
-       sed -e "s/\([^=]*\)=\(.*\)/#define \1 \2/g" $@.tmp >$@.2.tmp
-       rm -f $@.tmp
-       $(call move-if-changed,$@.2.tmp,$@)
-
 _libxl_list.h: $(XEN_INCLUDE)/xen-external/bsd-sys-queue-h-seddery 
$(XEN_INCLUDE)/xen-external/bsd-sys-queue.h
        $(PERL) $^ --prefix=libxl >$@.new
        $(call move-if-changed,$@.new,$@)
diff --git a/tools/python/Makefile b/tools/python/Makefile
index 74ed027..99479d6 100644
--- a/tools/python/Makefile
+++ b/tools/python/Makefile
@@ -6,11 +6,11 @@ all: build
 
 XENPATH = "xen/util/path.py"
 
-genpath-target = $(call buildmakevars2file,$(XENPATH))
-$(eval $(genpath-target))
+$(XENPATH): $(XEN_ROOT)/config/xen-environment-scripts
+       @cp $(XEN_ROOT)/config/xen-environment-scripts $@
 
 .PHONY: build
-build: genpath genwrap.py $(XEN_ROOT)/tools/libxl/libxl_types.idl \
+build: $(XENPATH) genwrap.py $(XEN_ROOT)/tools/libxl/libxl_types.idl \
                $(XEN_ROOT)/tools/libxl/idl.py
        PYTHONPATH=$(XEN_ROOT)/tools/libxl $(PYTHON) genwrap.py \
                $(XEN_ROOT)/tools/libxl/libxl_types.idl \
-- 
1.9.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.