selftests/landlock: Fix out-of-tree builds
These changes simplify the Makefile and handle these 5 ways to build Landlock tests: - make -C tools/testing/selftests/landlock - make -C tools/testing/selftests TARGETS=landlock gen_tar - make TARGETS=landlock kselftest-gen_tar - make TARGETS=landlock O=build kselftest-gen_tar - make -C /tmp/linux TARGETS=landlock O=/tmp/build kselftest-gen_tar This also makes $(KHDR_INCLUDES) available to other test collections when building in their directory. Fixes:f1227dc7d0
("selftests/landlock: fix broken include of linux/landlock.h") Fixes:3bb267a361
("selftests: drop khdr make target") Cc: Anders Roxell <anders.roxell@linaro.org> Cc: Guillaume Tucker <guillaume.tucker@collabora.com> Cc: Mark Brown <broonie@kernel.org> Cc: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Mickaël Salaün <mic@digikod.net> Link: https://lore.kernel.org/r/20220909103402.1501802-1-mic@digikod.net
This commit is contained in:
parent
80e78fcce8
commit
a52540522c
2 changed files with 14 additions and 9 deletions
|
@ -1,6 +1,11 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
#
|
||||||
|
# First run: make -C ../../../.. headers_install
|
||||||
|
|
||||||
CFLAGS += -Wall -O2 $(KHDR_INCLUDES)
|
CFLAGS += -Wall -O2 $(KHDR_INCLUDES)
|
||||||
|
LDLIBS += -lcap
|
||||||
|
|
||||||
|
LOCAL_HDRS += common.h
|
||||||
|
|
||||||
src_test := $(wildcard *_test.c)
|
src_test := $(wildcard *_test.c)
|
||||||
|
|
||||||
|
@ -8,14 +13,10 @@ TEST_GEN_PROGS := $(src_test:.c=)
|
||||||
|
|
||||||
TEST_GEN_PROGS_EXTENDED := true
|
TEST_GEN_PROGS_EXTENDED := true
|
||||||
|
|
||||||
OVERRIDE_TARGETS := 1
|
# Static linking for short targets:
|
||||||
top_srcdir := ../../../..
|
$(TEST_GEN_PROGS_EXTENDED): LDFLAGS += -static
|
||||||
|
|
||||||
include ../lib.mk
|
include ../lib.mk
|
||||||
|
|
||||||
khdr_dir = $(top_srcdir)/usr/include
|
# Static linking for targets with $(OUTPUT)/ prefix:
|
||||||
|
$(TEST_GEN_PROGS_EXTENDED): LDFLAGS += -static
|
||||||
$(OUTPUT)/true: true.c
|
|
||||||
$(LINK.c) $< $(LDLIBS) -o $@ -static
|
|
||||||
|
|
||||||
$(OUTPUT)/%_test: %_test.c $(khdr_dir)/linux/landlock.h ../kselftest_harness.h common.h
|
|
||||||
$(LINK.c) $< $(LDLIBS) -o $@ -lcap -I$(khdr_dir)
|
|
||||||
|
|
|
@ -42,6 +42,10 @@ endif
|
||||||
selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
|
selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
|
||||||
top_srcdir = $(selfdir)/../../..
|
top_srcdir = $(selfdir)/../../..
|
||||||
|
|
||||||
|
ifeq ($(KHDR_INCLUDES),)
|
||||||
|
KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include
|
||||||
|
endif
|
||||||
|
|
||||||
# The following are built by lib.mk common compile rules.
|
# The following are built by lib.mk common compile rules.
|
||||||
# TEST_CUSTOM_PROGS should be used by tests that require
|
# TEST_CUSTOM_PROGS should be used by tests that require
|
||||||
# custom build rule and prevent common build rule use.
|
# custom build rule and prevent common build rule use.
|
||||||
|
|
Loading…
Add table
Reference in a new issue