INCLUDES += rtapi

$(patsubst ./rtapi/%,../include/%,$(wildcard ./rtapi/*.h)): ../include/%.h: ./rtapi/%.h
	cp $^ $@
$(patsubst ./rtapi/%,../include/%,$(wildcard ./rtapi/*.hh)): ../include/%.hh: ./rtapi/%.hh
	cp $^ $@

ifeq ($(BUILD_SYS),uspace)

RTAPI_APP_SRCS := \
	rtapi/uspace_rtapi_app.cc \
	rtapi/uspace_rtapi_parport.cc \
	rtapi/uspace_rtapi_string.c \
	rtapi/rtapi_pci.cc
USERSRCS += $(RTAPI_APP_SRCS)

$(call TOOBJSDEPS, rtapi/rtapi_pci.cc): EXTRAFLAGS += $(LIBUDEV_CFLAGS) -O0
$(call TOOBJSDEPS, $(RTAPI_APP_SRCS)): EXTRAFLAGS += -DSIM \
	-UULAPI -DRTAPI -pthread
../bin/rtapi_app: $(call TOOBJS, $(RTAPI_APP_SRCS))
	$(ECHO) Linking $(notdir $@)
	$(Q)$(CXX) -rdynamic $(LDFLAGS) -o $@ $^ -ldl -pthread -lrt $(LIBUDEV_LIBS)
TARGETS += ../bin/rtapi_app
endif

TEST_RTAPI_VSNPRINTF_SRCS := rtapi/test_rtapi_vsnprintf.c
USERSRCS += $(TEST_RTAPI_VSNPRINTF_SRCS)
$(call TOOBJSDEPS, $(TEST_RTAPI_VSNPRINTF_SRCS)): EXTRAFLAGS += -DSIM
../bin/test_rtapi_vsnprintf: $(call TOOBJS, $(TEST_RTAPI_VSNPRINTF_SRCS))
	$(ECHO) Linking $(notdir $@)
	@$(CXX) -rdynamic $(LDFLAGS) -o $@ $^
TARGETS += ../bin/test_rtapi_vsnprintf

