-CFLAGS += -Wall -O2 -I../../../../usr/include
+LIBDIR := ../../../lib
+BPFOBJ := $(LIBDIR)/bpf/bpf.o
-TEST_GEN_PROGS = test_verifier test_maps test_lru_map
+CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR)
+
- test_objs = test_verifier test_tag test_maps test_lru_map test_lpm_map
++TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map
- TEST_PROGS := $(test_objs) test_kmod.sh
- TEST_FILES := $(test_objs)
+ TEST_PROGS := test_kmod.sh
- all: $(test_objs)
-
+.PHONY: all clean force
+
+# force a rebuild of BPFOBJ when its dependencies are updated
+force:
+
+$(BPFOBJ): force
+ $(MAKE) -C $(dir $(BPFOBJ))
+
+$(test_objs): $(BPFOBJ)
+
include ../lib.mk
-
- clean:
- $(RM) $(test_objs)
# Makefile for vm selftests
CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
- BINARIES = compaction_test
- BINARIES += hugepage-mmap
- BINARIES += hugepage-shm
- BINARIES += map_hugetlb
- BINARIES += mlock2-tests
- BINARIES += on-fault-limit
- BINARIES += thuge-gen
- BINARIES += transhuge-stress
- BINARIES += userfaultfd
- BINARIES += userfaultfd_hugetlb
- BINARIES += userfaultfd_shmem
- BINARIES += mlock-random-test
-
- all: $(BINARIES)
- %: %.c
- $(CC) $(CFLAGS) -o $@ $^ -lrt
- userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
- $(CC) $(CFLAGS) -O2 -o $@ $< -lpthread
-
- userfaultfd_hugetlb: userfaultfd.c ../../../../usr/include/linux/kernel.h
+ LDLIBS = -lrt
+ TEST_GEN_FILES = compaction_test
+ TEST_GEN_FILES += hugepage-mmap
+ TEST_GEN_FILES += hugepage-shm
+ TEST_GEN_FILES += map_hugetlb
+ TEST_GEN_FILES += mlock2-tests
+ TEST_GEN_FILES += on-fault-limit
+ TEST_GEN_FILES += thuge-gen
+ TEST_GEN_FILES += transhuge-stress
+ TEST_GEN_FILES += userfaultfd
++TEST_GEN_FILES += userfaultfd_hugetlb
++TEST_GEN_FILES += userfaultfd_shmem
+ TEST_GEN_FILES += mlock-random-test
+
+ TEST_PROGS := run_vmtests
+
+ include ../lib.mk
+
+ $(OUTPUT)/userfaultfd: LDLIBS += -lpthread ../../../../usr/include/linux/kernel.h
++
++$(OUTPUT)/userfaultfd_hugetlb: userfaultfd.c ../../../../usr/include/linux/kernel.h
+ $(CC) $(CFLAGS) -DHUGETLB_TEST -O2 -o $@ $< -lpthread
+
- userfaultfd_shmem: userfaultfd.c ../../../../usr/include/linux/kernel.h
++$(OUTPUT)/userfaultfd_shmem: userfaultfd.c ../../../../usr/include/linux/kernel.h
+ $(CC) $(CFLAGS) -DSHMEM_TEST -O2 -o $@ $< -lpthread
+
- mlock-random-test: mlock-random-test.c
- $(CC) $(CFLAGS) -o $@ $< -lcap
+ $(OUTPUT)/mlock-random-test: LDLIBS += -lcap
../../../../usr/include/linux/kernel.h:
make -C ../../../.. headers_install