mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-07 22:34:18 +08:00
211929fd3f
Commitb2d35fa5fc
("selftests: add headers_install to lib.mk") added khdr target to run headers_install target from the main Makefile. The logic uses KSFT_KHDR_INSTALL and top_srcdir as controls to initialize variables and include files to run headers_install from the top level Makefile. There are a few problems with this logic. 1. Exposes top_srcdir to all tests 2. Common logic impacts all tests 3. Uses KSFT_KHDR_INSTALL, top_srcdir, and khdr in an adhoc way. Tests add "khdr" dependency in their Makefiles to TEST_PROGS_EXTENDED in some cases, and STATIC_LIBS in other cases. This makes this framework confusing to use. The common logic that runs for all tests even when KSFT_KHDR_INSTALL isn't defined by the test. top_srcdir is initialized to a default value when test doesn't initialize it. It works for all tests without a sub-dir structure and tests with sub-dir structure fail to build. e.g: make -C sparc64/drivers/ or make -C drivers/dma-buf ../../lib.mk:20: ../../../../scripts/subarch.include: No such file or directory make: *** No rule to make target '../../../../scripts/subarch.include'. Stop. There is no reason to require all tests to define top_srcdir and there is no need to require tests to add khdr dependency using adhoc changes to TEST_* and other variables. Fix it with a consistent use of KSFT_KHDR_INSTALL and top_srcdir from tests that have the dependency on headers_install. Change common logic to include khdr target define and "all" target with dependency on khdr when KSFT_KHDR_INSTALL is defined. Only tests that have dependency on headers_install have to define just the KSFT_KHDR_INSTALL, and top_srcdir variables and there is no need to specify khdr dependency in the test Makefiles. Fixes:b2d35fa5fc
("selftests: add headers_install to lib.mk") Cc: stable@vger.kernel.org Signed-off-by: Shuah Khan <shuah@kernel.org>
57 lines
1.8 KiB
Makefile
57 lines
1.8 KiB
Makefile
all:
|
|
|
|
top_srcdir = ../../../..
|
|
KSFT_KHDR_INSTALL := 1
|
|
UNAME_M := $(shell uname -m)
|
|
|
|
LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/ucall.c lib/sparsebit.c
|
|
LIBKVM_x86_64 = lib/x86_64/processor.c lib/x86_64/vmx.c
|
|
LIBKVM_aarch64 = lib/aarch64/processor.c
|
|
|
|
TEST_GEN_PROGS_x86_64 = x86_64/platform_info_test
|
|
TEST_GEN_PROGS_x86_64 += x86_64/set_sregs_test
|
|
TEST_GEN_PROGS_x86_64 += x86_64/sync_regs_test
|
|
TEST_GEN_PROGS_x86_64 += x86_64/vmx_tsc_adjust_test
|
|
TEST_GEN_PROGS_x86_64 += x86_64/cr4_cpuid_sync_test
|
|
TEST_GEN_PROGS_x86_64 += x86_64/state_test
|
|
TEST_GEN_PROGS_x86_64 += x86_64/evmcs_test
|
|
TEST_GEN_PROGS_x86_64 += dirty_log_test
|
|
|
|
TEST_GEN_PROGS_aarch64 += dirty_log_test
|
|
|
|
TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
|
|
LIBKVM += $(LIBKVM_$(UNAME_M))
|
|
|
|
INSTALL_HDR_PATH = $(top_srcdir)/usr
|
|
LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
|
|
LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
|
|
CFLAGS += -O2 -g -std=gnu99 -I$(LINUX_TOOL_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(UNAME_M) -I..
|
|
LDFLAGS += -pthread
|
|
|
|
# After inclusion, $(OUTPUT) is defined and
|
|
# $(TEST_GEN_PROGS) starts with $(OUTPUT)/
|
|
include ../lib.mk
|
|
|
|
STATIC_LIBS := $(OUTPUT)/libkvm.a
|
|
LIBKVM_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM))
|
|
EXTRA_CLEAN += $(LIBKVM_OBJ) $(STATIC_LIBS) cscope.*
|
|
|
|
x := $(shell mkdir -p $(sort $(dir $(LIBKVM_OBJ))))
|
|
$(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
|
|
|
|
$(OUTPUT)/libkvm.a: $(LIBKVM_OBJ)
|
|
$(AR) crs $@ $^
|
|
|
|
all: $(STATIC_LIBS)
|
|
$(TEST_GEN_PROGS): $(STATIC_LIBS)
|
|
|
|
cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
|
|
cscope:
|
|
$(RM) cscope.*
|
|
(find $(include_paths) -name '*.h' \
|
|
-exec realpath --relative-base=$(PWD) {} \;; \
|
|
find . -name '*.c' \
|
|
-exec realpath --relative-base=$(PWD) {} \;) | sort -u > cscope.files
|
|
cscope -b
|