
ifeq ($(USE_CHECK),yes)

INCLUDES += $(CHECK_TESTS)

../include/%.h: ./$(CHECK_DIR)/%.h
	cp $^ $@


TESTS = check_tests
check_PROGRAMS = ../bin/check_tests 
check_tests_SOURCES = $(addprefix $(CHECK_TESTS)/, \
	timers.c \
	check-util.c \
	check_tests.c)


check_tests_CFLAGS = $(CHECK_CFLAGS)
check_tests_LDADD = ../lib/libmtalk.so.0 \
	../lib/libmkprotobuf.so.0 \
	../lib/liblinuxcnchal.so.0 \
	../lib/liblinuxcncini.so.0

$(call TOOBJSDEPS, $(check_tests_SOURCES)) : EXTRAFLAGS += \
	$(CHECK_CFLAGS) -DULAPI -DBUILD_SYS_USER_DSO -fPIC -pthread

TARGETS += $(check_PROGRAMS)

CHECKS  += $(check_PROGRAMS) # for make check
C_CHECKS  += $(check_PROGRAMS)


../bin/check_tests: $(call TOOBJS, $(check_tests_SOURCES)) \
	$(check_tests_LDADD)
	$(Q)$(CC) -o $@ $^  $(CHECK_LIBS) -lpthread

USERSRCS += $(check_tests_SOURCES)


# /tmp/foo_ring_expanded-c.i:
# 	$(CC)  -E $(CFLAGS) $(CHECK_CFLAGS) -DULAPI  -DBUILD_SYS_USER_DSO  -I. -Irtapi -x c -std=c11 \
# 	$(CHECK_TESTS)/check_tests.c | $(CB) > $@
# TARGETS += /tmp/foo_ring_expanded-c.i
endif
