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
7fdeb89d8SMathieu DesnoyersCFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ \
8fdeb89d8SMathieu Desnoyers	  $(CLANG_FLAGS)
9ccba8b64SMathieu DesnoyersLDLIBS += -lpthread
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
15ccba8b64SMathieu DesnoyersTEST_GEN_PROGS = basic_test basic_percpu_ops_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
22ccba8b64SMathieu Desnoyersinclude ../lib.mk
23ccba8b64SMathieu Desnoyers
24ccba8b64SMathieu Desnoyers$(OUTPUT)/librseq.so: rseq.c rseq.h rseq-*.h
25ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) -shared -fPIC $< $(LDLIBS) -o $@
26ccba8b64SMathieu Desnoyers
27ccba8b64SMathieu Desnoyers$(OUTPUT)/%: %.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
28ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
29ccba8b64SMathieu Desnoyers
30ccba8b64SMathieu Desnoyers$(OUTPUT)/param_test_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
31ccba8b64SMathieu Desnoyers					rseq.h rseq-*.h
32ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) -DBENCHMARK $< $(LDLIBS) -lrseq -o $@
33ccba8b64SMathieu Desnoyers
34ccba8b64SMathieu Desnoyers$(OUTPUT)/param_test_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
35ccba8b64SMathieu Desnoyers					rseq.h rseq-*.h
36ccba8b64SMathieu Desnoyers	$(CC) $(CFLAGS) -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@
37