ifdef CONFIG_RTAI_EXAMPLES
subdirs += examples
endif

ALL_SUB_DIRS := $(subdirs) 
MOD_SUB_DIRS := 
SUB_DIRS     := 

ifdef CONFIG_RTAI_NEW_CPP
SUB_DIRS     += $(subdirs)
MOD_SUB_DIRS += $(subdirs)
endif


EXTRA_CFLAGS := -I. -I../watchdog/ 
EXTRA_CXXFLAGS := -I. -I../watchdog/

rtai_cpp-objs := init.o builtin.o rtai_wrapper.o linux_wrapper.o \
                 module.o time.o count.o task.o sem.o mbx.o rtf.o \
                 tbx.o bits.o iostream.o mutex.o cond.o trace.o com.o


ifneq ($(CONFIG_RTAI_NEW_CPP),)
  M_OBJS += rtai_cpp.o
endif

ifdef TOPDIR
include $(TOPDIR)/Rules.make
else
all:
	make -C .. modules SUBDIRS=rtai_cpp
clean:
	make -C .. subclean SUBDIRS=rtai_cpp
endif

rtai_cpp.o: $(rtai_cpp-objs) crtbegin.o crtend.o crtmbegin.o crtmend.o
	$(LD) -r -o $@ $(rtai_cpp-objs)

crtbegin.o : crt.c
	$(CC) $(CFLAGS) -DCRT_BEGIN -c crt.c -o crtbegin.o
	
crtend.o : crt.c
	$(CC) $(CFLAGS) -DCRT_END -c crt.c -o crtend.o

crtmbegin.o : crt.c
	$(CC) $(CFLAGS) -DCRT_BEGIN -DUSE_MAIN -c crt.c -o crtmbegin.o

crtmend.o : crt.c 
	$(CC) $(CFLAGS) -DCRT_END -DUSE_MAIN -c crt.c -o crtmend.o
