Skip to contentSkip to conversation

Toolstack build system improvement, toward non-recursive makefiles

PATCH Superseded Anthony PERARD 8 participants 73 messages Jun 24, 2022 – Aug 8, 2022

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover Toolstack build system improvement, toward non-recursive makefiles

Patch series available in this git branch:
https://xenbits.xen.org/git-http/people/aperard/xen-unstable.git br.toolstack-build-system-v3

Changes in v3:
- rebased
- several new patches, starting with 13/25 "tools/libs/util: cleanup Makefile"
- introducing macros to deal with linking with in-tree xen libraries
- Add -Werror to CFLAGS for all builds in tools/

Changes in v2:
- one new patch
- other changes described in patch notes

Hi everyone,

I've been looking at reworking the build system we have for the "tools/", and transforming it to something that suit it better. There are a lot of dependencies between different sub-directories so it would be nice if GNU make could actually handle them. This is possible with "non-recursive makefiles".

With non-recursive makefiles, make will have to load/include all the makefiles and thus will have complete overview of all the dependencies. This will allow make to build the necessary targets in other directory, and we won't need to build sub-directories one by one.

To help with this transformation, I've chosen to go with a recent project called "subdirmk". It help to deal with the fact that all makefiles will share the same namespace, it is hooked into autoconf, we can easily run make from any subdirectory. Together "autoconf" and "subdirmk" will also help to get closer to be able to do out-of-tree build of the tools, but I'm mainly looking to have non-recursive makefile.

Link to the project:
https://www.chiark.greenend.org.uk/ucgi/~ian/git/subdirmk.git/

But before getting to the main course, I've got quite a few cleanup and some changes to the makefiles. I start the patch series with patches that remove old left over stuff, then start reworking makefiles. They are some common changes like removing the "build" targets in many places as "all" would be the more common way to spell it and "all" is the default target anyway. They are other changes related to the conversion to "subdirmk", I start to use the variable $(TARGETS) in several makefiles, this variable will have a special meaning in subdirmk which will build those target by default.

As for the conversion to non-recursive makefile, with subdirmk, I have this WIP branch, it contains some changes that I'm trying out, some notes, and the conversion, one Makefile per commit. Cleanup are still needed, some makefile not converted yet, but it's otherwise mostly done.

https://xenbits.xen.org/git-http/people/aperard/xen-unstable.git br.toolstack-build-system-v1-wip-extra

With that branch, you could tried something like:
./configure; cd tools/xl; make
and xl should be built as well as all the xen library needed. Also, things like make clean or rebuild should be faster in the all tools/ directory.

Cheers,

Anthony PERARD (25):
tools/console: have one Makefile per program/directory tools/debugger/gdbsx: Fix and cleanup makefiles tools/examples: cleanup Makefile tools/firmware/hvmloader: rework Makefile tools/fuzz/libelf: rework makefile tools/fuzz/x86_instruction_emulator: rework makefile tools/hotplug: cleanup Makefiles
tools/libfsimage: Cleanup makefiles
tools/xenpaging: Rework makefile
tools/xentop: rework makefile
tools/xentrace: rework Makefile
.gitignore: Cleanup ignores of tools/libs/*/{headers.chk,*.pc} tools/libs/util: cleanup Makefile
tools/flask/utils: list build targets in $(TARGETS) libs/libs.mk: Rename $(LIB) to $(TARGETS) libs/libs.mk: Remove the need for $(PKG_CONFIG_INST) libs/libs.mk: Rework target headers.chk dependencies
tools: Introduce $(xenlibs-rpath,..) to replace $(SHDEPS_lib*)
tools: Introduce $(xenlibs-ldlibs, ) macro
tools: Introduce $(xenlibs-ldflags, ) macro tools/helper: Cleanup Makefile
tools/console: Use $(xenlibs-ldlibs,)
tools/helpers: Fix build of xen-init-dom0 with -Werror
tools: Add -Werror by default to all tools/
tools: Remove -Werror everywhere else

 tools/configure.ac                            |  1 +
 tools/Makefile                                |  2 +-
 tools/console/Makefile                        | 49 +----------------
 tools/console/client/Makefile                 | 37 +++++++++++++
 tools/console/daemon/Makefile                 | 45 +++++++++++++++
 tools/debugger/gdbsx/Makefile                 | 20 +++----
 tools/debugger/gdbsx/gx/Makefile              | 15 +++--
 tools/debugger/gdbsx/xg/Makefile              | 25 +++------
 tools/debugger/kdd/Makefile                   |  1 -
 tools/examples/Makefile                       | 25 ++-------
 tools/firmware/hvmloader/Makefile             | 16 +++---
 tools/flask/utils/Makefile                    | 11 ++--
 tools/fuzz/cpu-policy/Makefile                |  2 +-
 tools/fuzz/libelf/Makefile                    | 21 ++++---
 tools/fuzz/x86_instruction_emulator/Makefile  | 32 +++++------
 tools/golang/xenlight/Makefile                |  2 +-
 tools/helpers/Makefile                        | 23 ++++----
 tools/hotplug/FreeBSD/Makefile                | 11 +---
 tools/hotplug/Linux/Makefile                  | 16 ++----
 tools/hotplug/Linux/systemd/Makefile          | 16 +++---
 tools/hotplug/NetBSD/Makefile                 |  9 +--
 tools/hotplug/common/Makefile                 | 16 ++----
 tools/libfsimage/common/Makefile              | 11 +---
 tools/libfsimage/ext2fs-lib/Makefile          |  9 ---
 tools/libfsimage/ext2fs/Makefile              |  9 ---
 tools/libfsimage/fat/Makefile                 |  9 ---
 tools/libfsimage/iso9660/Makefile             | 11 ----
 tools/libfsimage/reiserfs/Makefile            |  9 ---
 tools/libfsimage/ufs/Makefile                 |  9 ---
 tools/libfsimage/xfs/Makefile                 |  9 ---
 tools/libfsimage/zfs/Makefile                 |  9 ---
 tools/libs/util/Makefile                      |  3 +-
 tools/misc/Makefile                           |  1 -
 tools/tests/cpu-policy/Makefile               |  2 +-
 tools/tests/depriv/Makefile                   |  2 +-
 tools/tests/resource/Makefile                 |  1 -
 tools/tests/tsx/Makefile                      |  1 -
 tools/tests/xenstore/Makefile                 |  1 -
 tools/xcutils/Makefile                        |  2 -
 tools/xenmon/Makefile                         |  1 -
 tools/xenpaging/Makefile                      | 25 ++++-----
 tools/xenpmd/Makefile                         |  1 -
 tools/xentop/Makefile                         | 23 ++++----
 tools/xentrace/Makefile                       | 21 +++----
 tools/xl/Makefile                             |  2 +-
 tools/Rules.mk                                | 55 ++++++++++++++-----
 tools/debugger/gdbsx/Rules.mk                 |  2 +-
 tools/firmware/Rules.mk                       |  2 -
 tools/libfsimage/Rules.mk                     | 26 +++------
 tools/libfsimage/common.mk                    | 11 ++++
 tools/libs/libs.mk                            | 31 +++++------
 tools/helpers/xen-init-dom0.c                 |  2 +
 tools/ocaml/common.make                       |  2 +-
 .gitignore                                    | 35 ------------
 config/Tools.mk.in                            |  1 +
 tools/configure                               | 26 +++++++++
 tools/console/client/.gitignore               |  1 +
 tools/console/daemon/.gitignore               |  1 +
 tools/fuzz/libelf/.gitignore                  |  2 +
 .../fuzz/x86_instruction_emulator/.gitignore  |  7 +++
 tools/libs/.gitignore                         |  2 +
 tools/xenstore/Makefile.common                |  1 -
 62 files changed, 349 insertions(+), 424 deletions(-)
 create mode 100644 tools/console/client/Makefile
 create mode 100644 tools/console/daemon/Makefile
 create mode 100644 tools/libfsimage/common.mk
 create mode 100644 tools/console/client/.gitignore
 create mode 100644 tools/console/daemon/.gitignore
 create mode 100644 tools/fuzz/libelf/.gitignore
 create mode 100644 tools/fuzz/x86_instruction_emulator/.gitignore
Signature · 1 line
Anthony PERARD
#1 lore raw

PATCH v3 1/25 tools/console: have one Makefile per program/directory

Sources of both xenconsoled and xenconsole are already separated into different directory and don't share anything in common. Having two different Makefile means it's easier to deal with *FLAGS.

Some common changes:
Rename $(BIN) to $(TARGETS), this will be useful later. Stop removing *.so *.rpm *.a as they aren't created here. Use $(OBJS-y) to list objects.
Update $(CFLAGS) for the directory rather than a single object.

daemon:

    Remove the need for $(LDLIBS_xenconsoled), use $(LDLIBS) instead.
    Remove the need for $(CONSOLE_CFLAGS-y) and use $(CFLAGS-y)
	instead.

client:

    Remove the unused $(LDLIBS_xenconsole)

---

Notes:
v2:
- create per-directory .gitignore

 tools/console/Makefile          | 49 ++------------------------------
 tools/console/client/Makefile   | 39 +++++++++++++++++++++++++
 tools/console/daemon/Makefile   | 50 +++++++++++++++++++++++++++++++++
 .gitignore                      |  2 --
 tools/console/client/.gitignore |  1 +
 tools/console/daemon/.gitignore |  1 +
 6 files changed, 94 insertions(+), 48 deletions(-)
 create mode 100644 tools/console/client/Makefile
 create mode 100644 tools/console/daemon/Makefile
 create mode 100644 tools/console/client/.gitignore
 create mode 100644 tools/console/daemon/.gitignore
tools/console/Makefile +3 -46
index 207c04c9cd..63bd2ac302 100644
@@ -1,50 +1,7 @@
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS  += -Werror
+SUBDIRS-y := daemon client
 
-CFLAGS  += $(CFLAGS_libxenctrl)
-CFLAGS  += $(CFLAGS_libxenstore)
-LDLIBS += $(LDLIBS_libxenctrl)
-LDLIBS += $(LDLIBS_libxenstore)
-LDLIBS += $(SOCKET_LIBS)
-
-LDLIBS_xenconsoled += $(UTIL_LIBS)
-LDLIBS_xenconsoled += -lrt
-CONSOLE_CFLAGS-$(CONFIG_ARM) = -DCONFIG_ARM
-
-BIN      = xenconsoled xenconsole
-
-.PHONY: all
-all: $(BIN)
-
-.PHONY: clean
-clean:
-	$(RM) *.a *.so *.o *.rpm $(BIN) $(DEPS_RM)
-	$(RM) client/*.o daemon/*.o
-
-.PHONY: distclean
-distclean: clean
-
-daemon/main.o: CFLAGS += -include $(XEN_ROOT)/tools/config.h
-daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab) $(CFLAGS_libxenforeignmemory) $(CONSOLE_CFLAGS-y)
-xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c))
-	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxenforeignmemory) $(LDLIBS_xenconsoled) $(APPEND_LDFLAGS)
-
-client/main.o: CFLAGS += -include $(XEN_ROOT)/tools/config.h
-xenconsole: $(patsubst %.c,%.o,$(wildcard client/*.c))
-	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_xenconsole) $(APPEND_LDFLAGS)
-
-.PHONY: install
-install: $(BIN)
-	$(INSTALL_DIR) $(DESTDIR)/$(sbindir)
-	$(INSTALL_PROG) xenconsoled $(DESTDIR)/$(sbindir)
-	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
-	$(INSTALL_PROG) xenconsole $(DESTDIR)$(LIBEXEC_BIN)
-
-.PHONY: uninstall
-uninstall:
-	rm -f $(DESTDIR)$(LIBEXEC_BIN)/xenconsole
-	rm -f $(DESTDIR)$(sbindir)/xenconsoled
-
--include $(DEPS_INCLUDE)
+.PHONY: all clean install distclean uninstall
+all clean install distclean uninstall: %: subdirs-%
tools/console/client/Makefile new file +39 -0
new file mode 100644
index 0000000000..44176c6d93
@@ -0,0 +1,39 @@
+XEN_ROOT=$(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+CFLAGS += -Werror
+CFLAGS += $(CFLAGS_libxenctrl)
+CFLAGS += $(CFLAGS_libxenstore)
+CFLAGS += -include $(XEN_ROOT)/tools/config.h
+
+LDLIBS += $(LDLIBS_libxenctrl)
+LDLIBS += $(LDLIBS_libxenstore)
+LDLIBS += $(SOCKET_LIBS)
+
+OBJS-y := main.o
+
+TARGETS := xenconsole
+
+.PHONY: all
+all: $(TARGETS)
+
+xenconsole: $(OBJS-y)
+	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(APPEND_LDFLAGS)
+
+.PHONY: install
+install: all
+	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
+	$(INSTALL_PROG) xenconsole $(DESTDIR)$(LIBEXEC_BIN)
+
+.PHONY: uninstall
+uninstall:
+	rm -f $(DESTDIR)$(LIBEXEC_BIN)/xenconsole
+
+.PHONY: clean
+clean:
+	$(RM) *.o $(TARGETS) $(DEPS_RM)
+
+.PHONY: distclean
+distclean: clean
+
+-include $(DEPS_INCLUDE)
tools/console/daemon/Makefile new file +50 -0

50 lines not on this page · raw message

.gitignore +0 -2
index 18ef56a780..7cf26051db 100644
@@ -160,8 +160,6 @@ tools/libs/util/libxenutil.map
 tools/libs/vchan/headers.chk
 tools/libs/vchan/libxenvchan.map
 tools/libs/vchan/xenvchan.pc
-tools/console/xenconsole
-tools/console/xenconsoled
 tools/debugger/gdb/gdb-6.2.1-linux-i386-xen/*
 tools/debugger/gdb/gdb-6.2.1/*
 tools/debugger/gdb/gdb-6.2.1.tar.bz2
tools/console/client/.gitignore new file +1 -0
new file mode 100644
index 0000000000..b096a1d841
@@ -0,0 +1 @@
+/xenconsole
tools/console/daemon/.gitignore new file +1 -0
new file mode 100644
index 0000000000..55c8f84664
@@ -0,0 +1 @@
+/xenconsoled
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 1/25
#2 lore raw

Re: [XEN PATCH v3 01/25] tools/console: have one Makefile per program/directory

Quoted 19 lines · Anthony PERARD

Sources of both xenconsoled and xenconsole are already separated into different directory and don't share anything in common. Having two different Makefile means it's easier to deal with *FLAGS.

Some common changes:
Rename $(BIN) to $(TARGETS), this will be useful later. Stop removing *.so *.rpm *.a as they aren't created here. Use $(OBJS-y) to list objects.
Update $(CFLAGS) for the directory rather than a single object.

daemon:
Remove the need for $(LDLIBS_xenconsoled), use $(LDLIBS) instead. Remove the need for $(CONSOLE_CFLAGS-y) and use $(CFLAGS-y)
instead.

Quoted 4 lines

client:

   Remove the unused $(LDLIBS_xenconsole)

Hi Antony,

It looks good to me.

#3 lore raw

PATCH v3 2/25 tools/debugger/gdbsx: Fix and cleanup makefiles

In reply to Anthony PERARD

gdbsx/:
- Make use of subdir facility for the "clean" target.
- No need to remove the *.a, they aren't in this dir.
- Avoid calling "distclean" in subdirs as "distclean" targets do only call "clean", and the "clean" also runs "clean" in subdirs.
- Avoid the need to make "gx_all.a" and "xg_all.a" in the "all" recipe by forcing make to check for update of "xg/xg_all.a" and "gx/gx_all.a" by having "FORCE" as prerequisite. Now, when making "gdbsx", make will recurse even when both *.a already exist.
- List target in $(TARGETS).

gdbsx/*/:
- Fix dependency on *.h.
- Remove some dead code.
- List targets in $(TARGETS).
- Remove "build" target.
- Cleanup "clean" targets.
- remove comments about the choice of "ar" instead of "ld"
- Use "$(AR)" instead of plain "ar".

---

Notes:
v2:
- also replace plain "ar" by "$(AR)"

 tools/debugger/gdbsx/Makefile    | 20 ++++++++++----------
 tools/debugger/gdbsx/gx/Makefile | 15 +++++++--------
 tools/debugger/gdbsx/xg/Makefile | 25 +++++++------------------
 3 files changed, 24 insertions(+), 36 deletions(-)
tools/debugger/gdbsx/Makefile +10 -10
index 5571450a89..4aaf427c45 100644
@@ -1,20 +1,20 @@
 XEN_ROOT = $(CURDIR)/../../..
 include ./Rules.mk
 
+SUBDIRS-y += gx
+SUBDIRS-y += xg
+
+TARGETS := gdbsx
+
 .PHONY: all
-all:
-	$(MAKE) -C gx
-	$(MAKE) -C xg
-	$(MAKE) gdbsx
+all: $(TARGETS)
 
 .PHONY: clean
-clean:
-	rm -f xg_all.a gx_all.a gdbsx
-	set -e; for d in xg gx; do $(MAKE) -C $$d clean; done
+clean: subdirs-clean
+	rm -f $(TARGETS)
 
 .PHONY: distclean
 distclean: clean
-	set -e; for d in xg gx; do $(MAKE) -C $$d distclean; done
 
 .PHONY: install
 install: all
@@ -28,7 +28,7 @@ uninstall:
 gdbsx: gx/gx_all.a xg/xg_all.a 
 	$(CC) $(LDFLAGS) -o $@ $^
 
-xg/xg_all.a:
+xg/xg_all.a: FORCE
 	$(MAKE) -C xg
-gx/gx_all.a:
+gx/gx_all.a: FORCE
 	$(MAKE) -C gx
tools/debugger/gdbsx/gx/Makefile +7 -8
index 3b8467f799..e9859aea9c 100644
@@ -2,21 +2,20 @@ XEN_ROOT = $(CURDIR)/../../../..
 include ../Rules.mk
 
 GX_OBJS := gx_comm.o gx_main.o gx_utils.o gx_local.o
-GX_HDRS := $(wildcard *.h)
+
+TARGETS := gx_all.a
 
 .PHONY: all
-all: gx_all.a
+all: $(TARGETS)
 
 .PHONY: clean
 clean:
-	rm -rf gx_all.a *.o .*.d
+	rm -f *.o $(TARGETS) $(DEPS_RM)
 
 .PHONY: distclean
 distclean: clean
 
-#%.o: %.c $(GX_HDRS) Makefile
-#	$(CC) -c $(CFLAGS) -o $@ $<
-
-gx_all.a: $(GX_OBJS) Makefile $(GX_HDRS)
-	ar cr $@ $(GX_OBJS)        # problem with ld using -m32 
+gx_all.a: $(GX_OBJS) Makefile
+	$(AR) cr $@ $(GX_OBJS)
 
+-include $(DEPS_INCLUDE)
tools/debugger/gdbsx/xg/Makefile +7 -18
index acdcddf0d5..05325d6d81 100644
@@ -1,35 +1,24 @@
 XEN_ROOT = $(CURDIR)/../../../..
 include ../Rules.mk
 
-XG_HDRS := xg_public.h 
 XG_OBJS := xg_main.o 
 
 CFLAGS += -D__XEN_TOOLS__
 CFLAGS += $(CFLAGS_xeninclude)
 
+TARGETS := xg_all.a
 
 .PHONY: all
-all: build
+all: $(TARGETS)
 
-.PHONY: build
-build: xg_all.a $(XG_HDRS) $(XG_OBJS) Makefile
-# build: mk-symlinks xg_all.a $(XG_HDRS) $(XG_OBJS) Makefile
-# build: mk-symlinks xg_all.a
-
-xg_all.a: $(XG_OBJS) Makefile $(XG_HDRS)
-	ar cr $@ $(XG_OBJS)    # problems using -m32 in ld 
-#	$(LD) -b elf32-i386 $(LDFLAGS) -r -o $@ $^
-#	$(CC) -m32 -c -o $@ $^
-
-# xg_main.o: xg_main.c Makefile $(XG_HDRS)
-#$(CC) -c $(CFLAGS) -o $@ $<
-
-# %.o: %.c $(XG_HDRS) Makefile  -- doesn't work as it won't overwrite Rules.mk
-#%.o: %.c       -- doesn't recompile when .c changed
+xg_all.a: $(XG_OBJS) Makefile
+	$(AR) cr $@ $(XG_OBJS)
 
 .PHONY: clean
 clean:
-	rm -rf xen xg_all.a $(XG_OBJS)  .*.d
+	rm -f $(TARGETS) $(XG_OBJS) $(DEPS_RM)
 
 .PHONY: distclean
 distclean: clean
+
+-include $(DEPS_INCLUDE)
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 2/25
#4 lore raw

Re: [XEN PATCH v3 02/25] tools/debugger/gdbsx: Fix and cleanup makefiles

Quoted 24 lines · Anthony PERARD

gdbsx/:
- Make use of subdir facility for the "clean" target.
- No need to remove the *.a, they aren't in this dir.
- Avoid calling "distclean" in subdirs as "distclean" targets do only call "clean", and the "clean" also runs "clean" in subdirs.
- Avoid the need to make "gx_all.a" and "xg_all.a" in the "all" recipe by forcing make to check for update of "xg/xg_all.a" and "gx/gx_all.a" by having "FORCE" as prerequisite. Now, when making "gdbsx", make will recurse even when both *.a already exist.
- List target in $(TARGETS).

gdbsx/*/:
- Fix dependency on *.h.
- Remove some dead code.
- List targets in $(TARGETS).
- Remove "build" target.
- Cleanup "clean" targets.
- remove comments about the choice of "ar" instead of "ld"
- Use "$(AR)" instead of plain "ar".

Quoted 1 line

Hi Antony,

#5 lore raw

PATCH v3 3/25 tools/examples: cleanup Makefile

In reply to Anthony PERARD

Don't check if a target exist before installing it. For directory, install doesn't complain, and for file it would prevent from updating them. Also remove the existing loop and instead install all files with a single call to $(INSTALL_DATA).

Remove XEN_CONFIGS-y which isn't used.

Remove "build" target.

Add an empty line after the first comment. The comment isn't about $(XEN_READMES), it is about the makefile as a whole.

---

Notes:

    v2:
    - remove existing loops in install targets and use a single call to
      $(INSTALL_DATA) to install multiple files.
 tools/examples/Makefile | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
tools/examples/Makefile +6 -19
index 14e24f4cb3..c839bf5603 100644
@@ -2,6 +2,7 @@ XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 # Xen configuration dir and configs to go there.
+
 XEN_READMES = README
 
 XEN_CONFIGS += xlexample.hvm
@@ -10,14 +11,9 @@ XEN_CONFIGS += xlexample.pvhlinux
 XEN_CONFIGS += xl.conf
 XEN_CONFIGS += cpupool
 
-XEN_CONFIGS += $(XEN_CONFIGS-y)
-
 .PHONY: all
 all:
 
-.PHONY: build
-build:
-
 .PHONY: install
 install: all install-readmes install-configs
 
@@ -26,12 +22,8 @@ uninstall: uninstall-readmes uninstall-configs
 
 .PHONY: install-readmes
 install-readmes:
-	[ -d $(DESTDIR)$(XEN_CONFIG_DIR) ] || \
-		$(INSTALL_DIR) $(DESTDIR)$(XEN_CONFIG_DIR)
-	set -e; for i in $(XEN_READMES); \
-	    do [ -e $(DESTDIR)$(XEN_CONFIG_DIR)/$$i ] || \
-	    $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_CONFIG_DIR); \
-	done
+	$(INSTALL_DIR) $(DESTDIR)$(XEN_CONFIG_DIR)
+	$(INSTALL_DATA) $(XEN_READMES) $(DESTDIR)$(XEN_CONFIG_DIR)
 
 .PHONY: uninstall-readmes
 uninstall-readmes:
@@ -39,14 +31,9 @@ uninstall-readmes:
 
 .PHONY: install-configs
 install-configs: $(XEN_CONFIGS)
-	[ -d $(DESTDIR)$(XEN_CONFIG_DIR) ] || \
-		$(INSTALL_DIR) $(DESTDIR)$(XEN_CONFIG_DIR)
-	[ -d $(DESTDIR)$(XEN_CONFIG_DIR)/auto ] || \
-		$(INSTALL_DIR) $(DESTDIR)$(XEN_CONFIG_DIR)/auto
-	set -e; for i in $(XEN_CONFIGS); \
-	    do [ -e $(DESTDIR)$(XEN_CONFIG_DIR)/$$i ] || \
-	    $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_CONFIG_DIR); \
-	done
+	$(INSTALL_DIR) $(DESTDIR)$(XEN_CONFIG_DIR)
+	$(INSTALL_DIR) $(DESTDIR)$(XEN_CONFIG_DIR)/auto
+	$(INSTALL_DATA) $(XEN_CONFIGS) $(DESTDIR)$(XEN_CONFIG_DIR)
 
 .PHONY: uninstall-configs
 uninstall-configs:
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 3/25
#6 lore raw

Re: [XEN PATCH v3 03/25] tools/examples: cleanup Makefile

Quoted 9 lines · Anthony PERARD

Don't check if a target exist before installing it. For directory, install doesn't complain, and for file it would prevent from updating them. Also remove the existing loop and instead install all files with a single call to $(INSTALL_DATA).

Quoted 8 lines

Remove XEN_CONFIGS-y which isn't used.

Remove "build" target.

Add an empty line after the first comment. The comment isn't about $(XEN_READMES), it is about the makefile as a whole.

Hi Antony,

#7 lore raw

PATCH v3 4/25 tools/firmware/hvmloader: rework Makefile

In reply to Anthony PERARD

Setup proper dependencies with libacpi so we don't need to run "make hvmloader" in the "all" target. ("build.o" new prerequisite isn't exactly proper but a side effect of building the $(DSDT_FILES) is to generate the "ssdt_*.h" needed by "build.o".)

Make use if "-iquote" instead of a plain "-I".

For "roms.inc" target, use "$(SHELL)" instead of plain "sh". And use full path to "mkhex" instead of a relative one. Lastly, add "-f" flag to "mv", in case the target already exist.

---
 tools/firmware/hvmloader/Makefile | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
tools/firmware/hvmloader/Makefile +9 -7
index b754220839..fc20932110 100644
@@ -60,8 +60,7 @@ ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM)
 endif
 
 .PHONY: all
-all: acpi
-	$(MAKE) hvmloader
+all: hvmloader
 
 .PHONY: acpi
 acpi:
@@ -73,12 +72,15 @@ smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 ACPI_PATH = ../../libacpi
 DSDT_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
 ACPI_OBJS = $(patsubst %.c,%.o,$(DSDT_FILES)) build.o static_tables.o
-$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/util.h\"
+$(ACPI_OBJS): CFLAGS += -iquote . -DLIBACPI_STDUTILS=\"$(CURDIR)/util.h\"
 CFLAGS += -I$(ACPI_PATH)
 vpath build.c $(ACPI_PATH)
 vpath static_tables.c $(ACPI_PATH)
 OBJS += $(ACPI_OBJS)
 
+$(DSDT_FILES): acpi
+build.o: $(DSDT_FILES)
+
 hvmloader: $(OBJS) hvmloader.lds
 	$(LD) $(LDFLAGS_DIRECT) -N -T hvmloader.lds -o $@ $(OBJS)
 
@@ -87,21 +89,21 @@ roms.inc: $(ROMS)
 
 ifneq ($(ROMBIOS_ROM),)
 	echo "#ifdef ROM_INCLUDE_ROMBIOS" >> [email protected]
-	sh ../../misc/mkhex rombios $(ROMBIOS_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex rombios $(ROMBIOS_ROM) >> [email protected]
 	echo "#endif" >> [email protected]
 endif
 
 ifneq ($(STDVGA_ROM),)
 	echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]
-	sh ../../misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
 	echo "#endif" >> [email protected]
 endif
 ifneq ($(CIRRUSVGA_ROM),)
 	echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]
-	sh ../../misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
 	echo "#endif" >> [email protected]
 endif
-	mv [email protected] $@
+	mv -f [email protected] $@
 
 .PHONY: clean
 clean:
Signature · 1 line
Anthony PERARD
#8 lore raw

Re: [XEN PATCH v3 04/25] tools/firmware/hvmloader: rework Makefile

Quoted 72 lines · Anthony PERARD

Setup proper dependencies with libacpi so we don't need to run "make hvmloader" in the "all" target. ("build.o" new prerequisite isn't exactly proper but a side effect of building the $(DSDT_FILES) is to generate the "ssdt_*.h" needed by "build.o".)

Make use if "-iquote" instead of a plain "-I".

For "roms.inc" target, use "$(SHELL)" instead of plain "sh". And use full path to "mkhex" instead of a relative one. Lastly, add "-f" flag to "mv", in case the target already exist.

---
tools/firmware/hvmloader/Makefile | 16 +++++++++-------

1 file changed, 9 insertions(+), 7 deletions(-)
tools/firmware/hvmloader/Makefile +0 -0
index b754220839..fc20932110 100644
@@ -60,8 +60,7 @@ ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM)

endif

.PHONY: all

tools/firmware/hvmloader/Makefile +1 -2
-all: acpi
-	$(MAKE) hvmloader
+all: hvmloader

.PHONY: acpi
acpi:

tools/firmware/hvmloader/Makefile +0 -0
@@ -73,12 +72,15 @@ smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""

ACPI_PATH = ../../libacpi
DSDT_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c ACPI_OBJS = $(patsubst %.c,%.o,$(DSDT_FILES)) build.o static_tables.o -$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/util.h\" +$(ACPI_OBJS): CFLAGS += -iquote . -DLIBACPI_STDUTILS=\"$(CURDIR)/util.h\" CFLAGS += -I$(ACPI_PATH)
vpath build.c $(ACPI_PATH)
vpath static_tables.c $(ACPI_PATH)
OBJS += $(ACPI_OBJS)

+$(DSDT_FILES): acpi

tools/firmware/hvmloader/Makefile +2 -0
+build.o: $(DSDT_FILES)
+

hvmloader: $(OBJS) hvmloader.lds

	$(LD) $(LDFLAGS_DIRECT) -N -T hvmloader.lds -o $@ $(OBJS)
tools/firmware/hvmloader/Makefile +1 -1
@@ -87,21 +89,21 @@ roms.inc: $(ROMS)
 
 ifneq ($(ROMBIOS_ROM),)
 	echo "#ifdef ROM_INCLUDE_ROMBIOS" >> [email protected]
-	sh ../../misc/mkhex rombios $(ROMBIOS_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex rombios $(ROMBIOS_ROM) >> [email protected]
 	echo "#endif" >> [email protected]

endif

ifneq ($(STDVGA_ROM),)
echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]

tools/firmware/hvmloader/Makefile +1 -1
-	sh ../../misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
	echo "#endif" >> [email protected]

endif
ifneq ($(CIRRUSVGA_ROM),)
echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]

tools/firmware/hvmloader/Makefile +1 -1
-	sh ../../misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
	echo "#endif" >> [email protected]

endif

tools/firmware/hvmloader/Makefile roms.inc: $(ROMS) · line 106

Quoted 2 lines
tools/firmware/hvmloader/Makefile +1 -1
-	mv [email protected] $@
+	mv -f [email protected] $@

Here, instead of -f, is it safer -u? What’s your opinion on that? The patch looks good to me.

Quoted 7 lines

.PHONY: clean
clean:

Signature · 1 line
Anthony PERARD
#9 lore raw

Re: [XEN PATCH v3 04/25] tools/firmware/hvmloader: rework Makefile

Quoted 1 line · Luca Fancellu
Quoted 1 line · Anthony PERARD

[...]

Quoted 19 lines
Quoted 19 lines

For "roms.inc" target, use "$(SHELL)" instead of plain "sh". And use full path to "mkhex" instead of a relative one. Lastly, add "-f" flag to "mv", in case the target already exist.

---

tools/firmware/hvmloader/Makefile +1 -1
index b754220839..fc20932110 100644
@@ -87,21 +89,21 @@ roms.inc: $(ROMS)
 
 ifneq ($(ROMBIOS_ROM),)
 	echo "#ifdef ROM_INCLUDE_ROMBIOS" >> [email protected]
-	sh ../../misc/mkhex rombios $(ROMBIOS_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex rombios $(ROMBIOS_ROM) >> [email protected]
 	echo "#endif" >> [email protected]

endif

Quoted 16 lines
Quoted 12 lines

ifneq ($(STDVGA_ROM),)
echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]

tools/firmware/hvmloader/Makefile +1 -1
-	sh ../../misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
	echo "#endif" >> [email protected]

endif
ifneq ($(CIRRUSVGA_ROM),)
echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]

tools/firmware/hvmloader/Makefile +1 -1
-	sh ../../misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
	echo "#endif" >> [email protected]

endif

tools/firmware/hvmloader/Makefile roms.inc: $(ROMS) · line 106

Quoted 2 lines
tools/firmware/hvmloader/Makefile +1 -1
-	mv [email protected] $@
+	mv -f [email protected] $@

Here, instead of -f, is it safer -u? What’s your opinion on that? The patch looks good to me.

make want to rebuild the target, so there is no reason to keep the existing target. We do need to overwrite the existing target if it exist.

Thanks for the reviews!

Signature · 1 line
Anthony PERARD
Reviewed-by
#10 lore raw

Re: [XEN PATCH v3 04/25] tools/firmware/hvmloader: rework Makefile

Quoted 43 lines · Anthony PERARD
Quoted 1 line · Luca Fancellu
Quoted 1 line · Anthony PERARD

[...]

Quoted 19 lines
Quoted 19 lines

For "roms.inc" target, use "$(SHELL)" instead of plain "sh". And use full path to "mkhex" instead of a relative one. Lastly, add "-f" flag to "mv", in case the target already exist.

---

tools/firmware/hvmloader/Makefile +1 -1
index b754220839..fc20932110 100644
@@ -87,21 +89,21 @@ roms.inc: $(ROMS)
 
 ifneq ($(ROMBIOS_ROM),)
 	echo "#ifdef ROM_INCLUDE_ROMBIOS" >> [email protected]
-	sh ../../misc/mkhex rombios $(ROMBIOS_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex rombios $(ROMBIOS_ROM) >> [email protected]
 	echo "#endif" >> [email protected]

endif

Quoted 16 lines
Quoted 12 lines

ifneq ($(STDVGA_ROM),)
echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]

tools/firmware/hvmloader/Makefile +1 -1
-	sh ../../misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
	echo "#endif" >> [email protected]

endif
ifneq ($(CIRRUSVGA_ROM),)
echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]

tools/firmware/hvmloader/Makefile +1 -1
-	sh ../../misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
	echo "#endif" >> [email protected]

endif

tools/firmware/hvmloader/Makefile roms.inc: $(ROMS) · line 106

Quoted 2 lines
tools/firmware/hvmloader/Makefile +1 -1
-	mv [email protected] $@
+	mv -f [email protected] $@

Here, instead of -f, is it safer -u? What’s your opinion on that? The patch looks good to me.

Quoted 5 lines

make want to rebuild the target, so there is no reason to keep the existing target. We do need to overwrite the existing target if it exist.

Thanks for the reviews!

Ok thanks for the clarification, as I said the changes looks good to me:

Quoted 3 lines
Signature · 2 lines
-- 
Anthony PERARD
#11 lore raw

Re: [XEN PATCH v3 04/25] tools/firmware/hvmloader: rework Makefile

In reply to Luca Fancellu
Quoted 10 lines · Luca Fancellu
Quoted 10 lines · Anthony PERARD
tools/firmware/hvmloader/Makefile +1 -1
@@ -87,21 +89,21 @@ roms.inc: $(ROMS)
 
 ifneq ($(ROMBIOS_ROM),)
 	echo "#ifdef ROM_INCLUDE_ROMBIOS" >> [email protected]
-	sh ../../misc/mkhex rombios $(ROMBIOS_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex rombios $(ROMBIOS_ROM) >> [email protected]
 	echo "#endif" >> [email protected]

endif

Quoted 16 lines
Quoted 12 lines

ifneq ($(STDVGA_ROM),)
echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]

tools/firmware/hvmloader/Makefile +1 -1
-	sh ../../misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
	echo "#endif" >> [email protected]

endif
ifneq ($(CIRRUSVGA_ROM),)
echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]

tools/firmware/hvmloader/Makefile +1 -1
-	sh ../../misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
	echo "#endif" >> [email protected]

endif

tools/firmware/hvmloader/Makefile roms.inc: $(ROMS) · line 106

Quoted 2 lines
tools/firmware/hvmloader/Makefile +1 -1
-	mv [email protected] $@
+	mv -f [email protected] $@

Here, instead of -f, is it safer -u? What’s your opinion on that? The patch looks good to me.

Would -u be an option to use in the first place? It's not a standard option to mv, afaict.

Jan

#12 lore raw

Re: [XEN PATCH v3 04/25] tools/firmware/hvmloader: rework Makefile

In reply to Anthony PERARD
Quoted 4 lines · Anthony PERARD

Setup proper dependencies with libacpi so we don't need to run "make hvmloader" in the "all" target. ("build.o" new prerequisite isn't exactly proper but a side effect of building the $(DSDT_FILES) is to generate the "ssdt_*.h" needed by "build.o".)

Maybe leave a brief comment there?

Quoted 5 lines

Make use if "-iquote" instead of a plain "-I".

For "roms.inc" target, use "$(SHELL)" instead of plain "sh". And use full path to "mkhex" instead of a relative one. Lastly, add "-f" flag to "mv", in case the target already exist.

Hmm - according to my understanding -f isn't needed just because the file may already exist. It would be needed if a pre-existing file isn't writable. (I don't mind the addition of the flag, but I think what you say can end up misleading.)

Jan

Quoted 62 lines
---
 tools/firmware/hvmloader/Makefile | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
tools/firmware/hvmloader/Makefile +9 -7
index b754220839..fc20932110 100644
@@ -60,8 +60,7 @@ ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM)
 endif
 
 .PHONY: all
-all: acpi
-	$(MAKE) hvmloader
+all: hvmloader
 
 .PHONY: acpi
 acpi:
@@ -73,12 +72,15 @@ smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 ACPI_PATH = ../../libacpi
 DSDT_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
 ACPI_OBJS = $(patsubst %.c,%.o,$(DSDT_FILES)) build.o static_tables.o
-$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/util.h\"
+$(ACPI_OBJS): CFLAGS += -iquote . -DLIBACPI_STDUTILS=\"$(CURDIR)/util.h\"
 CFLAGS += -I$(ACPI_PATH)
 vpath build.c $(ACPI_PATH)
 vpath static_tables.c $(ACPI_PATH)
 OBJS += $(ACPI_OBJS)
 
+$(DSDT_FILES): acpi
+build.o: $(DSDT_FILES)
+
 hvmloader: $(OBJS) hvmloader.lds
 	$(LD) $(LDFLAGS_DIRECT) -N -T hvmloader.lds -o $@ $(OBJS)
 
@@ -87,21 +89,21 @@ roms.inc: $(ROMS)
 
 ifneq ($(ROMBIOS_ROM),)
 	echo "#ifdef ROM_INCLUDE_ROMBIOS" >> [email protected]
-	sh ../../misc/mkhex rombios $(ROMBIOS_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex rombios $(ROMBIOS_ROM) >> [email protected]
 	echo "#endif" >> [email protected]
 endif
 
 ifneq ($(STDVGA_ROM),)
 	echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]
-	sh ../../misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
 	echo "#endif" >> [email protected]
 endif
 ifneq ($(CIRRUSVGA_ROM),)
 	echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]
-	sh ../../misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
+	$(SHELL) $(XEN_ROOT)/tools/misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
 	echo "#endif" >> [email protected]
 endif
-	mv [email protected] $@
+	mv -f [email protected] $@
 
 .PHONY: clean
 clean:
#13 lore raw

Re: [XEN PATCH v3 04/25] tools/firmware/hvmloader: rework Makefile

Quoted 7 lines · Jan Beulich
Quoted 4 lines · Anthony PERARD

Setup proper dependencies with libacpi so we don't need to run "make hvmloader" in the "all" target. ("build.o" new prerequisite isn't exactly proper but a side effect of building the $(DSDT_FILES) is to generate the "ssdt_*.h" needed by "build.o".)

Maybe leave a brief comment there?

Sounds good.

Quoted 10 lines
Quoted 5 lines

Make use if "-iquote" instead of a plain "-I".

For "roms.inc" target, use "$(SHELL)" instead of plain "sh". And use full path to "mkhex" instead of a relative one. Lastly, add "-f" flag to "mv", in case the target already exist.

Hmm - according to my understanding -f isn't needed just because the file may already exist. It would be needed if a pre-existing file isn't writable. (I don't mind the addition of the flag, but I think what you say can end up misleading.)

Yes. After reading the posix doc about mv, the following would be better:

Lastly, add "-f" flag to "mv" to avoid a prompt in case the target already exist and we don't have write permission.

Thanks,

Signature · 1 line
Anthony PERARD
#14 lore raw

PATCH v3 5/25 tools/fuzz/libelf: rework makefile

In reply to Anthony PERARD

Rename ELF_LIB_OBJS to LIBELF_OBJS as to have the same name as in libs/guest/.

Replace "-I" by "-iquote".

Remove the use of "vpath". It will not works when we will convert this makefile to subdirmk. Instead, we create symlinks to the source files.

Since we are creating a new .gitignore for the links, also move the existing entry to it.

---

Notes:
v2:
- create a per-directory .gitignore to add new entry and existing one

 tools/fuzz/libelf/Makefile   | 21 ++++++++++-----------
 .gitignore                   |  1 -
 tools/fuzz/libelf/.gitignore |  2 ++
 3 files changed, 12 insertions(+), 12 deletions(-)
 create mode 100644 tools/fuzz/libelf/.gitignore
tools/fuzz/libelf/Makefile +10 -11
index 9eb30ee40c..9211f75951 100644
@@ -1,25 +1,24 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-# libelf fuzz target
-vpath %.c ../../../xen/common/libelf
-CFLAGS += -I../../../xen/common/libelf
-ELF_SRCS-y += libelf-tools.c libelf-loader.c libelf-dominfo.c
-ELF_LIB_OBJS := $(patsubst %.c,%.o,$(ELF_SRCS-y))
+LIBELF_OBJS := libelf-tools.o libelf-loader.o libelf-dominfo.o
 
-$(patsubst %.c,%.o,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
-
-$(ELF_LIB_OBJS): CFLAGS += -DFUZZ_NO_LIBXC $(CFLAGS_xeninclude)
+CFLAGS += -iquote ../../../xen/common/libelf
+$(LIBELF_OBJS): CFLAGS += -Wno-pointer-sign
+$(LIBELF_OBJS): CFLAGS += -DFUZZ_NO_LIBXC $(CFLAGS_xeninclude)
 
 libelf-fuzzer.o: CFLAGS += $(CFLAGS_xeninclude)
 
-libelf.a: libelf-fuzzer.o $(ELF_LIB_OBJS)
+$(LIBELF_OBJS:.o=.c): libelf-%.c: ../../../xen/common/libelf/libelf-%.c FORCE
+	ln -nsf $< $@
+
+libelf.a: libelf-fuzzer.o $(LIBELF_OBJS)
 	$(AR) rc $@ $^
 
 .PHONY: libelf-fuzzer-all
 libelf-fuzzer-all: libelf.a libelf-fuzzer.o
 
-afl-libelf-fuzzer: afl-libelf-fuzzer.o libelf-fuzzer.o $(ELF_LIB_OBJS)
+afl-libelf-fuzzer: afl-libelf-fuzzer.o libelf-fuzzer.o $(LIBELF_OBJS)
 	$(CC) $(CFLAGS) $^ -o $@
 
 # Common targets
@@ -31,7 +30,7 @@ distclean: clean
 
 .PHONY: clean
 clean:
-	rm -f *.o .*.d *.a *-libelf-fuzzer
+	rm -f *.o .*.d *.a *-libelf-fuzzer $(LIBELF_OBJS:.o=.c)
 
 .PHONY: install
 install: all
.gitignore +0 -1
index 7cf26051db..6410dfbc72 100644
@@ -195,7 +195,6 @@ tools/flask/utils/flask-loadpolicy
 tools/flask/utils/flask-setenforce
 tools/flask/utils/flask-set-bool
 tools/flask/utils/flask-label-pci
-tools/fuzz/libelf/afl-libelf-fuzzer
 tools/fuzz/x86_instruction_emulator/asm
 tools/fuzz/x86_instruction_emulator/afl-harness
 tools/fuzz/x86_instruction_emulator/afl-harness-cov
tools/fuzz/libelf/.gitignore new file +2 -0
new file mode 100644
index 0000000000..ed634214c9
@@ -0,0 +1,2 @@
+/afl-libelf-fuzzer
+/libelf-*.c
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 5/25
#15 lore raw

Re: [XEN PATCH v3 05/25] tools/fuzz/libelf: rework makefile

Quoted 9 lines · Anthony PERARD

Rename ELF_LIB_OBJS to LIBELF_OBJS as to have the same name as in libs/guest/.

Replace "-I" by "-iquote".

Quoted 8 lines

Remove the use of "vpath". It will not works when we will convert this makefile to subdirmk. Instead, we create symlinks to the source files.

Since we are creating a new .gitignore for the links, also move the existing entry to it.

—

Hi Antony,

#16 lore raw

PATCH v3 6/25 tools/fuzz/x86_instruction_emulator: rework makefile

In reply to Anthony PERARD

Rework dependencies of all objects. We don't need to add dependencies for headers that $(CC) is capable of generating, we only need to include $(DEPS_INCLUDE). Some dependencies are still needed so make knows to generate symlinks for them.

We remove the use of "vpath" for cpuid.c. While it works fine for now, when we will convert this makefile to subdirmk, vpath will not be usable. Also, "-iquote" is now needed to build "cpuid.o".

Replace "-I." by "-iquote .", so it applies to double-quote includes only.

Rather than checking if a symlink exist, always regenerate the symlink. So if the source tree changed location, the symlink is updated.

Since we are creating a new .gitignore for the symlink, also move the entry to it.

---

Notes:
v2:
- create a new per-directory .gitignore to add the new entry and existing ones

 tools/fuzz/x86_instruction_emulator/Makefile  | 32 ++++++++-----------
 .gitignore                                    |  6 ----
 .../fuzz/x86_instruction_emulator/.gitignore  |  7 ++++
 3 files changed, 21 insertions(+), 24 deletions(-)
 create mode 100644 tools/fuzz/x86_instruction_emulator/.gitignore
tools/fuzz/x86_instruction_emulator/Makefile +14 -18
index 1a6dbf94e1..f11437e6a2 100644
@@ -8,33 +8,27 @@ else
 x86-insn-fuzz-all:
 endif
 
-# Add libx86 to the build
-vpath %.c $(XEN_ROOT)/xen/lib/x86
+cpuid.c: %: $(XEN_ROOT)/xen/lib/x86/% FORCE
+	ln -nsf $< $@
 
-x86_emulate:
-	[ -L $@ ] || ln -sf $(XEN_ROOT)/xen/arch/x86/$@
+x86_emulate: FORCE
+	ln -nsf $(XEN_ROOT)/xen/arch/x86/$@
 
 x86_emulate/%: x86_emulate ;
 
-x86-emulate.c x86-emulate.h wrappers.c: %:
-	[ -L $* ] || ln -sf $(XEN_ROOT)/tools/tests/x86_emulator/$*
+x86-emulate.c x86-emulate.h wrappers.c: %: $(XEN_ROOT)/tools/tests/x86_emulator/% FORCE
+	ln -nsf $< $@
 
-CFLAGS += $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -I.
+CFLAGS += $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -iquote .
+cpuid.o: CFLAGS += -iquote $(XEN_ROOT)/xen/lib/x86
 
 GCOV_FLAGS := --coverage
 %-cov.o: %.c
 	$(CC) -c $(CFLAGS) $(GCOV_FLAGS) $< -o $@
 
-x86.h := $(addprefix $(XEN_ROOT)/tools/include/xen/asm/,\
-                     x86-vendors.h x86-defns.h msr-index.h) \
-         $(addprefix $(XEN_ROOT)/tools/include/xen/lib/x86/, \
-                     cpuid.h cpuid-autogen.h)
-x86_emulate.h := x86-emulate.h x86_emulate/x86_emulate.h $(x86.h)
-
-# x86-emulate.c will be implicit for both
-x86-emulate.o x86-emulate-cov.o: x86_emulate/x86_emulate.c $(x86_emulate.h)
-
-fuzz-emul.o fuzz-emulate-cov.o cpuid.o wrappers.o: $(x86_emulate.h)
+x86-emulate.h: x86_emulate/x86_emulate.h
+x86-emulate.o x86-emulate-cov.o: x86-emulate.h x86_emulate/x86_emulate.c
+fuzz-emul.o fuzz-emul-cov.o wrappers.o: x86-emulate.h
 
 x86-insn-fuzzer.a: fuzz-emul.o x86-emulate.o cpuid.o
 	$(AR) rc $@ $^
@@ -51,7 +45,7 @@ all: x86-insn-fuzz-all
 
 .PHONY: distclean
 distclean: clean
-	rm -f x86_emulate x86-emulate.c x86-emulate.h
+	rm -f x86_emulate x86-emulate.c x86-emulate.h wrappers.c cpuid.c
 
 .PHONY: clean
 clean:
@@ -67,3 +61,5 @@ afl: afl-harness
 
 .PHONY: afl-cov
 afl-cov: afl-harness-cov
+
+-include $(DEPS_INCLUDE)
.gitignore +0 -6
index 6410dfbc72..8b6886f3fd 100644
@@ -195,12 +195,6 @@ tools/flask/utils/flask-loadpolicy
 tools/flask/utils/flask-setenforce
 tools/flask/utils/flask-set-bool
 tools/flask/utils/flask-label-pci
-tools/fuzz/x86_instruction_emulator/asm
-tools/fuzz/x86_instruction_emulator/afl-harness
-tools/fuzz/x86_instruction_emulator/afl-harness-cov
-tools/fuzz/x86_instruction_emulator/wrappers.c
-tools/fuzz/x86_instruction_emulator/x86_emulate
-tools/fuzz/x86_instruction_emulator/x86-emulate.[ch]
 tools/helpers/init-xenstore-domain
 tools/helpers/xen-init-dom0
 tools/hotplug/common/hotplugpath.sh
tools/fuzz/x86_instruction_emulator/.gitignore new file +7 -0
new file mode 100644
index 0000000000..65c3cf9702
@@ -0,0 +1,7 @@
+/asm
+/afl-harness
+/afl-harness-cov
+/cpuid.c
+/wrappers.c
+/x86_emulate
+/x86-emulate.[ch]
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 6/25
#17 lore raw

Re: [XEN PATCH v3 06/25] tools/fuzz/x86_instruction_emulator: rework makefile

Quoted 20 lines · Anthony PERARD

Rework dependencies of all objects. We don't need to add dependencies for headers that $(CC) is capable of generating, we only need to include $(DEPS_INCLUDE). Some dependencies are still needed so make knows to generate symlinks for them.

We remove the use of "vpath" for cpuid.c. While it works fine for now, when we will convert this makefile to subdirmk, vpath will not be usable. Also, "-iquote" is now needed to build "cpuid.o".

Replace "-I." by "-iquote .", so it applies to double-quote includes only.

Rather than checking if a symlink exist, always regenerate the symlink. So if the source tree changed location, the symlink is updated.

Quoted 5 lines

Since we are creating a new .gitignore for the symlink, also move the entry to it.

—

Hi Antony,

#18 lore raw

Re: [XEN PATCH v3 06/25] tools/fuzz/x86_instruction_emulator: rework makefile

In reply to Anthony PERARD

tools/fuzz/x86_instruction_emulator/Makefile else · line 12

Quoted 10 lines · Anthony PERARD
tools/fuzz/x86_instruction_emulator/Makefile +2 -2
@@ -8,33 +8,27 @@ else
 x86-insn-fuzz-all:
 endif
 
-# Add libx86 to the build
-vpath %.c $(XEN_ROOT)/xen/lib/x86
+cpuid.c: %: $(XEN_ROOT)/xen/lib/x86/% FORCE
+	ln -nsf $< $@

I guess the idea with the original construct was to allow using further source files from libx86 with as little code churn as possible. Your change now requires two more lines to be touched. As long as we avoid name collisions in the various directories (wrapper.c and a few more files come from yet somewhere else), couldn't this rule simply be

%.c: $(XEN_ROOT)/xen/lib/x86/%.c FORCE

	ln -nsf $< $@

?

tools/fuzz/x86_instruction_emulator/Makefile else · line 20

Quoted 11 lines
tools/fuzz/x86_instruction_emulator/Makefile +4 -4
-x86_emulate:
-	[ -L $@ ] || ln -sf $(XEN_ROOT)/xen/arch/x86/$@
+x86_emulate: FORCE
+	ln -nsf $(XEN_ROOT)/xen/arch/x86/$@
 
 x86_emulate/%: x86_emulate ;
 
-x86-emulate.c x86-emulate.h wrappers.c: %:
-	[ -L $* ] || ln -sf $(XEN_ROOT)/tools/tests/x86_emulator/$*
+x86-emulate.c x86-emulate.h wrappers.c: %: $(XEN_ROOT)/tools/tests/x86_emulator/% FORCE
+	ln -nsf $< $@

And similarly

%.c: $(XEN_ROOT)/tools/tests/x86_emulator/%.c FORCE

	ln -nsf $< $@

%.h: $(XEN_ROOT)/tools/tests/x86_emulator/%.h FORCE

	ln -nsf $< $@

here? (I'm hesitant to suggest plain %, i.e. without the filename suffixes, as that would likely be at least confusing for Makefile.)

tools/fuzz/x86_instruction_emulator/Makefile afl: afl-harness · line 65

Quoted 6 lines
tools/fuzz/x86_instruction_emulator/Makefile +2 -0
@@ -67,3 +61,5 @@ afl: afl-harness
 
 .PHONY: afl-cov
 afl-cov: afl-harness-cov
+
+-include $(DEPS_INCLUDE)

I would expect doing so was avoided for some reason. Albeit it may well be that too much cloning of tests/x86_emulator was done here, and it's all fine this way. Can you confirm things to work when building locally in just this subdir, e.g. via

make -sC .../tools/fuzz/x86_instruction_emulator CC=/build/afl/2.52b-base/afl-gcc

?

Jan

#19 lore raw

Re: [XEN PATCH v3 06/25] tools/fuzz/x86_instruction_emulator: rework makefile

Quoted 18 lines · Jan Beulich

tools/fuzz/x86_instruction_emulator/Makefile else · line 12

Quoted 10 lines · Anthony PERARD
tools/fuzz/x86_instruction_emulator/Makefile +2 -2
@@ -8,33 +8,27 @@ else
 x86-insn-fuzz-all:
 endif
 
-# Add libx86 to the build
-vpath %.c $(XEN_ROOT)/xen/lib/x86
+cpuid.c: %: $(XEN_ROOT)/xen/lib/x86/% FORCE
+	ln -nsf $< $@

I guess the idea with the original construct was to allow using further source files from libx86 with as little code churn as possible. Your change now requires two more lines to be touched. As long as we avoid name collisions in the various directories (wrapper.c and a few more files come from yet somewhere else), couldn't this rule simply be

Quoted 4 lines

%.c: $(XEN_ROOT)/xen/lib/x86/%.c FORCE

	ln -nsf $< $@

?

Sounds good.

Quoted 14 lines

tools/fuzz/x86_instruction_emulator/Makefile else · line 20

Quoted 11 lines
tools/fuzz/x86_instruction_emulator/Makefile +4 -4
-x86_emulate:
-	[ -L $@ ] || ln -sf $(XEN_ROOT)/xen/arch/x86/$@
+x86_emulate: FORCE
+	ln -nsf $(XEN_ROOT)/xen/arch/x86/$@
 
 x86_emulate/%: x86_emulate ;
 
-x86-emulate.c x86-emulate.h wrappers.c: %:
-	[ -L $* ] || ln -sf $(XEN_ROOT)/tools/tests/x86_emulator/$*
+x86-emulate.c x86-emulate.h wrappers.c: %: $(XEN_ROOT)/tools/tests/x86_emulator/% FORCE
+	ln -nsf $< $@

And similarly

Quoted 8 lines

%.c: $(XEN_ROOT)/tools/tests/x86_emulator/%.c FORCE

	ln -nsf $< $@

%.h: $(XEN_ROOT)/tools/tests/x86_emulator/%.h FORCE

	ln -nsf $< $@

here? (I'm hesitant to suggest plain %, i.e. without the filename suffixes, as that would likely be at least confusing for Makefile.)

Will do.

Quoted 9 lines

tools/fuzz/x86_instruction_emulator/Makefile afl: afl-harness · line 65

Quoted 6 lines
tools/fuzz/x86_instruction_emulator/Makefile +2 -0
@@ -67,3 +61,5 @@ afl: afl-harness
 
 .PHONY: afl-cov
 afl-cov: afl-harness-cov
+
+-include $(DEPS_INCLUDE)

I would expect doing so was avoided for some reason. Albeit it may well be that too much cloning of tests/x86_emulator was done here,

There's quite a few places in tools/ where "-include $(DEPS_INCLUDE)" is missing, so I kind of expect it to be forgotten rather than avoided on purpose.

Quoted 6 lines

and it's all fine this way. Can you confirm things to work when building locally in just this subdir, e.g. via

make -sC .../tools/fuzz/x86_instruction_emulator CC=/build/afl/2.52b-base/afl-gcc

?

Yes, that still works. But I'm not sure why you would ask since the tools/ build system works this way, execution of make in a subdir doesn't depends on the execution from the parent dir (it doesn't depends on anything in the envvar).

Thanks,

Signature · 1 line
Anthony PERARD
#20 lore raw

Re: [XEN PATCH v3 06/25] tools/fuzz/x86_instruction_emulator: rework makefile

Quoted 4 lines · Anthony PERARD
Quoted 3 lines · Jan Beulich

Can you confirm things to work when
building locally in just this subdir, e.g. via

Quoted 8 lines
Quoted 3 lines

make -sC .../tools/fuzz/x86_instruction_emulator CC=/build/afl/2.52b-base/afl-gcc

?

Yes, that still works. But I'm not sure why you would ask since the tools/ build system works this way, execution of make in a subdir doesn't depends on the execution from the parent dir (it doesn't depends on anything in the envvar).

Oh, I wasn't even aware of this as a general feature in tools/. Is this going to survive your rework to use non-recursive makefiles?

Jan

#21 lore raw

Re: [XEN PATCH v3 06/25] tools/fuzz/x86_instruction_emulator: rework makefile

Quoted 9 lines · Jan Beulich
Quoted 8 lines · Anthony PERARD
Quoted 6 lines · Jan Beulich

Can you confirm things to work when
building locally in just this subdir, e.g. via

make -sC .../tools/fuzz/x86_instruction_emulator CC=/build/afl/2.52b-base/afl-gcc

?

Quoted 7 lines
Quoted 4 lines

Yes, that still works. But I'm not sure why you would ask since the tools/ build system works this way, execution of make in a subdir doesn't depends on the execution from the parent dir (it doesn't depends on anything in the envvar).

Oh, I wasn't even aware of this as a general feature in tools/. Is this going to survive your rework to use non-recursive makefiles?

Yes. Executing make in any subdir will still works. It should be even better than the current situation, even in a fresh clone, we could simply run ./configure && make -C subdir and make will make everything needed, that is probably the "include/" dir and the "libs/" if they are needed by anything in that subdir.

At the moment, one can run ./configure then make -C tools/include and make -C tools/libs and probably run make in most subdir without having to wait for a long run of make build-tools.

Cheers,

Signature · 1 line
Anthony PERARD
#22 lore raw

PATCH v3 7/25 tools/hotplug: cleanup Makefiles

In reply to Anthony PERARD

Remove "build" targets.

Use simply expanded variables when recursively expanded variable aren't needed. (Use ":=" instead of "=".)

Don't check if a directory already exist when installing, just create it.

Fix $(HOTPLUGPATH), it shouldn't have any double-quote.

Some reindentation.

FreeBSD, "hotplugpath.sh" is already installed by common/.

---
 tools/hotplug/FreeBSD/Makefile       | 11 +++--------
 tools/hotplug/Linux/Makefile         | 16 ++++++----------
 tools/hotplug/Linux/systemd/Makefile | 16 +++++++---------
 tools/hotplug/NetBSD/Makefile        |  9 +++------
 tools/hotplug/common/Makefile        | 16 ++++++----------
 5 files changed, 25 insertions(+), 43 deletions(-)
tools/hotplug/FreeBSD/Makefile +3 -8
index de9928cd86..a6552c9884 100644
@@ -2,18 +2,15 @@ XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 # Xen script dir and scripts to go there.
-XEN_SCRIPTS = vif-bridge block
+XEN_SCRIPTS := vif-bridge block
 
-XEN_SCRIPT_DATA =
+XEN_SCRIPT_DATA :=
 
-XEN_RCD_PROG = rc.d/xencommons rc.d/xendriverdomain
+XEN_RCD_PROG := rc.d/xencommons rc.d/xendriverdomain
 
 .PHONY: all
 all:
 
-.PHONY: build
-build:
-
 .PHONY: install
 install: install-scripts install-rcd
 
@@ -44,12 +41,10 @@ install-rcd:
 	   do \
 	   $(INSTALL_PROG) $$i $(DESTDIR)$(INITD_DIR); \
 	done
-	$(INSTALL_DATA) ../common/hotplugpath.sh $(DESTDIR)$(XEN_SCRIPT_DIR)
 
 .PHONY: uninstall-rcd
 uninstall-rcd:
 	rm -f $(addprefix $(DESTDIR)$(INITD_DIR)/, $(XEN_RCD_PROG))
-	rm -f $(DESTDIR)$(XEN_SCRIPT_DIR)/hotplugpath.sh
 
 .PHONY: clean
 clean:
tools/hotplug/Linux/Makefile +6 -10
index 0b1d111d7e..9a7b3a3515 100644
@@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 # Xen script dir and scripts to go there.
-XEN_SCRIPTS = vif-bridge
+XEN_SCRIPTS := vif-bridge
 XEN_SCRIPTS += vif-route
 XEN_SCRIPTS += vif-nat
 XEN_SCRIPTS += vif-openvswitch
@@ -22,16 +22,13 @@ XEN_SCRIPTS += launch-xenstore
 
 SUBDIRS-$(CONFIG_SYSTEMD) += systemd
 
-XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh
+XEN_SCRIPT_DATA := xen-script-common.sh locking.sh logging.sh
 XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh
 XEN_SCRIPT_DATA += block-common.sh
 
 .PHONY: all
 all: subdirs-all
 
-.PHONY: build
-build:
-
 .PHONY: install
 install: install-initd install-scripts subdirs-install
 
@@ -41,9 +38,9 @@ uninstall: uninstall-initd uninstall-scripts subdirs-uninstall
 # See docs/misc/distro_mapping.txt for INITD_DIR location
 .PHONY: install-initd
 install-initd:
-	[ -d $(DESTDIR)$(INITD_DIR) ] || $(INSTALL_DIR) $(DESTDIR)$(INITD_DIR)
-	[ -d $(DESTDIR)$(SYSCONFIG_DIR) ] || $(INSTALL_DIR) $(DESTDIR)$(SYSCONFIG_DIR)
-	[ -d $(DESTDIR)$(LIBEXEC_BIN) ] || $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
+	$(INSTALL_DIR) $(DESTDIR)$(INITD_DIR)
+	$(INSTALL_DIR) $(DESTDIR)$(SYSCONFIG_DIR)
+	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
 	$(INSTALL_DATA) init.d/sysconfig.xendomains $(DESTDIR)$(SYSCONFIG_DIR)/xendomains
 	$(INSTALL_DATA) init.d/sysconfig.xencommons $(DESTDIR)$(SYSCONFIG_DIR)/xencommons
 	$(INSTALL_PROG) xendomains $(DESTDIR)$(LIBEXEC_BIN)
@@ -64,8 +61,7 @@ uninstall-initd:
 
 .PHONY: install-scripts
 install-scripts:
-	[ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \
-		$(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
+	$(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
 	set -e; for i in $(XEN_SCRIPTS); \
 	    do \
 	    $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
tools/hotplug/Linux/systemd/Makefile +7 -9
index a5d41d86ef..26df2a43b1 100644
@@ -1,12 +1,12 @@
 XEN_ROOT = $(CURDIR)/../../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-XEN_SYSTEMD_MODULES = xen.conf
+XEN_SYSTEMD_MODULES := xen.conf
 
-XEN_SYSTEMD_MOUNT =  proc-xen.mount
+XEN_SYSTEMD_MOUNT := proc-xen.mount
 XEN_SYSTEMD_MOUNT += var-lib-xenstored.mount
 
-XEN_SYSTEMD_SERVICE  = xenstored.service
+XEN_SYSTEMD_SERVICE := xenstored.service
 XEN_SYSTEMD_SERVICE += xenconsoled.service
 XEN_SYSTEMD_SERVICE += xen-qemu-dom0-disk-backend.service
 XEN_SYSTEMD_SERVICE += xendomains.service
@@ -14,7 +14,7 @@ XEN_SYSTEMD_SERVICE += xen-watchdog.service
 XEN_SYSTEMD_SERVICE += xen-init-dom0.service
 XEN_SYSTEMD_SERVICE += xendriverdomain.service
 
-ALL_XEN_SYSTEMD =	$(XEN_SYSTEMD_MODULES)  \
+ALL_XEN_SYSTEMD :=	$(XEN_SYSTEMD_MODULES)  \
 			$(XEN_SYSTEMD_MOUNT)	\
 			$(XEN_SYSTEMD_SERVICE)
 
@@ -30,10 +30,8 @@ distclean: clean
 
 .PHONY: install
 install: $(ALL_XEN_SYSTEMD)
-	[ -d $(DESTDIR)$(XEN_SYSTEMD_DIR) ] || \
-		$(INSTALL_DIR) $(DESTDIR)$(XEN_SYSTEMD_DIR)
-	[ -d $(DESTDIR)$(XEN_SYSTEMD_MODULES_LOAD) ] || \
-		$(INSTALL_DIR) $(DESTDIR)$(XEN_SYSTEMD_MODULES_LOAD)
+	$(INSTALL_DIR) $(DESTDIR)$(XEN_SYSTEMD_DIR)
+	$(INSTALL_DIR) $(DESTDIR)$(XEN_SYSTEMD_MODULES_LOAD)
 	$(INSTALL_DATA) *.service $(DESTDIR)$(XEN_SYSTEMD_DIR)
 	$(INSTALL_DATA) *.mount $(DESTDIR)$(XEN_SYSTEMD_DIR)
 	$(INSTALL_DATA) *.conf $(DESTDIR)$(XEN_SYSTEMD_MODULES_LOAD)
@@ -48,5 +46,5 @@ $(XEN_SYSTEMD_MODULES):
 	rm -f [email protected]
 	for mod in $(LINUX_BACKEND_MODULES) ; do \
 		echo $$mod ; \
-		done > [email protected]
+	done > [email protected]
 	$(call move-if-changed,[email protected],$@)
tools/hotplug/NetBSD/Makefile +3 -6
index f909ffa367..1cd3db2ccb 100644
@@ -2,22 +2,19 @@ XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 # Xen script dir and scripts to go there.
-XEN_SCRIPTS =
+XEN_SCRIPTS :=
 XEN_SCRIPTS += locking.sh
 XEN_SCRIPTS += block
 XEN_SCRIPTS += vif-bridge
 XEN_SCRIPTS += vif-ip
 XEN_SCRIPTS += qemu-ifup
 
-XEN_SCRIPT_DATA =
-XEN_RCD_PROG = rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog rc.d/xendriverdomain
+XEN_SCRIPT_DATA :=
+XEN_RCD_PROG := rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog rc.d/xendriverdomain
 
 .PHONY: all
 all:
 
-.PHONY: build
-build:
-
 .PHONY: install
 install: install-scripts install-rcd
 
tools/hotplug/common/Makefile +6 -10
index ef48bfacc9..e8a8dbea6c 100644
@@ -1,22 +1,19 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-HOTPLUGPATH="hotplugpath.sh"
+HOTPLUGPATH := hotplugpath.sh
 
 # OS-independent hotplug scripts go in this directory
 
 # Xen scripts to go there.
-XEN_SCRIPTS =
-XEN_SCRIPT_DATA = $(HOTPLUGPATH)
+XEN_SCRIPTS :=
+XEN_SCRIPT_DATA := $(HOTPLUGPATH)
 
 genpath-target = $(call buildmakevars2file,$(HOTPLUGPATH))
 $(eval $(genpath-target))
 
 .PHONY: all
-all: build
-
-.PHONY: build
-build: $(HOTPLUGPATH)
+all: $(HOTPLUGPATH)
 
 .PHONY: install
 install: install-scripts
@@ -25,9 +22,8 @@ install: install-scripts
 uninstall: uninstall-scripts
 
 .PHONY: install-scripts
-install-scripts: build
-	[ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \
-		$(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
+install-scripts: all
+	$(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
 	set -e; for i in $(XEN_SCRIPTS); \
 	   do \
 	   $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 7/25
#23 lore raw

Re: [XEN PATCH v3 07/25] tools/hotplug: cleanup Makefiles

Quoted 12 lines · Anthony PERARD

Remove "build" targets.

Use simply expanded variables when recursively expanded variable aren't needed. (Use ":=" instead of "=".)

Don't check if a directory already exist when installing, just create it.

Quoted 7 lines

Fix $(HOTPLUGPATH), it shouldn't have any double-quote.

Some reindentation.

FreeBSD, "hotplugpath.sh" is already installed by common/.

Hi Antony,

Quoted 16 lines

---

tools/hotplug/FreeBSD/Makefile       | 11 +++--------
tools/hotplug/Linux/Makefile         | 16 ++++++----------
tools/hotplug/Linux/systemd/Makefile | 16 +++++++---------
tools/hotplug/NetBSD/Makefile        |  9 +++------
tools/hotplug/common/Makefile        | 16 ++++++----------
5 files changed, 25 insertions(+), 43 deletions(-)
tools/hotplug/FreeBSD/Makefile +0 -0
index de9928cd86..a6552c9884 100644
@@ -2,18 +2,15 @@ XEN_ROOT = $(CURDIR)/../../..

include $(XEN_ROOT)/tools/Rules.mk

# Xen script dir and scripts to go there.

tools/hotplug/FreeBSD/Makefile XEN_ROOT = $(CURDIR)/../../.. · line 7

Quoted 5 lines
tools/hotplug/FreeBSD/Makefile +2 -2
-XEN_SCRIPTS = vif-bridge block
+XEN_SCRIPTS := vif-bridge block
 
-XEN_SCRIPT_DATA =
+XEN_SCRIPT_DATA :=

Here (and also in NetBSD) the variable is empty, why are we keeping them and the related code? Is it to keep a certain structure?

However the changes works and looks good to me, so your choice if it needs to be addressed or not

#24 lore raw

PATCH v3 8/25 tools/libfsimage: Cleanup makefiles

In reply to Anthony PERARD

Remove the need for "fs-*" targets by creating a "common.mk" which have flags that are common to libfsimage/common/ and the other libfsimages/*/ directories.

In common.mk, make $(PIC_OBJS) a recursively expanded variable so it doesn't matter where $(LIB_SRCS-y) is defined, and remove the extra $(PIC_OBJS) from libfsimage/common/Makefile.

Use a $(TARGETS) variable to list things to be built. And $(TARGETS) can be use in the clean target in common.mk.

iso9660/:
Remove the explicit dependency between fsys_iso9660.c and iso9660.h, this is handled automaticaly by the .*.d dependency files, and iso9660.h already exist.

---
 tools/libfsimage/common/Makefile     | 11 +++--------
 tools/libfsimage/ext2fs-lib/Makefile |  9 ---------
 tools/libfsimage/ext2fs/Makefile     |  9 ---------
 tools/libfsimage/fat/Makefile        |  9 ---------
 tools/libfsimage/iso9660/Makefile    | 11 -----------
 tools/libfsimage/reiserfs/Makefile   |  9 ---------
 tools/libfsimage/ufs/Makefile        |  9 ---------
 tools/libfsimage/xfs/Makefile        |  9 ---------
 tools/libfsimage/zfs/Makefile        |  9 ---------
 tools/libfsimage/Rules.mk            | 26 ++++++++------------------
 tools/libfsimage/common.mk           | 11 +++++++++++
 11 files changed, 22 insertions(+), 100 deletions(-)
 create mode 100644 tools/libfsimage/common.mk
tools/libfsimage/common/Makefile +3 -8
index 0c5a34baea..79f8cfd28e 100644
@@ -1,5 +1,5 @@
 XEN_ROOT = $(CURDIR)/../../..
-include $(XEN_ROOT)/tools/libfsimage/Rules.mk
+include $(XEN_ROOT)/tools/libfsimage/common.mk
 
 MAJOR := $(shell $(XEN_ROOT)/version.sh $(XEN_ROOT)/xen/Makefile)
 MINOR = 0
@@ -13,12 +13,10 @@ LDFLAGS += $(PTHREAD_LDFLAGS)
 
 LIB_SRCS-y = fsimage.c fsimage_plugin.c fsimage_grub.c
 
-PIC_OBJS := $(patsubst %.c,%.opic,$(LIB_SRCS-y))
-
-LIB = libxenfsimage.so libxenfsimage.so.$(MAJOR) libxenfsimage.so.$(MAJOR).$(MINOR)
+TARGETS = libxenfsimage.so libxenfsimage.so.$(MAJOR) libxenfsimage.so.$(MAJOR).$(MINOR)
 
 .PHONY: all
-all: $(LIB)
+all: $(TARGETS)
 
 .PHONY: install
 install: all
@@ -40,9 +38,6 @@ uninstall:
 	rm -f $(DESTDIR)$(libdir)/libxenfsimage.so.$(MAJOR)
 	rm -f $(DESTDIR)$(libdir)/libxenfsimage.so.$(MAJOR).$(MINOR)
 
-clean distclean::
-	rm -f $(LIB)
-
 libxenfsimage.so: libxenfsimage.so.$(MAJOR)
 	ln -sf $< $@
 libxenfsimage.so.$(MAJOR): libxenfsimage.so.$(MAJOR).$(MINOR)
tools/libfsimage/ext2fs-lib/Makefile +0 -9
index 431a79068e..b9b560df75 100644
@@ -9,13 +9,4 @@ FS_LIBDEPS = $(EXTFS_LIBS)
 # Include configure output (config.h)
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
tools/libfsimage/ext2fs/Makefile +0 -9
index c62ae359ac..fe01f98148 100644
@@ -4,13 +4,4 @@ LIB_SRCS-y = fsys_ext2fs.c
 
 FS = ext2fs
 
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
tools/libfsimage/fat/Makefile +0 -9
index 7ee5e7588d..58bcc0751d 100644
@@ -4,13 +4,4 @@ LIB_SRCS-y = fsys_fat.c
 
 FS = fat
 
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
tools/libfsimage/iso9660/Makefile +0 -11
index bc86baf2c0..acf3164046 100644
@@ -4,15 +4,4 @@ LIB_SRCS-y = fsys_iso9660.c
 
 FS = iso9660
 
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
-fsys_iso9660.c: iso9660.h
-
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
tools/libfsimage/reiserfs/Makefile +0 -9
index 5acfedf25e..42b751e007 100644
@@ -4,13 +4,4 @@ LIB_SRCS-y = fsys_reiserfs.c
 
 FS = reiserfs
 
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
tools/libfsimage/ufs/Makefile +0 -9
index f32b9178bd..cca4f0a588 100644
@@ -4,13 +4,4 @@ LIB_SRCS-y = fsys_ufs.c
 
 FS = ufs
 
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
tools/libfsimage/xfs/Makefile +0 -9
index 54eeb6e35e..ebac7baf14 100644
@@ -4,13 +4,4 @@ LIB_SRCS-y = fsys_xfs.c
 
 FS = xfs
 
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
tools/libfsimage/zfs/Makefile +0 -9
index 084e5ec08d..434a9c3580 100644
@@ -28,13 +28,4 @@ LIB_SRCS-y = zfs_lzjb.c zfs_sha256.c zfs_fletcher.c fsi_zfs.c fsys_zfs.c
 
 FS = zfs
 
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
tools/libfsimage/Rules.mk +8 -18
index bb6d42abb4..cf37d6cb0d 100644
@@ -1,25 +1,18 @@
-include $(XEN_ROOT)/tools/Rules.mk
-
-CFLAGS += -Wno-unknown-pragmas -I$(XEN_ROOT)/tools/libfsimage/common/ -DFSIMAGE_FSDIR=\"$(FSDIR)\"
-CFLAGS += -Werror -D_GNU_SOURCE
-LDFLAGS += -L../common/
-
-PIC_OBJS := $(patsubst %.c,%.opic,$(LIB_SRCS-y))
-
-FSDIR = $(libdir)/xenfsimage
+include $(XEN_ROOT)/tools/libfsimage/common.mk
 
 FSLIB = fsimage.so
+TARGETS += $(FSLIB)
 
-.PHONY: fs-all
-fs-all: $(FSLIB)
+.PHONY: all
+all: $(TARGETS)
 
-.PHONY: fs-install
-fs-install: fs-all
+.PHONY: install
+install: all
 	$(INSTALL_DIR) $(DESTDIR)$(FSDIR)/$(FS)
 	$(INSTALL_PROG) $(FSLIB) $(DESTDIR)$(FSDIR)/$(FS)
 
-.PHONY: fs-uninstall
-fs-uninstall:
+.PHONY: uninstall
+uninstall:
 	rm -f $(addprefix $(DESTDIR)$(FSDIR)/$(FS)/, $(FSLIB))
 	if [ -d $(DESTDIR)$(FSDIR)/$(FS) ]; then \
 		rmdir $(DESTDIR)$(FSDIR)/$(FS); \
@@ -28,7 +21,4 @@ fs-uninstall:
 $(FSLIB): $(PIC_OBJS)
 	$(CC) $(LDFLAGS) $(SHLIB_LDFLAGS) -o $@ $^ -lxenfsimage $(FS_LIBDEPS) $(APPEND_LDFLAGS)
 
-clean distclean::
-	rm -f $(PIC_OBJS) $(FSLIB) $(DEPS_RM)
-
 -include $(DEPS_INCLUDE)
tools/libfsimage/common.mk new file +11 -0
new file mode 100644
index 0000000000..77bc957f27
@@ -0,0 +1,11 @@
+include $(XEN_ROOT)/tools/Rules.mk
+
+FSDIR := $(libdir)/xenfsimage
+CFLAGS += -Wno-unknown-pragmas -I$(XEN_ROOT)/tools/libfsimage/common/ -DFSIMAGE_FSDIR=\"$(FSDIR)\"
+CFLAGS += -Werror -D_GNU_SOURCE
+LDFLAGS += -L../common/
+
+PIC_OBJS = $(patsubst %.c,%.opic,$(LIB_SRCS-y))
+
+clean distclean::
+	rm -f $(PIC_OBJS) $(TARGETS) $(DEPS_RM)
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 8/25
#25 lore raw

Re: [XEN PATCH v3 08/25] tools/libfsimage: Cleanup makefiles

Quoted 15 lines · Anthony PERARD

Remove the need for "fs-*" targets by creating a "common.mk" which have flags that are common to libfsimage/common/ and the other libfsimages/*/ directories.

In common.mk, make $(PIC_OBJS) a recursively expanded variable so it doesn't matter where $(LIB_SRCS-y) is defined, and remove the extra $(PIC_OBJS) from libfsimage/common/Makefile.

Use a $(TARGETS) variable to list things to be built. And $(TARGETS) can be use in the clean target in common.mk.

Quoted 6 lines

iso9660/:
Remove the explicit dependency between fsys_iso9660.c and iso9660.h, this is handled automaticaly by the .*.d dependency files, and iso9660.h already exist.

Hi Antony,

Looks good to me

#26 lore raw

PATCH v3 9/25 tools/xenpaging: Rework makefile

In reply to Anthony PERARD

- Rename $(SRCS) to $(OBJS-y), we don't need to collect sources.
- Rename $(IBINS) to $(TARGETS)
- Stop cleaning "xen" and non-set variable $(LIB).

---
 tools/xenpaging/Makefile | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
tools/xenpaging/Makefile +12 -12
index 04743b335c..e2ed9eaa3f 100644
@@ -5,33 +5,33 @@ CFLAGS += $(CFLAGS_libxentoollog) $(CFLAGS_libxenevtchn) $(CFLAGS_libxenctrl) $(
 LDLIBS += $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(PTHREAD_LIBS)
 LDFLAGS += $(PTHREAD_LDFLAGS)
 
-POLICY    = default
+POLICY   := default
 
-SRC      :=
-SRCS     += file_ops.c xenpaging.c policy_$(POLICY).c
-SRCS     += pagein.c
+OBJS-y   := file_ops.o
+OBJS-y   += xenpaging.o
+OBJS-y   += policy_$(POLICY).o
+OBJS-y   += pagein.o
 
 CFLAGS   += -Werror
 CFLAGS   += -Wno-unused
 
-OBJS     = $(SRCS:.c=.o)
-IBINS    = xenpaging
+TARGETS := xenpaging
 
-all: $(IBINS)
+all: $(TARGETS)
 
-xenpaging: $(OBJS)
+xenpaging: $(OBJS-y)
 	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) $(APPEND_LDFLAGS)
 
 install: all
 	$(INSTALL_DIR) -m 0700 $(DESTDIR)$(XEN_PAGING_DIR)
 	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
-	$(INSTALL_PROG) $(IBINS) $(DESTDIR)$(LIBEXEC_BIN)
+	$(INSTALL_PROG) $(TARGETS) $(DESTDIR)$(LIBEXEC_BIN)
 
 uninstall:
-	rm -f $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/, $(IBINS))
+	rm -f $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/, $(TARGETS))
 
 clean:
-	rm -f *.o *~ $(DEPS_RM) xen TAGS $(IBINS) $(LIB)
+	rm -f *.o *~ $(DEPS_RM) TAGS $(TARGETS)
 
 distclean: clean
 
@@ -39,6 +39,6 @@ distclean: clean
 
 .PHONY: TAGS
 TAGS:
-	etags -t $(SRCS) *.h
+	etags -t *.c *.h
 
 -include $(DEPS_INCLUDE)
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 9/25
#27 lore raw

Re: [XEN PATCH v3 09/25] tools/xenpaging: Rework makefile

Quoted 9 lines · Anthony PERARD

- Rename $(SRCS) to $(OBJS-y), we don't need to collect sources.
- Rename $(IBINS) to $(TARGETS)
- Stop cleaning "xen" and non-set variable $(LIB).

Hi Antony,

Is it worth to mention also that POLICY now is now not recursively expanded?

In any case the patch works as before:

#28 lore raw

PATCH v3 10/25 tools/xentop: rework makefile

In reply to Anthony PERARD

Add "xentop" to "TARGETS" because this variable will be useful later.

Always define all the targets, even when configured with --disable-monitor, instead don't visit the subdirectory. This mean xentop/ isn't visited anymore during "make clean" that's how most other subdirs in the tools/ works.

Also add missing "xentop" rules. It only works without it because we still have make's built-ins rules and variables, but fix this to not have to rely on them.

Use $(TARGETS) with $(INSTALL_PROG), and thus install into the directory rather than spelling the program name.

In the "clean" rule, use $(RM) and remove all "*.o" instead of just one object.

---

Notes:
v2:
- use $(RM) in clean.
- remove all *.o instead of just one object in "clean" rule.
- in "install" rule, make use of $(TARGETS). install into a dir rather than to a specific path, in case there's more targets.

 tools/Makefile        |  2 +-
 tools/xentop/Makefile | 21 +++++++++------------
 2 files changed, 10 insertions(+), 13 deletions(-)
tools/Makefile +1 -1
index 79b4c7e3de..0c1d8b64a4 100644
@@ -17,7 +17,7 @@ SUBDIRS-$(CONFIG_XCUTILS) += xcutils
 SUBDIRS-$(CONFIG_X86) += firmware
 SUBDIRS-y += console
 SUBDIRS-y += xenmon
-SUBDIRS-y += xentop
+SUBDIRS-$(XENSTAT_XENTOP) += xentop
 SUBDIRS-y += libfsimage
 SUBDIRS-$(CONFIG_Linux) += vchan
 
tools/xentop/Makefile +9 -12
index 0034114684..7bd96f34d5 100644
@@ -13,36 +13,33 @@
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-ifneq ($(XENSTAT_XENTOP),y)
-.PHONY: all install xentop uninstall
-all install xentop uninstall:
-else
-
 CFLAGS += -DGCC_PRINTF -Werror $(CFLAGS_libxenstat)
 LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(TINFO_LIBS) $(SOCKET_LIBS) -lm
 CFLAGS += -DHOST_$(XEN_OS)
 
 # Include configure output (config.h)
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
-LDFLAGS += $(APPEND_LDFLAGS)
+
+TARGETS := xentop
 
 .PHONY: all
-all: xentop
+all: $(TARGETS)
+
+xentop: xentop.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS) $(APPEND_LDFLAGS)
 
 .PHONY: install
-install: xentop
+install: all
 	$(INSTALL_DIR) $(DESTDIR)$(sbindir)
-	$(INSTALL_PROG) xentop $(DESTDIR)$(sbindir)/xentop
+	$(INSTALL_PROG) $(TARGETS) $(DESTDIR)$(sbindir)
 
 .PHONY: uninstall
 uninstall:
 	rm -f $(DESTDIR)$(sbindir)/xentop
 
-endif
-
 .PHONY: clean
 clean:
-	rm -f xentop xentop.o $(DEPS_RM)
+	$(RM) *.o $(TARGETS) $(DEPS_RM)
 
 .PHONY: distclean
 distclean: clean
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 10/25
#29 lore raw

Re: [XEN PATCH v3 10/25] tools/xentop: rework makefile

Quoted 15 lines · Anthony PERARD

Add "xentop" to "TARGETS" because this variable will be useful later.

Always define all the targets, even when configured with --disable-monitor, instead don't visit the subdirectory. This mean xentop/ isn't visited anymore during "make clean" that's how most other subdirs in the tools/ works.

Also add missing "xentop" rules. It only works without it because we still have make's built-ins rules and variables, but fix this to not have to rely on them.

Quoted 8 lines

Use $(TARGETS) with $(INSTALL_PROG), and thus install into the directory rather than spelling the program name.

In the "clean" rule, use $(RM) and remove all "*.o" instead of just one object.

—

Hi Antony,

Nice, this does it with just one gcc invocation.

#30 lore raw

PATCH v3 11/25 tools/xentrace: rework Makefile

In reply to Anthony PERARD

Remove "build" targets.

Use "$(TARGETS)" to list binary to be built.

Cleanup "clean" rule.

Also drop conditional install of $(BIN) and $(LIBBIN) as those two variables are now always populated.

---

Notes:
v2:
- fix typo in title
- drop conditional install of $(BIN) and $(LIBBIN)

 tools/xentrace/Makefile | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
tools/xentrace/Makefile +7 -12
index 9fb7fc96e7..0995fa9203 100644
@@ -14,36 +14,31 @@ SBIN     = xentrace xentrace_setsize
 LIBBIN   = xenctx
 SCRIPTS  = xentrace_format
 
-.PHONY: all
-all: build
+TARGETS := $(BIN) $(SBIN) $(LIBBIN)
 
-.PHONY: build
-build: $(BIN) $(SBIN) $(LIBBIN)
+.PHONY: all
+all: $(TARGETS)
 
 .PHONY: install
-install: build
+install: all
 	$(INSTALL_DIR) $(DESTDIR)$(bindir)
 	$(INSTALL_DIR) $(DESTDIR)$(sbindir)
-	[ -z "$(LIBBIN)" ] || $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
-ifneq ($(BIN),)
+	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
 	$(INSTALL_PROG) $(BIN) $(DESTDIR)$(bindir)
-endif
 	$(INSTALL_PROG) $(SBIN) $(DESTDIR)$(sbindir)
 	$(INSTALL_PYTHON_PROG) $(SCRIPTS) $(DESTDIR)$(bindir)
-	[ -z "$(LIBBIN)" ] || $(INSTALL_PROG) $(LIBBIN) $(DESTDIR)$(LIBEXEC_BIN)
+	$(INSTALL_PROG) $(LIBBIN) $(DESTDIR)$(LIBEXEC_BIN)
 
 .PHONY: uninstall
 uninstall:
 	rm -f $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/, $(LIBBIN))
 	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS))
 	rm -f $(addprefix $(DESTDIR)$(sbindir)/, $(SBIN))
-ifneq ($(BIN),)
 	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(BIN))
-endif
 
 .PHONY: clean
 clean:
-	$(RM) *.a *.so *.o *.rpm $(BIN) $(SBIN) $(LIBBIN) $(DEPS_RM)
+	$(RM) *.o $(TARGETS) $(DEPS_RM)
 
 .PHONY: distclean
 distclean: clean
Signature · 1 line
Anthony PERARD
#31 lore raw

Re: [XEN PATCH v3 11/25] tools/xentrace: rework Makefile

Quoted 14 lines · Anthony PERARD

Remove "build" targets.

Use "$(TARGETS)" to list binary to be built.

Cleanup "clean" rule.

Also drop conditional install of $(BIN) and $(LIBBIN) as those two variables are now always populated.

Hi Antony,

Would it make sense to use := instead of =, for BIN, SBIN, LIBBIN, SCRIPTS?

Quoted 42 lines

---

Notes:
v2:
- fix typo in title
- drop conditional install of $(BIN) and $(LIBBIN)

tools/xentrace/Makefile | 19 +++++++------------

1 file changed, 7 insertions(+), 12 deletions(-)
tools/xentrace/Makefile +0 -0
index 9fb7fc96e7..0995fa9203 100644
@@ -14,36 +14,31 @@ SBIN     = xentrace xentrace_setsize

LIBBIN = xenctx
SCRIPTS = xentrace_format

-.PHONY: all

tools/xentrace/Makefile +3 -3
-all: build
+TARGETS := $(BIN) $(SBIN) $(LIBBIN)
 
-.PHONY: build
-build: $(BIN) $(SBIN) $(LIBBIN)
+.PHONY: all
+all: $(TARGETS)

.PHONY: install

tools/xentrace/Makefile +1 -1
-install: build
+install: all
	$(INSTALL_DIR) $(DESTDIR)$(bindir)
	$(INSTALL_DIR) $(DESTDIR)$(sbindir)
tools/xentrace/Makefile +1 -2
-	[ -z "$(LIBBIN)" ] || $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
-ifneq ($(BIN),)
+	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
	$(INSTALL_PROG) $(BIN) $(DESTDIR)$(bindir)
-endif
	$(INSTALL_PROG) $(SBIN) $(DESTDIR)$(sbindir)
	$(INSTALL_PYTHON_PROG) $(SCRIPTS) $(DESTDIR)$(bindir)
tools/xentrace/Makefile +1 -1
-	[ -z "$(LIBBIN)" ] || $(INSTALL_PROG) $(LIBBIN) $(DESTDIR)$(LIBEXEC_BIN)
+	$(INSTALL_PROG) $(LIBBIN) $(DESTDIR)$(LIBEXEC_BIN)
Quoted 8 lines

.PHONY: uninstall
uninstall:

	rm -f $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/, $(LIBBIN))
	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS))
	rm -f $(addprefix $(DESTDIR)$(sbindir)/, $(SBIN))
-ifneq ($(BIN),)
	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(BIN))

-endif

Why here don’t we use $(RM) ?

#32 lore raw

Re: [XEN PATCH v3 11/25] tools/xentrace: rework Makefile

Quoted 11 lines · Luca Fancellu
Quoted 9 lines · Anthony PERARD

.PHONY: uninstall
uninstall:

	rm -f $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/, $(LIBBIN))
	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS))
	rm -f $(addprefix $(DESTDIR)$(sbindir)/, $(SBIN))
-ifneq ($(BIN),)
	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(BIN))

-endif

Why here don’t we use $(RM) ?

Well, I don't think it matters which is used between $(RM) and rm -f, beside consistency maybe. So I don't think introducing changes on those line would be useful. (Also, it seems that the use of $(RM) for "uninstall" targets are exceptional so far.)

Signature · 1 line
Anthony PERARD
#33 lore raw

PATCH v3 12/25 .gitignore: Cleanup ignores of tools/libs/*/{headers.chk,*.pc}

In reply to Anthony PERARD

---

Notes:
v2:
- move new .gitignore entries to the one in tools/libs/

 .gitignore            | 26 --------------------------
 tools/libs/.gitignore |  2 ++
 2 files changed, 2 insertions(+), 26 deletions(-)
.gitignore +0 -26
index 8b6886f3fd..1de28c833c 100644
@@ -106,26 +106,8 @@ tools/config.cache
 config/Tools.mk
 config/Stubdom.mk
 config/Docs.mk
-tools/libs/toolcore/headers.chk
-tools/libs/toolcore/xentoolcore.pc
-tools/libs/toollog/headers.chk
-tools/libs/toollog/xentoollog.pc
-tools/libs/evtchn/headers.chk
-tools/libs/evtchn/xenevtchn.pc
-tools/libs/gnttab/headers.chk
-tools/libs/gnttab/xengnttab.pc
-tools/libs/hypfs/headers.chk
-tools/libs/hypfs/xenhypfs.pc
-tools/libs/call/headers.chk
-tools/libs/call/xencall.pc
 tools/libs/ctrl/libxenctrl.map
-tools/libs/ctrl/xencontrol.pc
-tools/libs/foreignmemory/headers.chk
-tools/libs/foreignmemory/xenforeignmemory.pc
-tools/libs/devicemodel/headers.chk
-tools/libs/devicemodel/xendevicemodel.pc
 tools/libs/guest/libxenguest.map
-tools/libs/guest/xenguest.pc
 tools/libs/guest/xc_bitops.h
 tools/libs/guest/xc_core.h
 tools/libs/guest/xc_core_arm.h
@@ -145,21 +127,13 @@ tools/libs/light/testidl.c
 tools/libs/light/test_timedereg
 tools/libs/light/test_fdderegrace
 tools/libs/light/tmp.*
-tools/libs/light/xenlight.pc
-tools/libs/stat/headers.chk
 tools/libs/stat/libxenstat.map
-tools/libs/stat/xenstat.pc
-tools/libs/store/headers.chk
 tools/libs/store/list.h
 tools/libs/store/utils.h
-tools/libs/store/xenstore.pc
 tools/libs/store/xs_lib.c
-tools/libs/util/*.pc
 tools/libs/util/libxlu_cfg_y.output
 tools/libs/util/libxenutil.map
-tools/libs/vchan/headers.chk
 tools/libs/vchan/libxenvchan.map
-tools/libs/vchan/xenvchan.pc
 tools/debugger/gdb/gdb-6.2.1-linux-i386-xen/*
 tools/debugger/gdb/gdb-6.2.1/*
 tools/debugger/gdb/gdb-6.2.1.tar.bz2
tools/libs/.gitignore +2 -0
index 4a13126144..1ad7c7f0cb 100644
@@ -1 +1,3 @@
+*/*.pc
+*/headers.chk
 */headers.lst
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 12/25
#35 lore raw

Re: [XEN PATCH v3 12/25] .gitignore: Cleanup ignores of tools/libs/*/{headers.chk,*.pc}

In reply to Anthony PERARD

Hi Anthony,

Quoted 3 lines · Anthony PERARD

Cheers
Bertrand

Quoted 75 lines

---

Notes:
v2:
- move new .gitignore entries to the one in tools/libs/

.gitignore | 26 --------------------------
tools/libs/.gitignore | 2 ++

2 files changed, 2 insertions(+), 26 deletions(-)
.gitignore +0 -0
index 8b6886f3fd..1de28c833c 100644
@@ -106,26 +106,8 @@ tools/config.cache

config/Tools.mk
config/Stubdom.mk
config/Docs.mk

.gitignore +0 -12
-tools/libs/toolcore/headers.chk
-tools/libs/toolcore/xentoolcore.pc
-tools/libs/toollog/headers.chk
-tools/libs/toollog/xentoollog.pc
-tools/libs/evtchn/headers.chk
-tools/libs/evtchn/xenevtchn.pc
-tools/libs/gnttab/headers.chk
-tools/libs/gnttab/xengnttab.pc
-tools/libs/hypfs/headers.chk
-tools/libs/hypfs/xenhypfs.pc
-tools/libs/call/headers.chk
-tools/libs/call/xencall.pc

tools/libs/ctrl/libxenctrl.map

.gitignore +0 -5
-tools/libs/ctrl/xencontrol.pc
-tools/libs/foreignmemory/headers.chk
-tools/libs/foreignmemory/xenforeignmemory.pc
-tools/libs/devicemodel/headers.chk
-tools/libs/devicemodel/xendevicemodel.pc

tools/libs/guest/libxenguest.map
-tools/libs/guest/xenguest.pc
tools/libs/guest/xc_bitops.h
tools/libs/guest/xc_core.h
tools/libs/guest/xc_core_arm.h

.gitignore +0 -0
@@ -145,21 +127,13 @@ tools/libs/light/testidl.c

tools/libs/light/test_timedereg
tools/libs/light/test_fdderegrace
tools/libs/light/tmp.*

.gitignore +0 -2
-tools/libs/light/xenlight.pc
-tools/libs/stat/headers.chk

tools/libs/stat/libxenstat.map

.gitignore +0 -2
-tools/libs/stat/xenstat.pc
-tools/libs/store/headers.chk

tools/libs/store/list.h
tools/libs/store/utils.h
-tools/libs/store/xenstore.pc
tools/libs/store/xs_lib.c
-tools/libs/util/*.pc
tools/libs/util/libxlu_cfg_y.output
tools/libs/util/libxenutil.map
-tools/libs/vchan/headers.chk
tools/libs/vchan/libxenvchan.map
-tools/libs/vchan/xenvchan.pc
tools/debugger/gdb/gdb-6.2.1-linux-i386-xen/*
tools/debugger/gdb/gdb-6.2.1/*
tools/debugger/gdb/gdb-6.2.1.tar.bz2

tools/libs/.gitignore +2 -0
index 4a13126144..1ad7c7f0cb 100644
@@ -1 +1,3 @@
+*/*.pc
+*/headers.chk
 */headers.lst
Signature · 1 line
Anthony PERARD
#36 lore raw

PATCH v3 13/25 tools/libs/util: cleanup Makefile

In reply to Anthony PERARD

Remove -I. from CFLAGS, it isn't necessary.

Removed $(AUTOSRCS), it isn't used.

---
 tools/libs/util/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/libs/util/Makefile +1 -2
index ffe507b379..493d2e00be 100644
@@ -11,7 +11,7 @@ OBJS-y += libxlu_pci.o
 
 CFLAGS += -Wno-format-zero-length -Wmissing-declarations \
 	-Wno-declaration-after-statement -Wformat-nonliteral
-CFLAGS += -I. $(CFLAGS_libxenctrl)
+CFLAGS += $(CFLAGS_libxenctrl)
 
 CFLAGS += $(PTHREAD_CFLAGS)
 LDFLAGS += $(PTHREAD_LDFLAGS)
@@ -29,7 +29,6 @@ ifeq ($(BISON),)
 endif
 
 AUTOINCS = libxlu_cfg_y.h libxlu_cfg_l.h libxlu_disk_l.h
-AUTOSRCS = libxlu_cfg_y.c libxlu_cfg_l.c
 
 LIBHEADER := libxlutil.h
 PKG_CONFIG_NAME := Xlutil
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 13/25
#38 lore raw

Re: [XEN PATCH v3 13/25] tools/libs/util: cleanup Makefile

In reply to Anthony PERARD

Hi Anthony,

Quoted 7 lines · Anthony PERARD

Remove -I. from CFLAGS, it isn't necessary.

Removed $(AUTOSRCS), it isn't used.

Cheers
Bertrand

Quoted 29 lines

---
tools/libs/util/Makefile | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
tools/libs/util/Makefile +1 -1
index ffe507b379..493d2e00be 100644
@@ -11,7 +11,7 @@ OBJS-y += libxlu_pci.o
 
 CFLAGS += -Wno-format-zero-length -Wmissing-declarations \
 	-Wno-declaration-after-statement -Wformat-nonliteral
-CFLAGS += -I. $(CFLAGS_libxenctrl)
+CFLAGS += $(CFLAGS_libxenctrl)
 
 CFLAGS += $(PTHREAD_CFLAGS)
 LDFLAGS += $(PTHREAD_LDFLAGS)
@@ -29,7 +29,6 @@ ifeq ($(BISON),)

endif

AUTOINCS = libxlu_cfg_y.h libxlu_cfg_l.h libxlu_disk_l.h -AUTOSRCS = libxlu_cfg_y.c libxlu_cfg_l.c

LIBHEADER := libxlutil.h
PKG_CONFIG_NAME := Xlutil

Signature · 1 line
Anthony PERARD
#39 lore raw

PATCH v3 14/25 tools/flask/utils: list build targets in $(TARGETS)

In reply to Anthony PERARD
---
 tools/flask/utils/Makefile | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/flask/utils/Makefile +5 -5
index db567b13dc..6be134142a 100644
@@ -4,10 +4,10 @@ include $(XEN_ROOT)/tools/Rules.mk
 CFLAGS += -Werror
 CFLAGS += $(CFLAGS_libxenctrl)
 
-CLIENTS := flask-loadpolicy flask-setenforce flask-getenforce flask-label-pci flask-get-bool flask-set-bool
+TARGETS := flask-loadpolicy flask-setenforce flask-getenforce flask-label-pci flask-get-bool flask-set-bool
 
 .PHONY: all
-all: $(CLIENTS)
+all: $(TARGETS)
 
 flask-loadpolicy: loadpolicy.o
 	$(CC) $(LDFLAGS) $< $(LDLIBS) $(LDLIBS_libxenctrl) -o $@
@@ -29,7 +29,7 @@ flask-set-bool: set-bool.o
 
 .PHONY: clean
 clean:
-	$(RM) *.o $(CLIENTS) $(DEPS_RM)
+	$(RM) *.o $(TARGETS) $(DEPS_RM)
 
 .PHONY: distclean
 distclean: clean
@@ -37,10 +37,10 @@ distclean: clean
 .PHONY: install
 install: all
 	$(INSTALL_DIR) $(DESTDIR)$(sbindir)
-	$(INSTALL_PROG) $(CLIENTS) $(DESTDIR)$(sbindir)
+	$(INSTALL_PROG) $(TARGETS) $(DESTDIR)$(sbindir)
 
 .PHONY: uninstall
 uninstall:
-	rm -f $(addprefix $(DESTDIR)$(sbindir)/, $(CLIENTS))
+	rm -f $(addprefix $(DESTDIR)$(sbindir)/, $(TARGETS))
 
 -include $(DEPS_INCLUDE)
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 14/25
#40 lore raw

RE: [XEN PATCH v3 14/25] tools/flask/utils: list build targets in $(TARGETS)

Hi Anthony,

Quoted 5 lines

-----Original Message-----
Subject: [XEN PATCH v3 14/25] tools/flask/utils: list build targets in $(TARGETS)

Kind regards,
Henry

Quoted 3 lines
---
 tools/flask/utils/Makefile | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
#41 lore raw

PATCH v3 15/25 libs/libs.mk: Rename $(LIB) to $(TARGETS)

In reply to Anthony PERARD
---
 tools/libs/libs.mk | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/libs/libs.mk +4 -4
index 58d8166b09..e02f91f95e 100644
@@ -23,9 +23,9 @@ LDLIBS += $(foreach lib, $(USELIBS_$(LIBNAME)), $(LDLIBS_libxen$(lib)))
 PIC_OBJS := $(OBJS-y:.o=.opic)
 
 LIB_FILE_NAME = $(FILENAME_$(LIBNAME))
-LIB := lib$(LIB_FILE_NAME).a
+TARGETS := lib$(LIB_FILE_NAME).a
 ifneq ($(nosharedlibs),y)
-LIB += lib$(LIB_FILE_NAME).so
+TARGETS += lib$(LIB_FILE_NAME).so
 endif
 
 PKG_CONFIG ?= $(LIB_FILE_NAME).pc
@@ -55,7 +55,7 @@ $(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_INCLUDE)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 
 .PHONY: all
-all: headers.chk $(LIB) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)
+all: headers.chk $(TARGETS) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)
 
 ifneq ($(NO_HEADERS_CHK),y)
 headers.chk:
@@ -124,7 +124,7 @@ TAGS:
 
 .PHONY: clean
 clean::
-	rm -rf $(LIB) *~ $(DEPS_RM) $(OBJS-y) $(PIC_OBJS)
+	rm -rf $(TARGETS) *~ $(DEPS_RM) $(OBJS-y) $(PIC_OBJS)
 	rm -f lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR) lib$(LIB_FILE_NAME).so.$(MAJOR)
 	rm -f headers.chk headers.lst
 	rm -f $(PKG_CONFIG)
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 15/25
#43 lore raw

Re: [XEN PATCH v3 15/25] libs/libs.mk: Rename $(LIB) to $(TARGETS)

In reply to Anthony PERARD

HI Anthony,

Quoted 3 lines · Anthony PERARD

Cheers
Bertrand

Quoted 42 lines

---
tools/libs/libs.mk | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
tools/libs/libs.mk +2 -2
index 58d8166b09..e02f91f95e 100644
@@ -23,9 +23,9 @@ LDLIBS += $(foreach lib, $(USELIBS_$(LIBNAME)), $(LDLIBS_libxen$(lib)))
 PIC_OBJS := $(OBJS-y:.o=.opic)
 
 LIB_FILE_NAME = $(FILENAME_$(LIBNAME))
-LIB := lib$(LIB_FILE_NAME).a
+TARGETS := lib$(LIB_FILE_NAME).a
 ifneq ($(nosharedlibs),y)
-LIB += lib$(LIB_FILE_NAME).so
+TARGETS += lib$(LIB_FILE_NAME).so

endif

PKG_CONFIG ?= $(LIB_FILE_NAME).pc

tools/libs/libs.mk +0 -0
@@ -55,7 +55,7 @@ $(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_INCLUDE)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 

.PHONY: all

tools/libs/libs.mk +1 -1
-all: headers.chk $(LIB) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)
+all: headers.chk $(TARGETS) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)

ifneq ($(NO_HEADERS_CHK),y)
headers.chk:

tools/libs/libs.mk +0 -0
@@ -124,7 +124,7 @@ TAGS:
 

.PHONY: clean
clean::

tools/libs/libs.mk +1 -1
-	rm -rf $(LIB) *~ $(DEPS_RM) $(OBJS-y) $(PIC_OBJS)
+	rm -rf $(TARGETS) *~ $(DEPS_RM) $(OBJS-y) $(PIC_OBJS)
	rm -f lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR) lib$(LIB_FILE_NAME).so.$(MAJOR)
	rm -f headers.chk headers.lst
	rm -f $(PKG_CONFIG)
Signature · 1 line
Anthony PERARD
#44 lore raw

PATCH v3 16/25 libs/libs.mk: Remove the need for $(PKG_CONFIG_INST)

In reply to Anthony PERARD

We can simply use $(PKG_CONFIG) to set the parameters, and add it to $(TARGETS) as necessary.

---
 tools/libs/libs.mk | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
tools/libs/libs.mk +5 -6
index e02f91f95e..7aee449370 100644
@@ -37,10 +37,10 @@ PKG_CONFIG_LIB := $(LIB_FILE_NAME)
 PKG_CONFIG_REQPRIV := $(subst $(space),$(comma),$(strip $(foreach lib,$(patsubst ctrl,control,$(USELIBS_$(LIBNAME))),xen$(lib))))
 
 ifneq ($(CONFIG_LIBXC_MINIOS),y)
-PKG_CONFIG_INST := $(PKG_CONFIG)
-$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
-$(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
-$(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
+TARGETS += $(PKG_CONFIG)
+$(PKG_CONFIG): PKG_CONFIG_PREFIX = $(prefix)
+$(PKG_CONFIG): PKG_CONFIG_INCDIR = $(includedir)
+$(PKG_CONFIG): PKG_CONFIG_LIBDIR = $(libdir)
 endif
 
 PKG_CONFIG_LOCAL := $(PKG_CONFIG_DIR)/$(PKG_CONFIG)
@@ -55,7 +55,7 @@ $(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_INCLUDE)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 
 .PHONY: all
-all: headers.chk $(TARGETS) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)
+all: headers.chk $(TARGETS) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)
 
 ifneq ($(NO_HEADERS_CHK),y)
 headers.chk:
@@ -127,7 +127,6 @@ clean::
 	rm -rf $(TARGETS) *~ $(DEPS_RM) $(OBJS-y) $(PIC_OBJS)
 	rm -f lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR) lib$(LIB_FILE_NAME).so.$(MAJOR)
 	rm -f headers.chk headers.lst
-	rm -f $(PKG_CONFIG)
 
 .PHONY: distclean
 distclean: clean
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 16/25
#46 lore raw

Re: [XEN PATCH v3 16/25] libs/libs.mk: Remove the need for $(PKG_CONFIG_INST)

In reply to Anthony PERARD

Hi Anthony,

Quoted 6 lines · Anthony PERARD

We can simply use $(PKG_CONFIG) to set the parameters, and add it to $(TARGETS) as necessary.

Cheers
Bertrand

Quoted 44 lines

---
tools/libs/libs.mk | 11 +++++------

1 file changed, 5 insertions(+), 6 deletions(-)
tools/libs/libs.mk +4 -4
index e02f91f95e..7aee449370 100644
@@ -37,10 +37,10 @@ PKG_CONFIG_LIB := $(LIB_FILE_NAME)
 PKG_CONFIG_REQPRIV := $(subst $(space),$(comma),$(strip $(foreach lib,$(patsubst ctrl,control,$(USELIBS_$(LIBNAME))),xen$(lib))))
 
 ifneq ($(CONFIG_LIBXC_MINIOS),y)
-PKG_CONFIG_INST := $(PKG_CONFIG)
-$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
-$(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
-$(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
+TARGETS += $(PKG_CONFIG)
+$(PKG_CONFIG): PKG_CONFIG_PREFIX = $(prefix)
+$(PKG_CONFIG): PKG_CONFIG_INCDIR = $(includedir)
+$(PKG_CONFIG): PKG_CONFIG_LIBDIR = $(libdir)

endif

PKG_CONFIG_LOCAL := $(PKG_CONFIG_DIR)/$(PKG_CONFIG)

tools/libs/libs.mk +0 -0
@@ -55,7 +55,7 @@ $(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_INCLUDE)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 

.PHONY: all

tools/libs/libs.mk +1 -1
-all: headers.chk $(TARGETS) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)
+all: headers.chk $(TARGETS) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)

ifneq ($(NO_HEADERS_CHK),y)
headers.chk:

tools/libs/libs.mk +0 -1
@@ -127,7 +127,6 @@ clean::
 	rm -rf $(TARGETS) *~ $(DEPS_RM) $(OBJS-y) $(PIC_OBJS)
 	rm -f lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR) lib$(LIB_FILE_NAME).so.$(MAJOR)
 	rm -f headers.chk headers.lst
-	rm -f $(PKG_CONFIG)
 

.PHONY: distclean
distclean: clean

Signature · 1 line
Anthony PERARD
#47 lore raw

PATCH v3 17/25 libs/libs.mk: Rework target headers.chk dependencies

In reply to Anthony PERARD

There is no need to call the "headers.chk" target when it isn't wanted, so it never need to be .PHONY.

Also, there is no more reason to separate the prerequisites from the recipe.

---
 tools/libs/libs.mk | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
tools/libs/libs.mk +4 -6
index 7aee449370..f778a7df82 100644
@@ -55,22 +55,20 @@ $(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_INCLUDE)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 
 .PHONY: all
-all: headers.chk $(TARGETS) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)
+all: $(TARGETS) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)
 
 ifneq ($(NO_HEADERS_CHK),y)
-headers.chk:
+all: headers.chk
+
+headers.chk: $(LIBHEADERS) $(AUTOINCS)
 	for i in $(filter %.h,$^); do \
 	    $(CC) -x c -ansi -Wall -Werror $(CFLAGS_xeninclude) \
 	          -S -o /dev/null $$i || exit 1; \
 	    echo $$i; \
 	done >[email protected]
 	mv [email protected] $@
-else
-.PHONY: headers.chk
 endif
 
-headers.chk: $(LIBHEADERS) $(AUTOINCS)
-
 headers.lst: FORCE
 	@{ set -e; $(foreach h,$(LIBHEADERS),echo $(h);) } > [email protected]
 	@$(call move-if-changed,[email protected],$@)
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 17/25
#48 lore raw

Re: [XEN PATCH v3 17/25] libs/libs.mk: Rework target headers.chk dependencies

Quoted 7 lines · Anthony PERARD

There is no need to call the "headers.chk" target when it isn't wanted, so it never need to be .PHONY.

Also, there is no more reason to separate the prerequisites from the recipe.

Juergen

Reviewed-by on v3 17/25
#49 lore raw

Re: [XEN PATCH v3 17/25] libs/libs.mk: Rework target headers.chk dependencies

In reply to Anthony PERARD

Hi Anthony,

Quoted 9 lines · Anthony PERARD

There is no need to call the "headers.chk" target when it isn't wanted, so it never need to be .PHONY.

Also, there is no more reason to separate the prerequisites from the recipe.

Cheers
Bertrand

Quoted 39 lines

---
tools/libs/libs.mk | 10 ++++------

1 file changed, 4 insertions(+), 6 deletions(-)
tools/libs/libs.mk +0 -0
index 7aee449370..f778a7df82 100644
@@ -55,22 +55,20 @@ $(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_INCLUDE)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 

.PHONY: all

tools/libs/libs.mk +1 -1
-all: headers.chk $(TARGETS) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)
+all: $(TARGETS) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)

ifneq ($(NO_HEADERS_CHK),y)

tools/libs/libs.mk +3 -1
-headers.chk:
+all: headers.chk
+
+headers.chk: $(LIBHEADERS) $(AUTOINCS)
	for i in $(filter %.h,$^); do \
	    $(CC) -x c -ansi -Wall -Werror $(CFLAGS_xeninclude) \
	          -S -o /dev/null $$i || exit 1; \
	    echo $$i; \
	done >[email protected]
	mv [email protected] $@

-else
-.PHONY: headers.chk
endif

tools/libs/libs.mk +0 -2
-headers.chk: $(LIBHEADERS) $(AUTOINCS)
-

headers.lst: FORCE

	@{ set -e; $(foreach h,$(LIBHEADERS),echo $(h);) } > [email protected]
	@$(call move-if-changed,[email protected],$@)
Signature · 1 line
Anthony PERARD
#50 lore raw

PATCH v3 18/25 tools: Introduce $(xenlibs-rpath,..) to replace $(SHDEPS_lib*)

In reply to Anthony PERARD

This patch introduce a new macro $(xenlibs-dependencies,) to generate a list of all the xen library that a library is list against, and they are listed only once. We use the side effect of $(sort ) which remove duplicates.

This is used by another macro $(xenlibs-rpath,) which is to replace $(SHDEPS_libxen*).

In libs.mk, we don't need to $(sort ) SHLIB_lib* anymore as this was used to remove duplicates and they are no more duplicates.

---
 tools/Rules.mk     | 29 ++++++++++++++++-------------
 tools/libs/libs.mk |  2 +-
 2 files changed, 17 insertions(+), 14 deletions(-)
tools/Rules.mk +16 -13
index 47424935ba..23979ed254 100644
@@ -61,13 +61,8 @@ endif
 #           public headers. Users of libfoo are therefore transitively
 #           using libbaz's header but not linking against libbaz.
 #
-# SHDEPS_libfoo: Flags for linking recursive dependencies of
-#                libfoo. Must contain SHLIB for every library which
-#                libfoo links against. So must contain both
-#                $(SHLIB_libbar) and $(SHLIB_libbaz).
-#
 # SHLIB_libfoo: Flags for recursively linking against libfoo. Must
-#               contains SHDEPS_libfoo and:
+#               contains $(call xenlibs-rpath,foo) and:
 #                   -Wl,-rpath-link=<directory containing libfoo.so>
 #
 # CFLAGS_libfoo: Flags for compiling against libfoo. Must add the
@@ -79,23 +74,31 @@ endif
 #                libfoo.
 #
 # LDLIBS_libfoo: Flags for linking against libfoo. Must contain
-#                $(SHDEPS_libfoo) and the path to libfoo.so
+#                $(call xenlibs-rpath,foo) and the path to libfoo.so
 #
 # Consumers of libfoo should include $(CFLAGS_libfoo) and
 # $(LDLIBS_libfoo) in their appropriate directories. They should not
 # include any CFLAGS or LDLIBS relating to libbar or libbaz unless
 # they use those libraries directly (not via libfoo) too.
-#
-# Consumers of libfoo should not directly use $(SHDEPS_libfoo) or
-# $(SHLIB_libfoo)
+
+# Give the list of Xen library that the libraries in $(1) are linked against,
+# directly or indirectly.
+define xenlibs-dependencies
+    $(sort $(foreach lib,$(1), \
+        $(USELIBS_$(lib)) $(call xenlibs-dependencies,$(USELIBS_$(lib)))))
+endef
+
+# Flags for linking recursive dependencies of Xen libraries in $(1)
+define xenlibs-rpath
+    $(addprefix -Wl$(comma)-rpath-link=$(XEN_ROOT)/tools/libs/,$(call xenlibs-dependencies,$(1)))
+endef
 
 define LIB_defs
  FILENAME_$(1) ?= xen$(1)
  XEN_libxen$(1) = $$(XEN_ROOT)/tools/libs/$(1)
  CFLAGS_libxen$(1) = $$(CFLAGS_xeninclude)
- SHDEPS_libxen$(1) = $$(foreach use,$$(USELIBS_$(1)),$$(SHLIB_libxen$$(use)))
- LDLIBS_libxen$(1) = $$(SHDEPS_libxen$(1)) $$(XEN_libxen$(1))/lib$$(FILENAME_$(1))$$(libextension)
- SHLIB_libxen$(1) = $$(SHDEPS_libxen$(1)) -Wl,-rpath-link=$$(XEN_libxen$(1))
+ SHLIB_libxen$(1) = $$(call xenlibs-rpath,$(1)) -Wl,-rpath-link=$$(XEN_libxen$(1))
+ LDLIBS_libxen$(1) = $$(call xenlibs-rpath,$(1)) $$(XEN_libxen$(1))/lib$$(FILENAME_$(1))$$(libextension)
 endef
 
 $(foreach lib,$(LIBS_LIBS),$(eval $(call LIB_defs,$(lib))))
tools/libs/libs.mk +1 -1
index f778a7df82..d7e1274249 100644
@@ -32,7 +32,7 @@ PKG_CONFIG ?= $(LIB_FILE_NAME).pc
 PKG_CONFIG_NAME ?= Xen$(LIBNAME)
 PKG_CONFIG_DESC ?= The $(PKG_CONFIG_NAME) library for Xen hypervisor
 PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
-PKG_CONFIG_USELIBS := $(sort $(SHLIB_libxen$(LIBNAME)))
+PKG_CONFIG_USELIBS := $(SHLIB_libxen$(LIBNAME))
 PKG_CONFIG_LIB := $(LIB_FILE_NAME)
 PKG_CONFIG_REQPRIV := $(subst $(space),$(comma),$(strip $(foreach lib,$(patsubst ctrl,control,$(USELIBS_$(LIBNAME))),xen$(lib))))
 
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 18/25
#51 lore raw

Re: [XEN PATCH v3 18/25] tools: Introduce $(xenlibs-rpath,..) to replace $(SHDEPS_lib*)

Quoted 5 lines · Anthony PERARD

This patch introduce a new macro $(xenlibs-dependencies,) to generate a list of all the xen library that a library is list against, and they are listed only once. We use the side effect of $(sort ) which remove duplicates.

Quoted 7 lines

This is used by another macro $(xenlibs-rpath,) which is to replace $(SHDEPS_libxen*).

In libs.mk, we don't need to $(sort ) SHLIB_lib* anymore as this was used to remove duplicates and they are no more duplicates.

Juergen

#52 lore raw

PATCH v3 19/25 tools: Introduce $(xenlibs-ldlibs, ) macro

In reply to Anthony PERARD

This can be used when linking against multiple in-tree Xen libraries, and avoid duplicated flags. It can be used instead of multiple $(LDLIBS_libxen*).

For now, replace the open-coding in libs.mk.

The macro $(xenlibs-libs, ) will be useful later when only the path to the libraries is wanted (e.g. for checking for dependencies).

---
 tools/Rules.mk     | 16 ++++++++++++++--
 tools/libs/libs.mk |  2 +-
 2 files changed, 15 insertions(+), 3 deletions(-)
tools/Rules.mk +14 -2
index 23979ed254..ce77dd2eb1 100644
@@ -93,12 +93,24 @@ define xenlibs-rpath
     $(addprefix -Wl$(comma)-rpath-link=$(XEN_ROOT)/tools/libs/,$(call xenlibs-dependencies,$(1)))
 endef
 
+# Provide a path for each library in $(1)
+define xenlibs-libs
+    $(foreach lib,$(1), \
+        $(XEN_ROOT)/tools/libs/$(lib)/lib$(FILENAME_$(lib))$(libextension))
+endef
+
+# Flags for linking against all Xen libraries listed in $(1)
+define xenlibs-ldlibs
+    $(call xenlibs-rpath,$(1)) $(call xenlibs-libs,$(1)) \
+    $(foreach lib,$(1),$(xenlibs-ldlibs-$(lib)))
+endef
+
 define LIB_defs
  FILENAME_$(1) ?= xen$(1)
  XEN_libxen$(1) = $$(XEN_ROOT)/tools/libs/$(1)
  CFLAGS_libxen$(1) = $$(CFLAGS_xeninclude)
  SHLIB_libxen$(1) = $$(call xenlibs-rpath,$(1)) -Wl,-rpath-link=$$(XEN_libxen$(1))
- LDLIBS_libxen$(1) = $$(call xenlibs-rpath,$(1)) $$(XEN_libxen$(1))/lib$$(FILENAME_$(1))$$(libextension)
+ LDLIBS_libxen$(1) = $$(call xenlibs-ldlibs,$(1))
 endef
 
 $(foreach lib,$(LIBS_LIBS),$(eval $(call LIB_defs,$(lib))))
@@ -108,7 +120,7 @@ $(foreach lib,$(LIBS_LIBS),$(eval $(call LIB_defs,$(lib))))
 CFLAGS_libxenctrl += -D__XEN_TOOLS__
 
 ifeq ($(CONFIG_Linux),y)
-LDLIBS_libxenstore += -ldl
+xenlibs-ldlibs-store := -ldl
 endif
 
 CFLAGS_libxenlight += $(CFLAGS_libxenctrl)
tools/libs/libs.mk +1 -1
index d7e1274249..2b8e7a6128 100644
@@ -18,7 +18,7 @@ CFLAGS   += -Werror -Wmissing-prototypes
 CFLAGS   += $(CFLAGS_xeninclude)
 CFLAGS   += $(foreach lib, $(USELIBS_$(LIBNAME)), $(CFLAGS_libxen$(lib)))
 
-LDLIBS += $(foreach lib, $(USELIBS_$(LIBNAME)), $(LDLIBS_libxen$(lib)))
+LDLIBS += $(call xenlibs-ldlibs,$(USELIBS_$(LIBNAME)))
 
 PIC_OBJS := $(OBJS-y:.o=.opic)
 
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 19/25
#53 lore raw

Re: [XEN PATCH v3 19/25] tools: Introduce $(xenlibs-ldlibs, ) macro

Quoted 10 lines · Anthony PERARD

This can be used when linking against multiple in-tree Xen libraries, and avoid duplicated flags. It can be used instead of multiple $(LDLIBS_libxen*).

For now, replace the open-coding in libs.mk.

The macro $(xenlibs-libs, ) will be useful later when only the path to the libraries is wanted (e.g. for checking for dependencies).

Juergen

#54 lore raw

PATCH v3 20/25 tools: Introduce $(xenlibs-ldflags, ) macro

In reply to Anthony PERARD

This avoid the need to open-coding the list of flags needed to link with an in-tree Xen library when using -lxen*.

---
 tools/golang/xenlight/Makefile | 2 +-
 tools/Rules.mk                 | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
tools/golang/xenlight/Makefile +1 -1
index 64671f246c..00e6d17f2b 100644
@@ -27,7 +27,7 @@ GOXL_GEN_FILES = types.gen.go helpers.gen.go
 # so that it can find the actual library.
 .PHONY: build
 build: xenlight.go $(GOXL_GEN_FILES)
-	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog) $(APPEND_CFLAGS)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_libxenlight) -L$(XEN_libxentoollog) $(APPEND_LDFLAGS)" $(GO) build -x
+	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog) $(APPEND_CFLAGS)" CGO_LDFLAGS="$(call xenlibs-ldflags,light toollog) $(APPEND_LDFLAGS)" $(GO) build -x
 
 .PHONY: install
 install: build
tools/Rules.mk +8 -0
index ce77dd2eb1..26958b2948 100644
@@ -105,6 +105,14 @@ define xenlibs-ldlibs
     $(foreach lib,$(1),$(xenlibs-ldlibs-$(lib)))
 endef
 
+# Provide needed flags for linking an in-tree Xen library by an external
+# project (or when it is necessary to link with "-lxen$(1)" instead of using
+# the full path to the library).
+define xenlibs-ldflags
+    $(call xenlibs-rpath,$(1)) \
+    $(foreach lib,$(1),-L$(XEN_ROOT)/tools/libs/$(lib))
+endef
+
 define LIB_defs
  FILENAME_$(1) ?= xen$(1)
  XEN_libxen$(1) = $$(XEN_ROOT)/tools/libs/$(1)
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 20/25
#55 lore raw

RE: [XEN PATCH v3 20/25] tools: Introduce $(xenlibs-ldflags, ) macro

Hi Anthony,

Quoted 7 lines

-----Original Message-----
Subject: [XEN PATCH v3 20/25] tools: Introduce $(xenlibs-ldflags, ) macro

This avoid the need to open-coding the list of flags needed to link with an in-tree Xen library when using -lxen*.

Kind regards,
Henry

Quoted 3 lines
---
 tools/golang/xenlight/Makefile | 2 +-
 tools/Rules.mk                 | 8 ++++++++
#56 lore raw

PATCH v3 21/25 tools/helper: Cleanup Makefile

In reply to Anthony PERARD

Use $(TARGETS) to collect targets.
Collect library to link against in $(LDLIBS). Remove extra "-f" flags that is already part of $(RM).

---

Notes:
v3:
- apply changes to the new "init-dom0less" helper.
- make use of the new macro $(xenlibs-ldlibs,)

 tools/helpers/Makefile | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
tools/helpers/Makefile +13 -10
index 8d78ab1e90..7c9d671b32 100644
@@ -5,13 +5,13 @@
 XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-PROGS += xen-init-dom0
+TARGETS += xen-init-dom0
 ifeq ($(CONFIG_Linux),y)
 ifeq ($(CONFIG_X86),y)
-PROGS += init-xenstore-domain
+TARGETS += init-xenstore-domain
 endif
 ifeq ($(CONFIG_ARM),y)
-PROGS += init-dom0less
+TARGETS += init-dom0less
 endif
 endif
 
@@ -20,6 +20,7 @@ $(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
 $(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxenstore)
 $(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxenlight)
 $(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxenctrl)
+xen-init-dom0: LDLIBS += $(call xenlibs-ldlibs,ctrl toollog store light)
 
 INIT_XENSTORE_DOMAIN_OBJS = init-xenstore-domain.o init-dom-json.o
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
@@ -28,6 +29,7 @@ $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxenctrl)
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxenstore)
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxenlight)
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h
+init-xenstore-domain: LDLIBS += $(call xenlibs-ldlibs,toollog store ctrl guest light)
 
 INIT_DOM0LESS_OBJS = init-dom0less.o init-dom-json.o
 $(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
@@ -35,30 +37,31 @@ $(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenstore)
 $(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenlight)
 $(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenctrl)
 $(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenevtchn)
+init-dom0less: LDLIBS += $(call xenlibs-ldlibs,ctrl evtchn toollog store light guest foreignmemory)
 
 .PHONY: all
-all: $(PROGS)
+all: $(TARGETS)
 
 xen-init-dom0: $(XEN_INIT_DOM0_OBJS)
-	$(CC) $(LDFLAGS) -o $@ $(XEN_INIT_DOM0_OBJS) $(LDLIBS_libxenctrl) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenlight) $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) -o $@ $(XEN_INIT_DOM0_OBJS) $(LDLIBS) $(APPEND_LDFLAGS)
 
 init-xenstore-domain: $(INIT_XENSTORE_DOMAIN_OBJS)
-	$(CC) $(LDFLAGS) -o $@ $(INIT_XENSTORE_DOMAIN_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenlight) $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) -o $@ $(INIT_XENSTORE_DOMAIN_OBJS) $(LDLIBS) $(APPEND_LDFLAGS)
 
 init-dom0less: $(INIT_DOM0LESS_OBJS)
-	$(CC) $(LDFLAGS) -o $@ $(INIT_DOM0LESS_OBJS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenevtchn) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenlight) $(LDLIBS_libxenguest) $(LDLIBS_libxenforeignmemory) $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) -o $@ $(INIT_DOM0LESS_OBJS) $(LDLIBS) $(APPEND_LDFLAGS)
 
 .PHONY: install
 install: all
 	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
-	for i in $(PROGS); do $(INSTALL_PROG) $$i $(DESTDIR)$(LIBEXEC_BIN); done
+	for i in $(TARGETS); do $(INSTALL_PROG) $$i $(DESTDIR)$(LIBEXEC_BIN); done
 
 .PHONY: uninstall
 uninstall:
-	for i in $(PROGS); do rm -f $(DESTDIR)$(LIBEXEC_BIN)/$$i; done
+	for i in $(TARGETS); do rm -f $(DESTDIR)$(LIBEXEC_BIN)/$$i; done
 
 .PHONY: clean
 clean:
-	$(RM) -f *.o $(PROGS) $(DEPS_RM)
+	$(RM) *.o $(TARGETS) $(DEPS_RM)
 
 distclean: clean
Signature · 1 line
Anthony PERARD
Reviewed-by Tested-by on v3 21/25
#57 lore raw

Re: [XEN PATCH v3 21/25] tools/helper: Cleanup Makefile

Quoted 27 lines · Anthony PERARD

Use $(TARGETS) to collect targets.
Collect library to link against in $(LDLIBS). Remove extra "-f" flags that is already part of $(RM).

---

Notes:
v3:
- apply changes to the new "init-dom0less" helper.
- make use of the new macro $(xenlibs-ldlibs,)

tools/helpers/Makefile | 23 +++++++++++++----------

1 file changed, 13 insertions(+), 10 deletions(-)
tools/helpers/Makefile +0 -0
index 8d78ab1e90..7c9d671b32 100644
@@ -5,13 +5,13 @@

XEN_ROOT = $(CURDIR)/../..
include $(XEN_ROOT)/tools/Rules.mk

tools/helpers/Makefile line 8

Quoted 2 lines
tools/helpers/Makefile +1 -1
-PROGS += xen-init-dom0
+TARGETS += xen-init-dom0

Can this be TARGETS :=

The rest looks good, so with this addressed

I’ve also built and run the tool stack with (up to) this patch on both fvp-base for arm and qemu for x86_64 and the binaries are ok.

#58 lore raw

PATCH v3 22/25 tools/console: Use $(xenlibs-ldlibs,)

In reply to Anthony PERARD
---
 tools/console/client/Makefile | 3 +--
 tools/console/daemon/Makefile | 6 +-----
 2 files changed, 2 insertions(+), 7 deletions(-)
tools/console/client/Makefile +1 -2
index 44176c6d93..e2f2554f92 100644
@@ -6,8 +6,7 @@ CFLAGS += $(CFLAGS_libxenctrl)
 CFLAGS += $(CFLAGS_libxenstore)
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
-LDLIBS += $(LDLIBS_libxenctrl)
-LDLIBS += $(LDLIBS_libxenstore)
+LDLIBS += $(call xenlibs-ldlibs,ctrl store)
 LDLIBS += $(SOCKET_LIBS)
 
 OBJS-y := main.o
tools/console/daemon/Makefile +1 -5
index 0f004f0b14..99bb33b6a2 100644
@@ -10,11 +10,7 @@ CFLAGS += $(CFLAGS_libxenforeignmemory)
 CFLAGS-$(CONFIG_ARM) += -DCONFIG_ARM
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
-LDLIBS += $(LDLIBS_libxenctrl)
-LDLIBS += $(LDLIBS_libxenstore)
-LDLIBS += $(LDLIBS_libxenevtchn)
-LDLIBS += $(LDLIBS_libxengnttab)
-LDLIBS += $(LDLIBS_libxenforeignmemory)
+LDLIBS += $(call xenlibs-ldlibs,ctrl store evtchn gnttab foreignmemory)
 LDLIBS += $(SOCKET_LIBS)
 LDLIBS += $(UTIL_LIBS)
 LDLIBS += -lrt
Signature · 1 line
Anthony PERARD
#60 lore raw

PATCH v3 23/25 tools/helpers: Fix build of xen-init-dom0 with -Werror

In reply to Anthony PERARD

Missing prototype of asprintf() without _GNU_SOURCE.

---
 tools/helpers/xen-init-dom0.c | 2 ++
 1 file changed, 2 insertions(+)
tools/helpers/xen-init-dom0.c +2 -0
index 37eff8868f..764f837887 100644
@@ -1,3 +1,5 @@
+#define _GNU_SOURCE
+
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 23/25
#61 lore raw

RE: [XEN PATCH v3 23/25] tools/helpers: Fix build of xen-init-dom0 with -Werror

Hi Anthony,

Quoted 7 lines

-----Original Message-----
Subject: [XEN PATCH v3 23/25] tools/helpers: Fix build of xen-init-dom0 with -Werror

Missing prototype of asprintf() without _GNU_SOURCE.

Kind regards,
Henry

Quoted 3 lines
---
 tools/helpers/xen-init-dom0.c | 2 ++
 1 file changed, 2 insertions(+)
#62 lore raw

PATCH v3 24/25 tools: Add -Werror by default to all tools/

In reply to Anthony PERARD

And provide an option to ./configure to disable it.

A follow-up patch will remove -Werror from every other Makefile in tools/. ("tools: Remove -Werror everywhere else")

---
 tools/configure.ac |  1 +
 tools/Rules.mk     |  4 ++++
 config/Tools.mk.in |  1 +
 tools/configure    | 26 ++++++++++++++++++++++++++
 4 files changed, 32 insertions(+)
tools/configure.ac +1 -0
index 1094d896fc..06311b99c2 100644
@@ -79,6 +79,7 @@ m4_include([../m4/header.m4])
 AX_XEN_EXPAND_CONFIG()
 
 # Enable/disable options
+AX_ARG_DEFAULT_ENABLE([werror], [Build tools without -Werror])
 AX_ARG_DEFAULT_DISABLE([rpath], [Build tools with -Wl,-rpath,LIBDIR])
 AX_ARG_DEFAULT_DISABLE([githttp], [Download GIT repositories via HTTP])
 AX_ARG_DEFAULT_ENABLE([monitors], [Disable xenstat and xentop monitoring tools])
tools/Rules.mk +4 -0
index 26958b2948..a165dc4bda 100644
@@ -133,6 +133,10 @@ endif
 
 CFLAGS_libxenlight += $(CFLAGS_libxenctrl)
 
+ifeq ($(CONFIG_WERROR),y)
+CFLAGS += -Werror
+endif
+
 ifeq ($(debug),y)
 # Use -Og if available, -O0 otherwise
 dbg_opt_level := $(call cc-option,$(CC),-Og,-O0)
config/Tools.mk.in +1 -0
index 6c1a0a676f..d0d460f922 100644
@@ -1,5 +1,6 @@
 -include $(XEN_ROOT)/config/Paths.mk
 
+CONFIG_WERROR       := @werror@
 CONFIG_RUMP         := @CONFIG_RUMP@
 ifeq ($(CONFIG_RUMP),y)
 XEN_OS              := NetBSDRump
tools/configure +26 -0
index a052c186a5..986cb1d933 100755
@@ -716,6 +716,7 @@ ocamltools
 monitors
 githttp
 rpath
+werror
 DEBUG_DIR
 XEN_DUMP_DIR
 XEN_PAGING_DIR
@@ -805,6 +806,7 @@ with_xen_scriptdir
 with_xen_dumpdir
 with_rundir
 with_debugdir
+enable_werror
 enable_rpath
 enable_githttp
 enable_monitors
@@ -1490,6 +1492,7 @@ Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --disable-largefile     omit support for large files
+  --disable-werror        Build tools without -Werror (default is ENABLED)
   --enable-rpath          Build tools with -Wl,-rpath,LIBDIR (default is
                           DISABLED)
   --enable-githttp        Download GIT repositories via HTTP (default is
@@ -4111,6 +4114,29 @@ DEBUG_DIR=$debugdir_path
 
 # Enable/disable options
 
+# Check whether --enable-werror was given.
+if test "${enable_werror+set}" = set; then :
+  enableval=$enable_werror;
+fi
+
+
+if test "x$enable_werror" = "xno"; then :
+
+    ax_cv_werror="n"
+
+elif test "x$enable_werror" = "xyes"; then :
+
+    ax_cv_werror="y"
+
+elif test -z $ax_cv_werror; then :
+
+    ax_cv_werror="y"
+
+fi
+werror=$ax_cv_werror
+
+
+
 # Check whether --enable-rpath was given.
 if test "${enable_rpath+set}" = set; then :
   enableval=$enable_rpath;
Signature · 1 line
Anthony PERARD
Reviewed-by on v3 24/25
#63 lore raw

Re: [XEN PATCH v3 24/25] tools: Add -Werror by default to all tools/

Quoted 10 lines · Anthony PERARD

And provide an option to ./configure to disable it.

A follow-up patch will remove -Werror from every other Makefile in tools/. ("tools: Remove -Werror everywhere else")

Hi Antony,

Looks good to me

#64 lore raw

PATCH v3 25/25 tools: Remove -Werror everywhere else

In reply to Anthony PERARD

Patch "tools: Add -Werror by default to all tools/" have added "-Werror" to CFLAGS in tools/Rules.mk, remove it from every other makefiles as it is now duplicated.

---
 tools/console/client/Makefile   | 1 -
 tools/console/daemon/Makefile   | 1 -
 tools/debugger/kdd/Makefile     | 1 -
 tools/flask/utils/Makefile      | 1 -
 tools/fuzz/cpu-policy/Makefile  | 2 +-
 tools/misc/Makefile             | 1 -
 tools/tests/cpu-policy/Makefile | 2 +-
 tools/tests/depriv/Makefile     | 2 +-
 tools/tests/resource/Makefile   | 1 -
 tools/tests/tsx/Makefile        | 1 -
 tools/tests/xenstore/Makefile   | 1 -
 tools/xcutils/Makefile          | 2 --
 tools/xenmon/Makefile           | 1 -
 tools/xenpaging/Makefile        | 1 -
 tools/xenpmd/Makefile           | 1 -
 tools/xentop/Makefile           | 2 +-
 tools/xentrace/Makefile         | 2 --
 tools/xl/Makefile               | 2 +-
 tools/debugger/gdbsx/Rules.mk   | 2 +-
 tools/firmware/Rules.mk         | 2 --
 tools/libfsimage/common.mk      | 2 +-
 tools/libs/libs.mk              | 2 +-
 tools/ocaml/common.make         | 2 +-
 tools/xenstore/Makefile.common  | 1 -
 24 files changed, 9 insertions(+), 27 deletions(-)
tools/console/client/Makefile +0 -1
index e2f2554f92..62d89fdeb9 100644
@@ -1,7 +1,6 @@
 XEN_ROOT=$(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += -Werror
 CFLAGS += $(CFLAGS_libxenctrl)
 CFLAGS += $(CFLAGS_libxenstore)
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
tools/console/daemon/Makefile +0 -1
index 99bb33b6a2..9fc3b6711f 100644
@@ -1,7 +1,6 @@
 XEN_ROOT=$(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += -Werror
 CFLAGS += $(CFLAGS_libxenctrl)
 CFLAGS += $(CFLAGS_libxenstore)
 CFLAGS += $(CFLAGS_libxenevtchn)
tools/debugger/kdd/Makefile +0 -1
index 26116949d4..a72ad3b1e0 100644
@@ -1,7 +1,6 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS  += -Werror
 CFLAGS  += $(CFLAGS_libxenctrl)
 CFLAGS  += -DXC_WANT_COMPAT_MAP_FOREIGN_API
 LDLIBS  += $(LDLIBS_libxenctrl)
tools/flask/utils/Makefile +0 -1
index 6be134142a..88d7edb6b1 100644
@@ -1,7 +1,6 @@
 XEN_ROOT=$(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += -Werror
 CFLAGS += $(CFLAGS_libxenctrl)
 
 TARGETS := flask-loadpolicy flask-setenforce flask-getenforce flask-label-pci flask-get-bool flask-set-bool
tools/fuzz/cpu-policy/Makefile +1 -1
index 41a2230408..6e7743e0aa 100644
@@ -17,7 +17,7 @@ install: all
 
 .PHONY: uninstall
 
-CFLAGS += -Werror $(CFLAGS_xeninclude) -D__XEN_TOOLS__
+CFLAGS += $(CFLAGS_xeninclude) -D__XEN_TOOLS__
 CFLAGS += $(APPEND_CFLAGS) -Og
 
 vpath %.c ../../../xen/lib/x86
tools/misc/Makefile +0 -1
index 0e02401227..1c6e1d6a04 100644
@@ -1,7 +1,6 @@
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += -Werror
 # Include configure output (config.h)
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 CFLAGS += $(CFLAGS_libxenevtchn)
tools/tests/cpu-policy/Makefile +1 -1
index 93af9d76fa..c5b81afc71 100644
@@ -36,7 +36,7 @@ install: all
 uninstall:
 	$(RM) -- $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/,$(TARGETS))
 
-CFLAGS += -Werror -D__XEN_TOOLS__
+CFLAGS += -D__XEN_TOOLS__
 CFLAGS += $(CFLAGS_xeninclude)
 CFLAGS += $(APPEND_CFLAGS)
 
tools/tests/depriv/Makefile +1 -1
index 3cba28da25..7d9e3b01bb 100644
@@ -1,7 +1,7 @@
 XEN_ROOT=$(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += -Werror -Wno-declaration-after-statement
+CFLAGS += -Wno-declaration-after-statement
 
 CFLAGS += $(CFLAGS_xeninclude)
 CFLAGS += $(CFLAGS_libxenctrl)
tools/tests/resource/Makefile +0 -1
index b3cd70c06d..a5856bf095 100644
@@ -27,7 +27,6 @@ install: all
 uninstall:
 	$(RM) -- $(DESTDIR)$(LIBEXEC_BIN)/$(TARGET)
 
-CFLAGS += -Werror
 CFLAGS += $(CFLAGS_xeninclude)
 CFLAGS += $(CFLAGS_libxenctrl)
 CFLAGS += $(CFLAGS_libxenforeginmemory)
tools/tests/tsx/Makefile +0 -1
index d7d2a5d95e..a4f516b725 100644
@@ -26,7 +26,6 @@ uninstall:
 .PHONY: uninstall
 uninstall:
 
-CFLAGS += -Werror
 CFLAGS += -I$(XEN_ROOT)/tools/libs/ctrl -I$(XEN_ROOT)/tools/libs/guest
 CFLAGS += $(CFLAGS_xeninclude)
 CFLAGS += $(CFLAGS_libxenctrl)
tools/tests/xenstore/Makefile +0 -1
index 239e1dce47..202dda0d3c 100644
@@ -27,7 +27,6 @@ install: all
 uninstall:
 	$(RM) -- $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/,$(TARGETS))
 
-CFLAGS += -Werror
 CFLAGS += $(CFLAGS_libxenstore)
 CFLAGS += $(APPEND_CFLAGS)
 
tools/xcutils/Makefile +0 -2
index e40a2c4bfa..3687f6cd8f 100644
@@ -13,8 +13,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 TARGETS := readnotes lsevtchn
 
-CFLAGS += -Werror
-
 CFLAGS_readnotes.o  := $(CFLAGS_libxenevtchn) $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
 CFLAGS_lsevtchn.o   := $(CFLAGS_libxenevtchn) $(CFLAGS_libxenctrl)
 
tools/xenmon/Makefile +0 -1
index 3e150b0659..679c4b41a3 100644
@@ -13,7 +13,6 @@
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS  += -Werror
 CFLAGS  += $(CFLAGS_libxenevtchn)
 CFLAGS  += $(CFLAGS_libxenctrl)
 LDLIBS  += $(LDLIBS_libxenctrl)
tools/xenpaging/Makefile +0 -1
index e2ed9eaa3f..835cf2b965 100644
@@ -12,7 +12,6 @@ OBJS-y   += xenpaging.o
 OBJS-y   += policy_$(POLICY).o
 OBJS-y   += pagein.o
 
-CFLAGS   += -Werror
 CFLAGS   += -Wno-unused
 
 TARGETS := xenpaging
tools/xenpmd/Makefile +0 -1
index e0d3f06ab2..8da20510b5 100644
@@ -1,7 +1,6 @@
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += -Werror
 CFLAGS += $(CFLAGS_libxenstore)
 
 LDLIBS += $(LDLIBS_libxenstore)
tools/xentop/Makefile +1 -1
index 7bd96f34d5..70cc2211c5 100644
@@ -13,7 +13,7 @@
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += -DGCC_PRINTF -Werror $(CFLAGS_libxenstat)
+CFLAGS += -DGCC_PRINTF $(CFLAGS_libxenstat)
 LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(TINFO_LIBS) $(SOCKET_LIBS) -lm
 CFLAGS += -DHOST_$(XEN_OS)
 
tools/xentrace/Makefile +0 -2
index 0995fa9203..b188ba70d6 100644
@@ -1,8 +1,6 @@
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += -Werror
-
 CFLAGS += $(CFLAGS_libxenevtchn)
 CFLAGS += $(CFLAGS_libxenctrl)
 LDLIBS += $(LDLIBS_libxenevtchn)
tools/xl/Makefile +1 -1
index b7f439121a..5f7aa5f46c 100644
@@ -5,7 +5,7 @@
 XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations \
+CFLAGS += -Wno-format-zero-length -Wmissing-declarations \
 	-Wno-declaration-after-statement -Wformat-nonliteral
 CFLAGS += -fPIC
 
tools/debugger/gdbsx/Rules.mk +1 -1
index 920f1c87fb..0610db873b 100644
@@ -1,6 +1,6 @@
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS   += -Werror -Wmissing-prototypes 
+CFLAGS   += -Wmissing-prototypes 
 # (gcc 4.3x and later)   -Wconversion -Wno-sign-conversion
 
 CFLAGS-$(clang) += -Wno-ignored-attributes
tools/firmware/Rules.mk +0 -2
index 278cca01e4..d3482c9ec4 100644
@@ -11,8 +11,6 @@ ifneq ($(debug),y)
 CFLAGS += -DNDEBUG
 endif
 
-CFLAGS += -Werror
-
 $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
 
 $(call cc-option-add,CFLAGS,CC,-fcf-protection=none)
tools/libfsimage/common.mk +1 -1
index 77bc957f27..4fc8c66795 100644
@@ -2,7 +2,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 FSDIR := $(libdir)/xenfsimage
 CFLAGS += -Wno-unknown-pragmas -I$(XEN_ROOT)/tools/libfsimage/common/ -DFSIMAGE_FSDIR=\"$(FSDIR)\"
-CFLAGS += -Werror -D_GNU_SOURCE
+CFLAGS += -D_GNU_SOURCE
 LDFLAGS += -L../common/
 
 PIC_OBJS = $(patsubst %.c,%.opic,$(LIB_SRCS-y))
tools/libs/libs.mk +1 -1
index 2b8e7a6128..e47fb30ed4 100644
@@ -14,7 +14,7 @@ MINOR ?= 0
 
 SHLIB_LDFLAGS += -Wl,--version-script=libxen$(LIBNAME).map
 
-CFLAGS   += -Werror -Wmissing-prototypes
+CFLAGS   += -Wmissing-prototypes
 CFLAGS   += $(CFLAGS_xeninclude)
 CFLAGS   += $(foreach lib, $(USELIBS_$(LIBNAME)), $(CFLAGS_libxen$(lib)))
 
tools/ocaml/common.make +1 -1
index d5478f626f..0c8a597d5b 100644
@@ -9,7 +9,7 @@ OCAMLLEX ?= ocamllex
 OCAMLYACC ?= ocamlyacc
 OCAMLFIND ?= ocamlfind
 
-CFLAGS += -fPIC -Werror -I$(shell ocamlc -where)
+CFLAGS += -fPIC -I$(shell ocamlc -where)
 
 OCAMLOPTFLAG_G := $(shell $(OCAMLOPT) -h 2>&1 | sed -n 's/^  *\(-g\) .*/\1/p')
 OCAMLOPTFLAGS = $(OCAMLOPTFLAG_G) -ccopt "$(LDFLAGS)" -dtypes $(OCAMLINCLUDE) -cc $(CC) -w F -warn-error F
tools/xenstore/Makefile.common +0 -1
index 21b78b0538..ddbac052ac 100644
@@ -9,7 +9,6 @@ XENSTORED_OBJS-$(CONFIG_NetBSD) += xenstored_posix.o
 XENSTORED_OBJS-$(CONFIG_FreeBSD) += xenstored_posix.o
 XENSTORED_OBJS-$(CONFIG_MiniOS) += xenstored_minios.o
 
-CFLAGS += -Werror
 # Include configure output (config.h)
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 CFLAGS += -I./include
Signature · 1 line
Anthony PERARD
#65 lore raw

Re: [XEN PATCH v3 25/25] tools: Remove -Werror everywhere else

+ CC: Stefano Stabellini

Quoted 7 lines · Anthony PERARD

Patch "tools: Add -Werror by default to all tools/" have added "-Werror" to CFLAGS in tools/Rules.mk, remove it from every other makefiles as it is now duplicated.

Hi Anthony,

I will try to review the serie when I manage to have some time, in the mean time I can say the whole serie builds fine in my Yocto setup on arm64 and x86_64, I’ve tried also the tool stack to create/destroy/console guests and no problem so far.

The only problem I have is building for arm32 because, I think, this patch does a great job and it discovers a problem here:

arm-poky-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a15 --sysroot=/data_sdc1/lucfan01/test_kirkstone_xen/build/xtp-qemu-arm32/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/xen-tools/4.17+git1-r0/recipe-sysroot -marm -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs -Werror -O2 -fomit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MP -MF .init-dom0less.o.d -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a15 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/data_sdc1/lucfan01/test_kirkstone_xen/build/xtp-qemu-arm32/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/xen-tools/4.17+git1-r0=/usr/src/debug/xen-tools/4.17+git1-r0 -fdebug-prefix-map=/data_sdc1/lucfan01/test_kirkstone_xen/build/xtp-qemu-arm32/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/xen-tools/4.17+git1-r0=/usr/src/debug/xen-tools/4.17+git1-r0 -fdebug-prefix-map=/data_sdc1/lucfan01/test_kirkstone_xen/build/xtp-qemu-arm32/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/xen-tools/4.17+git1-r0/recipe-sysroot= -fdebug-prefix-map=/data_sdc1/lucfan01/test_kirkstone_xen/build/xtp-qemu-arm32/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/xen-tools/4.17+git1-r0/recipe-sysroot-native= -I/data_sdc1/lucfan01/test_kirkstone_xen/build/xtp-qemu-arm32/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/xen-tools/4.17+git1-r0/local-xen/xen/tools/helpers/../../tools/include -I/data_sdc1/lucfan01/test_kirkstone_xen/build/xtp-qemu-arm32/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/xen-tools/4.17+git1-r0/local-xen/xen/tools/helpers/../../tools/include -I/data_sdc1/lucfan01/test_kirkstone_xen/build/xtp-qemu-arm32/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/xen-tools/4.17+git1-r0/local-xen/xen/tools/helpers/../../tools/include -I/data_sdc1/lucfan01/test_kirkstone_xen/build/xtp-qemu-arm32/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/xen-tools/4.17+git1-r0/local-xen/xen/tools/helpers/../../tools/include -D__XEN_TOOLS__ -I/data_sdc1/lucfan01/test_kirkstone_xen/build/xtp-qemu-arm32/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/xen-tools/4.17+git1-r0/local-xen/xen/tools/helpers/../../tools/include -D__XEN_TOOLS__ -I/data_sdc1/lucfan01/test_kirkstone_xen/build/xtp-qemu-arm32/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/xen-tools/4.17+git1-r0/local-xen/xen/tools/helpers/../../tools/include -c -o init-dom0less.o init-dom0less.c
init-dom0less.c: In function 'create_xenstore':
init-dom0less.c:141:53: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]

  141 |     rc = snprintf(max_memkb_str, STR_MAX_LENGTH, "%lu", info->max_memkb);
      |                                                   ~~^   ~~~~~~~~~~~~~~~
      |                                                     |       |
      |                                                     |       uint64_t {aka long long unsigned int}
      |                                                     long unsigned int
      |                                                   %llu
init-dom0less.c:144:56: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]
  144 |     rc = snprintf(target_memkb_str, STR_MAX_LENGTH, "%lu", info->current_memkb);
      |                                                      ~~^   ~~~~~~~~~~~~~~~~~~~
      |                                                        |       |
      |                                                        |       uint64_t {aka long long unsigned int}
      |                                                        long unsigned int
      |                                                      %llu

Won’t be too difficult to fix, if I have time I will do it, otherwise if someone wants to do it’s fine for me.

Cheers,
Luca

#66 lore raw

Re: [XEN PATCH v3 25/25] tools: Remove -Werror everywhere else

Quoted 10 lines · Luca Fancellu

+ CC: Stefano Stabellini

Quoted 7 lines · Anthony PERARD

Patch "tools: Add -Werror by default to all tools/" have added "-Werror" to CFLAGS in tools/Rules.mk, remove it from every other makefiles as it is now duplicated.

Quoted 8 lines

Hi Anthony,

I will try to review the serie when I manage to have some time, in the mean time I can say the whole serie builds fine in my Yocto setup on arm64 and x86_64, I’ve tried also the tool stack to create/destroy/console guests and no problem so far.

The only problem I have is building for arm32 because, I think, this patch does a great job and it discovers a problem here:

That reminds me that we only have arm32 Xen hypervisor builds in gitlab-ci, we don't have any arm32 Xen tools builds. I'll add it to my TODO but if someone (not necessarily Luca) has some spare time it could be a nice project. It could be done with Yocto by adding a Yocto build container to automation/build/.

#67 lore raw

Re: [XEN PATCH v3 25/25] tools: Remove -Werror everywhere else

Hi Stefano,

Quoted 19 lines · Stefano Stabellini
Quoted 16 lines · Luca Fancellu

+ CC: Stefano Stabellini

Quoted 7 lines · Anthony PERARD

Patch "tools: Add -Werror by default to all tools/" have added "-Werror" to CFLAGS in tools/Rules.mk, remove it from every other makefiles as it is now duplicated.

Hi Anthony,

I will try to review the serie when I manage to have some time, in the mean time I can say the whole serie builds fine in my Yocto setup on arm64 and x86_64, I’ve tried also the tool stack to create/destroy/console guests and no problem so far.

Quoted 8 lines
Quoted 2 lines

The only problem I have is building for arm32 because, I think, this patch does a great job and it discovers a problem here:

That reminds me that we only have arm32 Xen hypervisor builds in gitlab-ci, we don't have any arm32 Xen tools builds. I'll add it to my TODO but if someone (not necessarily Luca) has some spare time it could be a nice project. It could be done with Yocto by adding a Yocto build container to automation/build/.

We have now a way to build and run xen for arm32 on qemu using Yocto.
We are using this internally and also will test Xen with guests on arm32 using this soon.

I am upstreaming to meta-virtualisation all the fixes needed for that so it should be fairly straight forward do reproduce this in Yocto build in a container.

Please tell me what you need and I will try to provide you a set of scripts or instructions do reproduce that on gitlab.

Cheers
Bertrand

#68 lore raw

Re: [XEN PATCH v3 25/25] tools: Remove -Werror everywhere else

Quoted 28 lines · Bertrand Marquis
Quoted 19 lines · Stefano Stabellini
Quoted 16 lines · Luca Fancellu

+ CC: Stefano Stabellini

Quoted 7 lines · Anthony PERARD

Patch "tools: Add -Werror by default to all tools/" have added "-Werror" to CFLAGS in tools/Rules.mk, remove it from every other makefiles as it is now duplicated.

Hi Anthony,

I will try to review the serie when I manage to have some time, in the mean time I can say the whole serie builds fine in my Yocto setup on arm64 and x86_64, I’ve tried also the tool stack to create/destroy/console guests and no problem so far.

Quoted 8 lines
Quoted 2 lines

The only problem I have is building for arm32 because, I think, this patch does a great job and it discovers a problem here:

That reminds me that we only have arm32 Xen hypervisor builds in gitlab-ci, we don't have any arm32 Xen tools builds. I'll add it to my TODO but if someone (not necessarily Luca) has some spare time it could be a nice project. It could be done with Yocto by adding a Yocto build container to automation/build/.

Quoted 6 lines

We have now a way to build and run xen for arm32 on qemu using Yocto.
We are using this internally and also will test Xen with guests on arm32 using this soon.

I am upstreaming to meta-virtualisation all the fixes needed for that so it should be fairly straight forward do reproduce this in Yocto build in a container.

Please tell me what you need and I will try to provide you a set of scripts or instructions do reproduce that on gitlab.

That would be great!

We need two things:

- a Yocto build container
- a build script

The build container would be something like:
automation/build/debian/unstable-arm64v8.dockerfile. It is a Dockerfile to create a container with Yocto and all required dependencies. It could be based on Debian arm64. The build container is only built once and pushed to the gitlab registry, but it is executed every time a gitlab pipeline is started.

We probably want the meta layers to be pulled as part of the build container build (git clone from the Dockerfile) because otherwise we would end up git cloining them every time we run a gitlab-ci pipeline, slowing everything down.

The build script is the script executed in the build container for every pipeline.

Imagine you have a container "yocto-arm32", basically we want to do:

# docker run yocto-arm32 build.script

where build.script is the script that actually triggers the Xen build and produces the binary output.

The current build script is automation/scripts/build; it is used for all build containers (all of them, from Debian to Fedora and Alpine) but it is probably not suitable to be used for Yocto. It simply calls ./configure; make; make install. It is more for normal distros.

I imagine that the build script for Yocto would call bitbake.

With the build container Dockerfile and the build script it becomes very simple to add Yocto arm32 to gitlab-ci.

I realize that the actual build could be done on both arm64 or x86. Currently the arm32 hypervisor-only cross-build is done on x86. See automation/build/debian/unstable-arm32-gcc.dockerfile. Either way is OK.

#69 lore raw

Re: [XEN PATCH v3 25/25] tools: Remove -Werror everywhere else

Hi Stefano,

Quoted 77 lines · Stefano Stabellini
Quoted 28 lines · Bertrand Marquis
Quoted 19 lines · Stefano Stabellini
Quoted 16 lines · Luca Fancellu

+ CC: Stefano Stabellini

Quoted 7 lines · Anthony PERARD

Patch "tools: Add -Werror by default to all tools/" have added "-Werror" to CFLAGS in tools/Rules.mk, remove it from every other makefiles as it is now duplicated.

Hi Anthony,

I will try to review the serie when I manage to have some time, in the mean time I can say the whole serie builds fine in my Yocto setup on arm64 and x86_64, I’ve tried also the tool stack to create/destroy/console guests and no problem so far.

Quoted 8 lines
Quoted 2 lines

The only problem I have is building for arm32 because, I think, this patch does a great job and it discovers a problem here:

That reminds me that we only have arm32 Xen hypervisor builds in gitlab-ci, we don't have any arm32 Xen tools builds. I'll add it to my TODO but if someone (not necessarily Luca) has some spare time it could be a nice project. It could be done with Yocto by adding a Yocto build container to automation/build/.

Quoted 6 lines

We have now a way to build and run xen for arm32 on qemu using Yocto.
We are using this internally and also will test Xen with guests on arm32 using this soon.

I am upstreaming to meta-virtualisation all the fixes needed for that so it should be fairly straight forward do reproduce this in Yocto build in a container.

Please tell me what you need and I will try to provide you a set of scripts or instructions do reproduce that on gitlab.

That would be great!

We need two things:

- a Yocto build container
- a build script

The build container would be something like:
automation/build/debian/unstable-arm64v8.dockerfile. It is a Dockerfile to create a container with Yocto and all required dependencies. It could be based on Debian arm64. The build container is only built once and pushed to the gitlab registry, but it is executed every time a gitlab pipeline is started.

We probably want the meta layers to be pulled as part of the build container build (git clone from the Dockerfile) because otherwise we would end up git cloining them every time we run a gitlab-ci pipeline, slowing everything down.

The build script is the script executed in the build container for every pipeline.

Imagine you have a container "yocto-arm32", basically we want to do:

# docker run yocto-arm32 build.script

where build.script is the script that actually triggers the Xen build and produces the binary output.

The current build script is automation/scripts/build; it is used for all build containers (all of them, from Debian to Fedora and Alpine) but it is probably not suitable to be used for Yocto. It simply calls ./configure; make; make install. It is more for normal distros.

I imagine that the build script for Yocto would call bitbake.

Quoted 6 lines

With the build container Dockerfile and the build script it becomes very simple to add Yocto arm32 to gitlab-ci.

I realize that the actual build could be done on both arm64 or x86. Currently the arm32 hypervisor-only cross-build is done on x86. See automation/build/debian/unstable-arm32-gcc.dockerfile. Either way is OK.

I will work on that and I think we can take this discussion offline as there are some elements missing right now (like where is the xen tree to test).

Cheers
Bertrand

#70 lore raw

Re: [XEN PATCH v3 25/25] tools: Remove -Werror everywhere else

Quoted 77 lines · Bertrand Marquis
Quoted 77 lines · Stefano Stabellini
Quoted 28 lines · Bertrand Marquis
Quoted 19 lines · Stefano Stabellini
Quoted 16 lines · Luca Fancellu

+ CC: Stefano Stabellini

Quoted 7 lines · Anthony PERARD

Patch "tools: Add -Werror by default to all tools/" have added "-Werror" to CFLAGS in tools/Rules.mk, remove it from every other makefiles as it is now duplicated.

Hi Anthony,

I will try to review the serie when I manage to have some time, in the mean time I can say the whole serie builds fine in my Yocto setup on arm64 and x86_64, I’ve tried also the tool stack to create/destroy/console guests and no problem so far.

Quoted 8 lines
Quoted 2 lines

The only problem I have is building for arm32 because, I think, this patch does a great job and it discovers a problem here:

That reminds me that we only have arm32 Xen hypervisor builds in gitlab-ci, we don't have any arm32 Xen tools builds. I'll add it to my TODO but if someone (not necessarily Luca) has some spare time it could be a nice project. It could be done with Yocto by adding a Yocto build container to automation/build/.

Quoted 6 lines

We have now a way to build and run xen for arm32 on qemu using Yocto.
We are using this internally and also will test Xen with guests on arm32 using this soon.

I am upstreaming to meta-virtualisation all the fixes needed for that so it should be fairly straight forward do reproduce this in Yocto build in a container.

Please tell me what you need and I will try to provide you a set of scripts or instructions do reproduce that on gitlab.

That would be great!

We need two things:

- a Yocto build container
- a build script

The build container would be something like:
automation/build/debian/unstable-arm64v8.dockerfile. It is a Dockerfile to create a container with Yocto and all required dependencies. It could be based on Debian arm64. The build container is only built once and pushed to the gitlab registry, but it is executed every time a gitlab pipeline is started.

We probably want the meta layers to be pulled as part of the build container build (git clone from the Dockerfile) because otherwise we would end up git cloining them every time we run a gitlab-ci pipeline, slowing everything down.

The build script is the script executed in the build container for every pipeline.

Imagine you have a container "yocto-arm32", basically we want to do:

# docker run yocto-arm32 build.script

where build.script is the script that actually triggers the Xen build and produces the binary output.

The current build script is automation/scripts/build; it is used for all build containers (all of them, from Debian to Fedora and Alpine) but it is probably not suitable to be used for Yocto. It simply calls ./configure; make; make install. It is more for normal distros.

I imagine that the build script for Yocto would call bitbake.

Quoted 8 lines
Quoted 6 lines

With the build container Dockerfile and the build script it becomes very simple to add Yocto arm32 to gitlab-ci.

I realize that the actual build could be done on both arm64 or x86. Currently the arm32 hypervisor-only cross-build is done on x86. See automation/build/debian/unstable-arm32-gcc.dockerfile. Either way is OK.

I will work on that and I think we can take this discussion offline as there are some elements missing right now (like where is the xen tree to test).

No problem, I am happy to help offline as well. The Xen tree is given to you automatically by gitlab-ci (because it is the repository with the .gitlab* yaml files.) The build container starts execution with the Xen repository to test ready inside.