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
7ef89d054SMichael EllermanCFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L$(OUTPUT) -Wl,-rpath=./ \
8fdeb89d8SMathieu Desnoyers	  $(CLANG_FLAGS)
9233e667eSMathieu DesnoyersLDLIBS += -lpthread -ldl
10ccba8b64SMathieu Desnoyers
11ccba8b64SMathieu Desnoyers# Own dependencies because we only want to build against 1st prerequisite, but
12ccba8b64SMathieu Desnoyers# still track changes to header files and depend on shared object.
13ccba8b64SMathieu DesnoyersOVERRIDE_TARGETS = 1
14ccba8b64SMathieu Desnoyers
15cead7206SMathieu DesnoyersTEST_GEN_PROGS = basic_test basic_percpu_ops_test basic_percpu_ops_mm_cid_test param_test \
16*ee31fff0SMathieu Desnoyers		param_test_benchmark param_test_compare_twice param_test_mm_cid \
17*ee31fff0SMathieu Desnoyers		param_test_mm_cid_benchmark param_test_mm_cid_compare_twice
18ccba8b64SMathieu Desnoyers
19ccba8b64SMathieu DesnoyersTEST_GEN_PROGS_EXTENDED = librseq.so
20ccba8b64SMathieu Desnoyers
21ccba8b64SMathieu DesnoyersTEST_PROGS = run_param_test.sh
22ccba8b64SMathieu Desnoyers
23b9167c80SMichael EllermanTEST_FILES := settings
24b9167c80SMichael Ellerman
25ccba8b64SMathieu Desnoyersinclude ../lib.mk
26ccba8b64SMathieu Desnoyers
27ccba8b64SMathieu Desnoyers$(OUTPUT)/librseq.so: rseq.c rseq.h rseq-*.h
28ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) -shared -fPIC $< $(LDLIBS) -o $@
29ccba8b64SMathieu Desnoyers
30ccba8b64SMathieu Desnoyers$(OUTPUT)/%: %.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
31ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
32ccba8b64SMathieu Desnoyers
33cead7206SMathieu Desnoyers$(OUTPUT)/basic_percpu_ops_mm_cid_test: basic_percpu_ops_test.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
34cead7206SMathieu Desnoyers	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID_ID $< $(LDLIBS) -lrseq -o $@
35cead7206SMathieu Desnoyers
36ccba8b64SMathieu Desnoyers$(OUTPUT)/param_test_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
37ccba8b64SMathieu Desnoyers					rseq.h rseq-*.h
38ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) -DBENCHMARK $< $(LDLIBS) -lrseq -o $@
39ccba8b64SMathieu Desnoyers
40ccba8b64SMathieu Desnoyers$(OUTPUT)/param_test_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
41ccba8b64SMathieu Desnoyers					rseq.h rseq-*.h
42ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@
43*ee31fff0SMathieu Desnoyers
44*ee31fff0SMathieu Desnoyers$(OUTPUT)/param_test_mm_cid: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
45*ee31fff0SMathieu Desnoyers					rseq.h rseq-*.h
46*ee31fff0SMathieu Desnoyers	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID $< $(LDLIBS) -lrseq -o $@
47*ee31fff0SMathieu Desnoyers
48*ee31fff0SMathieu Desnoyers$(OUTPUT)/param_test_mm_cid_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
49*ee31fff0SMathieu Desnoyers					rseq.h rseq-*.h
50*ee31fff0SMathieu Desnoyers	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID -DBENCHMARK $< $(LDLIBS) -lrseq -o $@
51*ee31fff0SMathieu Desnoyers
52*ee31fff0SMathieu Desnoyers$(OUTPUT)/param_test_mm_cid_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
53*ee31fff0SMathieu Desnoyers					rseq.h rseq-*.h
54*ee31fff0SMathieu Desnoyers	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@
55