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
15*cead7206SMathieu DesnoyersTEST_GEN_PROGS = basic_test basic_percpu_ops_test basic_percpu_ops_mm_cid_test param_test \
16ccba8b64SMathieu Desnoyers		param_test_benchmark param_test_compare_twice
17ccba8b64SMathieu Desnoyers
18ccba8b64SMathieu DesnoyersTEST_GEN_PROGS_EXTENDED = librseq.so
19ccba8b64SMathieu Desnoyers
20ccba8b64SMathieu DesnoyersTEST_PROGS = run_param_test.sh
21ccba8b64SMathieu Desnoyers
22b9167c80SMichael EllermanTEST_FILES := settings
23b9167c80SMichael Ellerman
24ccba8b64SMathieu Desnoyersinclude ../lib.mk
25ccba8b64SMathieu Desnoyers
26ccba8b64SMathieu Desnoyers$(OUTPUT)/librseq.so: rseq.c rseq.h rseq-*.h
27ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) -shared -fPIC $< $(LDLIBS) -o $@
28ccba8b64SMathieu Desnoyers
29ccba8b64SMathieu Desnoyers$(OUTPUT)/%: %.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
30ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
31ccba8b64SMathieu Desnoyers
32*cead7206SMathieu Desnoyers$(OUTPUT)/basic_percpu_ops_mm_cid_test: basic_percpu_ops_test.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
33*cead7206SMathieu Desnoyers	$(CC) $(CFLAGS) -DBUILDOPT_RSEQ_PERCPU_MM_CID_ID $< $(LDLIBS) -lrseq -o $@
34*cead7206SMathieu Desnoyers
35ccba8b64SMathieu Desnoyers$(OUTPUT)/param_test_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
36ccba8b64SMathieu Desnoyers					rseq.h rseq-*.h
37ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) -DBENCHMARK $< $(LDLIBS) -lrseq -o $@
38ccba8b64SMathieu Desnoyers
39ccba8b64SMathieu Desnoyers$(OUTPUT)/param_test_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
40ccba8b64SMathieu Desnoyers					rseq.h rseq-*.h
41ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@
42