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

Re: [Xen-devel] [PATCH 8/9] tools/libxc: provide variable paths to libxc



On Wed, Apr 23, Ian Campbell wrote:

> libxl has the exact same thing. Can we make it a common
> genpath-include-target or something please.

I came up with the untested change below.

> I'm not sure why this isn't handled vi autoconf and tools/config.h.in.

Should these variables (in BUILD_MAKE_VARS) be set via configure?

Olaf


 Config.mk                | 19 +++++++++++++++----
 tools/libxc/Makefile     |  8 ++++++++
 tools/libxc/xc_private.h |  1 +
 tools/libxl/Makefile     |  7 +------
 4 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/Config.mk b/Config.mk
index 6a93533..0e07fd6 100644
--- a/Config.mk
+++ b/Config.mk
@@ -166,19 +166,30 @@ define move-if-changed
        if ! cmp -s $(1) $(2); then mv -f $(1) $(2); else rm -f $(1); fi
 endef
 
+BUILD_MAKE_VARS := SBINDIR BINDIR LIBEXEC LIBDIR SHAREDIR PRIVATE_BINDIR \
+                  XENFIRMWAREDIR XEN_CONFIG_DIR XEN_SCRIPT_DIR XEN_LOCK_DIR \
+                  XEN_RUN_DIR XEN_PAGING_DIR
+
 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,                               \
+       $(foreach var, $(BUILD_MAKE_VARS)                         \
                  echo "$(var)=\"$($(var))\"" >>$(1).tmp;)        \
        $(call move-if-changed,$(1).tmp,$(1))
 endef
 
+buildmakevars2header = $(eval $(call buildmakevars2header-closure,$(1)))
+define buildmakevars2header-closure
+    .PHONY: genpath
+    genpath:
+       rm -f $(1).tmp;                                                     \
+       $(foreach var, $(BUILD_MAKE_VARS)                         \
+                 echo "#define $(var) \"$($(var))\"" >>$(1).tmp;)\
+       $(call move-if-changed,$(1).tmp,$(1))
+endef
+
 ifeq ($(debug_symbols),y)
 CFLAGS += -g
 endif
diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index a74b19e..cbba502 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -118,6 +118,13 @@ ifneq ($(stubdom),y)
 LIB += xenctrl_osdep_ENOSYS.so
 endif
 
+genpath-target = $(call buildmakevars2header,_paths.h)
+$(eval $(genpath-target))
+
+xc_private.h: _paths.h
+
+$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) $(OSDEP_LIB_OBJS): xc_private.h
+
 .PHONY: all
 all: build
 
@@ -150,6 +157,7 @@ TAGS:
 .PHONY: clean
 clean:
        rm -rf *.rpm $(LIB) *~ $(DEPS) \
+            _paths.h \
             $(CTRL_LIB_OBJS) $(CTRL_PIC_OBJS) \
             $(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS) \
             $(OSDEP_LIB_OBJS) $(OSDEP_PIC_OBJS)
diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h
index 670a82d..786dc61 100644
--- a/tools/libxc/xc_private.h
+++ b/tools/libxc/xc_private.h
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <sys/ioctl.h>
 
+#include "_paths.h"
 #include "xenctrl.h"
 #include "xenctrlosdep.h"
 
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 4cfa275..6c8a14b 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -141,7 +141,7 @@ $(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)
+genpath-target = $(call buildmakevars2header,_paths.h)
 $(eval $(genpath-target))
 
 libxl.api-ok: check-libxl-api-rules _libxl.api-for-check
@@ -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,$@)

_______________________________________________
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®.