diff mbox series

[06/12] selftests: lib.mk: Add rule to build object file from C source file

Message ID 20190114135144.26096-7-geert+renesas@glider.be (mailing list archive)
State New
Headers show
Series selftests: Miscellaneous fixes | expand

Commit Message

Geert Uytterhoeven Jan. 14, 2019, 1:51 p.m. UTC
Currently there are rules to compile and link one or more C or
assembler source files into a full executable, and to assemble a single
assembler source into an object file.

Add a generic rule to compile a single C source file into an object
file, for reuse of object files in multiple executables.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 tools/testing/selftests/lib.mk | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 8b0f16409ed7eb53..77a71264d8c5a743 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -141,6 +141,7 @@  clean:
 #
 ifneq ($(KBUILD_SRC),)
 LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
+COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
 COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
 LINK.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
 endif
@@ -151,6 +152,9 @@  ifeq ($(OVERRIDE_TARGETS),)
 $(OUTPUT)/%:%.c
 	$(LINK.c) $^ $(LDLIBS) -o $@
 
+$(OUTPUT)/%.o:%.c
+	$(COMPILE.c) $^ -o $@
+
 $(OUTPUT)/%.o:%.S
 	$(COMPILE.S) $^ -o $@