build: stubdom and tools should depend on public header target
authorWei Liu <wei.liu2@citrix.com>
Wed, 17 May 2017 14:26:08 +0000 (15:26 +0100)
committerWei Liu <wei.liu2@citrix.com>
Thu, 18 May 2017 09:53:17 +0000 (10:53 +0100)
Build can fail if stubdom build is run before tools build because:

1. tools/include build uses relative path and depends on XEN_OS
2. stubdom needs tools/include to be built, at which time XEN_OS is
   mini-os and corresponding symlinks are created
3. libraries inside tools needs tools/include to be built, at which
   time XEN_OS is the host os name, but symlinks won't be created
   because they are already there
4. libraries get the wrong headers and fail to build

Since both tools and stubdom build need the public headers, we build
tools/include before stubdom and tools. Remove runes in stubdom and
tools to avoid building tools/include more than once.

Provide a new dist target for tools/include.  Hook up the install,
clean, dist and distclean targets for tools/include.

The new arrangement ensures tools build gets the correct headers
because XEN_OS is set to host os when building tools/include. As for
stubdom, it explicitly links to the mini-os directory without relying
on XEN_OS so it should be fine.

Reported-by: Steven Haigh <netwiz@crc.id.au>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Steven Haigh <netwiz@crc.id.au>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-acked-by: Julien Grall <julien.grall@arm.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Makefile
stubdom/Makefile
tools/Makefile
tools/include/Makefile

index 084588e11eff8d6f664d898eab9a18d93910c468..3e1e065537e8dc1f61265c72f58c93c2e2d7a3f5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -38,9 +38,14 @@ mini-os-dir-force-update: mini-os-dir
 export XEN_TARGET_ARCH
 export DESTDIR
 
+.PHONY: build-tools-public-headers
+build-tools-public-headers:
+       $(MAKE) -C tools/include
+
 # build and install everything into the standard system directories
 .PHONY: install
 install: $(TARGS_INSTALL)
+       $(MAKE) -C tools/include install
 
 .PHONY: build
 build: $(TARGS_BUILD)
@@ -50,11 +55,11 @@ build-xen:
        $(MAKE) -C xen build
 
 .PHONY: build-tools
-build-tools:
+build-tools: build-tools-public-headers
        $(MAKE) -C tools build
 
 .PHONY: build-stubdom
-build-stubdom: mini-os-dir
+build-stubdom: mini-os-dir build-tools-public-headers
        $(MAKE) -C stubdom build
 ifeq (x86_64,$(XEN_TARGET_ARCH))
        XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub
@@ -75,6 +80,7 @@ test:
 .PHONY: dist
 dist: DESTDIR=$(DISTDIR)/install
 dist: $(TARGS_DIST) dist-misc
+       make -C tools/include dist
 
 dist-misc:
        $(INSTALL_DIR) $(DISTDIR)/
@@ -101,7 +107,7 @@ install-tools:
        $(MAKE) -C tools install
 
 .PHONY: install-stubdom
-install-stubdom: mini-os-dir
+install-stubdom: mini-os-dir build-tools-public-headers
        $(MAKE) -C stubdom install
 ifeq (x86_64,$(XEN_TARGET_ARCH))
        XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom install-grub
@@ -168,6 +174,7 @@ src-tarball: subtree-force-update-all
 
 .PHONY: clean
 clean: $(TARGS_CLEAN)
+       $(MAKE) -C tools/include clean
 
 .PHONY: clean-xen
 clean-xen:
@@ -191,6 +198,7 @@ clean-docs:
 # clean, but blow away tarballs
 .PHONY: distclean
 distclean: $(TARGS_DISTCLEAN)
+       $(MAKE) -C tools/include distclean
        rm -f config/Toplevel.mk
        rm -rf dist
        rm -rf config.log config.status config.cache autom4te.cache
index aef705dd1e7f68cf869b20dc9a6d226dc14c3a4e..db0182707095a0f9aef152c85e200ef7304c2c1a 100644 (file)
@@ -355,7 +355,6 @@ LINK_DIRS := libxc-$(XEN_TARGET_ARCH) xenstore $(foreach dir,$(LINK_LIBS_DIRS),l
 LINK_STAMPS := $(foreach dir,$(LINK_DIRS),$(dir)/stamp)
 
 mk-headers-$(XEN_TARGET_ARCH): $(IOEMU_LINKFARM_TARGET) $(LINK_STAMPS)
-       $(MAKE) -C $(XEN_ROOT)/tools/include
        mkdir -p include/xen && \
           ln -sf $(wildcard $(XEN_ROOT)/xen/include/public/*.h) include/xen && \
           ln -sf $(addprefix $(XEN_ROOT)/xen/include/public/,arch-x86 hvm io xsm) include/xen && \
index 1396d95b5034483d44fa93a587a0d7a2064931f5..496428e3a918cda49b9bace50d4d412eb18008f1 100644 (file)
@@ -5,7 +5,6 @@ export PKG_CONFIG_DIR = $(CURDIR)/pkg-config
 include $(XEN_ROOT)/tools/Rules.mk
 
 SUBDIRS-y :=
-SUBDIRS-y += include
 SUBDIRS-y += libs
 SUBDIRS-y += libxc
 SUBDIRS-y += flask
@@ -50,7 +49,7 @@ SUBDIRS-$(OCAML_TOOLS) += ocaml
 endif
 
 ifeq ($(CONFIG_RUMP),y)
-SUBDIRS-y := include libxc xenstore
+SUBDIRS-y := libxc xenstore
 endif
 
 # For the sake of linking, set the sys-root
index f1af91c1298011043bbc7c00155d12681b76129a..98b479f6a398d01afdace4657bff79d70a4cb06e 100644 (file)
@@ -63,6 +63,8 @@ clean:
        rm -rf xen xen-xsm acpi
        $(MAKE) -C xen-foreign clean
 
+.PHONY: dist
+dist: install
 
 .PHONY: distclean
 distclean: clean