Skip to content

Commit 5ed1952

Browse files
Yu Zhangsean-jc
authored andcommitted
KVM: selftests: Add new CFLAGS to generate dependency files
Add "-MD" in CFLAGS to generate dependency files. Currently, each time a header file is updated in KVM selftest, we will have to run "make clean && make" to rebuild the whole test suite. By adding new compiling flags and dependent rules in Makefile, we do not need to make clean && make each time a header file is updated. Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com> Link: https://lore.kernel.org/r/20230601080338.212942-1-yu.c.zhang@linux.intel.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent d4ec586 commit 5ed1952

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tools/testing/selftests/kvm/Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(ARCH_DIR))
184184
TEST_GEN_PROGS_EXTENDED += $(TEST_GEN_PROGS_EXTENDED_$(ARCH_DIR))
185185
LIBKVM += $(LIBKVM_$(ARCH_DIR))
186186

187+
OVERRIDE_TARGETS = 1
188+
187189
# lib.mak defines $(OUTPUT), prepends $(OUTPUT)/ to $(TEST_GEN_PROGS), and most
188190
# importantly defines, i.e. overwrites, $(CC) (unless `make -e` or `make CC=`,
189191
# which causes the environment variable to override the makefile).
@@ -198,7 +200,7 @@ else
198200
LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
199201
endif
200202
CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
201-
-Wno-gnu-variable-sized-type-not-at-end \
203+
-Wno-gnu-variable-sized-type-not-at-end -MD\
202204
-fno-builtin-memcmp -fno-builtin-memcpy -fno-builtin-memset \
203205
-fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
204206
-I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \
@@ -225,7 +227,18 @@ LIBKVM_S_OBJ := $(patsubst %.S, $(OUTPUT)/%.o, $(LIBKVM_S))
225227
LIBKVM_STRING_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_STRING))
226228
LIBKVM_OBJS = $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ) $(LIBKVM_STRING_OBJ)
227229

228-
EXTRA_CLEAN += $(LIBKVM_OBJS) cscope.*
230+
TEST_GEN_OBJ = $(patsubst %, %.o, $(TEST_GEN_PROGS))
231+
TEST_GEN_OBJ += $(patsubst %, %.o, $(TEST_GEN_PROGS_EXTENDED))
232+
TEST_DEP_FILES = $(patsubst %.o, %.d, $(TEST_GEN_OBJ))
233+
TEST_DEP_FILES += $(patsubst %.o, %.d, $(LIBKVM_OBJS))
234+
-include $(TEST_DEP_FILES)
235+
236+
$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): %: %.o
237+
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIBKVM_OBJS) $(LDLIBS) -o $@
238+
$(TEST_GEN_OBJ): $(OUTPUT)/%.o: %.c
239+
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
240+
241+
EXTRA_CLEAN += $(LIBKVM_OBJS) $(TEST_DEP_FILES) $(TEST_GEN_OBJ) cscope.*
229242

230243
x := $(shell mkdir -p $(sort $(dir $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ))))
231244
$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c

0 commit comments

Comments
 (0)