Merge tag 'ceph-for-5.11-rc2' of git://github.com/ceph/ceph-client
[linux-2.6-microblaze.git] / tools / testing / selftests / vm / Makefile
1 # SPDX-License-Identifier: GPL-2.0
2 # Makefile for vm selftests
3
4 include local_config.mk
5
6 uname_M := $(shell uname -m 2>/dev/null || echo not)
7 MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/ppc64/')
8
9 # Without this, failed build products remain, with up-to-date timestamps,
10 # thus tricking Make (and you!) into believing that All Is Well, in subsequent
11 # make invocations:
12 .DELETE_ON_ERROR:
13
14 # Avoid accidental wrong builds, due to built-in rules working just a little
15 # bit too well--but not quite as well as required for our situation here.
16 #
17 # In other words, "make userfaultfd" is supposed to fail to build at all,
18 # because this Makefile only supports either "make" (all), or "make /full/path".
19 # However,  the built-in rules, if not suppressed, will pick up CFLAGS and the
20 # initial LDLIBS (but not the target-specific LDLIBS, because those are only
21 # set for the full path target!). This causes it to get pretty far into building
22 # things despite using incorrect values such as an *occasionally* incomplete
23 # LDLIBS.
24 MAKEFLAGS += --no-builtin-rules
25
26 CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
27 LDLIBS = -lrt -lpthread
28 TEST_GEN_FILES = compaction_test
29 TEST_GEN_FILES += gup_test
30 TEST_GEN_FILES += hmm-tests
31 TEST_GEN_FILES += hugepage-mmap
32 TEST_GEN_FILES += hugepage-shm
33 TEST_GEN_FILES += khugepaged
34 TEST_GEN_FILES += map_fixed_noreplace
35 TEST_GEN_FILES += map_hugetlb
36 TEST_GEN_FILES += map_populate
37 TEST_GEN_FILES += mlock-random-test
38 TEST_GEN_FILES += mlock2-tests
39 TEST_GEN_FILES += mremap_dontunmap
40 TEST_GEN_FILES += mremap_test
41 TEST_GEN_FILES += on-fault-limit
42 TEST_GEN_FILES += thuge-gen
43 TEST_GEN_FILES += transhuge-stress
44 TEST_GEN_FILES += userfaultfd
45
46 ifeq ($(MACHINE),x86_64)
47 CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_32bit_program.c -m32)
48 CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_64bit_program.c)
49 CAN_BUILD_WITH_NOPIE := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_program.c -no-pie)
50
51 TARGETS := protection_keys
52 BINARIES_32 := $(TARGETS:%=%_32)
53 BINARIES_64 := $(TARGETS:%=%_64)
54
55 ifeq ($(CAN_BUILD_WITH_NOPIE),1)
56 CFLAGS += -no-pie
57 endif
58
59 ifeq ($(CAN_BUILD_I386),1)
60 TEST_GEN_FILES += $(BINARIES_32)
61 endif
62
63 ifeq ($(CAN_BUILD_X86_64),1)
64 TEST_GEN_FILES += $(BINARIES_64)
65 endif
66 else
67
68 ifneq (,$(findstring $(MACHINE),ppc64))
69 TEST_GEN_FILES += protection_keys
70 endif
71
72 endif
73
74 ifneq (,$(filter $(MACHINE),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sh64 sparc64 x86_64))
75 TEST_GEN_FILES += va_128TBswitch
76 TEST_GEN_FILES += virtual_address_range
77 TEST_GEN_FILES += write_to_hugetlbfs
78 endif
79
80 TEST_PROGS := run_vmtests.sh
81
82 TEST_FILES := test_vmalloc.sh
83
84 KSFT_KHDR_INSTALL := 1
85 include ../lib.mk
86
87 ifeq ($(MACHINE),x86_64)
88 BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32))
89 BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))
90
91 define gen-target-rule-32
92 $(1) $(1)_32: $(OUTPUT)/$(1)_32
93 .PHONY: $(1) $(1)_32
94 endef
95
96 define gen-target-rule-64
97 $(1) $(1)_64: $(OUTPUT)/$(1)_64
98 .PHONY: $(1) $(1)_64
99 endef
100
101 ifeq ($(CAN_BUILD_I386),1)
102 $(BINARIES_32): CFLAGS += -m32
103 $(BINARIES_32): LDLIBS += -lrt -ldl -lm
104 $(BINARIES_32): %_32: %.c
105         $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(notdir $^) $(LDLIBS) -o $@
106 $(foreach t,$(TARGETS),$(eval $(call gen-target-rule-32,$(t))))
107 endif
108
109 ifeq ($(CAN_BUILD_X86_64),1)
110 $(BINARIES_64): CFLAGS += -m64
111 $(BINARIES_64): LDLIBS += -lrt -ldl
112 $(BINARIES_64): %_64: %.c
113         $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(notdir $^) $(LDLIBS) -o $@
114 $(foreach t,$(TARGETS),$(eval $(call gen-target-rule-64,$(t))))
115 endif
116
117 # x86_64 users should be encouraged to install 32-bit libraries
118 ifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),01)
119 all: warn_32bit_failure
120
121 warn_32bit_failure:
122         @echo "Warning: you seem to have a broken 32-bit build" 2>&1;           \
123         echo  "environment. This will reduce test coverage of 64-bit" 2>&1;     \
124         echo  "kernels. If you are using a Debian-like distribution," 2>&1;     \
125         echo  "try:"; 2>&1;                                                     \
126         echo  "";                                                               \
127         echo  "  apt-get install gcc-multilib libc6-i386 libc6-dev-i386";       \
128         echo  "";                                                               \
129         echo  "If you are using a Fedora-like distribution, try:";              \
130         echo  "";                                                               \
131         echo  "  yum install glibc-devel.*i686";                                \
132         exit 0;
133 endif
134 endif
135
136 $(OUTPUT)/mlock-random-test: LDLIBS += -lcap
137
138 $(OUTPUT)/gup_test: ../../../../mm/gup_test.h
139
140 $(OUTPUT)/hmm-tests: local_config.h
141
142 # HMM_EXTRA_LIBS may get set in local_config.mk, or it may be left empty.
143 $(OUTPUT)/hmm-tests: LDLIBS += $(HMM_EXTRA_LIBS)
144
145 local_config.mk local_config.h: check_config.sh
146         /bin/sh ./check_config.sh $(CC)
147
148 EXTRA_CLEAN += local_config.mk local_config.h
149
150 ifeq ($(HMM_EXTRA_LIBS),)
151 all: warn_missing_hugelibs
152
153 warn_missing_hugelibs:
154         @echo ; \
155         echo "Warning: missing libhugetlbfs support. Some HMM tests will be skipped." ; \
156         echo
157 endif