18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0+ OR MIT
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
48c2ecf20Sopenharmony_ciCLANG_FLAGS += -no-integrated-as
58c2ecf20Sopenharmony_ciendif
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_citop_srcdir = ../../../..
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ciCFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L$(OUTPUT) -Wl,-rpath=./ \
108c2ecf20Sopenharmony_ci	  $(CLANG_FLAGS) -I$(top_srcdir)/tools/include
118c2ecf20Sopenharmony_ciLDLIBS += -lpthread -ldl
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci# Own dependencies because we only want to build against 1st prerequisite, but
148c2ecf20Sopenharmony_ci# still track changes to header files and depend on shared object.
158c2ecf20Sopenharmony_ciOVERRIDE_TARGETS = 1
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciTEST_GEN_PROGS = basic_test basic_percpu_ops_test param_test \
188c2ecf20Sopenharmony_ci		param_test_benchmark param_test_compare_twice
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciTEST_GEN_PROGS_EXTENDED = librseq.so
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciTEST_PROGS = run_param_test.sh
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciTEST_FILES := settings
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciinclude ../lib.mk
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci$(OUTPUT)/librseq.so: rseq.c rseq.h rseq-*.h
298c2ecf20Sopenharmony_ci	$(CC) $(CFLAGS) -shared -fPIC $< $(LDLIBS) -o $@
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci$(OUTPUT)/%: %.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
328c2ecf20Sopenharmony_ci	$(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci$(OUTPUT)/param_test_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
358c2ecf20Sopenharmony_ci					rseq.h rseq-*.h
368c2ecf20Sopenharmony_ci	$(CC) $(CFLAGS) -DBENCHMARK $< $(LDLIBS) -lrseq -o $@
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci$(OUTPUT)/param_test_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
398c2ecf20Sopenharmony_ci					rseq.h rseq-*.h
408c2ecf20Sopenharmony_ci	$(CC) $(CFLAGS) -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@
41