diff mbox series

[XEN,37/57] tools/xentop: rework makefile

Message ID 20211206170241.13165-38-anthony.perard@citrix.com (mailing list archive)
State New, archived
Headers show
Series Toolstack build system improvement, toward non-recursive makefiles | expand

Commit Message

Anthony PERARD Dec. 6, 2021, 5:02 p.m. UTC
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.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/Makefile        |  2 +-
 tools/xentop/Makefile | 19 ++++++++-----------
 2 files changed, 9 insertions(+), 12 deletions(-)

Comments

Andrew Cooper Dec. 16, 2021, 6:36 p.m. UTC | #1
On 06/12/2021 17:02, Anthony PERARD wrote:
> diff --git a/tools/xentop/Makefile b/tools/xentop/Makefile
> index 0034114684..1e52b29b37 100644
> --- a/tools/xentop/Makefile
> +++ b/tools/xentop/Makefile
> @@ -13,24 +13,23 @@
>  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

$(TARGETS) ?

>  
> @@ -38,11 +37,9 @@ install: xentop
>  uninstall:
>  	rm -f $(DESTDIR)$(sbindir)/xentop
>  
> -endif
> -
>  .PHONY: clean
>  clean:
> -	rm -f xentop xentop.o $(DEPS_RM)
> +	rm -f $(TARGETS) xentop.o $(DEPS_RM)

$(RM) *.o ?

~Andrew

>  
>  .PHONY: distclean
>  distclean: clean
diff mbox series

Patch

diff --git a/tools/Makefile b/tools/Makefile
index 79b4c7e3de..0c1d8b64a4 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -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
 
diff --git a/tools/xentop/Makefile b/tools/xentop/Makefile
index 0034114684..1e52b29b37 100644
--- a/tools/xentop/Makefile
+++ b/tools/xentop/Makefile
@@ -13,24 +13,23 @@ 
 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
 
@@ -38,11 +37,9 @@  install: xentop
 uninstall:
 	rm -f $(DESTDIR)$(sbindir)/xentop
 
-endif
-
 .PHONY: clean
 clean:
-	rm -f xentop xentop.o $(DEPS_RM)
+	rm -f $(TARGETS) xentop.o $(DEPS_RM)
 
 .PHONY: distclean
 distclean: clean