Skip to contentSkip to conversation

tools changes to honor --prefix=

PATCH In review Olaf Hering 2 participants 31 messages Jul 28, 2014 – Sep 19, 2014

lore
Share & tools
lore
#0 lore raw

v2 cover tools changes to honor --prefix=

In my attempt to get a xen.rpm from 'make rpmball' which operates entirely below the configured --prefix= I came up with these changes.

This series contains also two unrelated cleanup changes at the end.

This is a resend of the same series with the comments incorporated:
http://lists.xenproject.org/archives/html/xen-devel/2014-04/msg03240.html

Huge CC list due to changes in Config.mk.

Olaf

Olaf Hering (13):
Config.mk: move directory list into BUILD_MAKE_VARS Config.mk: replace dependency to genpath with actual targe Config.mk: add new macro buildmakevars2header tools/libxl: use buildmakevars2header to create _paths.h tools/libxc: provide variable paths to libxc tools/libxc: use XEN_RUN_DIR for SUSPEND_LOCK_FILE tools/pygrub: store kernels in /var/run/xen/pygrub tools/hotplug: use XEN_SCRIPT_DIR instead of hardcoded path tools/hotplug: create XEN_RUN_DIR at runtime tools/hotplug: create XEN_LOCK_DIR at runtime tools/hotplug: use XEN_LOCK_DIR instead of hardcoded path tools/examples: remove obsolete install targets remove obsolete SUBSYS_DIR variable

 .gitignore                                         |  9 +++++
 Config.mk                                          | 30 +++++++++++-----
 docs/misc/distro_mapping.txt                       |  1 -
 stubdom/Makefile                                   | 16 ++++-----
 tools/examples/Makefile                            | 21 +-----------
 tools/hotplug/Linux/Makefile                       | 40 +++++++++++++++++++---
 .../Linux/init.d/{xen-watchdog => xen-watchdog.in} |  2 +-
 .../Linux/init.d/{xencommons => xencommons.in}     |  5 +--
 .../Linux/init.d/{xendomains => xendomains.in}     |  2 +-
 tools/hotplug/Linux/{vif-setup => vif-setup.in}    |  2 +-
 .../{xen-backend.rules => xen-backend.rules.in}    | 16 ++++-----
 ...-hotplug-common.sh => xen-hotplug-common.sh.in} |  2 +-
 tools/hotplug/Linux/{xendomains => xendomains.in}  |  9 ++---
 tools/hotplug/common/Makefile                      |  2 +-
 tools/libxc/Makefile                               |  9 +++++
 tools/libxc/xc_private.h                           |  1 +
 tools/libxc/xc_suspend.c                           |  2 +-
 tools/libxl/Makefile                               |  7 +---
 tools/pygrub/src/pygrub                            |  9 ++++-
 tools/python/Makefile                              |  2 +-
 20 files changed, 113 insertions(+), 74 deletions(-)
 rename tools/hotplug/Linux/init.d/{xen-watchdog => xen-watchdog.in} (97%)
 rename tools/hotplug/Linux/init.d/{xencommons => xencommons.in} (98%)
 rename tools/hotplug/Linux/init.d/{xendomains => xendomains.in} (97%)
 rename tools/hotplug/Linux/{vif-setup => vif-setup.in} (60%)
 rename tools/hotplug/Linux/{xen-backend.rules => xen-backend.rules.in} (60%)
 rename tools/hotplug/Linux/{xen-hotplug-common.sh => xen-hotplug-common.sh.in} (98%)
 rename tools/hotplug/Linux/{xendomains => xendomains.in} (98%)
#1 lore raw

PATCH v2 1/13 Config.mk: move directory list into BUILD_MAKE_VARS

To maintain the list of directories in a single place, move the existing list into its own variable and use it in buildmakevars2file. Required for upcoming changes.
Trim also whitespaces.

---
 Config.mk | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
Config.mk +7 -6
index 5370e23..2408fa6 100644
@@ -166,16 +166,17 @@ 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,                               \
-	          echo "$(var)=\"$($(var))\"" >>$(1).tmp;)        \
+	rm -f $(1).tmp; \
+	$(foreach var, $(BUILD_MAKE_VARS), \
+	          echo "$(var)=\"$($(var))\"" >>$(1).tmp;) \
 	$(call move-if-changed,$(1).tmp,$(1))
 endef
#2 lore raw

PATCH v2 2/13 Config.mk: replace dependency to genpath with actual target

In reply to Olaf Hering

genpath is a detail of buildmakevars2file. Replace the dependency to genpath with the actual buildmakevars2file target. This change by itself does not fix any bug. Upcoming changes will add dependencies to $(target), but no rule exist to create $(target).

No change in behaviour is expected by this patch.

Note: target.tmp ($(1).tmp) is not marked as .PHONY because move-if-changed in the target rule will remove target.tmp by renaming it to target. As a result make will always attempt to rebuild it.

---
 Config.mk                     |  9 +++++----
 stubdom/Makefile              | 16 ++++++++--------
 tools/hotplug/common/Makefile |  2 +-
 tools/libxl/Makefile          |  2 +-
 tools/python/Makefile         |  2 +-
 5 files changed, 16 insertions(+), 15 deletions(-)
Config.mk +5 -4
index 2408fa6..28e9930 100644
@@ -172,11 +172,12 @@ BUILD_MAKE_VARS := SBINDIR BINDIR LIBEXEC LIBDIR SHAREDIR PRIVATE_BINDIR \
 
 buildmakevars2file = $(eval $(call buildmakevars2file-closure,$(1)))
 define buildmakevars2file-closure
-    .PHONY: genpath
-    genpath:
-	rm -f $(1).tmp; \
+    $(1).tmp:
+	rm -f $(1).newtmp; \
 	$(foreach var, $(BUILD_MAKE_VARS), \
-	          echo "$(var)=\"$($(var))\"" >>$(1).tmp;) \
+	          echo "$(var)=\"$($(var))\"" >>$(1).newtmp;) \
+	$(call move-if-changed,$(1).newtmp,$(1).tmp)
+    $(1): $(1).tmp
 	$(call move-if-changed,$(1).tmp,$(1))
 endef
 
stubdom/Makefile +8 -8
index 6bea68b..333112c 100644
@@ -48,18 +48,18 @@ TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
 
 TARGETS=$(STUBDOM_TARGETS)
 
+STUBDOMPATH="stubdompath.sh"
+genpath-target = $(call buildmakevars2file,$(STUBDOMPATH))
+$(eval $(genpath-target))
+
 .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
 ##############
@@ -449,9 +449,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:
tools/hotplug/common/Makefile +1 -1
index 18d87aa..657a8e3 100644
@@ -16,7 +16,7 @@ $(eval $(genpath-target))
 all: build
 
 .PHONY: build
-build: genpath
+build: $(HOTPLUGPATH)
 
 .PHONY: install
 install: all install-scripts
tools/libxl/Makefile +1 -1
index bd0db3b..a3a25ac 100644
@@ -159,7 +159,7 @@ _%.api-for-check: %.h $(AUTOINCS)
 		>[email protected]
 	mv -f [email protected] $@
 
-_paths.h: genpath
+_paths.h: _paths.h.tmp
 	sed -e "s/\([^=]*\)=\(.*\)/#define \1 \2/g" [email protected] >[email protected]
 	rm -f [email protected]
 	$(call move-if-changed,[email protected],$@)
tools/python/Makefile +1 -1
index c914332..7b25291 100644
@@ -10,7 +10,7 @@ genpath-target = $(call buildmakevars2file,$(XENPATH))
 $(eval $(genpath-target))
 
 .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 \
#14 lore raw

PATCH v2 3/13 Config.mk: add new macro buildmakevars2header

In reply to Olaf Hering

This macro is similar to buildmakevars2file, it just creates a C header file instead of shell style syntax. Upcoming changes will use this macro in libxl and libxc.

Note: if target ($(1)) is marked as .PHONY everything that depends on target will be constantly rebuild. The reason for that seems to be that make will internally drop target. As a result target is non-existant, which triggers a rebuild. With the intermediate target.tmp this will not happen because target changes only if target.tmp really changes.

---
 Config.mk | 11 +++++++++++
 1 file changed, 11 insertions(+)
Config.mk +11 -0
index 28e9930..92c0567 100644
@@ -181,6 +181,17 @@ define buildmakevars2file-closure
 	$(call move-if-changed,$(1).tmp,$(1))
 endef
 
+buildmakevars2header = $(eval $(call buildmakevars2header-closure,$(1)))
+define buildmakevars2header-closure
+    $(1).tmp:
+	rm -f $(1).newtmp; \
+	$(foreach var, $(BUILD_MAKE_VARS), \
+	          echo "#define $(var) \"$($(var))\"" >>$(1).newtmp;) \
+	$(call move-if-changed,$(1).newtmp,$(1).tmp)
+    $(1): $(1).tmp
+	$(call move-if-changed,$(1).tmp,$(1))
+endef
+
 ifeq ($(debug_symbols),y)
 CFLAGS += -g
 endif
#16 lore raw

PATCH v2 4/13 tools/libxl: use buildmakevars2header to create _paths.h

In reply to Olaf Hering

Replace usage of buildmakevars2file with buildmakevars2header. The macro generates a C header file, so remove code which converts shell variables into C defines. Also update the dependency, the macro itself creates a dependency for _paths.h. A temporary file is not needed anymore.

---
 tools/libxl/Makefile | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
tools/libxl/Makefile +1 -6
index a3a25ac..1991661 100644
@@ -146,7 +146,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
@@ -159,11 +159,6 @@ _%.api-for-check: %.h $(AUTOINCS)
 		>[email protected]
 	mv -f [email protected] $@
 
-_paths.h: _paths.h.tmp
-	sed -e "s/\([^=]*\)=\(.*\)/#define \1 \2/g" [email protected] >[email protected]
-	rm -f [email protected]
-	$(call move-if-changed,[email protected],$@)
-
 _libxl_list.h: $(XEN_INCLUDE)/xen-external/bsd-sys-queue-h-seddery $(XEN_INCLUDE)/xen-external/bsd-sys-queue.h
 	$(PERL) $^ --prefix=libxl >[email protected]
 	$(call move-if-changed,[email protected],$@)
#17 lore raw

PATCH v2 5/13 tools/libxc: provide variable paths to libxc

In reply to Olaf Hering

In preparation to remove hardcoded /var/run/xen paths, provide XEN_RUN_DIR and related directories to xc_private.h. Similar code exists already for libxl, stubdom and other parts.

---
 .gitignore               | 1 +
 tools/libxc/Makefile     | 9 +++++++++
 tools/libxc/xc_private.h | 1 +
 3 files changed, 11 insertions(+)
.gitignore +1 -0
index fefe13c..685df89 100644
@@ -306,6 +306,7 @@ tools/include/xen-foreign/arm64.h
 .git
 tools/misc/xen-hptool
 tools/misc/xen-mfndump
+tools/libxc/_*.[ch]
 tools/libxl/_*.[ch]
 tools/libxl/testidl
 tools/libxl/testidl.c
tools/libxc/Makefile +9 -0
index 22eef8e..741053e 100644
@@ -122,6 +122,14 @@ ifneq ($(nosharedlibs),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) \
+$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS) $(OSDEP_PIC_OBJS): xc_private.h
+
 .PHONY: all
 all: build
 
@@ -154,6 +162,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)
tools/libxc/xc_private.h +1 -0
index c50a7c9..e7a3422 100644
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <sys/ioctl.h>
 
+#include "_paths.h"
 #include "xenctrl.h"
 #include "xenctrlosdep.h"
#18 lore raw

PATCH v2 6/13 tools/libxc: use XEN_RUN_DIR for SUSPEND_LOCK_FILE

In reply to Olaf Hering

Remove hardcoded /var/run/xen directory path, use XEN_RUN_DIR instead.

---
 tools/libxc/xc_suspend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxc/xc_suspend.c +1 -1
index 200d381..e22f4ac 100644
@@ -20,7 +20,7 @@
 #include "xc_private.h"
 #include "xenguest.h"
 
-#define SUSPEND_LOCK_FILE "/var/run/xen/suspend-evtchn-%d.lock"
+#define SUSPEND_LOCK_FILE    XEN_RUN_DIR "/suspend-evtchn-%d.lock"
 
 /*
  * locking
#19 lore raw

PATCH v2 7/13 tools/pygrub: store kernels in /var/run/xen/pygrub

In reply to Olaf Hering

Move location of temporary bootfiles from /var/run/xend/boot to /var/run/xen/pygrub. Create the subdirectory if does not exist. The <dir> argument --output-directory must be an existing directory.

The reason for this change is that all entrys below /var/run have to be created at runtime in case /var/run is cleared on every boot.

---
 tools/pygrub/src/pygrub | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
tools/pygrub/src/pygrub +8 -1
index 2618e11..9d8c5a1 100644
@@ -14,6 +14,7 @@
 #
 
 import os, sys, string, struct, tempfile, re, traceback
+import errno
 import copy
 import logging
 import platform
@@ -778,7 +779,7 @@ if __name__ == "__main__":
     debug = False
     not_really = False
     output_format = "sxp"
-    output_directory = "/var/run/xend/boot"
+    output_directory = "/var/run/xen/pygrub"
 
     # what was passed in
     incfg = { "kernel": None, "ramdisk": None, "args": "" }
@@ -829,11 +830,17 @@ if __name__ == "__main__":
                 sys.exit(1)
             output_format = a
         elif o in ("--output-directory",):
+            if not os.path.isdir(a):
+                print "%s is not an existing directory" % a
+                sys.exit(1)
             output_directory = a
 
     if debug:
 	logging.basicConfig(level=logging.DEBUG)
 
+    if not os.path.isdir(output_directory):
+        os.mkdir(output_directory, 0700)
+
     if output is None or output == "-":
         fd = sys.stdout.fileno()
     else:
#21 lore raw

PATCH v2 8/13 tools/hotplug: use XEN_SCRIPT_DIR instead of hardcoded path

In reply to Olaf Hering

Helper scripts get installed into XEN_SCRIPT_DIR, but initscripts, helper scripts and udev rules still refer to the hardcoded location /etc/xen/scripts/. Update scripts, rules and Makefile to refer to @@XEN_SCRIPT_DIR@@ instead.

---
 .gitignore                                         |  8 +++++
 tools/hotplug/Linux/Makefile                       | 40 +++++++++++++++++++---
 .../Linux/init.d/{xen-watchdog => xen-watchdog.in} |  2 +-
 .../Linux/init.d/{xencommons => xencommons.in}     |  2 +-
 .../Linux/init.d/{xendomains => xendomains.in}     |  2 +-
 tools/hotplug/Linux/{vif-setup => vif-setup.in}    |  2 +-
 .../{xen-backend.rules => xen-backend.rules.in}    | 16 ++++-----
 ...-hotplug-common.sh => xen-hotplug-common.sh.in} |  2 +-
 tools/hotplug/Linux/{xendomains => xendomains.in}  |  2 +-
 9 files changed, 57 insertions(+), 19 deletions(-)
 rename tools/hotplug/Linux/init.d/{xen-watchdog => xen-watchdog.in} (97%)
 rename tools/hotplug/Linux/init.d/{xencommons => xencommons.in} (99%)
 rename tools/hotplug/Linux/init.d/{xendomains => xendomains.in} (97%)
 rename tools/hotplug/Linux/{vif-setup => vif-setup.in} (60%)
 rename tools/hotplug/Linux/{xen-backend.rules => xen-backend.rules.in} (60%)
 rename tools/hotplug/Linux/{xen-hotplug-common.sh => xen-hotplug-common.sh.in} (98%)
 rename tools/hotplug/Linux/{xendomains => xendomains.in} (99%)
.gitignore +8 -0
index 685df89..cf2febe 100644
@@ -159,6 +159,14 @@ tools/flask/utils/flask-set-bool
 tools/flask/utils/flask-label-pci
 tools/fs-back/fs-backend
 tools/hotplug/common/hotplugpath.sh
+tools/hotplug/Linux/init.d/xen-watchdog
+tools/hotplug/Linux/init.d/xencommons
+tools/hotplug/Linux/init.d/xendomains
+tools/hotplug/Linux/vif-setup
+tools/hotplug/Linux/xen-backend.rules
+tools/hotplug/Linux/xen-hotplug-common.sh
+tools/hotplug/Linux/xendomains
+tools/hotplug/Linux/_used_path.sh
 tools/include/xen/*
 tools/include/xen-foreign/*.(c|h|size)
 tools/include/xen-foreign/checker
tools/hotplug/Linux/Makefile +35 -5
index d5de9e6..fb9f1e6 100644
@@ -32,18 +32,47 @@ XEN_SCRIPT_DATA += block-common.sh
 UDEV_RULES_DIR = $(CONFIG_DIR)/udev
 UDEV_RULES = xen-backend.rules $(UDEV_RULES-y)
 
+USED_PATH = "_used_path.sh"
+genpath-target = $(call buildmakevars2file,$(USED_PATH))
+$(eval $(genpath-target))
+
+XEN_SCRIPT_DIR_INPUTS := \
+        init.d/xen-watchdog.in \
+        init.d/xencommons.in \
+        init.d/xendomains.in \
+        vif-setup.in \
+        xen-backend.rules.in \
+        xen-hotplug-common.sh.in \
+        xendomains.in
+
+.SUFFIXES:
+XEN_SCRIPT_DIR_OUTPUTS := $(patsubst %.in,%,$(XEN_SCRIPT_DIR_INPUTS))
+%: %.in
+	set -e; \
+		rm -f [email protected] ; \
+		sed 's|@@XEN_SCRIPT_DIR@@|$(XEN_SCRIPT_DIR)|g' $< >[email protected] ; \
+		$(call move-if-changed,[email protected],$@)
+
+init.d/%: init.d/%.in
+	set -e; \
+		rm -f [email protected] ; \
+		sed 's|@@XEN_SCRIPT_DIR@@|$(XEN_SCRIPT_DIR)|g' $< >[email protected] ; \
+		$(call move-if-changed,[email protected],$@)
+
+$(XEN_SCRIPT_DIR_OUTPUTS): $(USED_PATH)
+
 .PHONY: all
-all:
+all: build
 
 .PHONY: build
-build:
+build: $(XEN_SCRIPT_DIR_OUTPUTS)
 
 .PHONY: install
 install: all install-initd install-scripts install-udev
 
 # See docs/misc/distro_mapping.txt for INITD_DIR location
 .PHONY: install-initd
-install-initd:
+install-initd: all
 	[ -d $(DESTDIR)$(INITD_DIR) ] || $(INSTALL_DIR) $(DESTDIR)$(INITD_DIR)
 	[ -d $(DESTDIR)$(SYSCONFIG_DIR) ] || $(INSTALL_DIR) $(DESTDIR)$(SYSCONFIG_DIR)
 	[ -d $(DESTDIR)$(LIBEXEC) ] || $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)
@@ -55,7 +84,7 @@ install-initd:
 	$(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR)
 
 .PHONY: install-scripts
-install-scripts:
+install-scripts: all
 	[ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \
 		$(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
 	set -e; for i in $(XEN_SCRIPTS); \
@@ -68,7 +97,7 @@ install-scripts:
 	done
 
 .PHONY: install-udev
-install-udev:
+install-udev: all
 	[ -d $(DESTDIR)$(UDEV_RULES_DIR) ] || \
 		$(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)/rules.d
 	set -e; for i in $(UDEV_RULES); \
@@ -78,3 +107,4 @@ install-udev:
 
 .PHONY: clean
 clean:
+	rm -f $(XEN_SCRIPT_DIR_OUTPUTS)
tools/hotplug/Linux/init.d/xen-watchdog.in renamed from tools/hotplug/Linux/init.d/xen-watchdog +1 -1
similarity index 97%
rename from tools/hotplug/Linux/init.d/xen-watchdog
rename to tools/hotplug/Linux/init.d/xen-watchdog.in
index 3592fda..d0d7966 100644
@@ -17,7 +17,7 @@
 ### END INIT INFO
 #
 
-. /etc/xen/scripts/hotplugpath.sh
+. @@XEN_SCRIPT_DIR@@/hotplugpath.sh
 
 DAEMON=${SBINDIR}/xenwatchdogd
 base=$(basename $DAEMON)
tools/hotplug/Linux/init.d/xencommons.in renamed from tools/hotplug/Linux/init.d/xencommons +1 -1
similarity index 99%
rename from tools/hotplug/Linux/init.d/xencommons
rename to tools/hotplug/Linux/init.d/xencommons.in
index 4ebd636..c62bdb8 100644
@@ -18,7 +18,7 @@
 # Description:       Starts and stops the daemons neeeded for xl/xend
 ### END INIT INFO
 
-. /etc/xen/scripts/hotplugpath.sh
+. @@XEN_SCRIPT_DIR@@/hotplugpath.sh
 
 if [ -d /etc/sysconfig ]; then
 	xencommons_config=/etc/sysconfig
tools/hotplug/Linux/init.d/xendomains.in renamed from tools/hotplug/Linux/init.d/xendomains +1 -1
similarity index 97%
rename from tools/hotplug/Linux/init.d/xendomains
rename to tools/hotplug/Linux/init.d/xendomains.in
index d0122fc..8eb7e6e 100644
@@ -24,7 +24,7 @@
 #                    systemd systems.
 ### END INIT INFO
 
-. /etc/xen/scripts/hotplugpath.sh
+. @@XEN_SCRIPT_DIR@@/hotplugpath.sh
 
 case "$1" in
     start)
tools/hotplug/Linux/vif-setup.in renamed from tools/hotplug/Linux/vif-setup +1 -1
similarity index 60%
rename from tools/hotplug/Linux/vif-setup
rename to tools/hotplug/Linux/vif-setup.in
index bcc462e..ce1ba56 100644
@@ -4,6 +4,6 @@ if test "$script"
 then
     exec $script $*
 else
-    exec /etc/xen/scripts/vif-bridge $*
+    exec @@XEN_SCRIPT_DIR@@/vif-bridge $*
 fi
 
tools/hotplug/Linux/xen-backend.rules.in renamed from tools/hotplug/Linux/xen-backend.rules +8 -8
similarity index 60%
rename from tools/hotplug/Linux/xen-backend.rules
rename to tools/hotplug/Linux/xen-backend.rules.in
index a0d409e..8e01533 100644
@@ -1,10 +1,10 @@
-SUBSYSTEM=="xen-backend", KERNEL=="tap*", ENV{UDEV_CALL}="1", RUN+="/etc/xen/scripts/blktap $env{ACTION}"
-SUBSYSTEM=="xen-backend", KERNEL=="vbd*", ENV{UDEV_CALL}="1", RUN+="/etc/xen/scripts/block $env{ACTION}"
-SUBSYSTEM=="xen-backend", KERNEL=="vif2-*", RUN+="/etc/xen/scripts/vif2 $env{ACTION}"
-SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ENV{UDEV_CALL}="1", ACTION=="online", RUN+="/etc/xen/scripts/vif-setup online type_if=vif"
-SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ENV{UDEV_CALL}="1", ACTION=="offline", RUN+="/etc/xen/scripts/vif-setup offline type_if=vif"
-SUBSYSTEM=="xen-backend", KERNEL=="vscsi*", RUN+="/etc/xen/scripts/vscsi $env{ACTION}"
-SUBSYSTEM=="xen-backend", ACTION=="remove", ENV{UDEV_CALL}="1", RUN+="/etc/xen/scripts/xen-hotplug-cleanup"
+SUBSYSTEM=="xen-backend", KERNEL=="tap*", ENV{UDEV_CALL}="1", RUN+="@@XEN_SCRIPT_DIR@@/blktap $env{ACTION}"
+SUBSYSTEM=="xen-backend", KERNEL=="vbd*", ENV{UDEV_CALL}="1", RUN+="@@XEN_SCRIPT_DIR@@/block $env{ACTION}"
+SUBSYSTEM=="xen-backend", KERNEL=="vif2-*", RUN+="@@XEN_SCRIPT_DIR@@/vif2 $env{ACTION}"
+SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ENV{UDEV_CALL}="1", ACTION=="online", RUN+="@@XEN_SCRIPT_DIR@@/vif-setup online type_if=vif"
+SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ENV{UDEV_CALL}="1", ACTION=="offline", RUN+="@@XEN_SCRIPT_DIR@@/vif-setup offline type_if=vif"
+SUBSYSTEM=="xen-backend", KERNEL=="vscsi*", RUN+="@@XEN_SCRIPT_DIR@@/vscsi $env{ACTION}"
+SUBSYSTEM=="xen-backend", ACTION=="remove", ENV{UDEV_CALL}="1", RUN+="@@XEN_SCRIPT_DIR@@/xen-hotplug-cleanup"
 KERNEL=="evtchn", NAME="xen/%k"
 SUBSYSTEM=="xen", KERNEL=="blktap[0-9]*", NAME="xen/%k", MODE="0600"
 SUBSYSTEM=="blktap2", KERNEL=="blktap[0-9]*", NAME="xen/blktap-2/%k", MODE="0600"
@@ -12,4 +12,4 @@ KERNEL=="blktap-control", NAME="xen/blktap-2/control", MODE="0600"
 KERNEL=="gntdev", NAME="xen/%k", MODE="0600"
 KERNEL=="pci_iomul", NAME="xen/%k", MODE="0600"
 KERNEL=="tapdev[a-z]*", NAME="xen/blktap-2/tapdev%m", MODE="0600"
-SUBSYSTEM=="net", KERNEL=="vif*-emu", ACTION=="add", ENV{UDEV_CALL}="1", RUN+="/etc/xen/scripts/vif-setup $env{ACTION} type_if=tap"
+SUBSYSTEM=="net", KERNEL=="vif*-emu", ACTION=="add", ENV{UDEV_CALL}="1", RUN+="@@XEN_SCRIPT_DIR@@/vif-setup $env{ACTION} type_if=tap"
tools/hotplug/Linux/xen-hotplug-common.sh.in renamed from tools/hotplug/Linux/xen-hotplug-common.sh +1 -1
similarity index 98%
rename from tools/hotplug/Linux/xen-hotplug-common.sh
rename to tools/hotplug/Linux/xen-hotplug-common.sh.in
index 7af4688..8128b9e 100644
@@ -112,7 +112,7 @@ xenstore_write() {
 # Execute each hook in the <hook> directory.
 #
 call_hooks() {
-  for f in /etc/xen/scripts/${1}-${2}.d/*.hook; do
+  for f in @@XEN_SCRIPT_DIR@@/${1}-${2}.d/*.hook; do
     if [ -x "$f" ]; then . "$f"; fi
   done
 }
tools/hotplug/Linux/xendomains.in renamed from tools/hotplug/Linux/xendomains +1 -1
similarity index 99%
rename from tools/hotplug/Linux/xendomains
rename to tools/hotplug/Linux/xendomains.in
index 0794bb9..0882ef6 100644
@@ -27,7 +27,7 @@
 #                    boots / shuts down.
 ### END INIT INFO
 
-. /etc/xen/scripts/hotplugpath.sh
+. @@XEN_SCRIPT_DIR@@/hotplugpath.sh
 
 CMD=${SBINDIR}/xl
 HEADCOMP="Xen saved domain"
#24 lore raw

PATCH v2 9/13 tools/hotplug: create XEN_RUN_DIR at runtime

In reply to Olaf Hering

Create XEN_RUN_DIR instead of hardcoded path because it is a compiletime setting. Also /var/run might be empty on startup because it is a tmpfs mount point.

---
 tools/hotplug/Linux/init.d/xencommons.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/Linux/init.d/xencommons.in +1 -1
index c62bdb8..2326a9c 100644
@@ -72,7 +72,7 @@ do_start () {
 	modprobe pciback 2>/dev/null
 	modprobe xen-acpi-processor 2>/dev/null
 	modprobe blktap2 2>/dev/null || modprobe blktap 2>/dev/null
-	mkdir -p /var/run/xen
+	mkdir -p ${XEN_RUN_DIR}
 
 	if ! `${BINDIR}/xenstore-read -s / >/dev/null 2>&1`
 	then
#25 lore raw

PATCH v2 10/13 tools/hotplug: create XEN_LOCK_DIR at runtime

In reply to Olaf Hering

Create XEN_LOCK_DIR because it is a compiletime setting. Also /var/lock might be empty on startup because it is a tmpfs mount point.

---
 tools/hotplug/Linux/init.d/xencommons.in | 1 +
 1 file changed, 1 insertion(+)
tools/hotplug/Linux/init.d/xencommons.in +1 -0
index 2326a9c..0b14568 100644
@@ -73,6 +73,7 @@ do_start () {
 	modprobe xen-acpi-processor 2>/dev/null
 	modprobe blktap2 2>/dev/null || modprobe blktap 2>/dev/null
 	mkdir -p ${XEN_RUN_DIR}
+	mkdir -p ${XEN_LOCK_DIR}
 
 	if ! `${BINDIR}/xenstore-read -s / >/dev/null 2>&1`
 	then
#26 lore raw

PATCH v2 11/13 tools/hotplug: use XEN_LOCK_DIR instead of hardcoded path

In reply to Olaf Hering

Use XEN_LOCK_DIR because it is a compiletime setting.

---
 tools/hotplug/Linux/xendomains.in | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
tools/hotplug/Linux/xendomains.in +1 -6
index 0882ef6..792b755 100644
@@ -49,12 +49,7 @@ if ! [ -e /proc/xen/privcmd ]; then
 	exit 0
 fi
 
-# See docs/misc/distro_mapping.txt
-if [ -d /var/lock/subsys ]; then
-	LOCKFILE=/var/lock/subsys/xendomains
-else
-	LOCKFILE=/var/lock/xendomains
-fi
+LOCKFILE=${XEN_LOCK_DIR}/xendomains
 
 if [ -d /etc/sysconfig ]; then
 	XENDOM_CONFIG=/etc/sysconfig/xendomains
#28 lore raw

PATCH v2 12/13 tools/examples: remove obsolete install targets

In reply to Olaf Hering

install-hotplug and install-udev are obsolete since commit 57bcfa11 ("tools/hotplug: Separate OS-specific scripts.")

---
 tools/examples/Makefile | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)
tools/examples/Makefile +1 -20
index 86d9cc1..473580e 100644
@@ -19,7 +19,7 @@ all:
 build:
 
 .PHONY: install
-install: all install-readmes install-configs $(HOTPLUGS)
+install: all install-readmes install-configs
 
 .PHONY: install-readmes
 install-readmes:
@@ -41,24 +41,5 @@ install-configs: $(XEN_CONFIGS)
 	    $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_CONFIG_DIR); \
 	done
 
-.PHONY: install-hotplug
-install-hotplug:
-	[ -d $(DESTDIR)$(XEN_HOTPLUG_DIR) ] || \
-		$(INSTALL_DIR) $(DESTDIR)$(XEN_HOTPLUG_DIR)
-	set -e; for i in $(XEN_HOTPLUG_SCRIPTS); \
-	    do \
-	    $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_HOTPLUG_DIR); \
-	done
-
-.PHONY: install-udev
-install-udev:
-	[ -d $(DESTDIR)$(UDEV_RULES_DIR) ] || \
-		$(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)/rules.d
-	set -e; for i in $(UDEV_RULES); \
-	    do \
-	    $(INSTALL_DATA) $$i $(DESTDIR)$(UDEV_RULES_DIR); \
-	    ln -sf ../$$i $(DESTDIR)$(UDEV_RULES_DIR)/rules.d; \
-	done
-
 .PHONY: clean
 clean:
#29 lore raw

PATCH v2 13/13 remove obsolete SUBSYS_DIR variable

In reply to Olaf Hering

/var/run is a runtime directory. It is not supposed to be packaged. Remove unused SUBSYS_DIR variable from Config.mk and distro_mapping.txt.

---
 Config.mk                    | 1 -
 docs/misc/distro_mapping.txt | 1 -
 2 files changed, 2 deletions(-)
Config.mk +0 -1
index 92c0567..18dbd4a 100644
@@ -75,7 +75,6 @@ endef
 
 # See distro_mapping.txt for other options
 $(eval $(call setvar_dir,CONFIG_LEAF_DIR,,/etc/sysconfig,sysconfig,default))
-$(eval $(call setvar_dir,SUBSYS_DIR,/var/run,/subsys,/subsys,))
 $(eval $(call setvar_dir,INITD_DIR,/etc,/rc.d/init.d,/rc.d/init.d,/init.d))
 
 ifneq ($(EXTRA_PREFIX),)
docs/misc/distro_mapping.txt +0 -1
index f56e281..f849d07 100644
@@ -5,7 +5,6 @@ other distros one needs to set the variables for the elements below
                  | Red Hat          |  Debian       |  Suse          |
 -----------------+------------------+---------------+----------------+
 CONFIG_LEAF_DIR  | sysconfig        | default       | sysconfig      |
-SUBSYS_DIR       | /var/run/subsys  | /var/run      | /var/run       |
 INITD_DIR        | /etc/rc.d/init.d | /etc/init.d   | /etc/init.d    |
 -----------------+------------------+---------------+----------------+
#3 lore raw

Re: [PATCH 02/13] Config.mk: replace dependency to genpath with actual target

In reply to Olaf Hering

On Mon, 2014-07-28 at 11:05 +0200, Olaf Hering wrote:

Sorry for the delay in looking into this, I've been on vacation and travel.

Quoted 10 lines

genpath is a detail of buildmakevars2file. Replace the dependency to genpath with the actual buildmakevars2file target. This change by itself does not fix any bug. Upcoming changes will add dependencies to $(target), but no rule exist to create $(target).

No change in behaviour is expected by this patch.

Note: target.tmp ($(1).tmp) is not marked as .PHONY because move-if-changed in the target rule will remove target.tmp by renaming it to target. As a result make will always attempt to rebuild it.

Does the scheme you've got here end up differing from:

    $(1):
       rm -f $(1).tmp; \
        $(foreach var, $(BUILD_MAKE_VARS), \
                 echo "$(var)=\"$($(var))\"" >>$(1).tmp;) \
        $(call move-if-changed,$(1).tmp,$(1))

(i.e. avoiding the $(1).tmp rule)

Ian.

#15 lore raw

Re: [PATCH 03/13] Config.mk: add new macro buildmakevars2header

In reply to Olaf Hering
Quoted 7 lines · Olaf Hering

This macro is similar to buildmakevars2file, it just creates a C header file instead of shell style syntax. Upcoming changes will use this macro in libxl and libxc.

Note: if target ($(1)) is marked as .PHONY everything that depends on target will be constantly rebuild. The reason for that seems to be that make will internally drop target. As a result target is non-existant,

"existent"

Quoted 2 lines

which triggers a rebuild. With the intermediate target.tmp this will not happen because target changes only if target.tmp really changes.

Similar to the previous patch do you really need $(1).tmp as a target as well as a (non-.PHONY) $(1) target?

Ian.

Acked-by on v2 7/13
#20 lore raw

Re: [PATCH 07/13] tools/pygrub: store kernels in /var/run/xen/pygrub

In reply to Olaf Hering
Quoted 17 lines · Olaf Hering

Move location of temporary bootfiles from /var/run/xend/boot to /var/run/xen/pygrub. Create the subdirectory if does not exist. The <dir> argument --output-directory must be an existing directory.

The reason for this change is that all entrys below /var/run have to be created at runtime in case /var/run is cleared on every boot.

---
 tools/pygrub/src/pygrub | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
tools/pygrub/src/pygrub +0 -0
index 2618e11..9d8c5a1 100644

tools/pygrub/src/pygrub line 17

Quoted 4 lines
tools/pygrub/src/pygrub +1 -0
@@ -14,6 +14,7 @@
 #
 
 import os, sys, string, struct, tempfile, re, traceback
+import errno

Isn't this unused? If so then with it removed:

If it is used then the ack applies to the patch unchanged ;-)

#22 lore raw

Re: [PATCH 08/13] tools/hotplug: use XEN_SCRIPT_DIR instead of hardcoded path

In reply to Olaf Hering
Quoted 49 lines · Olaf Hering

Helper scripts get installed into XEN_SCRIPT_DIR, but initscripts, helper scripts and udev rules still refer to the hardcoded location /etc/xen/scripts/. Update scripts, rules and Makefile to refer to @@XEN_SCRIPT_DIR@@ instead.

---
 .gitignore                                         |  8 +++++
 tools/hotplug/Linux/Makefile                       | 40 +++++++++++++++++++---
 .../Linux/init.d/{xen-watchdog => xen-watchdog.in} |  2 +-
 .../Linux/init.d/{xencommons => xencommons.in}     |  2 +-
 .../Linux/init.d/{xendomains => xendomains.in}     |  2 +-
 tools/hotplug/Linux/{vif-setup => vif-setup.in}    |  2 +-
 .../{xen-backend.rules => xen-backend.rules.in}    | 16 ++++-----
 ...-hotplug-common.sh => xen-hotplug-common.sh.in} |  2 +-
 tools/hotplug/Linux/{xendomains => xendomains.in}  |  2 +-
 9 files changed, 57 insertions(+), 19 deletions(-)
 rename tools/hotplug/Linux/init.d/{xen-watchdog => xen-watchdog.in} (97%)
 rename tools/hotplug/Linux/init.d/{xencommons => xencommons.in} (99%)
 rename tools/hotplug/Linux/init.d/{xendomains => xendomains.in} (97%)
 rename tools/hotplug/Linux/{vif-setup => vif-setup.in} (60%)
 rename tools/hotplug/Linux/{xen-backend.rules => xen-backend.rules.in} (60%)
 rename tools/hotplug/Linux/{xen-hotplug-common.sh => xen-hotplug-common.sh.in} (98%)
 rename tools/hotplug/Linux/{xendomains => xendomains.in} (99%)
.gitignore +8 -0
index 685df89..cf2febe 100644
@@ -159,6 +159,14 @@ tools/flask/utils/flask-set-bool
 tools/flask/utils/flask-label-pci
 tools/fs-back/fs-backend
 tools/hotplug/common/hotplugpath.sh
+tools/hotplug/Linux/init.d/xen-watchdog
+tools/hotplug/Linux/init.d/xencommons
+tools/hotplug/Linux/init.d/xendomains
+tools/hotplug/Linux/vif-setup
+tools/hotplug/Linux/xen-backend.rules
+tools/hotplug/Linux/xen-hotplug-common.sh
+tools/hotplug/Linux/xendomains
+tools/hotplug/Linux/_used_path.sh
 tools/include/xen/*
 tools/include/xen-foreign/*.(c|h|size)
 tools/include/xen-foreign/checker
tools/hotplug/Linux/Makefile +0 -0
index d5de9e6..fb9f1e6 100644

tools/hotplug/Linux/Makefile XEN_SCRIPT_DATA += block-common.sh · line 37

Quoted 6 lines
tools/hotplug/Linux/Makefile +3 -0
@@ -32,18 +32,47 @@ XEN_SCRIPT_DATA += block-common.sh
 UDEV_RULES_DIR = $(CONFIG_DIR)/udev
 UDEV_RULES = xen-backend.rules $(UDEV_RULES-y)
 
+USED_PATH = "_used_path.sh"
+genpath-target = $(call buildmakevars2file,$(USED_PATH))
+$(eval $(genpath-target))

I can't see where _used_path.sh is consumed.

tools/hotplug/Linux/Makefile XEN_SCRIPT_DATA += block-common.sh · line 54

Quoted 5 lines
tools/hotplug/Linux/Makefile +5 -0
+%: %.in
+	set -e; \
+		rm -f [email protected] ; \
+		sed 's|@@XEN_SCRIPT_DIR@@|$(XEN_SCRIPT_DIR)|g' $< >[email protected] ; \
+		$(call move-if-changed,[email protected],$@)

Can you make these substitutions directly from tools/configure.ac? I think Luis did something similar for the systemd stuff?

If not then you should remove all the "; \" bits and treat this as three consecutive things in the normal way (the set -e becomes redundant then).

#4 lore raw

Re: [PATCH 02/13] Config.mk: replace dependency to genpath with actual target

In reply to Ian Campbell
Quoted 18 lines · Ian Campbell

On Mon, 2014-07-28 at 11:05 +0200, Olaf Hering wrote:

Sorry for the delay in looking into this, I've been on vacation and travel.

Quoted 10 lines

genpath is a detail of buildmakevars2file. Replace the dependency to genpath with the actual buildmakevars2file target. This change by itself does not fix any bug. Upcoming changes will add dependencies to $(target), but no rule exist to create $(target).

No change in behaviour is expected by this patch.

Note: target.tmp ($(1).tmp) is not marked as .PHONY because move-if-changed in the target rule will remove target.tmp by renaming it to target. As a result make will always attempt to rebuild it.

Does the scheme you've got here end up differing from:

Quoted 7 lines
    $(1):
       rm -f $(1).tmp; \
        $(foreach var, $(BUILD_MAKE_VARS), \
                 echo "$(var)=\"$($(var))\"" >>$(1).tmp;) \
        $(call move-if-changed,$(1).tmp,$(1))

(i.e. avoiding the $(1).tmp rule)

In my testing make did always rebuild the targets depending on _paths.h for example. The reason is that _paths.h is .PHONY, which cause make to drop _paths.h and see it as new, even if the content did not change. With _paths.h.tmp being .PHONY _paths.h remains the same for make.

Not sure why that happens, perhaps thats how .PHONY works.

Olaf

#23 lore raw

Re: [PATCH 08/13] tools/hotplug: use XEN_SCRIPT_DIR instead of hardcoded path

In reply to Ian Campbell
Quoted 10 lines · Ian Campbell

tools/hotplug/Linux/Makefile XEN_SCRIPT_DATA += block-common.sh · line 37

Quoted 8 lines · Olaf Hering

+++ b/tools/hotplug/Linux/Makefile

tools/hotplug/Linux/Makefile +3 -0
@@ -32,18 +32,47 @@ XEN_SCRIPT_DATA += block-common.sh
 UDEV_RULES_DIR = $(CONFIG_DIR)/udev
 UDEV_RULES = xen-backend.rules $(UDEV_RULES-y)
 
+USED_PATH = "_used_path.sh"
+genpath-target = $(call buildmakevars2file,$(USED_PATH))
+$(eval $(genpath-target))

I can't see where _used_path.sh is consumed.

I will add a comment, has something todo with the need to rerun the rules if the PATHS do change.

Quoted 8 lines

tools/hotplug/Linux/Makefile XEN_SCRIPT_DATA += block-common.sh · line 54

Quoted 5 lines
tools/hotplug/Linux/Makefile +5 -0
+%: %.in
+	set -e; \
+		rm -f [email protected] ; \
+		sed 's|@@XEN_SCRIPT_DIR@@|$(XEN_SCRIPT_DIR)|g' $< >[email protected] ; \
+		$(call move-if-changed,[email protected],$@)

Can you make these substitutions directly from tools/configure.ac? I think Luis did something similar for the systemd stuff?

Maybe, what I remmeber is that sed is used as well now.
I have to rebase my series to staging and see how the result looks like.

Olaf

#5 lore raw

Re: [PATCH 02/13] Config.mk: replace dependency to genpath with actual target

In reply to Olaf Hering
Quoted 26 lines · Olaf Hering
Quoted 24 lines · Ian Campbell

On Mon, 2014-07-28 at 11:05 +0200, Olaf Hering wrote:

Sorry for the delay in looking into this, I've been on vacation and travel.

Quoted 10 lines

genpath is a detail of buildmakevars2file. Replace the dependency to genpath with the actual buildmakevars2file target. This change by itself does not fix any bug. Upcoming changes will add dependencies to $(target), but no rule exist to create $(target).

No change in behaviour is expected by this patch.

Note: target.tmp ($(1).tmp) is not marked as .PHONY because move-if-changed in the target rule will remove target.tmp by renaming it to target. As a result make will always attempt to rebuild it.

Does the scheme you've got here end up differing from:

    $(1):
       rm -f $(1).tmp; \
        $(foreach var, $(BUILD_MAKE_VARS), \
                 echo "$(var)=\"$($(var))\"" >>$(1).tmp;) \
        $(call move-if-changed,$(1).tmp,$(1))
Quoted 5 lines
Quoted 1 line

(i.e. avoiding the $(1).tmp rule)

In my testing make did always rebuild the targets depending on _paths.h for example. The reason is that _paths.h is .PHONY, which cause make to drop _paths.h and see it as new, even if the content did not change.

It seems that the bug here is that _paths.h is .PHONY then. Without that the use of move-if-changed would prevent the output file changing unnecessarily and make would not bother to rebuild the dependents.

Quoted 3 lines

With _paths.h.tmp being .PHONY _paths.h remains the same for make.

Not sure why that happens, perhaps thats how .PHONY works.

It essentially indicates to make that the target is not an actual file (it is in some sense "virtual") so make never checks for an existing file.

Ian.

#6 lore raw

Re: [PATCH 02/13] Config.mk: replace dependency to genpath with actual target

Quoted 3 lines · Ian Campbell

It seems that the bug here is that _paths.h is .PHONY then. Without that the use of move-if-changed would prevent the output file changing unnecessarily and make would not bother to rebuild the dependents.

It has to be checked every time to catch possible changes in the variables. How would that be checked without a .PHONY target, $(1) in this case?

Olaf

#7 lore raw

Re: [PATCH 02/13] Config.mk: replace dependency to genpath with actual target

Quoted 9 lines · Olaf Hering
Quoted 3 lines · Ian Campbell

It seems that the bug here is that _paths.h is .PHONY then. Without that the use of move-if-changed would prevent the output file changing unnecessarily and make would not bother to rebuild the dependents.

It has to be checked every time to catch possible changes in the variables. How would that be checked without a .PHONY target, $(1) in this case?

Sounds like we need something similar to the FORCE target used by both the xen subtree and Linux etc. See xen/Rules.mk.

Ian.

#8 lore raw

Re: [PATCH 02/13] Config.mk: replace dependency to genpath with actual target

Quoted 2 lines · Ian Campbell

Sounds like we need something similar to the FORCE target used by both the xen subtree and Linux etc. See xen/Rules.mk.

Thanks for the suggestion. I will have a look at this in about two weeks from now.

Olaf

#9 lore raw

Re: [PATCH 02/13] Config.mk: replace dependency to genpath with actual target

In reply to Olaf Hering

A question related to the change below:

How are the make variables supposed to be changed? Right now this can be done either with rerunning configure (untested by me) and by calling something like 'make SBINDIR=/x/y XEN_RUN_DIR=/a/b' (used as testcase).

I think we should arrange the code such that a new configure run is required to change their value.

Olaf

Quoted 40 lines · Olaf Hering

genpath is a detail of buildmakevars2file. Replace the dependency to genpath with the actual buildmakevars2file target. This change by itself does not fix any bug. Upcoming changes will add dependencies to $(target), but no rule exist to create $(target).

No change in behaviour is expected by this patch.

Note: target.tmp ($(1).tmp) is not marked as .PHONY because move-if-changed in the target rule will remove target.tmp by renaming it to target. As a result make will always attempt to rebuild it.

---
 Config.mk                     |  9 +++++----
 stubdom/Makefile              | 16 ++++++++--------
 tools/hotplug/common/Makefile |  2 +-
 tools/libxl/Makefile          |  2 +-
 tools/python/Makefile         |  2 +-
 5 files changed, 16 insertions(+), 15 deletions(-)
Config.mk +5 -4
index 2408fa6..28e9930 100644
@@ -172,11 +172,12 @@ BUILD_MAKE_VARS := SBINDIR BINDIR LIBEXEC LIBDIR SHAREDIR PRIVATE_BINDIR \
 
 buildmakevars2file = $(eval $(call buildmakevars2file-closure,$(1)))
 define buildmakevars2file-closure
-    .PHONY: genpath
-    genpath:
-	rm -f $(1).tmp; \
+    $(1).tmp:
+	rm -f $(1).newtmp; \
 	$(foreach var, $(BUILD_MAKE_VARS), \
-	          echo "$(var)=\"$($(var))\"" >>$(1).tmp;) \
+	          echo "$(var)=\"$($(var))\"" >>$(1).newtmp;) \
+	$(call move-if-changed,$(1).newtmp,$(1).tmp)
+    $(1): $(1).tmp
 	$(call move-if-changed,$(1).tmp,$(1))
 endef
#10 lore raw

Re: [PATCH 02/13] Config.mk: replace dependency to genpath with actual target

Quoted 8 lines · Olaf Hering

A question related to the change below:

How are the make variables supposed to be changed? Right now this can be done either with rerunning configure (untested by me) and by calling something like 'make SBINDIR=/x/y XEN_RUN_DIR=/a/b' (used as testcase).

I think we should arrange the code such that a new configure run is required to change their value.

I think we've been moving (and should be moving) in the direction of configuring these things via configure, so that would be ok by me. (I'm assuming these don't affect the hypervisor build/install, which isn't configure driven)

#11 lore raw

Re: [PATCH 02/13] Config.mk: replace dependency to genpath with actual target

Quoted 7 lines · Ian Campbell
Quoted 6 lines · Olaf Hering

A question related to the change below:

How are the make variables supposed to be changed? Right now this can be done either with rerunning configure (untested by me) and by calling something like 'make SBINDIR=/x/y XEN_RUN_DIR=/a/b' (used as testcase).

Quoted 7 lines
Quoted 2 lines

I think we should arrange the code such that a new configure run is required to change their value.

I think we've been moving (and should be moving) in the direction of configuring these things via configure, so that would be ok by me. (I'm assuming these don't affect the hypervisor build/install, which isn't configure driven)

Unfortunately, m4/paths.m4 shows that configure will change just prefix and libdir. Other parts of config/Paths.mk.in are kind of hardcoded. I will see how to implement a knob for at least CONFIG_DIR and INITD_DIR.

Olaf

#12 lore raw

Re: [PATCH 02/13] Config.mk: replace dependency to genpath with actual target

Quoted 12 lines · Olaf Hering
Quoted 10 lines · Ian Campbell
Quoted 8 lines · Olaf Hering

A question related to the change below:

How are the make variables supposed to be changed? Right now this can be done either with rerunning configure (untested by me) and by calling something like 'make SBINDIR=/x/y XEN_RUN_DIR=/a/b' (used as testcase).

I think we should arrange the code such that a new configure run is required to change their value.

Quoted 8 lines
Quoted 4 lines

I think we've been moving (and should be moving) in the direction of configuring these things via configure, so that would be ok by me. (I'm assuming these don't affect the hypervisor build/install, which isn't configure driven)

Unfortunately, m4/paths.m4 shows that configure will change just prefix and libdir. Other parts of config/Paths.mk.in are kind of hardcoded. I will see how to implement a knob for at least CONFIG_DIR and INITD_DIR.

I think there is an existing autoconf name for CONFIG_DIR (sysconfdir?) which I suppose we aren't properly using.

Not sure how INITD_DIR is dealt with in autofoo world, I suppose the default is $sysconfdir/init.d? Does it ever get set to anything else?

Ian.

#13 lore raw

Re: [PATCH 02/13] Config.mk: replace dependency to genpath with actual target

Quoted 6 lines · Ian Campbell
Quoted 3 lines · Olaf Hering

Unfortunately, m4/paths.m4 shows that configure will change just prefix and libdir. Other parts of config/Paths.mk.in are kind of hardcoded. I will see how to implement a knob for at least CONFIG_DIR and INITD_DIR.

I think there is an existing autoconf name for CONFIG_DIR (sysconfdir?) which I suppose we aren't properly using.

Once I resend this series it will include also additional changes to set a few important paths via configure.

Olaf