tests/cpu-policy: Rework Makefile
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 15 Jun 2021 14:37:49 +0000 (15:37 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 9 Jul 2021 15:38:27 +0000 (16:38 +0100)
In particular, fill in the install/uninstall rules so this test can be
packaged to be automated sensibly.

Rework TARGET-y to be TARGETS, drop redundant -f's for $(RM), drop the
unconditional -O3 and use the default instead, and drop CFLAGS from the link
line but honour APPEND_LDFLAGS.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
tools/tests/cpu-policy/Makefile

index 70ff154da6b4eb08a16229b2e8d88a8a3b94bdad..93af9d76fa6834c9d9c2e8d327bd8f4dc37dc988 100644 (file)
@@ -1,21 +1,19 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-TARGET-y := test-cpu-policy
+TARGETS :=
 
 # For brevity, these tests make extensive use of designated initialisers in
 # anonymous unions, but GCCs older than 4.6 can't cope.  Ignore the test in
 # this case.
-ifneq ($(clang),y)
-TARGET-$(call cc-ver,$(CC),lt,0x040600) :=
-endif
-
-ifeq ($(TARGET-y),)
+ifneq ($(gcc)$(call cc-ver,$(CC),lt,0x040600),yy)
+TARGETS += test-cpu-policy
+else
 $(warning Test harness not built, use newer compiler than "$(CC)" (version $(shell $(CC) -dumpversion)))
 endif
 
 .PHONY: all
-all: $(TARGET-y)
+all: $(TARGETS)
 
 .PHONY: run
 run: $(TARGET-y)
@@ -23,23 +21,32 @@ run: $(TARGET-y)
 
 .PHONY: clean
 clean:
-       $(RM) -f -- *.o .*.d .*.d2 test-cpu-policy
+       $(RM) -- *.o $(TARGETS) $(DEPS_RM)
 
 .PHONY: distclean
 distclean: clean
-       $(RM) -f -- *~
+       $(RM) -- *~
 
 .PHONY: install
 install: all
+       $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
+       $(if $(TARGETS),$(INSTALL_PROG) $(TARGETS) $(DESTDIR)$(LIBEXEC_BIN))
 
 .PHONY: uninstall
+uninstall:
+       $(RM) -- $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/,$(TARGETS))
 
-CFLAGS += -Werror $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -O3
+CFLAGS += -Werror -D__XEN_TOOLS__
+CFLAGS += $(CFLAGS_xeninclude)
 CFLAGS += $(APPEND_CFLAGS)
 
+LDFLAGS += $(APPEND_LDFLAGS)
+
 vpath %.c ../../../xen/lib/x86
 
+%.o: Makefile
+
 test-cpu-policy: test-cpu-policy.o msr.o cpuid.o policy.o
-       $(CC) $(CFLAGS) $^ -o $@
+       $(CC) $^ -o $@ $(LDFLAGS)
 
 -include $(DEPS_INCLUDE)