Skip to contentSkip to conversation

Toolstack build system improvement, toward non-recursive makefiles

PATCH Superseded Anthony PERARD 6 participants 40 messages Feb 25, 2022 – Jun 17, 2022

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 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-v2

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.

stubdom has some changes also as it won't be able to use tools/ Makefiles as-is anymore.

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 (29):
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/helper: Cleanup Makefile
tools/hotplug: cleanup Makefiles
tools/libfsimage: Cleanup makefiles
tools/xenpaging: Rework makefile
tools/xenstore: Cleanup makefile
tools/xentop: rework makefile
tools/xentrace: rework Makefile
libs: rename LDUSELIBS to LDLIBS and use it instead of APPEND_LDFLAGS
libs: Remove need for *installlocal targets libs,tools/include: Clean "clean" targets
libs: Rename $(SRCS-y) to $(OBJS-y)
libs/guest: rename ELF_OBJS to LIBELF_OBJS
libs/guest: rework CFLAGS
libs/store: use of -iquote instead of -I
libs/stat: Fix and rework python-bindings build
libs/stat: Fix and rework perl-binding build
.gitignore: Cleanup ignores of tools/libs/*/{headers.chk,*.pc}
stubdom: introduce xenlibs.mk
tools/libs: create Makefile.common to be used by stubdom build system tools/xenstore: introduce Makefile.common to be used by stubdom
stubdom: build xenstore*-stubdom using new Makefile.common
stubdom: xenlibs linkfarm, ignore non-regular files tools/ocaml: fix build dependency target

 stubdom/Makefile                              |  24 +-
 tools/Makefile                                |   2 +-
 tools/console/Makefile                        |  49 +---
 tools/console/client/Makefile                 |  39 ++++
 tools/console/daemon/Makefile                 |  50 +++++
 tools/debugger/gdbsx/Makefile                 |  20 +-
 tools/debugger/gdbsx/gx/Makefile              |  15 +-
 tools/debugger/gdbsx/xg/Makefile              |  25 +--
 tools/examples/Makefile                       |  25 +--
 tools/firmware/hvmloader/Makefile             |  16 +-
 tools/fuzz/libelf/Makefile                    |  21 +-
 tools/fuzz/x86_instruction_emulator/Makefile  |  32 ++-
 tools/helpers/Makefile                        |  25 ++-
 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/include/Makefile                        |   1 +
 tools/include/xen-foreign/Makefile            |   1 +
 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/call/Makefile                      |   7 +-
 tools/libs/ctrl/Makefile                      |  50 +----
 tools/libs/devicemodel/Makefile               |   7 +-
 tools/libs/evtchn/Makefile                    |   7 +-
 tools/libs/foreignmemory/Makefile             |   7 +-
 tools/libs/gnttab/Makefile                    |   9 +-
 tools/libs/guest/Makefile                     | 100 +--------
 tools/libs/hypfs/Makefile                     |   4 +-
 tools/libs/light/Makefile                     | 209 +++++++++---------
 tools/libs/stat/Makefile                      |  72 +++---
 tools/libs/store/Makefile                     |  18 +-
 tools/libs/toolcore/Makefile                  |   2 +-
 tools/libs/toollog/Makefile                   |   3 +-
 tools/libs/util/Makefile                      |  23 +-
 tools/libs/vchan/Makefile                     |   9 +-
 tools/ocaml/libs/eventchn/Makefile            |   8 +-
 tools/ocaml/libs/mmap/Makefile                |   8 +-
 tools/ocaml/libs/xb/Makefile                  |   8 +-
 tools/ocaml/libs/xc/Makefile                  |   8 +-
 tools/ocaml/libs/xentoollog/Makefile          |   8 +-
 tools/ocaml/libs/xl/Makefile                  |   8 +-
 tools/ocaml/libs/xs/Makefile                  |   8 +-
 tools/xenpaging/Makefile                      |  24 +-
 tools/xenstore/Makefile                       |  94 +++-----
 tools/xentop/Makefile                         |  21 +-
 tools/xentrace/Makefile                       |  19 +-
 stubdom/xenlibs.mk                            |  13 ++
 tools/libfsimage/Rules.mk                     |  26 +--
 tools/libfsimage/common.mk                    |  11 +
 tools/libs/libs.mk                            |  17 +-
 tools/libs/guest/xg_offline_page.c            |   2 +-
 tools/ocaml/Makefile.rules                    |   2 +-
 .gitignore                                    |  35 ---
 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/libs/call/Makefile.common               |   6 +
 tools/libs/ctrl/Makefile.common               |  44 ++++
 tools/libs/devicemodel/Makefile.common        |   6 +
 tools/libs/evtchn/Makefile.common             |   6 +
 tools/libs/foreignmemory/Makefile.common      |   6 +
 tools/libs/gnttab/Makefile.common             |   8 +
 tools/libs/guest/Makefile.common              |  84 +++++++
 tools/libs/stat/bindings/swig/perl/.empty     |   1 -
 tools/libs/stat/bindings/swig/python/.empty   |   1 -
 tools/libs/toolcore/Makefile.common           |   1 +
 tools/libs/toollog/Makefile.common            |   2 +
 tools/xenstore/Makefile.common                |  33 +++
 79 files changed, 732 insertions(+), 824 deletions(-)
 create mode 100644 tools/console/client/Makefile
 create mode 100644 tools/console/daemon/Makefile
 create mode 100644 stubdom/xenlibs.mk
 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
 create mode 100644 tools/libs/call/Makefile.common
 create mode 100644 tools/libs/ctrl/Makefile.common
 create mode 100644 tools/libs/devicemodel/Makefile.common
 create mode 100644 tools/libs/evtchn/Makefile.common
 create mode 100644 tools/libs/foreignmemory/Makefile.common
 create mode 100644 tools/libs/gnttab/Makefile.common
 create mode 100644 tools/libs/guest/Makefile.common
 delete mode 100644 tools/libs/stat/bindings/swig/perl/.empty
 delete mode 100644 tools/libs/stat/bindings/swig/python/.empty
 create mode 100644 tools/libs/toolcore/Makefile.common
 create mode 100644 tools/libs/toollog/Makefile.common
 create mode 100644 tools/xenstore/Makefile.common
Signature · 1 line
Anthony PERARD
#1 lore raw

PATCH v2 1/29 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 d425be4bd9..4e2a850f94 100644
@@ -159,8 +159,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
#2 lore raw

PATCH v2 2/29 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
#3 lore raw

PATCH v2 3/29 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
#4 lore raw

PATCH v2 4/29 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
#5 lore raw

PATCH v2 5/29 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 4e2a850f94..fb29d42342 100644
@@ -194,7 +194,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
#6 lore raw

PATCH v2 6/29 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 fb29d42342..3da56594c5 100644
@@ -194,12 +194,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
#7 lore raw

PATCH v2 7/29 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).

---
 tools/helpers/Makefile | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
tools/helpers/Makefile +17 -8
index 7f6c422440..2fe3be2f89 100644
@@ -5,10 +5,10 @@
 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
 endif
 
@@ -17,6 +17,10 @@ $(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 += $(LDLIBS_libxenctrl)
+xen-init-dom0: LDLIBS += $(LDLIBS_libxentoollog)
+xen-init-dom0: LDLIBS += $(LDLIBS_libxenstore)
+xen-init-dom0: LDLIBS += $(LDLIBS_libxenlight)
 
 INIT_XENSTORE_DOMAIN_OBJS = init-xenstore-domain.o init-dom-json.o
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
@@ -25,27 +29,32 @@ $(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 += $(LDLIBS_libxentoollog)
+init-xenstore-domain: LDLIBS += $(LDLIBS_libxenstore)
+init-xenstore-domain: LDLIBS += $(LDLIBS_libxenctrl)
+init-xenstore-domain: LDLIBS += $(LDLIBS_libxenguest)
+init-xenstore-domain: LDLIBS += $(LDLIBS_libxenlight)
 
 .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)
 
 .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
#8 lore raw

PATCH v2 8/29 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
#9 lore raw

PATCH v2 9/29 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
#10 lore raw

PATCH v2 10/29 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
#11 lore raw

PATCH v2 11/29 tools/xenstore: Cleanup makefile

In reply to Anthony PERARD

Regroup *FLAGS together, use $(LDLIBS).

Remove $(LDLIBS_xenstored) which was the wrong name name as it doesn't decribe how to link to a potential libxenstored.so, instead add the value to $(LDLIBS) of xenstored.

Add SYSTEMD_LIBS into $(LDLIBS) instead of $(LDFLAGS).

Remove the "-I." from $(CFLAGS), it shouldn't be needed.

Removed $(CFLAGS-y) and $(LDFLAGS-y). $(CFLAGS-y) is already included in $(CFLAGS) and both aren't used anyway.

Rename ALL_TARGETS to TARGETS.
Only add programmes we want to build in $(TARGETS), not phony-targets (replace "clients").

Store all xenstored objs into $(XENSTORED_OBJS-y).

Replace one $< by $^ even if there's only one dependency, (xenstore-control).

clean: "init-xenstore-domain" isn't built here any more, so stop trying to remove it, remove $(TARGETS). Also regroup all files to be removed in one command, using $(RM).

Drop $(MAJOR) and $(MINOR), they aren't used anymore.

Drop ".SECONDARY:", it doesn't appear there's intermediate files that would be deleted anymore.

Drop "tarball:" target.

---

Notes:
v2:
- drop MAJOR and MINOR variables
- drop tarball rule
- drop ".SECONDARY:"
- rework "clean:" to have one command

 tools/xenstore/Makefile | 91 +++++++++++++++++++----------------------
 1 file changed, 43 insertions(+), 48 deletions(-)
tools/xenstore/Makefile +43 -48
index c86278fdb1..830052c65f 100644
@@ -1,11 +1,7 @@
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-MAJOR = 3.0
-MINOR = 3
-
 CFLAGS += -Werror
-CFLAGS += -I.
 # Include configure output (config.h)
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 CFLAGS += -I./include
@@ -16,71 +12,77 @@ CFLAGS += $(CFLAGS_libxentoolcore)
 CFLAGS += -DXEN_LIB_STORED="\"$(XEN_LIB_STORED)\""
 CFLAGS += -DXEN_RUN_STORED="\"$(XEN_RUN_STORED)\""
 
-CFLAGS  += $(CFLAGS-y)
-LDFLAGS += $(LDFLAGS-y)
+ifdef CONFIG_STUBDOM
+CFLAGS += -DNO_SOCKETS=1
+endif
 
-CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm xenstore-chmod
-CLIENTS += xenstore-write xenstore-ls xenstore-watch
+XENSTORED_OBJS-y := xenstored_core.o xenstored_watch.o xenstored_domain.o
+XENSTORED_OBJS-y += xenstored_transaction.o xenstored_control.o
+XENSTORED_OBJS-y += xs_lib.o talloc.o utils.o tdb.o hashtable.o
 
-XENSTORED_OBJS = xenstored_core.o xenstored_watch.o xenstored_domain.o
-XENSTORED_OBJS += xenstored_transaction.o xenstored_control.o
-XENSTORED_OBJS += xs_lib.o talloc.o utils.o tdb.o hashtable.o
+XENSTORED_OBJS-$(CONFIG_Linux) += xenstored_posix.o
+XENSTORED_OBJS-$(CONFIG_NetBSD) += xenstored_posix.o
+XENSTORED_OBJS-$(CONFIG_FreeBSD) += xenstored_posix.o
+XENSTORED_OBJS-$(CONFIG_MiniOS) += xenstored_minios.o
 
-XENSTORED_OBJS_$(CONFIG_Linux) = xenstored_posix.o
-XENSTORED_OBJS_$(CONFIG_NetBSD) = xenstored_posix.o
-XENSTORED_OBJS_$(CONFIG_FreeBSD) = xenstored_posix.o
-XENSTORED_OBJS_$(CONFIG_MiniOS) = xenstored_minios.o
+$(XENSTORED_OBJS-y): CFLAGS += $(CFLAGS_libxengnttab)
 
-XENSTORED_OBJS += $(XENSTORED_OBJS_y)
-LDLIBS_xenstored += -lrt
+xenstored: LDLIBS += $(LDLIBS_libxenevtchn)
+xenstored: LDLIBS += $(LDLIBS_libxengnttab)
+xenstored: LDLIBS += $(LDLIBS_libxenctrl)
+xenstored: LDLIBS += -lrt
+xenstored: LDLIBS += $(SOCKET_LIBS)
 
-ALL_TARGETS = clients
-ifeq ($(XENSTORE_XENSTORED),y)
-ALL_TARGETS += xs_tdb_dump xenstored
+ifeq ($(CONFIG_SYSTEMD),y)
+$(XENSTORED_OBJS-y): CFLAGS += $(SYSTEMD_CFLAGS)
+xenstored: LDLIBS += $(SYSTEMD_LIBS)
 endif
 
-ifdef CONFIG_STUBDOM
-CFLAGS += -DNO_SOCKETS=1
+xenstore: LDLIBS += $(LDLIBS_libxenstore)
+xenstore: LDLIBS += $(LDLIBS_libxentoolcore)
+xenstore: LDLIBS += $(SOCKET_LIBS)
+
+xenstore-control: LDLIBS += $(LDLIBS_libxenstore)
+xenstore-control: LDLIBS += $(LDLIBS_libxenctrl)
+xenstore-control: LDLIBS += $(LDLIBS_libxenguest)
+xenstore-control: LDLIBS += $(LDLIBS_libxentoolcore)
+xenstore-control: LDLIBS += $(SOCKET_LIBS)
+
+CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm xenstore-chmod
+CLIENTS += xenstore-write xenstore-ls xenstore-watch
+
+TARGETS := xenstore $(CLIENTS) xenstore-control
+ifeq ($(XENSTORE_XENSTORED),y)
+TARGETS += xs_tdb_dump xenstored
 endif
 
 .PHONY: all
-all: $(ALL_TARGETS)
+all: $(TARGETS)
 
 .PHONY: clients
 clients: xenstore $(CLIENTS) xenstore-control
 
-ifeq ($(CONFIG_SYSTEMD),y)
-$(XENSTORED_OBJS): CFLAGS += $(SYSTEMD_CFLAGS)
-xenstored: LDFLAGS += $(SYSTEMD_LIBS)
-endif
-
-$(XENSTORED_OBJS): CFLAGS += $(CFLAGS_libxengnttab)
-
-xenstored: $(XENSTORED_OBJS)
-	$(CC) $^ $(LDFLAGS) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxenctrl) $(LDLIBS_xenstored) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS)
+xenstored: $(XENSTORED_OBJS-y)
+	$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ $(APPEND_LDFLAGS)
 
-xenstored.a: $(XENSTORED_OBJS)
+xenstored.a: $(XENSTORED_OBJS-y)
 	$(AR) cr $@ $^
 
 $(CLIENTS): xenstore
 	ln -f xenstore $@
 
 xenstore: xenstore_client.o xs_lib.o
-	$(CC) $^ $(LDFLAGS) $(LDLIBS_libxenstore) $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ $(APPEND_LDFLAGS)
 
 xenstore-control: xenstore_control.o
-	$(CC) $< $(LDFLAGS) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ $(APPEND_LDFLAGS)
 
 xs_tdb_dump: xs_tdb_dump.o utils.o tdb.o talloc.o
-	$(CC) $^ $(LDFLAGS) -o $@ $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) $^ -o $@ $(APPEND_LDFLAGS)
 
 .PHONY: clean
 clean:
-	rm -f *.a *.o
-	rm -f xenstored
-	rm -f xs_tdb_dump xenstore-control init-xenstore-domain
-	rm -f xenstore $(CLIENTS)
-	$(RM) $(DEPS_RM)
+	$(RM) *.a *.o $(TARGETS) $(DEPS_RM)
 
 .PHONY: distclean
 distclean: clean
@@ -89,10 +91,6 @@ distclean: clean
 TAGS:
 	etags `find . -name '*.[ch]'`
 
-.PHONY: tarball
-tarball: clean
-	cd .. && tar -c -j -v -h -f xenstore.tar.bz2 xenstore/
-
 .PHONY: install
 install: all
 	$(INSTALL_DIR) $(DESTDIR)$(bindir)
@@ -135,6 +133,3 @@ clients-install: clients
 	done
 
 -include $(DEPS_INCLUDE)
-
-# never delete any intermediate files.
-.SECONDARY:
Signature · 1 line
Anthony PERARD
Reviewed-by on v2 11/29
#12 lore raw

Re: [XEN PATCH v2 11/29] tools/xenstore: Cleanup makefile

Quoted 26 lines · Anthony PERARD

Regroup *FLAGS together, use $(LDLIBS).

Remove $(LDLIBS_xenstored) which was the wrong name name as it doesn't decribe how to link to a potential libxenstored.so, instead add the value to $(LDLIBS) of xenstored.

Add SYSTEMD_LIBS into $(LDLIBS) instead of $(LDFLAGS).

Remove the "-I." from $(CFLAGS), it shouldn't be needed.

Removed $(CFLAGS-y) and $(LDFLAGS-y). $(CFLAGS-y) is already included in $(CFLAGS) and both aren't used anyway.

Rename ALL_TARGETS to TARGETS.
Only add programmes we want to build in $(TARGETS), not phony-targets (replace "clients").

Store all xenstored objs into $(XENSTORED_OBJS-y).

Replace one $< by $^ even if there's only one dependency, (xenstore-control).

clean: "init-xenstore-domain" isn't built here any more, so stop trying to remove it, remove $(TARGETS). Also regroup all files to be removed in one command, using $(RM).

Quoted 8 lines

Drop $(MAJOR) and $(MINOR), they aren't used anymore.

Drop ".SECONDARY:", it doesn't appear there's intermediate files that would be deleted anymore.

Drop "tarball:" target.

Juergen

#13 lore raw

PATCH v2 12/29 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
#14 lore raw

PATCH v2 13/29 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
#15 lore raw

PATCH v2 14/29 libs: rename LDUSELIBS to LDLIBS and use it instead of APPEND_LDFLAGS

In reply to Anthony PERARD

LDLIBS is more appropriate and intended to be used to add library dependencies. APPEND_LDFLAGS wasn't intended to be changed by the build system.

---

Notes:
v2:
- reviewed

 tools/libs/guest/Makefile |  2 +-
 tools/libs/hypfs/Makefile |  2 +-
 tools/libs/light/Makefile | 18 +++++++++---------
 tools/libs/stat/Makefile  |  2 +-
 tools/libs/store/Makefile |  2 +-
 tools/libs/libs.mk        |  4 ++--
 6 files changed, 15 insertions(+), 15 deletions(-)
tools/libs/guest/Makefile +1 -1
index ab580e1b64..2005d8a67d 100644
@@ -102,7 +102,7 @@ NO_HEADERS_CHK := y
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
-libxenguest.so.$(MAJOR).$(MINOR): APPEND_LDFLAGS += $(ZLIB_LIBS) -lz
+libxenguest.so.$(MAJOR).$(MINOR): LDLIBS += $(ZLIB_LIBS) -lz
 
 .PHONY: cleanlocal
 cleanlocal:
tools/libs/hypfs/Makefile +1 -1
index 39feca87e8..efa955bd50 100644
@@ -4,7 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 0
 
-APPEND_LDFLAGS += -lz
+LDLIBS += -lz
 
 SRCS-y                 += core.c
 
tools/libs/light/Makefile +9 -9
index 453bea0067..7c0a5dca85 100644
@@ -166,14 +166,14 @@ NO_HEADERS_CHK := y
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
-LDUSELIBS-y += $(PTYFUNCS_LIBS)
-LDUSELIBS-$(CONFIG_LIBNL) += $(LIBNL3_LIBS)
-LDUSELIBS-$(CONFIG_Linux) += -luuid
-LDUSELIBS-$(CONFIG_Linux) += -lrt
-LDUSELIBS-$(CONFIG_ARM) += -lfdt
-LDUSELIBS-y += $(PTHREAD_LIBS)
-LDUSELIBS-y += -lyajl
-LDUSELIBS += $(LDUSELIBS-y)
+LDLIBS-y += $(PTYFUNCS_LIBS)
+LDLIBS-$(CONFIG_LIBNL) += $(LIBNL3_LIBS)
+LDLIBS-$(CONFIG_Linux) += -luuid
+LDLIBS-$(CONFIG_Linux) += -lrt
+LDLIBS-$(CONFIG_ARM) += -lfdt
+LDLIBS-y += $(PTHREAD_LIBS)
+LDLIBS-y += -lyajl
+LDLIBS += $(LDLIBS-y)
 
 $(LIB_OBJS) $(PIC_OBJS) $(LIBXL_TEST_OBJS): CFLAGS += $(CFLAGS_LIBXL) -include $(XEN_ROOT)/tools/config.h
 $(ACPI_OBJS) $(ACPI_PIC_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\"
@@ -228,7 +228,7 @@ $(XEN_INCLUDE)/_%.h: _%.h
 	$(call move-if-changed,_$*.h,$(XEN_INCLUDE)/_$*.h)
 
 libxenlight_test.so: $(PIC_OBJS) $(LIBXL_TEST_OBJS)
-	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDUSELIBS) $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS) $(APPEND_LDFLAGS)
 
 test_%: test_%.o test_common.o libxenlight_test.so
 	$(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) -lyajl $(APPEND_LDFLAGS)
tools/libs/stat/Makefile +1 -1
index 5840213376..6cd0af5239 100644
@@ -26,7 +26,7 @@ SRCS-$(CONFIG_FreeBSD) += xenstat_freebsd.c
 
 LDLIBS-y += -lyajl
 LDLIBS-$(CONFIG_SunOS) += -lkstat
-APPEND_LDFLAGS += $(LDLIBS-y)
+LDLIBS += $(LDLIBS-y)
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
tools/libs/store/Makefile +1 -1
index 8e33db6a66..18ae1fe94d 100644
@@ -5,7 +5,7 @@ MAJOR = 4
 MINOR = 0
 
 ifeq ($(CONFIG_Linux),y)
-APPEND_LDFLAGS += -ldl
+LDLIBS += -ldl
 endif
 
 SRCS-y   += xs_lib.c
tools/libs/libs.mk +2 -2
index b3d784c57f..3118cb4194 100644
@@ -18,7 +18,7 @@ CFLAGS   += -Werror -Wmissing-prototypes
 CFLAGS   += $(CFLAGS_xeninclude)
 CFLAGS   += $(foreach lib, $(USELIBS_$(LIBNAME)), $(CFLAGS_libxen$(lib)))
 
-LDUSELIBS = $(foreach lib, $(USELIBS_$(LIBNAME)), $(LDLIBS_libxen$(lib)))
+LDLIBS += $(foreach lib, $(USELIBS_$(LIBNAME)), $(LDLIBS_libxen$(lib)))
 
 LIB_OBJS := $(SRCS-y:.c=.o)
 PIC_OBJS := $(SRCS-y:.c=.opic)
@@ -88,7 +88,7 @@ lib$(LIB_FILE_NAME).so.$(MAJOR): lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR)
 	$(SYMLINK_SHLIB) $< $@
 
 lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR): $(PIC_OBJS) libxen$(LIBNAME).map
-	$(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,lib$(LIB_FILE_NAME).so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDUSELIBS) $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,lib$(LIB_FILE_NAME).so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDLIBS) $(APPEND_LDFLAGS)
 
 # If abi-dumper is available, write out the ABI analysis
 ifneq ($(ABI_DUMPER),)
Signature · 1 line
Anthony PERARD
#16 lore raw

PATCH v2 15/29 libs: Remove need for *installlocal targets

In reply to Anthony PERARD

There is no need for an extra "installlocal" target, we can use double-colon rules instead.

"install-headers" in "libs/store" was introduced for the same reason that "installlocal" exist, so it is replaced as well.

---

Notes:
v2:
- fix libs/stat/Makefile, make *install targets of the binding also double-column.

 tools/libs/light/Makefile | 10 ++--------
 tools/libs/stat/Makefile  |  8 ++++----
 tools/libs/store/Makefile | 10 ++--------
 tools/libs/libs.mk        |  4 ++--
 4 files changed, 10 insertions(+), 22 deletions(-)
tools/libs/light/Makefile +2 -8
index 7c0a5dca85..769e2a83e2 100644
@@ -239,17 +239,11 @@ libxl-save-helper: $(SAVE_HELPER_OBJS) libxenlight.so
 testidl: testidl.o libxenlight.so
 	$(CC) $(LDFLAGS) -o $@ testidl.o $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)
 
-install: installlocal $(LIBHEADERS)
-
-.PHONY: installlocal
-installlocal: libxl-save-helper
+install:: $(LIBHEADERS) libxl-save-helper
 	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
 	$(INSTALL_PROG) libxl-save-helper $(DESTDIR)$(LIBEXEC_BIN)
 
-uninstall: uninstalllocal
-
-.PHONY: uninstalllocal
-uninstalllocal:
+uninstall::
 	rm -f $(DESTDIR)$(LIBEXEC_BIN)/libxl-save-helper
 
 clean: cleanlocal
tools/libs/stat/Makefile +4 -4
index 6cd0af5239..1aef25a9bb 100644
@@ -78,8 +78,8 @@ uninstall-python-bindings:
 ifeq ($(XENSTAT_PYTHON_BINDINGS),y)
 .PHONY: all
 all: python-bindings
-install: install-python-bindings
-uninstall: uninstall-python-bindings
+install:: install-python-bindings
+uninstall:: uninstall-python-bindings
 endif
 
 # Perl bindings
@@ -111,8 +111,8 @@ ifeq ($(XENSTAT_PERL_BINDINGS),y)
 all: perl-bindings
 
 .PHONY: install
-install: install-perl-bindings
-uninstall: uninstall-perl-bindings
+install:: install-perl-bindings
+uninstall:: uninstall-perl-bindings
 endif
 
 clean: cleanlocal
tools/libs/store/Makefile +2 -8
index 18ae1fe94d..b94060be8d 100644
@@ -30,10 +30,7 @@ xs.opic: CFLAGS += -DUSE_DLSYM
 endif
 
 .PHONY: install
-install: install-headers
-
-.PHONY: install-headers
-install-headers:
+install::
 	$(INSTALL_DIR) $(DESTDIR)$(includedir)
 	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xenstore-compat
 	$(INSTALL_DATA) $(XEN_INCLUDE)/xenstore-compat/xs.h $(DESTDIR)$(includedir)/xenstore-compat/xs.h
@@ -42,10 +39,7 @@ install-headers:
 	ln -sf xenstore-compat/xs_lib.h $(DESTDIR)$(includedir)/xs_lib.h
 
 .PHONY: uninstall
-uninstall: uninstall-headers
-
-.PHONY: uninstall-headers
-uninstall-headers:
+uninstall::
 	rm -f $(DESTDIR)$(includedir)/xs_lib.h
 	rm -f $(DESTDIR)$(includedir)/xs.h
 	rm -f $(DESTDIR)$(includedir)/xenstore-compat/xs_lib.h
tools/libs/libs.mk +2 -2
index 3118cb4194..a173f59a8b 100644
@@ -100,7 +100,7 @@ endif
 endif
 
 .PHONY: install
-install: all
+install:: all
 	$(INSTALL_DIR) $(DESTDIR)$(libdir)
 	$(INSTALL_DIR) $(DESTDIR)$(includedir)
 	$(INSTALL_SHLIB) lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
@@ -111,7 +111,7 @@ install: all
 	$(INSTALL_DATA) $(PKG_CONFIG) $(DESTDIR)$(PKG_INSTALLDIR)
 
 .PHONY: uninstall
-uninstall:
+uninstall::
 	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/$(LIB_FILE_NAME).pc
 	for i in $(LIBHEADER); do rm -f $(DESTDIR)$(includedir)/$$i; done
 	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so
Signature · 1 line
Anthony PERARD
Reviewed-by on v2 15/29
#17 lore raw

Re: [XEN PATCH v2 15/29] libs: Remove need for *installlocal targets

Quoted 7 lines · Anthony PERARD

There is no need for an extra "installlocal" target, we can use double-colon rules instead.

"install-headers" in "libs/store" was introduced for the same reason that "installlocal" exist, so it is replaced as well.

Juergen

#18 lore raw

PATCH v2 16/29 libs,tools/include: Clean "clean" targets

In reply to Anthony PERARD

There is no need for an extra "cleanlocal" target, we can use double-colon rules instead.

Generated headers are now in tools/include/, so remove those file there.

Remove -f flag as it's already in $(RM).

libs.mk:
- don't try to remove "*.rpm" anymore.

libs/light:
- "_paths.*.tmp" isn't created anymore.
- clean "libxenlight_test.so" and "libxl_test_*.opic".

libs/stat:
- don't remove $(DEPS_RM) from here as it is already done in

    "libs.mk".

libs/util:
- fix clean of version-script file.

include/xen-foreign:
- remove __pycache__

---

Notes:
v2:
- stop removing $(DEPS_RM) from libs/stat/Makefile.

 tools/include/Makefile             |  1 +
 tools/include/xen-foreign/Makefile |  1 +
 tools/libs/ctrl/Makefile           |  5 +----
 tools/libs/guest/Makefile          |  3 +--
 tools/libs/light/Makefile          | 19 ++++++++-----------
 tools/libs/stat/Makefile           |  8 ++------
 tools/libs/util/Makefile           |  7 ++-----
 tools/libs/vchan/Makefile          |  5 +----
 tools/libs/libs.mk                 |  4 ++--
 9 files changed, 19 insertions(+), 34 deletions(-)
tools/include/Makefile +1 -0
index d965987f55..3a03a0b0fa 100644
@@ -82,6 +82,7 @@ uninstall:
 clean:
 	rm -rf xen xen-xsm acpi
 	$(MAKE) -C xen-foreign clean
+	rm -f _*.h
 
 .PHONY: dist
 dist: install
tools/include/xen-foreign/Makefile +1 -0
index 6ce51daf5e..b538d0ea94 100644
@@ -13,6 +13,7 @@ clean:
 	rm -f $(headers)
 	rm -f checker checker.c
 	rm -f *.pyc *.o *~
+	rm -rf __pycache__
 
 distclean: clean
 
tools/libs/ctrl/Makefile +1 -4
index ef7362327f..f58c4ef1aa 100644
@@ -54,8 +54,5 @@ NO_HEADERS_CHK := y
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
-clean: cleanlocal
-
-.PHONY: cleanlocal
-cleanlocal:
+clean::
 	rm -f libxenctrl.map
tools/libs/guest/Makefile +1 -2
index 2005d8a67d..56483c545f 100644
@@ -104,6 +104,5 @@ include $(XEN_ROOT)/tools/libs/libs.mk
 
 libxenguest.so.$(MAJOR).$(MINOR): LDLIBS += $(ZLIB_LIBS) -lz
 
-.PHONY: cleanlocal
-cleanlocal:
+clean::
 	rm -f libxenguest.map
tools/libs/light/Makefile +8 -11
index 769e2a83e2..0c04a5b5cb 100644
@@ -246,15 +246,12 @@ install:: $(LIBHEADERS) libxl-save-helper
 uninstall::
 	rm -f $(DESTDIR)$(LIBEXEC_BIN)/libxl-save-helper
 
-clean: cleanlocal
-
-.PHONY: cleanlocal
-cleanlocal:
-	$(RM) -f _*.h *.o $(CLIENTS)
-	$(RM) -f _*.c *.pyc _paths.*.tmp _*.api-for-check
-	$(RM) -f testidl.c.new testidl.c *.api-ok
-	$(RM) -f $(TEST_PROGS)
-	$(RM) -rf __pycache__
-	$(RM) -f libxenlight.map
-	$(RM) -f $(AUTOSRCS) $(AUTOINCS)
+clean::
+	$(RM) _*.h *.o $(CLIENTS)
+	$(RM) _*.c *.pyc _*.api-for-check
+	$(RM) testidl.c.new testidl.c *.api-ok
+	$(RM) $(TEST_PROGS) libxenlight_test.so libxl_test_*.opic
+	$(RM) -r __pycache__
+	$(RM) libxenlight.map
+	$(RM) $(AUTOSRCS) $(AUTOINCS)
 	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean
tools/libs/stat/Makefile +2 -6
index 1aef25a9bb..39a671d7ed 100644
@@ -115,9 +115,5 @@ install:: install-perl-bindings
 uninstall:: uninstall-perl-bindings
 endif
 
-clean: cleanlocal
-
-.PHONY: cleanlocal
-cleanlocal:
-	rm -f $(BINDINGS) $(BINDINGSRC) $(DEPS_RM)
-	rm -f libxenstat.map
+clean::
+	$(RM) libxenstat.map $(BINDINGS) $(BINDINGSRC)
tools/libs/util/Makefile +2 -5
index 72fecb4c49..7a658e9446 100644
@@ -49,8 +49,5 @@ $(LIB_OBJS) $(PIC_OBJS): $(AUTOINCS)
 	@rm -f $*.[ch]
 	$(FLEX) --header-file=$*.h --outfile=$*.c $<
 
-clean: cleanlocal
-
-.PHONY: cleanlocal
-cleanlocal:
-	$(RM) -f libxlutil.map
+clean::
+	$(RM) libxenutil.map
tools/libs/vchan/Makefile +1 -4
index 83a45d2817..4ccb4dd1f6 100644
@@ -12,8 +12,5 @@ NO_HEADERS_CHK := y
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
-clean: cleanlocal
-
-.PHONY: cleanlocal
-cleanlocal:
+clean::
 	rm -f libxenvchan.map
tools/libs/libs.mk +2 -2
index a173f59a8b..c2eaefc928 100644
@@ -124,8 +124,8 @@ TAGS:
 	etags -t *.c *.h
 
 .PHONY: clean
-clean:
-	rm -rf *.rpm $(LIB) *~ $(DEPS_RM) $(LIB_OBJS) $(PIC_OBJS)
+clean::
+	rm -rf $(LIB) *~ $(DEPS_RM) $(LIB_OBJS) $(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 v2 16/29
#19 lore raw

Re: [XEN PATCH v2 16/29] libs,tools/include: Clean "clean" targets

Quoted 48 lines · Anthony PERARD

There is no need for an extra "cleanlocal" target, we can use double-colon rules instead.

Generated headers are now in tools/include/, so remove those file there.

Remove -f flag as it's already in $(RM).

libs.mk:
- don't try to remove "*.rpm" anymore.

libs/light:
- "_paths.*.tmp" isn't created anymore.
- clean "libxenlight_test.so" and "libxl_test_*.opic".

libs/stat:
- don't remove $(DEPS_RM) from here as it is already done in

     "libs.mk".

libs/util:
- fix clean of version-script file.

include/xen-foreign:
- remove __pycache__

---

Notes:
v2:
- stop removing $(DEPS_RM) from libs/stat/Makefile.

  tools/include/Makefile             |  1 +
  tools/include/xen-foreign/Makefile |  1 +
  tools/libs/ctrl/Makefile           |  5 +----
  tools/libs/guest/Makefile          |  3 +--
  tools/libs/light/Makefile          | 19 ++++++++-----------
  tools/libs/stat/Makefile           |  8 ++------
  tools/libs/util/Makefile           |  7 ++-----
  tools/libs/vchan/Makefile          |  5 +----
  tools/libs/libs.mk                 |  4 ++--
  9 files changed, 19 insertions(+), 34 deletions(-)
tools/include/Makefile +0 -0
index d965987f55..3a03a0b0fa 100644

tools/include/Makefile uninstall: · line 85

Quoted 4 lines
tools/include/Makefile +1 -0
@@ -82,6 +82,7 @@ uninstall:
  clean:
  	rm -rf xen xen-xsm acpi
  	$(MAKE) -C xen-foreign clean
+	rm -f _*.h

Use $(RM) instead? OTOH this could be done in a patch of its own switching all rm -f instances to $(RM). Either way is fine with me, so:

Juergen

#20 lore raw

Re: [XEN PATCH v2 16/29] libs,tools/include: Clean "clean" targets

Quoted 13 lines · Juergen Gross

tools/include/Makefile uninstall: · line 85

Quoted 9 lines · Anthony PERARD
tools/include/Makefile +1 -0
index d965987f55..3a03a0b0fa 100644
@@ -82,6 +82,7 @@ uninstall:
  clean:
  	rm -rf xen xen-xsm acpi
  	$(MAKE) -C xen-foreign clean
+	rm -f _*.h

Use $(RM) instead? OTOH this could be done in a patch of its own switching all rm -f instances to $(RM).

This isn't really something that I think matter. Per GNU make's manual, "rm" need to exist. Without it part of the build system could be broken. Also setting $(RM) to something other than "rm -f" isn't going to work well either. So whether we use $(RM) or rm -f shouldn't matter.

All of that to say that I'm not necessarily change one for the other. It mostly depends on context.

Also, I might change those "clean:" rules later to collect files to clean in a variable $(&CLEAN_FILES), when that will be possible.

Quoted 1 line

Thanks,

Signature · 1 line
Anthony PERARD
#21 lore raw

PATCH v2 17/29 libs: Rename $(SRCS-y) to $(OBJS-y)

In reply to Anthony PERARD

The only thing done thing done with $(SRCS-y) is to replace ".c" by ".o". It is more useful to collect which object we want to build as make will figure out how to build it and from which source file.

---

Notes:
v2:
- reviewed

 tools/libs/call/Makefile          |  12 +--
 tools/libs/ctrl/Makefile          |  74 +++++++-------
 tools/libs/devicemodel/Makefile   |  12 +--
 tools/libs/evtchn/Makefile        |  12 +--
 tools/libs/foreignmemory/Makefile |  12 +--
 tools/libs/gnttab/Makefile        |  14 +--
 tools/libs/guest/Makefile         |  86 ++++++++--------
 tools/libs/hypfs/Makefile         |   2 +-
 tools/libs/light/Makefile         | 162 +++++++++++++++---------------
 tools/libs/stat/Makefile          |  12 +--
 tools/libs/store/Makefile         |   4 +-
 tools/libs/toolcore/Makefile      |   2 +-
 tools/libs/toollog/Makefile       |   4 +-
 tools/libs/util/Makefile          |  16 +--
 tools/libs/vchan/Makefile         |   4 +-
 tools/libs/libs.mk                |   7 +-
 16 files changed, 217 insertions(+), 218 deletions(-)
tools/libs/call/Makefile +6 -6
index 93d404b79e..e5cb7c937c 100644
@@ -4,11 +4,11 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 3
 
-SRCS-y                 += core.c buffer.c
-SRCS-$(CONFIG_Linux)   += linux.c
-SRCS-$(CONFIG_FreeBSD) += freebsd.c
-SRCS-$(CONFIG_SunOS)   += solaris.c
-SRCS-$(CONFIG_NetBSD)  += netbsd.c
-SRCS-$(CONFIG_MiniOS)  += minios.c
+OBJS-y                 += core.o buffer.o
+OBJS-$(CONFIG_Linux)   += linux.o
+OBJS-$(CONFIG_FreeBSD) += freebsd.o
+OBJS-$(CONFIG_SunOS)   += solaris.o
+OBJS-$(CONFIG_NetBSD)  += netbsd.o
+OBJS-$(CONFIG_MiniOS)  += minios.o
 
 include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/ctrl/Makefile +37 -37

80 lines not on this page · raw message

tools/libs/devicemodel/Makefile +6 -6
index 3e50ff6d90..a0a2d24f99 100644
@@ -4,11 +4,11 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 4
 
-SRCS-y                 += core.c
-SRCS-$(CONFIG_Linux)   += common.c
-SRCS-$(CONFIG_FreeBSD) += common.c
-SRCS-$(CONFIG_SunOS)   += compat.c
-SRCS-$(CONFIG_NetBSD)  += compat.c
-SRCS-$(CONFIG_MiniOS)  += compat.c
+OBJS-y                 += core.o
+OBJS-$(CONFIG_Linux)   += common.o
+OBJS-$(CONFIG_FreeBSD) += common.o
+OBJS-$(CONFIG_SunOS)   += compat.o
+OBJS-$(CONFIG_NetBSD)  += compat.o
+OBJS-$(CONFIG_MiniOS)  += compat.o
 
 include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/evtchn/Makefile +6 -6
index b8c37b5b97..8208ecf650 100644
@@ -4,11 +4,11 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 2
 
-SRCS-y                 += core.c
-SRCS-$(CONFIG_Linux)   += linux.c
-SRCS-$(CONFIG_FreeBSD) += freebsd.c
-SRCS-$(CONFIG_SunOS)   += solaris.c
-SRCS-$(CONFIG_NetBSD)  += netbsd.c
-SRCS-$(CONFIG_MiniOS)  += minios.c
+OBJS-y                 += core.o
+OBJS-$(CONFIG_Linux)   += linux.o
+OBJS-$(CONFIG_FreeBSD) += freebsd.o
+OBJS-$(CONFIG_SunOS)   += solaris.o
+OBJS-$(CONFIG_NetBSD)  += netbsd.o
+OBJS-$(CONFIG_MiniOS)  += minios.o
 
 include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/foreignmemory/Makefile +6 -6
index 0eb9a3a712..4427435932 100644
@@ -4,11 +4,11 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 4
 
-SRCS-y                 += core.c
-SRCS-$(CONFIG_Linux)   += linux.c
-SRCS-$(CONFIG_FreeBSD) += freebsd.c
-SRCS-$(CONFIG_SunOS)   += compat.c solaris.c
-SRCS-$(CONFIG_NetBSD)  += netbsd.c
-SRCS-$(CONFIG_MiniOS)  += minios.c
+OBJS-y                 += core.o
+OBJS-$(CONFIG_Linux)   += linux.o
+OBJS-$(CONFIG_FreeBSD) += freebsd.o
+OBJS-$(CONFIG_SunOS)   += compat.o solaris.o
+OBJS-$(CONFIG_NetBSD)  += netbsd.o
+OBJS-$(CONFIG_MiniOS)  += minios.o
 
 include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/gnttab/Makefile +7 -7
index ae390ce60f..7d7aeeadff 100644
@@ -4,13 +4,13 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 2
 
-SRCS-GNTTAB            += gnttab_core.c
-SRCS-GNTSHR            += gntshr_core.c
+OBJS-GNTTAB            += gnttab_core.o
+OBJS-GNTSHR            += gntshr_core.o
 
-SRCS-$(CONFIG_Linux)   += $(SRCS-GNTTAB) $(SRCS-GNTSHR) linux.c
-SRCS-$(CONFIG_MiniOS)  += $(SRCS-GNTTAB) gntshr_unimp.c minios.c
-SRCS-$(CONFIG_FreeBSD) += $(SRCS-GNTTAB) $(SRCS-GNTSHR) freebsd.c
-SRCS-$(CONFIG_NetBSD)  += $(SRCS-GNTTAB) $(SRCS-GNTSHR) netbsd.c
-SRCS-$(CONFIG_SunOS)   += gnttab_unimp.c gntshr_unimp.c
+OBJS-$(CONFIG_Linux)   += $(OBJS-GNTTAB) $(OBJS-GNTSHR) linux.o
+OBJS-$(CONFIG_MiniOS)  += $(OBJS-GNTTAB) gntshr_unimp.o minios.o
+OBJS-$(CONFIG_FreeBSD) += $(OBJS-GNTTAB) $(OBJS-GNTSHR) freebsd.o
+OBJS-$(CONFIG_NetBSD)  += $(OBJS-GNTTAB) $(OBJS-GNTSHR) netbsd.o
+OBJS-$(CONFIG_SunOS)   += gnttab_unimp.o gntshr_unimp.o
 
 include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/guest/Makefile +43 -43

112 lines not on this page · raw message

tools/libs/hypfs/Makefile +1 -1
index efa955bd50..630e1e6f3e 100644
@@ -6,6 +6,6 @@ MINOR    = 0
 
 LDLIBS += -lz
 
-SRCS-y                 += core.c
+OBJS-y += core.o
 
 include ../libs.mk
tools/libs/light/Makefile +81 -81

216 lines not on this page · raw message

tools/libs/stat/Makefile +6 -6
index 39a671d7ed..998435d494 100644
@@ -17,12 +17,12 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
-SRCS-y += xenstat.c
-SRCS-y += xenstat_qmp.c
-SRCS-$(CONFIG_Linux) += xenstat_linux.c
-SRCS-$(CONFIG_SunOS) += xenstat_solaris.c
-SRCS-$(CONFIG_NetBSD) += xenstat_netbsd.c
-SRCS-$(CONFIG_FreeBSD) += xenstat_freebsd.c
+OBJS-y += xenstat.o
+OBJS-y += xenstat_qmp.o
+OBJS-$(CONFIG_Linux) += xenstat_linux.o
+OBJS-$(CONFIG_SunOS) += xenstat_solaris.o
+OBJS-$(CONFIG_NetBSD) += xenstat_netbsd.o
+OBJS-$(CONFIG_FreeBSD) += xenstat_freebsd.o
 
 LDLIBS-y += -lyajl
 LDLIBS-$(CONFIG_SunOS) += -lkstat
tools/libs/store/Makefile +2 -2
index b94060be8d..778da51f95 100644
@@ -8,8 +8,8 @@ ifeq ($(CONFIG_Linux),y)
 LDLIBS += -ldl
 endif
 
-SRCS-y   += xs_lib.c
-SRCS-y   += xs.c
+OBJS-y   += xs_lib.o
+OBJS-y   += xs.o
 
 LIBHEADER = xenstore.h xenstore_lib.h
 
tools/libs/toolcore/Makefile +1 -1
index 9c013b2879..ce417ea648 100644
@@ -6,7 +6,7 @@ MINOR	= 0
 
 LIBHEADER := xentoolcore.h
 
-SRCS-y	+= handlereg.c
+OBJS-y	+= handlereg.o
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
tools/libs/toollog/Makefile +2 -2
index dce1b2de85..c09aa02ba5 100644
@@ -4,7 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR	= 1
 MINOR	= 0
 
-SRCS-y	+= xtl_core.c
-SRCS-y	+= xtl_logger_stdio.c
+OBJS-y	+= xtl_core.o
+OBJS-y	+= xtl_logger_stdio.o
 
 include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/util/Makefile +8 -8
index 7a658e9446..ffe507b379 100644
@@ -1,13 +1,13 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-SRCS-y += libxlu_cfg_y.c
-SRCS-y += libxlu_cfg_l.c
-SRCS-y += libxlu_cfg.c
-SRCS-y += libxlu_disk_l.c
-SRCS-y += libxlu_disk.c
-SRCS-y += libxlu_vif.c
-SRCS-y += libxlu_pci.c
+OBJS-y += libxlu_cfg_y.o
+OBJS-y += libxlu_cfg_l.o
+OBJS-y += libxlu_cfg.o
+OBJS-y += libxlu_disk_l.o
+OBJS-y += libxlu_disk.o
+OBJS-y += libxlu_vif.o
+OBJS-y += libxlu_pci.o
 
 CFLAGS += -Wno-format-zero-length -Wmissing-declarations \
 	-Wno-declaration-after-statement -Wformat-nonliteral
@@ -39,7 +39,7 @@ NO_HEADERS_CHK := y
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
-$(LIB_OBJS) $(PIC_OBJS): $(AUTOINCS)
+$(OBJS-y) $(PIC_OBJS): $(AUTOINCS)
 
 %.c %.h:: %.y
 	@rm -f $*.[ch]
tools/libs/vchan/Makefile +2 -2
index 4ccb4dd1f6..ac2bff66f5 100644
@@ -5,8 +5,8 @@ CFLAGS += $(CFLAGS_libxenctrl)
 
 LIBHEADER := libxenvchan.h
 
-SRCS-y += init.c
-SRCS-y += io.c
+OBJS-y += init.o
+OBJS-y += io.o
 
 NO_HEADERS_CHK := y
 
tools/libs/libs.mk +3 -4
index c2eaefc928..58d8166b09 100644
@@ -20,8 +20,7 @@ CFLAGS   += $(foreach lib, $(USELIBS_$(LIBNAME)), $(CFLAGS_libxen$(lib)))
 
 LDLIBS += $(foreach lib, $(USELIBS_$(LIBNAME)), $(LDLIBS_libxen$(lib)))
 
-LIB_OBJS := $(SRCS-y:.c=.o)
-PIC_OBJS := $(SRCS-y:.c=.opic)
+PIC_OBJS := $(OBJS-y:.o=.opic)
 
 LIB_FILE_NAME = $(FILENAME_$(LIBNAME))
 LIB := lib$(LIB_FILE_NAME).a
@@ -79,7 +78,7 @@ headers.lst: FORCE
 libxen$(LIBNAME).map:
 	echo 'VERS_$(MAJOR).$(MINOR) { global: *; };' >$@
 
-lib$(LIB_FILE_NAME).a: $(LIB_OBJS)
+lib$(LIB_FILE_NAME).a: $(OBJS-y)
 	$(AR) rc $@ $^
 
 lib$(LIB_FILE_NAME).so: lib$(LIB_FILE_NAME).so.$(MAJOR)
@@ -125,7 +124,7 @@ TAGS:
 
 .PHONY: clean
 clean::
-	rm -rf $(LIB) *~ $(DEPS_RM) $(LIB_OBJS) $(PIC_OBJS)
+	rm -rf $(LIB) *~ $(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
#22 lore raw

PATCH v2 18/29 libs/guest: rename ELF_OBJS to LIBELF_OBJS

In reply to Anthony PERARD

It seems a better name. Later, we will introduce LIBX86_OBJS to collect lib/x86/* objects.

---

Notes:
v2:
- fix typo in patch description
- reviewed

 tools/libs/guest/Makefile | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
tools/libs/guest/Makefile +4 -5
index 17eb0ebf4b..7707d4300f 100644
@@ -33,13 +33,12 @@ CFLAGS += -I$(XEN_libxenctrl)
 vpath %.c ../../../xen/common/libelf
 CFLAGS += -I../../../xen/common/libelf
 
-ELF_OBJS-y += libelf-tools.o libelf-loader.o
-ELF_OBJS-y += libelf-dominfo.o
+LIBELF_OBJS += libelf-tools.o libelf-loader.o
+LIBELF_OBJS += libelf-dominfo.o
 
-OBJS-y += $(ELF_OBJS-y)
+OBJS-y += $(LIBELF_OBJS)
 
-$(ELF_OBJS-y): CFLAGS += -Wno-pointer-sign
-$(ELF_OBJS-y:.o=.opic): CFLAGS += -Wno-pointer-sign
+$(LIBELF_OBJS) $(LIBELF_OBJS:.o=.opic): CFLAGS += -Wno-pointer-sign
 
 ifeq ($(CONFIG_X86),y) # Add libx86 to the build
 vpath %.c ../../../xen/lib/x86
Signature · 1 line
Anthony PERARD
#23 lore raw

PATCH v2 19/29 libs/guest: rework CFLAGS

In reply to Anthony PERARD

Remove '-Werror -Wmissing-progress -I./include $(CFLAGS_xeninclude)', those flags are already added via "libs.mk".

Flag "-I." isn't needed, we just need to fix the #include of "xg_core.h" as this header isn't expected to be installed.

Make use of "-iquote" instead of '-I' for double-quote included headers.

Also, regroup the CFLAGS into the same place in the makefile.

---

Notes:
v2:
- reviewed

 tools/libs/guest/Makefile          | 20 +++++++++-----------
 tools/libs/guest/xg_offline_page.c |  2 +-
 2 files changed, 10 insertions(+), 12 deletions(-)
tools/libs/guest/Makefile +9 -11
index 7707d4300f..4f2373101f 100644
@@ -28,18 +28,13 @@ OBJS-y       += xg_core.o
 OBJS-$(CONFIG_X86) += xg_core_x86.o
 OBJS-$(CONFIG_ARM) += xg_core_arm.o
 
-CFLAGS += -I$(XEN_libxenctrl)
-
 vpath %.c ../../../xen/common/libelf
-CFLAGS += -I../../../xen/common/libelf
 
 LIBELF_OBJS += libelf-tools.o libelf-loader.o
 LIBELF_OBJS += libelf-dominfo.o
 
 OBJS-y += $(LIBELF_OBJS)
 
-$(LIBELF_OBJS) $(LIBELF_OBJS:.o=.opic): CFLAGS += -Wno-pointer-sign
-
 ifeq ($(CONFIG_X86),y) # Add libx86 to the build
 vpath %.c ../../../xen/lib/x86
 
@@ -70,10 +65,12 @@ OBJS-y                 += xg_dom_decompress_unsafe_xz.o
 OBJS-y                 += xg_dom_decompress_unsafe_zstd.o
 endif
 
-CFLAGS   += -Werror -Wmissing-prototypes
-CFLAGS   += -I. -I./include $(CFLAGS_xeninclude)
-CFLAGS   += -D__XEN_TOOLS__
-CFLAGS   += -include $(XEN_ROOT)/tools/config.h
+CFLAGS += -D__XEN_TOOLS__
+CFLAGS += -include $(XEN_ROOT)/tools/config.h
+CFLAGS += -iquote ../../../xen/common/libelf
+
+# To be able to include xc_private.h
+CFLAGS += -iquote $(XEN_libxenctrl)
 
 # Needed for posix_fadvise64() in xc_linux.c
 CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
@@ -92,8 +89,9 @@ ZLIB_CFLAGS :=
 ZLIB_LIBS :=
 endif
 
-xg_dom_bzimageloader.o: CFLAGS += $(ZLIB_CFLAGS)
-xg_dom_bzimageloader.opic: CFLAGS += $(ZLIB_CFLAGS)
+xg_dom_bzimageloader.o xg_dom_bzimageloader.opic: CFLAGS += $(ZLIB_CFLAGS)
+
+$(LIBELF_OBJS) $(LIBELF_OBJS:.o=.opic): CFLAGS += -Wno-pointer-sign
 
 LIBHEADER := xenguest.h
 
tools/libs/guest/xg_offline_page.c +1 -1
index cfe0e2d537..c594fdba41 100644
@@ -25,7 +25,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/time.h>
-#include <xg_core.h>
+#include "xg_core.h"
 
 #include "xc_private.h"
 #include "xg_private.h"
Signature · 1 line
Anthony PERARD
#24 lore raw

PATCH v2 20/29 libs/store: use of -iquote instead of -I

In reply to Anthony PERARD

---

Notes:
v2:
- reviewed

 tools/libs/store/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libs/store/Makefile +1 -1
index 778da51f95..2334c953bb 100644
@@ -22,7 +22,7 @@ CFLAGS += -DXEN_LIB_STORED="\"$(XEN_LIB_STORED)\""
 CFLAGS += -DXEN_RUN_STORED="\"$(XEN_RUN_STORED)\""
 
 vpath xs_lib.c $(XEN_ROOT)/tools/xenstore
-CFLAGS += -I $(XEN_ROOT)/tools/xenstore
+CFLAGS += -iquote $(XEN_ROOT)/tools/xenstore
 
 xs.opic: CFLAGS += -DUSE_PTHREAD
 ifeq ($(CONFIG_Linux),y)
Signature · 1 line
Anthony PERARD
#25 lore raw

PATCH v2 21/29 libs/stat: Fix and rework python-bindings build

In reply to Anthony PERARD

Fix the dependency on the library, $(SHLIB) variable doesn't exist anymore.

Rework dependency on the include file, we can let swig generate the dependency for us with the use of "-M*" flags.

The xenstat.h file has moved so we need to fix the include location.

Rather than relaying on the VCS to create an empty directory for us, we can create one before generating the *.c file for the bindings.

Make use of generic variable names to build a shared library from a source file: CFLAGS, LDFLAGS, and LDLIBS.

Fix python's specific *flags by using python-config, and add them to generic flags variables: CFLAGS, LDLIBS.

To build a shared library, we need to build the source file with "-fPIC", which was drop by 6d0ec05390 (tools: split libxenstat into new tools/libs/stat directory).

The source file generated by swig seems to be missing a prototype for the "init" function, so we need "-Wno-missing-prototypes" in order to build it.

Add some targets to .PHONY.

---

Notes:
v2:
- reviewed

 tools/libs/stat/Makefile                    | 27 +++++++++++++++------
 tools/libs/stat/bindings/swig/python/.empty |  1 -
 2 files changed, 19 insertions(+), 9 deletions(-)
 delete mode 100644 tools/libs/stat/bindings/swig/python/.empty
tools/libs/stat/Makefile +19 -8
index 998435d494..b8d75810fc 100644
@@ -49,23 +49,34 @@ install-bindings: install-perl-bindings install-python-bindings
 .PHONY: uninstall-bindings
 uninstall-bindings: uninstall-perl-bindings uninstall-python-bindings
 
-$(BINDINGS): $(SHLIB) $(SHLIB_LINKS) include/xenstat.h
+$(BINDINGS): libxenstat.so
 
-SWIG_FLAGS=-module xenstat -Iinclude -I.
+SWIG_FLAGS = -module xenstat -I$(XEN_INCLUDE)
+SWIG_FLAGS += -MMD -MP -MF .$(if $(filter-out .,$(@D)),$(subst /,@,$(@D))@)$(@F).d
 
 # Python bindings
-PYTHON_VERSION=$(PYTHON:python%=%)
-PYTHON_FLAGS=-I/usr/include/python$(PYTHON_VERSION) -lpython$(PYTHON_VERSION)
 $(PYMOD): $(PYSRC)
 $(PYSRC): bindings/swig/xenstat.i
-	swig -python $(SWIG_FLAGS) -outdir $(@D) -o $(PYSRC) $<
-
+	mkdir -p $(@D)
+	swig -python $(SWIG_FLAGS) -outdir $(@D) -o $@ $<
+
+$(PYLIB): CFLAGS += $(shell $(PYTHON)-config --includes)
+$(PYLIB): CFLAGS += -fPIC
+$(PYLIB): CFLAGS += -Wno-missing-prototypes
+$(PYLIB): LDFLAGS += $(SHLIB_LDFLAGS)
+$(PYLIB): LDLIBS := $(shell $(PYTHON)-config --libs)
+$(PYLIB): LDLIBS += $(LDLIBS_libxenstat)
 $(PYLIB): $(PYSRC)
-	$(CC) $(CFLAGS) $(LDFLAGS) $(PYTHON_FLAGS) $(SHLIB_LDFLAGS) -lxenstat -o $@ $< $(APPEND_LDFLAGS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS) $(APPEND_LDFLAGS)
 
+.PHONY: python-bindings
 python-bindings: $(PYLIB) $(PYMOD)
 
-pythonlibdir=$(prefix)/lib/python$(PYTHON_VERSION)/site-packages
+pythonlibdir = $(shell $(PYTHON) -c \
+	       'import distutils.sysconfig as cfg; \
+	        print(cfg.get_python_lib(False, False, prefix="$(prefix)"))')
+
+.PHONY: install-python-bindings
 install-python-bindings: $(PYLIB) $(PYMOD)
 	$(INSTALL_PROG) $(PYLIB) $(DESTDIR)$(pythonlibdir)/_xenstat.so
 	$(INSTALL_PROG) $(PYMOD) $(DESTDIR)$(pythonlibdir)/xenstat.py
tools/libs/stat/bindings/swig/python/.empty deleted +0 -1
deleted file mode 100644
index 2a8dd4274d..0000000000
@@ -1 +0,0 @@
-This directory is empty; this file is included to prevent version control systems from removing the directory.
Signature · 1 line
Anthony PERARD
#26 lore raw

PATCH v2 22/29 libs/stat: Fix and rework perl-binding build

In reply to Anthony PERARD

For PERL_FLAGS, use make's shell rather than a backquote.

Rather than relying on the VCS to create an empty directory for us, we can create one before generating the *.c file for the bindings.

Make use of generic variable names to build a shared library from a source file: CFLAGS, LDFLAGS, and LDLIBS.

To build a shared library, we need to build the source file with "-fPIC", which was drop by 6d0ec05390 (tools: split libxenstat into new tools/libs/stat directory).

The source file generated by swig seems to be missing many prototype for many functions, so we need "-Wno-missing-prototypes" in order to build it. Also, one of the prototype is deemed malformed, so we also need "-Wno-strict-prototypes".

---

Notes:
v2:
- reviewed

 tools/libs/stat/Makefile                  | 15 +++++++++++----
 tools/libs/stat/bindings/swig/perl/.empty |  1 -
 2 files changed, 11 insertions(+), 5 deletions(-)
 delete mode 100644 tools/libs/stat/bindings/swig/perl/.empty
tools/libs/stat/Makefile +11 -4
index b8d75810fc..7eaf50e91e 100644
@@ -94,13 +94,20 @@ uninstall:: uninstall-python-bindings
 endif
 
 # Perl bindings
-PERL_FLAGS=`perl -MConfig -e 'print "$$Config{ccflags} -I$$Config{archlib}/CORE";'`
+PERL_FLAGS = $(shell $(PERL) -MConfig -e 'print "$$Config{ccflags} -I$$Config{archlib}/CORE";')
 $(PERLMOD): $(PERLSRC)
 $(PERLSRC): bindings/swig/xenstat.i
-	swig -perl $(SWIG_FLAGS) -outdir $(@D) -o $(PERLSRC) $<
-
+	mkdir -p $(@D)
+	swig -perl $(SWIG_FLAGS) -outdir $(@D) -o $@ $<
+
+$(PERLLIB): CFLAGS += -fPIC
+$(PERLLIB): CFLAGS += -Wno-strict-prototypes
+$(PERLLIB): CFLAGS += -Wno-missing-prototypes
+$(PERLLIB): LDFLAGS += $(PERL_FLAGS)
+$(PERLLIB): LDFLAGS += $(SHLIB_LDFLAGS)
+$(PERLLIB): LDLIBS := $(LDLIBS_libxenstat)
 $(PERLLIB): $(PERLSRC)
-	$(CC) $(CFLAGS) $(LDFLAGS) $(PERL_FLAGS) $(SHLIB_LDFLAGS) -lxenstat -o $@ $< $(APPEND_LDFLAGS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS) $(APPEND_LDFLAGS)
 
 .PHONY: perl-bindings
 perl-bindings: $(PERLLIB) $(PERLMOD)
tools/libs/stat/bindings/swig/perl/.empty deleted +0 -1
deleted file mode 100644
index 2a8dd4274d..0000000000
@@ -1 +0,0 @@
-This directory is empty; this file is included to prevent version control systems from removing the directory.
Signature · 1 line
Anthony PERARD
#27 lore raw

PATCH v2 23/29 .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 3da56594c5..7a04dc3a89 100644
@@ -105,26 +105,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
@@ -144,21 +126,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
#28 lore raw

PATCH v2 24/29 stubdom: introduce xenlibs.mk

In reply to Anthony PERARD

This new makefile will be used to build libraries that provides "Makefile.common".

At some point, we will be converting Makefile in tools/ to "subdirmk" and stubdom build will not be able to use those new makefiles, so we will put the necessary information for stubdom to build the xen libraries into a new Makefile.common and xenlibs.mk will use it. We only need to build static libraries and don't need anything else.

The check for the presence of "Makefile.common" will go aways once there is one for all libraries used by stubdom build.

Also remove DESTDIR= from "clean" targets, we don't do installation in this recipe so the value of DESTDIR doesn't matter.

---

Notes:
v2:
- reviewed

 stubdom/Makefile   |  9 +++++++--
 stubdom/xenlibs.mk | 13 +++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 stubdom/xenlibs.mk
stubdom/Makefile +7 -2
index 5fb5dbc341..fba4c977ef 100644
@@ -346,6 +346,7 @@ define do_links
   cd $(dir $@); \
   ln -sf $(dir $<)include/*.h include/; \
   ln -sf $(dir $<)*.[ch] .; \
+  [ -e $(dir $<)Makefile.common ] && ln -sf $(dir $<)Makefile.common . ||:; \
   ln -sf $(dir $<)Makefile .
   touch $@
 endef
@@ -355,10 +356,14 @@ define BUILD_lib
  libxen$(1): libs-$$(XEN_TARGET_ARCH)/$(1)/libxen$(1).a
  libs-$$(XEN_TARGET_ARCH)/$(1)/libxen$(1).a: $$(LIBDEPS_$(1)) $$(LIBDEP_$(1))
  libs-$$(XEN_TARGET_ARCH)/$(1)/libxen$(1).a: mk-headers-$$(XEN_TARGET_ARCH) $$(NEWLIB_STAMPFILE) .phony
-	CPPFLAGS="$$(TARGET_CPPFLAGS)" CFLAGS="$$(TARGET_CFLAGS)" $$(MAKE) CONFIG_LIBXC_MINIOS=y -C $$(@D) $$(@F)
+	CPPFLAGS="$$(TARGET_CPPFLAGS)" CFLAGS="$$(TARGET_CFLAGS)" $$(MAKE) CONFIG_LIBXC_MINIOS=y $$(if $$(wildcard $$(@D)/Makefile.common),-f $(CURDIR)/xenlibs.mk) -C $$(@D) $$(@F)
 
  clean-libxen$(1):
-	[ ! -e libs-$$(XEN_TARGET_ARCH)/$(1)/Makefile ] || $$(MAKE) DESTDIR= -C libs-$$(XEN_TARGET_ARCH)/$(1) clean
+	if [ -e libs-$$(XEN_TARGET_ARCH)/$(1)/Makefile.common ]; then \
+	    $$(MAKE) -f $(CURDIR)/xenlibs.mk -C libs-$$(XEN_TARGET_ARCH)/$(1) clean; \
+	elif [ -e libs-$$(XEN_TARGET_ARCH)/$(1)/Makefile ]; then \
+	    $$(MAKE) -C libs-$$(XEN_TARGET_ARCH)/$(1) clean; \
+	fi
 
  libs-$$(XEN_TARGET_ARCH)/$(1)/stamp: $$(XEN_ROOT)/tools/libs/$(1)/Makefile
 	$$(do_links)
stubdom/xenlibs.mk new file +13 -0
new file mode 100644
index 0000000000..5c8742ccf9
@@ -0,0 +1,13 @@
+include $(XEN_ROOT)/tools/Rules.mk
+
+include Makefile.common
+
+LIBNAME := $(notdir $(CURDIR))
+FILENAME_$(LIBNAME) ?= xen$(LIBNAME)
+LIB_FILE_NAME = $(FILENAME_$(LIBNAME))
+
+lib$(LIB_FILE_NAME).a: $(OBJS-y)
+	$(AR) rc $@ $^
+
+clean::
+	rm -f $(OBJS-y) lib$(LIB_FILE_NAME).a
Signature · 1 line
Anthony PERARD
#29 lore raw

PATCH v2 25/29 tools/libs: create Makefile.common to be used by stubdom build system

In reply to Anthony PERARD

This new "Makefile.common" is intended to be used by both tools/ and stubdom/ build system without stubdom needed to use tools/ build system.

It should contain the necessary list of objects and CFLAGS needed to build a static library.

Change stubdom/ to check Makefile.common, for the linkfarm.

---

Notes:
v2:
- reviewed

 stubdom/Makefile                         |  2 +-
 tools/libs/call/Makefile                 |  7 +-
 tools/libs/ctrl/Makefile                 | 45 +-----------
 tools/libs/devicemodel/Makefile          |  7 +-
 tools/libs/evtchn/Makefile               |  7 +-
 tools/libs/foreignmemory/Makefile        |  7 +-
 tools/libs/gnttab/Makefile               |  9 +--
 tools/libs/guest/Makefile                | 90 +-----------------------
 tools/libs/toolcore/Makefile             |  2 +-
 tools/libs/toollog/Makefile              |  3 +-
 tools/libs/call/Makefile.common          |  6 ++
 tools/libs/ctrl/Makefile.common          | 44 ++++++++++++
 tools/libs/devicemodel/Makefile.common   |  6 ++
 tools/libs/evtchn/Makefile.common        |  6 ++
 tools/libs/foreignmemory/Makefile.common |  6 ++
 tools/libs/gnttab/Makefile.common        |  8 +++
 tools/libs/guest/Makefile.common         | 84 ++++++++++++++++++++++
 tools/libs/toolcore/Makefile.common      |  1 +
 tools/libs/toollog/Makefile.common       |  2 +
 19 files changed, 174 insertions(+), 168 deletions(-)
 create mode 100644 tools/libs/call/Makefile.common
 create mode 100644 tools/libs/ctrl/Makefile.common
 create mode 100644 tools/libs/devicemodel/Makefile.common
 create mode 100644 tools/libs/evtchn/Makefile.common
 create mode 100644 tools/libs/foreignmemory/Makefile.common
 create mode 100644 tools/libs/gnttab/Makefile.common
 create mode 100644 tools/libs/guest/Makefile.common
 create mode 100644 tools/libs/toolcore/Makefile.common
 create mode 100644 tools/libs/toollog/Makefile.common
stubdom/Makefile +1 -1
index fba4c977ef..fbc63a5063 100644
@@ -365,7 +365,7 @@ define BUILD_lib
 	    $$(MAKE) -C libs-$$(XEN_TARGET_ARCH)/$(1) clean; \
 	fi
 
- libs-$$(XEN_TARGET_ARCH)/$(1)/stamp: $$(XEN_ROOT)/tools/libs/$(1)/Makefile
+ libs-$$(XEN_TARGET_ARCH)/$(1)/stamp: $$(XEN_ROOT)/tools/libs/$(1)/Makefile.common
 	$$(do_links)
 endef
 
tools/libs/call/Makefile +1 -6
index e5cb7c937c..103f5ad360 100644
@@ -4,11 +4,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 3
 
-OBJS-y                 += core.o buffer.o
-OBJS-$(CONFIG_Linux)   += linux.o
-OBJS-$(CONFIG_FreeBSD) += freebsd.o
-OBJS-$(CONFIG_SunOS)   += solaris.o
-OBJS-$(CONFIG_NetBSD)  += netbsd.o
-OBJS-$(CONFIG_MiniOS)  += minios.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/ctrl/Makefile +1 -44

51 lines not on this page · raw message

tools/libs/devicemodel/Makefile +1 -6
index a0a2d24f99..b70dd774e4 100644
@@ -4,11 +4,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 4
 
-OBJS-y                 += core.o
-OBJS-$(CONFIG_Linux)   += common.o
-OBJS-$(CONFIG_FreeBSD) += common.o
-OBJS-$(CONFIG_SunOS)   += compat.o
-OBJS-$(CONFIG_NetBSD)  += compat.o
-OBJS-$(CONFIG_MiniOS)  += compat.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/evtchn/Makefile +1 -6
index 8208ecf650..3dad3840c6 100644
@@ -4,11 +4,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 2
 
-OBJS-y                 += core.o
-OBJS-$(CONFIG_Linux)   += linux.o
-OBJS-$(CONFIG_FreeBSD) += freebsd.o
-OBJS-$(CONFIG_SunOS)   += solaris.o
-OBJS-$(CONFIG_NetBSD)  += netbsd.o
-OBJS-$(CONFIG_MiniOS)  += minios.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/foreignmemory/Makefile +1 -6
index 4427435932..b70dd774e4 100644
@@ -4,11 +4,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 4
 
-OBJS-y                 += core.o
-OBJS-$(CONFIG_Linux)   += linux.o
-OBJS-$(CONFIG_FreeBSD) += freebsd.o
-OBJS-$(CONFIG_SunOS)   += compat.o solaris.o
-OBJS-$(CONFIG_NetBSD)  += netbsd.o
-OBJS-$(CONFIG_MiniOS)  += minios.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/gnttab/Makefile +1 -8
index 7d7aeeadff..3dad3840c6 100644
@@ -4,13 +4,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 2
 
-OBJS-GNTTAB            += gnttab_core.o
-OBJS-GNTSHR            += gntshr_core.o
-
-OBJS-$(CONFIG_Linux)   += $(OBJS-GNTTAB) $(OBJS-GNTSHR) linux.o
-OBJS-$(CONFIG_MiniOS)  += $(OBJS-GNTTAB) gntshr_unimp.o minios.o
-OBJS-$(CONFIG_FreeBSD) += $(OBJS-GNTTAB) $(OBJS-GNTSHR) freebsd.o
-OBJS-$(CONFIG_NetBSD)  += $(OBJS-GNTTAB) $(OBJS-GNTSHR) netbsd.o
-OBJS-$(CONFIG_SunOS)   += gnttab_unimp.o gntshr_unimp.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/guest/Makefile +2 -88

99 lines not on this page · raw message

tools/libs/toolcore/Makefile +1 -1
index ce417ea648..0d92b68b3b 100644
@@ -6,7 +6,7 @@ MINOR	= 0
 
 LIBHEADER := xentoolcore.h
 
-OBJS-y	+= handlereg.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
tools/libs/toollog/Makefile +1 -2
index c09aa02ba5..2361b8cbf1 100644
@@ -4,7 +4,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR	= 1
 MINOR	= 0
 
-OBJS-y	+= xtl_core.o
-OBJS-y	+= xtl_logger_stdio.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
tools/libs/call/Makefile.common new file +6 -0
new file mode 100644
index 0000000000..85e608f8ad
@@ -0,0 +1,6 @@
+OBJS-y                 += core.o buffer.o
+OBJS-$(CONFIG_Linux)   += linux.o
+OBJS-$(CONFIG_FreeBSD) += freebsd.o
+OBJS-$(CONFIG_SunOS)   += solaris.o
+OBJS-$(CONFIG_NetBSD)  += netbsd.o
+OBJS-$(CONFIG_MiniOS)  += minios.o
tools/libs/ctrl/Makefile.common new file +44 -0

44 lines not on this page · raw message

tools/libs/devicemodel/Makefile.common new file +6 -0
new file mode 100644
index 0000000000..a7bf7c35bb
@@ -0,0 +1,6 @@
+OBJS-y                 += core.o
+OBJS-$(CONFIG_Linux)   += common.o
+OBJS-$(CONFIG_FreeBSD) += common.o
+OBJS-$(CONFIG_SunOS)   += compat.o
+OBJS-$(CONFIG_NetBSD)  += compat.o
+OBJS-$(CONFIG_MiniOS)  += compat.o
tools/libs/evtchn/Makefile.common new file +6 -0
new file mode 100644
index 0000000000..20629f521a
@@ -0,0 +1,6 @@
+OBJS-y                 += core.o
+OBJS-$(CONFIG_Linux)   += linux.o
+OBJS-$(CONFIG_FreeBSD) += freebsd.o
+OBJS-$(CONFIG_SunOS)   += solaris.o
+OBJS-$(CONFIG_NetBSD)  += netbsd.o
+OBJS-$(CONFIG_MiniOS)  += minios.o
tools/libs/foreignmemory/Makefile.common new file +6 -0
new file mode 100644
index 0000000000..ff3b1d4f3e
@@ -0,0 +1,6 @@
+OBJS-y                 += core.o
+OBJS-$(CONFIG_Linux)   += linux.o
+OBJS-$(CONFIG_FreeBSD) += freebsd.o
+OBJS-$(CONFIG_SunOS)   += compat.o solaris.o
+OBJS-$(CONFIG_NetBSD)  += netbsd.o
+OBJS-$(CONFIG_MiniOS)  += minios.o
tools/libs/gnttab/Makefile.common new file +8 -0
new file mode 100644
index 0000000000..759e36e1cb
@@ -0,0 +1,8 @@
+OBJS-GNTTAB            += gnttab_core.o
+OBJS-GNTSHR            += gntshr_core.o
+
+OBJS-$(CONFIG_Linux)   += $(OBJS-GNTTAB) $(OBJS-GNTSHR) linux.o
+OBJS-$(CONFIG_MiniOS)  += $(OBJS-GNTTAB) gntshr_unimp.o minios.o
+OBJS-$(CONFIG_FreeBSD) += $(OBJS-GNTTAB) $(OBJS-GNTSHR) freebsd.o
+OBJS-$(CONFIG_NetBSD)  += $(OBJS-GNTTAB) $(OBJS-GNTSHR) netbsd.o
+OBJS-$(CONFIG_SunOS)   += gnttab_unimp.o gntshr_unimp.o
tools/libs/guest/Makefile.common new file +84 -0

84 lines not on this page · raw message

tools/libs/toolcore/Makefile.common new file +1 -0
new file mode 100644
index 0000000000..9ade6c12bf
@@ -0,0 +1 @@
+OBJS-y	+= handlereg.o
tools/libs/toollog/Makefile.common new file +2 -0
new file mode 100644
index 0000000000..c053ac6a73
@@ -0,0 +1,2 @@
+OBJS-y	+= xtl_core.o
+OBJS-y	+= xtl_logger_stdio.o
Signature · 1 line
Anthony PERARD
#30 lore raw

PATCH v2 26/29 tools/xenstore: introduce Makefile.common to be used by stubdom

In reply to Anthony PERARD

Also change stubdom to depends on Makefile.common.

---

Notes:
v2:
- reviewed

 stubdom/Makefile               |  4 ++--
 tools/xenstore/Makefile        | 33 +++------------------------------
 tools/xenstore/Makefile.common | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 32 deletions(-)
 create mode 100644 tools/xenstore/Makefile.common
stubdom/Makefile +2 -2
index fbc63a5063..6b804824ba 100644
@@ -371,10 +371,10 @@ endef
 
 $(foreach lib,$(STUB_LIBS),$(eval $(call BUILD_lib,$(lib))))
 
-xenstore/stamp: $(XEN_ROOT)/tools/xenstore/Makefile
+xenstore/stamp: $(XEN_ROOT)/tools/xenstore/Makefile.common
 	$(do_links)
 
-xenstorepvh/stamp: $(XEN_ROOT)/tools/xenstore/Makefile
+xenstorepvh/stamp: $(XEN_ROOT)/tools/xenstore/Makefile.common
 	$(do_links)
 
 LINK_DIRS := xenstore xenstorepvh $(foreach dir,$(STUB_LIBS),libs-$(XEN_TARGET_ARCH)/$(dir))
tools/xenstore/Makefile +3 -30
index 830052c65f..1b66190cc5 100644
@@ -1,31 +1,7 @@
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += -Werror
-# Include configure output (config.h)
-CFLAGS += -include $(XEN_ROOT)/tools/config.h
-CFLAGS += -I./include
-CFLAGS += $(CFLAGS_libxenevtchn)
-CFLAGS += $(CFLAGS_libxenctrl)
-CFLAGS += $(CFLAGS_libxenguest)
-CFLAGS += $(CFLAGS_libxentoolcore)
-CFLAGS += -DXEN_LIB_STORED="\"$(XEN_LIB_STORED)\""
-CFLAGS += -DXEN_RUN_STORED="\"$(XEN_RUN_STORED)\""
-
-ifdef CONFIG_STUBDOM
-CFLAGS += -DNO_SOCKETS=1
-endif
-
-XENSTORED_OBJS-y := xenstored_core.o xenstored_watch.o xenstored_domain.o
-XENSTORED_OBJS-y += xenstored_transaction.o xenstored_control.o
-XENSTORED_OBJS-y += xs_lib.o talloc.o utils.o tdb.o hashtable.o
-
-XENSTORED_OBJS-$(CONFIG_Linux) += xenstored_posix.o
-XENSTORED_OBJS-$(CONFIG_NetBSD) += xenstored_posix.o
-XENSTORED_OBJS-$(CONFIG_FreeBSD) += xenstored_posix.o
-XENSTORED_OBJS-$(CONFIG_MiniOS) += xenstored_minios.o
-
-$(XENSTORED_OBJS-y): CFLAGS += $(CFLAGS_libxengnttab)
+include Makefile.common
 
 xenstored: LDLIBS += $(LDLIBS_libxenevtchn)
 xenstored: LDLIBS += $(LDLIBS_libxengnttab)
@@ -65,9 +41,6 @@ clients: xenstore $(CLIENTS) xenstore-control
 xenstored: $(XENSTORED_OBJS-y)
 	$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ $(APPEND_LDFLAGS)
 
-xenstored.a: $(XENSTORED_OBJS-y)
-	$(AR) cr $@ $^
-
 $(CLIENTS): xenstore
 	ln -f xenstore $@
 
@@ -81,8 +54,8 @@ xs_tdb_dump: xs_tdb_dump.o utils.o tdb.o talloc.o
 	$(CC) $(LDFLAGS) $^ -o $@ $(APPEND_LDFLAGS)
 
 .PHONY: clean
-clean:
-	$(RM) *.a *.o $(TARGETS) $(DEPS_RM)
+clean::
+	$(RM) $(TARGETS) $(DEPS_RM)
 
 .PHONY: distclean
 distclean: clean
tools/xenstore/Makefile.common new file +33 -0
new file mode 100644
index 0000000000..21b78b0538
@@ -0,0 +1,33 @@
+# Makefile shared with stubdom
+
+XENSTORED_OBJS-y := xenstored_core.o xenstored_watch.o xenstored_domain.o
+XENSTORED_OBJS-y += xenstored_transaction.o xenstored_control.o
+XENSTORED_OBJS-y += xs_lib.o talloc.o utils.o tdb.o hashtable.o
+
+XENSTORED_OBJS-$(CONFIG_Linux) += xenstored_posix.o
+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
+CFLAGS += $(CFLAGS_libxenevtchn)
+CFLAGS += $(CFLAGS_libxenctrl)
+CFLAGS += $(CFLAGS_libxenguest)
+CFLAGS += $(CFLAGS_libxentoolcore)
+CFLAGS += -DXEN_LIB_STORED="\"$(XEN_LIB_STORED)\""
+CFLAGS += -DXEN_RUN_STORED="\"$(XEN_RUN_STORED)\""
+
+ifdef CONFIG_STUBDOM
+CFLAGS += -DNO_SOCKETS=1
+endif
+
+$(XENSTORED_OBJS-y): CFLAGS += $(CFLAGS_libxengnttab)
+
+xenstored.a: $(XENSTORED_OBJS-y)
+	$(AR) cr $@ $^
+
+clean::
+	$(RM) *.a *.o
Signature · 1 line
Anthony PERARD
#31 lore raw

PATCH v2 27/29 stubdom: build xenstore*-stubdom using new Makefile.common

In reply to Anthony PERARD

Makefile.common have everything needed by stubdom, when used with xenlibs.mk, so we don't need "Makefile" anymore.

Also, remove DESTDIR for "xenstore" related targets, "xenlibs.mk" doesn't use DESTDIR so its value doesn't matter.

---

Notes:
v2:
- reviewed

 stubdom/Makefile | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
stubdom/Makefile +6 -9
index 6b804824ba..1fa075b9ad 100644
@@ -346,8 +346,7 @@ define do_links
   cd $(dir $@); \
   ln -sf $(dir $<)include/*.h include/; \
   ln -sf $(dir $<)*.[ch] .; \
-  [ -e $(dir $<)Makefile.common ] && ln -sf $(dir $<)Makefile.common . ||:; \
-  ln -sf $(dir $<)Makefile .
+  ln -sf $(dir $<)Makefile.common .
   touch $@
 endef
 
@@ -356,13 +355,11 @@ define BUILD_lib
  libxen$(1): libs-$$(XEN_TARGET_ARCH)/$(1)/libxen$(1).a
  libs-$$(XEN_TARGET_ARCH)/$(1)/libxen$(1).a: $$(LIBDEPS_$(1)) $$(LIBDEP_$(1))
  libs-$$(XEN_TARGET_ARCH)/$(1)/libxen$(1).a: mk-headers-$$(XEN_TARGET_ARCH) $$(NEWLIB_STAMPFILE) .phony
-	CPPFLAGS="$$(TARGET_CPPFLAGS)" CFLAGS="$$(TARGET_CFLAGS)" $$(MAKE) CONFIG_LIBXC_MINIOS=y $$(if $$(wildcard $$(@D)/Makefile.common),-f $(CURDIR)/xenlibs.mk) -C $$(@D) $$(@F)
+	CPPFLAGS="$$(TARGET_CPPFLAGS)" CFLAGS="$$(TARGET_CFLAGS)" $$(MAKE) CONFIG_LIBXC_MINIOS=y -f $(CURDIR)/xenlibs.mk -C $$(@D) $$(@F)
 
  clean-libxen$(1):
 	if [ -e libs-$$(XEN_TARGET_ARCH)/$(1)/Makefile.common ]; then \
 	    $$(MAKE) -f $(CURDIR)/xenlibs.mk -C libs-$$(XEN_TARGET_ARCH)/$(1) clean; \
-	elif [ -e libs-$$(XEN_TARGET_ARCH)/$(1)/Makefile ]; then \
-	    $$(MAKE) -C libs-$$(XEN_TARGET_ARCH)/$(1) clean; \
 	fi
 
  libs-$$(XEN_TARGET_ARCH)/$(1)/stamp: $$(XEN_ROOT)/tools/libs/$(1)/Makefile.common
@@ -494,7 +491,7 @@ xenstore-minios-config.mk: $(CURDIR)/xenstore-minios.cfg
 
 .PHONY: xenstore
 xenstore: $(CROSS_ROOT) xenstore-minios-config.mk
-	CPPFLAGS="$(TARGET_CPPFLAGS) $(shell cat xenstore-minios-config.mk)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C $@ xenstored.a CONFIG_STUBDOM=y
+	CPPFLAGS="$(TARGET_CPPFLAGS) $(shell cat xenstore-minios-config.mk)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -f $(CURDIR)/xenlibs.mk -C $@ xenstored.a CONFIG_STUBDOM=y
 
 #############
 # xenstorepvh
@@ -505,7 +502,7 @@ xenstorepvh-minios-config.mk: $(CURDIR)/xenstorepvh-minios.cfg
 
 .PHONY: xenstorepvh
 xenstorepvh: $(CROSS_ROOT) xenstorepvh-minios-config.mk
-	CPPFLAGS="$(TARGET_CPPFLAGS) $(shell cat xenstorepvh-minios-config.mk)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C $@ xenstored.a CONFIG_STUBDOM=y
+	CPPFLAGS="$(TARGET_CPPFLAGS) $(shell cat xenstorepvh-minios-config.mk)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -f $(CURDIR)/xenlibs.mk -C $@ xenstored.a CONFIG_STUBDOM=y
 
 ########
 # minios
@@ -657,8 +654,8 @@ clean:
 	rm -f *-minios-config.mk
 	rm -fr pkg-config
 	-[ ! -d ioemu ] || $(MAKE) DESTDIR= -C ioemu clean
-	-[ ! -d xenstore ] || $(MAKE) DESTDIR= -C xenstore clean
-	-[ ! -d xenstorepvh ] || $(MAKE) DESTDIR= -C xenstorepvh clean
+	-[ ! -d xenstore ] || $(MAKE) -f $(CURDIR)/xenlibs.mk -C xenstore clean
+	-[ ! -d xenstorepvh ] || $(MAKE) -f $(CURDIR)/xenlibs.mk -C xenstorepvh clean
 
 # clean the cross-compilation result
 .PHONY: crossclean
Signature · 1 line
Anthony PERARD
#32 lore raw

PATCH v2 28/29 stubdom: xenlibs linkfarm, ignore non-regular files

In reply to Anthony PERARD

When we will convert tools/ build system, their will be a need to replace some use of "vpath". This will done making symbolic links. Those symlinks are not wanted by stubdom build system when making a linkfarm for the Xen libraries. To avoid them, we will use find instead of plain shell globbing.

For example, there will be a link to "xen/lib/x86/cpuid.o" in "tools/libs/guest/".

---

Notes:
v2:
- reviewed

 stubdom/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
stubdom/Makefile +1 -1
index 1fa075b9ad..b312f710cd 100644
@@ -345,7 +345,7 @@ define do_links
   mkdir -p $(dir $@)include
   cd $(dir $@); \
   ln -sf $(dir $<)include/*.h include/; \
-  ln -sf $(dir $<)*.[ch] .; \
+  find $(dir $<) -maxdepth 1 -type f -name '*.[ch]' -exec ln -sf {} . \; ; \
   ln -sf $(dir $<)Makefile.common .
   touch $@
 endef
Signature · 1 line
Anthony PERARD
#33 lore raw

PATCH v2 29/29 tools/ocaml: fix build dependency target

In reply to Anthony PERARD

They are two competiting spelling for the variable holding the path to "tools/ocaml", $(TOPLEVEL) and $(OCAML_TOPLEVEL). The "Makefile.rules" which is included in all ocaml Makefiles have one rule which make use of that variable which is then sometime unset. When building "ocaml/xenstored", make isn't capable of generating ".ocamldep.make" because $(TOPLEVEL) isn't defined in this case.

This can fail with an error like this when paths.ml have been regenerated:
Error: Files define.cmx and paths.cmx
make inconsistent assumptions over interface Paths

This patch fix ".ocamldep.make" rule by always spelling the variable $(OCAML_TOPLEVEL).

---

Notes:
v2:
- new patch

 tools/ocaml/libs/eventchn/Makefile   | 8 ++++----
 tools/ocaml/libs/mmap/Makefile       | 8 ++++----
 tools/ocaml/libs/xb/Makefile         | 8 ++++----
 tools/ocaml/libs/xc/Makefile         | 8 ++++----
 tools/ocaml/libs/xentoollog/Makefile | 8 ++++----
 tools/ocaml/libs/xl/Makefile         | 8 ++++----
 tools/ocaml/libs/xs/Makefile         | 8 ++++----
 tools/ocaml/Makefile.rules           | 2 +-
 8 files changed, 29 insertions(+), 29 deletions(-)
tools/ocaml/libs/eventchn/Makefile +4 -4
index 154efd4a8e..7362a28d9e 100644
@@ -1,6 +1,6 @@
-TOPLEVEL=$(CURDIR)/../..
-XEN_ROOT=$(TOPLEVEL)/../..
-include $(TOPLEVEL)/common.make
+OCAML_TOPLEVEL=$(CURDIR)/../..
+XEN_ROOT=$(OCAML_TOPLEVEL)/../..
+include $(OCAML_TOPLEVEL)/common.make
 
 CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_xeninclude)
 
@@ -31,5 +31,5 @@ install: $(LIBS) META
 uninstall:
 	$(OCAMLFIND) remove -destdir $(OCAMLDESTDIR) xeneventchn
 
-include $(TOPLEVEL)/Makefile.rules
+include $(OCAML_TOPLEVEL)/Makefile.rules
 
tools/ocaml/libs/mmap/Makefile +4 -4
index df45819df5..a621537135 100644
@@ -1,6 +1,6 @@
-TOPLEVEL=$(CURDIR)/../..
-XEN_ROOT=$(TOPLEVEL)/../..
-include $(TOPLEVEL)/common.make
+OCAML_TOPLEVEL=$(CURDIR)/../..
+XEN_ROOT=$(OCAML_TOPLEVEL)/../..
+include $(OCAML_TOPLEVEL)/common.make
 
 OBJS = xenmmap
 INTF = $(foreach obj, $(OBJS),$(obj).cmi)
@@ -26,5 +26,5 @@ install: $(LIBS) META
 uninstall:
 	$(OCAMLFIND) remove -destdir $(OCAMLDESTDIR) xenmmap
 
-include $(TOPLEVEL)/Makefile.rules
+include $(OCAML_TOPLEVEL)/Makefile.rules
 
tools/ocaml/libs/xb/Makefile +4 -4
index be4499147e..ff4428af6d 100644
@@ -1,6 +1,6 @@
-TOPLEVEL=$(CURDIR)/../..
-XEN_ROOT=$(TOPLEVEL)/../..
-include $(TOPLEVEL)/common.make
+OCAML_TOPLEVEL=$(CURDIR)/../..
+XEN_ROOT=$(OCAML_TOPLEVEL)/../..
+include $(OCAML_TOPLEVEL)/common.make
 
 CFLAGS += -I../mmap
 CFLAGS += $(CFLAGS_libxenctrl) # For xen_mb()
@@ -49,4 +49,4 @@ install: $(LIBS) META
 uninstall:
 	$(OCAMLFIND) remove -destdir $(OCAMLDESTDIR) xenbus
 
-include $(TOPLEVEL)/Makefile.rules
+include $(OCAML_TOPLEVEL)/Makefile.rules
tools/ocaml/libs/xc/Makefile +4 -4
index b6da4fdbaf..67acc46bee 100644
@@ -1,6 +1,6 @@
-TOPLEVEL=$(CURDIR)/../..
-XEN_ROOT=$(TOPLEVEL)/../..
-include $(TOPLEVEL)/common.make
+OCAML_TOPLEVEL=$(CURDIR)/../..
+XEN_ROOT=$(OCAML_TOPLEVEL)/../..
+include $(OCAML_TOPLEVEL)/common.make
 
 CFLAGS += -I../mmap $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
 CFLAGS += $(APPEND_CFLAGS)
@@ -38,4 +38,4 @@ xenctrl_abi_check.h: abi-check xenctrl_stubs.c xenctrl.ml
 
 GENERATED_FILES += xenctrl_abi_check.h
 
-include $(TOPLEVEL)/Makefile.rules
+include $(OCAML_TOPLEVEL)/Makefile.rules
tools/ocaml/libs/xentoollog/Makefile +4 -4
index 593f9e9e9d..9ede2fd124 100644
@@ -1,6 +1,6 @@
-TOPLEVEL=$(CURDIR)/../..
-XEN_ROOT=$(TOPLEVEL)/../..
-include $(TOPLEVEL)/common.make
+OCAML_TOPLEVEL=$(CURDIR)/../..
+XEN_ROOT=$(OCAML_TOPLEVEL)/../..
+include $(OCAML_TOPLEVEL)/common.make
 
 # allow mixed declarations and code
 CFLAGS += -Wno-declaration-after-statement
@@ -62,4 +62,4 @@ install: $(LIBS) META
 uninstall:
 	ocamlfind remove -destdir $(OCAMLDESTDIR) xentoollog
 
-include $(TOPLEVEL)/Makefile.rules
+include $(OCAML_TOPLEVEL)/Makefile.rules
tools/ocaml/libs/xl/Makefile +4 -4
index cbe1569cc5..7c1c4edced 100644
@@ -1,6 +1,6 @@
-TOPLEVEL=$(CURDIR)/../..
-XEN_ROOT=$(TOPLEVEL)/../..
-include $(TOPLEVEL)/common.make
+OCAML_TOPLEVEL=$(CURDIR)/../..
+XEN_ROOT=$(OCAML_TOPLEVEL)/../..
+include $(OCAML_TOPLEVEL)/common.make
 
 # ignore unused generated functions and allow mixed declarations and code
 CFLAGS += -Wno-unused -Wno-declaration-after-statement
@@ -68,4 +68,4 @@ install: $(LIBS) META
 uninstall:
 	$(OCAMLFIND) remove -destdir $(OCAMLDESTDIR) xenlight
 
-include $(TOPLEVEL)/Makefile.rules
+include $(OCAML_TOPLEVEL)/Makefile.rules
tools/ocaml/libs/xs/Makefile +4 -4
index 572efb76c4..e934bbb550 100644
@@ -1,6 +1,6 @@
-TOPLEVEL=$(CURDIR)/../..
-XEN_ROOT=$(TOPLEVEL)/../..
-include $(TOPLEVEL)/common.make
+OCAML_TOPLEVEL=$(CURDIR)/../..
+XEN_ROOT=$(OCAML_TOPLEVEL)/../..
+include $(OCAML_TOPLEVEL)/common.make
 
 OCAMLINCLUDE += -I ../xb/
 OCAMLOPTFLAGS += -for-pack Xenstore
@@ -43,7 +43,7 @@ install: $(LIBS) META
 uninstall:
 	$(OCAMLFIND) remove -destdir $(OCAMLDESTDIR) xenstore
 
-include $(TOPLEVEL)/Makefile.rules
+include $(OCAML_TOPLEVEL)/Makefile.rules
 
 genpath-target = $(call buildmakevars2module,paths.ml)
 $(eval $(genpath-target))
tools/ocaml/Makefile.rules +1 -1
index abfbc64ce0..7e4db457a1 100644
@@ -44,7 +44,7 @@ META: META.in
 
 ALL_OCAML_OBJ_SOURCES=$(addsuffix .ml, $(ALL_OCAML_OBJS))
 
-.ocamldep.make: $(ALL_OCAML_OBJ_SOURCES) Makefile $(TOPLEVEL)/Makefile.rules
+.ocamldep.make: $(ALL_OCAML_OBJ_SOURCES) Makefile $(OCAML_TOPLEVEL)/Makefile.rules
 	$(call quiet-command, $(OCAMLDEP) $(ALL_OCAML_OBJ_SOURCES) *.mli $o,MLDEP,)
 
 clean: $(CLEAN_HOOKS)
Signature · 1 line
Anthony PERARD
Acked-by on v2 29/29
#34 lore raw

Re: [XEN PATCH v2 29/29] tools/ocaml: fix build dependency target

Quoted 14 lines · Anthony PERARD

This patch fix ".ocamldep.make" rule by always spelling the variable $(OCAML_TOPLEVEL).

---

Notes:
v2:
- new patch

Quoted 8 lines
tools/ocaml/libs/eventchn/Makefile   | 8 ++++----
tools/ocaml/libs/mmap/Makefile       | 8 ++++----
tools/ocaml/libs/xb/Makefile         | 8 ++++----
tools/ocaml/libs/xc/Makefile         | 8 ++++----
tools/ocaml/libs/xentoollog/Makefile | 8 ++++----
tools/ocaml/libs/xl/Makefile         | 8 ++++----
tools/ocaml/libs/xs/Makefile         | 8 ++++----
tools/ocaml/Makefile.rules           | 2 +-

I am fine with this but in general think that the OCaml part should be built using Dune (but invoked from Make), which is now the standard tool to build OCaml projects and is simple, fast, and accurate. Edwin maintains such a build for all development work on the OCaml side but it is not upstreamed.

— C

#35 lore raw

Re: [XEN PATCH v2 29/29] tools/ocaml: fix build dependency target

Quoted 23 lines · Christian Lindig
Quoted 14 lines · Anthony PERARD

This patch fix ".ocamldep.make" rule by always spelling the variable $(OCAML_TOPLEVEL).

---

Notes:
v2:
- new patch

Quoted 8 lines
tools/ocaml/libs/eventchn/Makefile   | 8 ++++----
tools/ocaml/libs/mmap/Makefile       | 8 ++++----
tools/ocaml/libs/xb/Makefile         | 8 ++++----
tools/ocaml/libs/xc/Makefile         | 8 ++++----
tools/ocaml/libs/xentoollog/Makefile | 8 ++++----
tools/ocaml/libs/xl/Makefile         | 8 ++++----
tools/ocaml/libs/xs/Makefile         | 8 ++++----
tools/ocaml/Makefile.rules           | 2 +-
Quoted 3 lines

I am fine with this but in general think that the OCaml part should be built using Dune (but invoked from Make), which is now the standard tool to build OCaml projects and is simple, fast, and accurate. Edwin maintains such a build for all development work on the OCaml side but it is not upstreamed.

ocaml-dune doesn't seems to be available on debian oldstable. So I don't think we can use it for now.

But thanks for pointing that out.

Signature · 1 line
Anthony PERARD
#36 lore raw

Re: [XEN PATCH v2 29/29] tools/ocaml: fix build dependency target

Quoted 28 lines · Anthony PERARD
Quoted 23 lines · Christian Lindig
Quoted 22 lines · Anthony PERARD

This patch fix ".ocamldep.make" rule by always spelling the variable $(OCAML_TOPLEVEL).

---

Notes:
v2:
- new patch

tools/ocaml/libs/eventchn/Makefile   | 8 ++++----
tools/ocaml/libs/mmap/Makefile       | 8 ++++----
tools/ocaml/libs/xb/Makefile         | 8 ++++----
tools/ocaml/libs/xc/Makefile         | 8 ++++----
tools/ocaml/libs/xentoollog/Makefile | 8 ++++----
tools/ocaml/libs/xl/Makefile         | 8 ++++----
tools/ocaml/libs/xs/Makefile         | 8 ++++----
tools/ocaml/Makefile.rules           | 2 +-
Quoted 9 lines
Quoted 3 lines

I am fine with this but in general think that the OCaml part should be built using Dune (but invoked from Make), which is now the standard tool to build OCaml projects and is simple, fast, and accurate. Edwin maintains such a build for all development work on the OCaml side but it is not upstreamed.

ocaml-dune doesn't seems to be available on debian oldstable. So I don't think we can use it for now.

But thanks for pointing that out.

I think we should try to add it as an optional build-system: when available use it, and at some point in the future remove the old one.
It is pretty much impossible to do development on the codebase without it, any developer who wants to make the changes to the OCaml code will likely want it. (Of course those who only want to build and install oxenstored may not require dune, and may be fine with the Makefiles as they wouldn't require incremental builds or editor support).

Best regards,
--Edwin

Quoted 2 lines
Signature · 1 line
Anthony PERARD
#37 lore raw
In reply to Anthony PERARD

Hi,

There's quite a few patch in this series that are reviewed and could be committed. The one reviewed don't depends on the other ones.

The list I've gathered that I think are reviewed properly are:

11: tools/xenstore: Cleanup makefile
14: libs: rename LDUSELIBS to LDLIBS and use it instead of APPEND_LDFLAGS 15: libs: Remove need for *installlocal targets
16: libs,tools/include: Clean "clean" targets
17: libs: Rename $(SRCS-y) to $(OBJS-y)
18: libs/guest: rename ELF_OBJS to LIBELF_OBJS
19: libs/guest: rework CFLAGS
20: libs/store: use of -iquote instead of -I
21: libs/stat: Fix and rework python-bindings build
22: libs/stat: Fix and rework perl-binding build
24: stubdom: introduce xenlibs.mk
25: tools/libs: create Makefile.common to be used by stubdom build system 26: tools/xenstore: introduce Makefile.common to be used by stubdom 27: stubdom: build xenstore*-stubdom using new Makefile.common 28: stubdom: xenlibs linkfarm, ignore non-regular files
29: tools/ocaml: fix build dependency target

(I didn't a run with them on our gitlab ci, and no build issue.)

Thanks,

Signature · 1 line
Anthony PERARD
#38 lore raw
Quoted 1 line · Anthony PERARD

Hi,

Hi Anthony,

Quoted 5 lines

There's quite a few patch in this series that are reviewed and could be committed. The one reviewed don't depends on the other ones.

The list I've gathered that I think are reviewed properly are:

Quoted 16 lines

11: tools/xenstore: Cleanup makefile
14: libs: rename LDUSELIBS to LDLIBS and use it instead of APPEND_LDFLAGS 15: libs: Remove need for *installlocal targets
16: libs,tools/include: Clean "clean" targets
17: libs: Rename $(SRCS-y) to $(OBJS-y)
18: libs/guest: rename ELF_OBJS to LIBELF_OBJS
19: libs/guest: rework CFLAGS
20: libs/store: use of -iquote instead of -I
21: libs/stat: Fix and rework python-bindings build
22: libs/stat: Fix and rework perl-binding build
24: stubdom: introduce xenlibs.mk
25: tools/libs: create Makefile.common to be used by stubdom build system 26: tools/xenstore: introduce Makefile.common to be used by stubdom 27: stubdom: build xenstore*-stubdom using new Makefile.common 28: stubdom: xenlibs linkfarm, ignore non-regular files
29: tools/ocaml: fix build dependency target

Committed.

Quoted 2 lines

(I didn't a run with them on our gitlab ci, and no build issue.)

I am guessing you mean you *did* a run?

Cheers,

Signature · 1 line
Julien Grall
#39 lore raw
In reply to Anthony PERARD

Hi Anthony,

Quoted 26 lines · Anthony PERARD

Hi,

There's quite a few patch in this series that are reviewed and could be committed. The one reviewed don't depends on the other ones.

The list I've gathered that I think are reviewed properly are:

11: tools/xenstore: Cleanup makefile
14: libs: rename LDUSELIBS to LDLIBS and use it instead of APPEND_LDFLAGS 15: libs: Remove need for *installlocal targets
16: libs,tools/include: Clean "clean" targets
17: libs: Rename $(SRCS-y) to $(OBJS-y)
18: libs/guest: rename ELF_OBJS to LIBELF_OBJS
19: libs/guest: rework CFLAGS
20: libs/store: use of -iquote instead of -I
21: libs/stat: Fix and rework python-bindings build
22: libs/stat: Fix and rework perl-binding build
24: stubdom: introduce xenlibs.mk
25: tools/libs: create Makefile.common to be used by stubdom build system 26: tools/xenstore: introduce Makefile.common to be used by stubdom 27: stubdom: build xenstore*-stubdom using new Makefile.common 28: stubdom: xenlibs linkfarm, ignore non-regular files
29: tools/ocaml: fix build dependency target

Quoted 1 line

(I didn't a run with them on our gitlab ci, and no build issue.)

If you do not mind resend a v3 with the remaining patches rebase on staging, I can spend some time next week to test and review them.

Maybe you can also put in the fixes for the header check.

Cheers
Bertrand