MSGCOMP_DIR=machinetalk/msgcomponents

# NANOPB_CFLAGS is set in  protobuf/Submakefile
# for msgcomponents when building an RT comp

# or at least should - the reference to NANOPB_CFLAGS isnt resolved here; no idea why

RTFLAGS +=   $(PROTO_NANOPB_CFLAGS)

obj-m += pbmsgs.o
pbmsgs-objs := \
	$(MSGCOMP_DIR)/pbmsgs.o	\
	$(PBGEN)/$(NAMESPACEDIR)/canon.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/emcclass.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/log.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/message.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/motcmds.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/object.npb.o  \
	$(PBGEN)/$(NAMESPACEDIR)/rtapi_message.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/rtapicommand.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/task.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/test.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/types.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/config.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/preview.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/status.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/ros.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/sample.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/jplan.npb.o \
	$(PBGEN)/$(NAMESPACEDIR)/value.npb.o


#obj-m += pbring.o
#pbring-objs := $(MSGCOMP_DIR)/pbring.o


ifneq "$(filter normal user-dso,$(BUILD_SYS))" ""
$(RTLIBDIR)/pbmsgs$(MODULE_EXT): $(addprefix $(OBJDIR)/,$(pbmsgs-objs))
#$(RTLIBDIR)/pbring$(MODULE_EXT): $(addprefix $(OBJDIR)/,$(pbring-objs))
endif


../include/%.h: ./$(MSGCOMP_DIR)/%.h
	$(ECHO) Copying header file $@
	$(Q)cp $^ $@

# ifeq ($(BUILD_EXAMPLES),yes)

# RB_SRCS :=  $(addprefix hal/msgcomponents/, \
# 	ringbench.c)

# RB_CCFLAGS := -g
# RB_LDFLAGS := -g -lpthread

# $(call TOOBJSDEPS, $(RB_SRCS)) : EXTRAFLAGS += $(RB_CCFLAGS) -O0

# ../bin/ringbench: $(call TOOBJS, $(RB_SRCS)) \
# 	../lib/liblinuxcnchal.so
# 	$(ECHO) Linking $(notdir $@)
# 	$(Q)$(CC) -o $@ $^ $(LDFLAGS) $(RB_LDFLAGS)

# USERSRCS += $(RB_SRCS) $(RB_SRCS)
# TARGETS += ../bin/ringbench
# endif
