diff mbox series

[kvm-unit-tests,v2,8/8] s390x/Makefile: add an extra `%.aux.o` target

Message ID 20230119114045.34553-9-mhartmay@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Some cleanup patches | expand

Commit Message

Marc Hartmayer Jan. 19, 2023, 11:40 a.m. UTC
It's unusual to create multiple files in one target rule, therefore
let's create an extra target for `%.aux.o`. As a side effect, this
change fixes the dependency tracking of the prerequisites of `.aux.o`
(lib/auxinfo.c wasn't listed before).

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
 s390x/Makefile | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Marc Hartmayer Jan. 19, 2023, 11:59 a.m. UTC | #1
Marc Hartmayer <mhartmay@linux.ibm.com> writes:

> It's unusual to create multiple files in one target rule, therefore
> let's create an extra target for `%.aux.o`. As a side effect, this
> change fixes the dependency tracking of the prerequisites of `.aux.o`
> (lib/auxinfo.c wasn't listed before).
>
> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> ---
>  s390x/Makefile | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/s390x/Makefile b/s390x/Makefile
> index 9a8e2af1b2be..6fa62416c0e9 100644
> --- a/s390x/Makefile
> +++ b/s390x/Makefile
> @@ -162,13 +162,14 @@ $(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPP
>  %.lds: %.lds.S $(asm-offsets)
>  	$(CPP) $(autodepend-flags) $(CPPFLAGS) -P -C -o $@ $<
>  
> +%.aux.o: $(SRCDIR)/lib/auxinfo.c
> +	$(CC) $(CFLAGS) -c -o $@ $^ -DPROGNAME=\"$(@:.aux.o=.elf)\"
> +
>  .SECONDEXPANSION:
> -%.elf: $(FLATLIBS) $(asmlib) $(SRCDIR)/s390x/flat.lds $$(snippets-obj) $$(snippet-hdr-obj) %.o
> -	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$@\"
> +%.elf: $(FLATLIBS) $(asmlib) $(SRCDIR)/s390x/flat.lds $$(snippets-obj) $$(snippet-hdr-obj) %.o %.aux.o
>  	@$(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds \
> -		$(filter %.o, $^) $(FLATLIBS) $(snippets-obj) $(snippet-hdr-obj) $(@:.elf=.aux.o) || \
> +		$(filter %.o, $^) $(FLATLIBS) $(snippets-obj) $(snippet-hdr-obj) || \
>  		{ echo "Failure probably caused by missing definition of gen-se-header executable"; exit 1; }
> -	$(RM) $(@:.elf=.aux.o)
>  	@chmod a-x $@
>  
>  # Secure Execution Customer Communication Key file
> -- 
> 2.34.1
>

I don’t have a strong opinion about this patch, but we could either
change the ARM & Power Makefiles as well or just drop this patch.
diff mbox series

Patch

diff --git a/s390x/Makefile b/s390x/Makefile
index 9a8e2af1b2be..6fa62416c0e9 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -162,13 +162,14 @@  $(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) $(SNIPP
 %.lds: %.lds.S $(asm-offsets)
 	$(CPP) $(autodepend-flags) $(CPPFLAGS) -P -C -o $@ $<
 
+%.aux.o: $(SRCDIR)/lib/auxinfo.c
+	$(CC) $(CFLAGS) -c -o $@ $^ -DPROGNAME=\"$(@:.aux.o=.elf)\"
+
 .SECONDEXPANSION:
-%.elf: $(FLATLIBS) $(asmlib) $(SRCDIR)/s390x/flat.lds $$(snippets-obj) $$(snippet-hdr-obj) %.o
-	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$@\"
+%.elf: $(FLATLIBS) $(asmlib) $(SRCDIR)/s390x/flat.lds $$(snippets-obj) $$(snippet-hdr-obj) %.o %.aux.o
 	@$(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds \
-		$(filter %.o, $^) $(FLATLIBS) $(snippets-obj) $(snippet-hdr-obj) $(@:.elf=.aux.o) || \
+		$(filter %.o, $^) $(FLATLIBS) $(snippets-obj) $(snippet-hdr-obj) || \
 		{ echo "Failure probably caused by missing definition of gen-se-header executable"; exit 1; }
-	$(RM) $(@:.elf=.aux.o)
 	@chmod a-x $@
 
 # Secure Execution Customer Communication Key file