1ccba8b64SMathieu Desnoyers# SPDX-License-Identifier: GPL-2.0+ OR MIT
2fdeb89d8SMathieu Desnoyers
3fdeb89d8SMathieu Desnoyersifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
4fdeb89d8SMathieu DesnoyersCLANG_FLAGS += -no-integrated-as
5fdeb89d8SMathieu Desnoyersendif
6fdeb89d8SMathieu Desnoyers
72279bfc0SMathieu Desnoyerstop_srcdir = ../../../..
8fdeb89d8SMathieu Desnoyers
9233e667eSMathieu DesnoyersCFLAGS += -O2 -Wall -g -I./ $(KHDR_INCLUDES) -L$(OUTPUT) -Wl,-rpath=./ \
10ccba8b64SMathieu Desnoyers	  $(CLANG_FLAGS) -I$(top_srcdir)/tools/include
11ccba8b64SMathieu DesnoyersLDLIBS += -lpthread -ldl
12ccba8b64SMathieu Desnoyers
13ccba8b64SMathieu Desnoyers# Own dependencies because we only want to build against 1st prerequisite, but
14ccba8b64SMathieu Desnoyers# still track changes to header files and depend on shared object.
15cead7206SMathieu DesnoyersOVERRIDE_TARGETS = 1
16ee31fff0SMathieu Desnoyers
17ee31fff0SMathieu DesnoyersTEST_GEN_PROGS = basic_test basic_percpu_ops_test basic_percpu_ops_mm_cid_test param_test \
18ccba8b64SMathieu Desnoyers		param_test_benchmark param_test_compare_twice param_test_mm_cid \
19ccba8b64SMathieu Desnoyers		param_test_mm_cid_benchmark param_test_mm_cid_compare_twice
20ccba8b64SMathieu Desnoyers
21ccba8b64SMathieu DesnoyersTEST_GEN_PROGS_EXTENDED = librseq.so
22ccba8b64SMathieu Desnoyers
23b9167c80SMichael EllermanTEST_PROGS = run_param_test.sh
24b9167c80SMichael Ellerman
25ccba8b64SMathieu DesnoyersTEST_FILES := settings
26ccba8b64SMathieu Desnoyers
27ccba8b64SMathieu Desnoyersinclude ../lib.mk
28ccba8b64SMathieu Desnoyers
29ccba8b64SMathieu Desnoyers$(OUTPUT)/librseq.so: rseq.c rseq.h rseq-*.h
30ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) -shared -fPIC $< $(LDLIBS) -o $@
31ccba8b64SMathieu Desnoyers
32ccba8b64SMathieu Desnoyers$(OUTPUT)/%: %.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
33cead7206SMathieu Desnoyers	$(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
34*c0d87e43SMathieu Desnoyers
35cead7206SMathieu Desnoyers$(OUTPUT)/basic_percpu_ops_mm_cid_test: basic_percpu_ops_test.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
36ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID $< $(LDLIBS) -lrseq -o $@
37ccba8b64SMathieu Desnoyers
38ccba8b64SMathieu Desnoyers$(OUTPUT)/param_test_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
39ccba8b64SMathieu Desnoyers					rseq.h rseq-*.h
40ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) -DBENCHMARK $< $(LDLIBS) -lrseq -o $@
41ccba8b64SMathieu Desnoyers
42ccba8b64SMathieu Desnoyers$(OUTPUT)/param_test_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
43ee31fff0SMathieu Desnoyers					rseq.h rseq-*.h
44ee31fff0SMathieu Desnoyers	$(CC) $(CFLAGS) -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@
45ee31fff0SMathieu Desnoyers
46ee31fff0SMathieu Desnoyers$(OUTPUT)/param_test_mm_cid: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
47ee31fff0SMathieu Desnoyers					rseq.h rseq-*.h
48ee31fff0SMathieu Desnoyers	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID $< $(LDLIBS) -lrseq -o $@
49ee31fff0SMathieu Desnoyers
50ee31fff0SMathieu Desnoyers$(OUTPUT)/param_test_mm_cid_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
51ee31fff0SMathieu Desnoyers					rseq.h rseq-*.h
52ee31fff0SMathieu Desnoyers	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID -DBENCHMARK $< $(LDLIBS) -lrseq -o $@
53ee31fff0SMathieu Desnoyers
54ee31fff0SMathieu Desnoyers$(OUTPUT)/param_test_mm_cid_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
55					rseq.h rseq-*.h
56	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@
57