# (C) Finite State Machine Labs Inc. 2000 business@fsmlabs.com
#
# Released under the terms of GPL 2.
# Open RTLinux makes use of a patented process described in
# US Patent 5,995,745. Use of this process is governed
# by the Open RTLinux Patent License which can be obtained from
# www.fsmlabs.com/PATENT or by sending email to
# licensequestions@fsmlabs.com

ALL = periodic_test.o periodic_monitor oneshot_test.o oneshot_monitor linuxtime fifo_module.o fifo_app thread_app thread_time.o hello.o hello_app rt_process.o

ifdef CONFIG_RTL_FP_SUPPORT
ALL += fp_test.o fp_app
endif

ifdef CONFIG_PSC
ALL += rtlsigirq_app rtlsigtimer_app rtlgethrtime_test psc_fifo_test psc_dbg_oob psc_dbg_div0 psc_dbg_libcall
endif

all : $(ALL)

ifneq ($(wildcard ../rtl.mk),)
include ../rtl.mk
endif

install: all
	@echo "Installing regression tests to" $(INSTDIR)/regression
	@mkdir -p $(INSTDIR)/regression
	@for head in $(ALL); do \
	   cp $$head $(INSTDIR)/regression; \
	done

clean: dummy
	rm -f *.o periodic_monitor modules.dep oneshot_monitor \
	rtlsigirq_app fifo_app linuxtime rtlsigtimer_app thread_app \
	rtlgethrtime_test psc_dbg_div0 psc_dbg_oob psc_dbg_libcall \
	psc_fifo_test rtlsetfp_test fp_app fp_test.o hello.o hello_app \
	rt_process.o switch_app state_app

thread_time.o: thread_time.c
	$(CC) ${INCLUDE} ${CFLAGS} -c thread_time.c

fp_test.o: fp_test.c
	$(CC) ${INCLUDE} ${CFLAGS} -c fp_test.c

switch_time.o: switch_time.c switch_test.h
	$(CC) ${INCLUDE} ${CFLAGS} -c switch_time.c

state_test.o: state_test.c state_common.h
	$(CC) ${INCLUDE} ${CFLAGS} -c state_test.c

fifo_module.o: fifo_module.c
	$(CC) ${INCLUDE} ${CFLAGS} -c fifo_module.c

rt_process.o: rt_process.c
	$(CC) ${CFLAGS} -c rt_process.c

hello.o: hello.c
	$(CC) ${INCLUDE} ${CFLAGS} -c hello.c

switch_module.o: switch_module.c
	$(CC) ${INCLUDE} ${CFLAGS} -c switch_module.c

periodic_test.o: periodic_test.c
	$(CC) ${INCLUDE} ${CFLAGS} -c periodic_test.c

periodic_monitor: periodic_monitor.c
	$(CC) ${INCLUDE} ${USER_CFLAGS} -o periodic_monitor periodic_monitor.c

oneshot_test.o: oneshot_test.c
	$(CC) ${INCLUDE} ${CFLAGS} -c oneshot_test.c

oneshot_monitor: oneshot_monitor.c
	$(CC) ${INCLUDE} ${USER_CFLAGS} -o oneshot_monitor oneshot_monitor.c

thread_app: thread_app.c
	$(CC) ${INCLUDE} ${USER_CFLAGS} -o thread_app thread_app.c

fp_app: fp_app.c
	$(CC) ${INCLUDE} ${USER_CFLAGS} -Wall -o fp_app fp_app.c

state_app: state_app.c state_common.h
	$(CC) ${INCLUDE} ${USER_CFLAGS} -Wall -o state_app state_app.c

switch_app: switch_app.c switch_test.h
	$(CC) ${INCLUDE} ${USER_CFLAGS} -Wall -o switch_app switch_app.c

fifo_app: fifo_app.c
	$(CC) ${INCLUDE} ${USER_CFLAGS} -o fifo_app fifo_app.c

hello_app: hello_app.c
	$(CC) ${INCLUDE} ${USER_CFLAGS} -o hello_app hello_app.c

linuxtime: linuxtime.c
	$(CC) ${INCLUDE} ${USER_CFLAGS} -o linuxtime linuxtime.c

rtlsigirq_app: rtlsigirq_app.c ../psc/librtlinux.a
	$(CC) ${INCLUDE} ${USER_CFLAGS} -o rtlsigirq_app rtlsigirq_app.c -L../psc/ -lrtlinux -lpthread

rtlsigtimer_app: rtlsigtimer_app.c ../psc/librtlinux.a
	$(CC) ${INCLUDE} ${USER_CFLAGS} -o rtlsigtimer_app rtlsigtimer_app.c -L../psc/ -lrtlinux -lpthread

rtlsetfp_test: rtlsetfp_test.c ../psc/librtlinux.a
	$(CC) ${INCLUDE} ${USER_CFLAGS} -o rtlsetfp_test rtlsetfp_test.c -L../psc/ -lrtlinux -lpthread

rtlgethrtime_test: rtlgethrtime_test.c ../psc/librtlinux.a
	$(CC) ${INCLUDE} ${USER_CFLAGS} -o rtlgethrtime_test rtlgethrtime_test.c -L../psc/ -lrtlinux -lpthread

psc_dbg_oob: psc_dbg_oob.c ../psc/librtlinux.a
	$(CC) ${INCLUDE} ${USER_CFLAGS} -g -o psc_dbg_oob psc_dbg_oob.c -L../psc/ -lrtlinux -lpthread

psc_dbg_div0: psc_dbg_div0.c ../psc/librtlinux.a
	$(CC) ${INCLUDE} ${USER_CFLAGS} -g -o psc_dbg_div0 psc_dbg_div0.c -L../psc/ -lrtlinux -lpthread

psc_dbg_libcall: psc_dbg_libcall.c ../psc/librtlinux.a
	$(CC) ${INCLUDE} ${USER_CFLAGS} -g -o psc_dbg_libcall psc_dbg_libcall.c -L../psc/ -lrtlinux -lpthread

psc_dbg_breakpoint: psc_dbg_breakpoint.c ../psc/librtlinux.a
	$(CC) ${INCLUDE} ${USER_CFLAGS} -g -o psc_dbg_breakpoint psc_dbg_breakpoint.c -L../psc/ -lrtlinux -lpthread

psc_fifo_test: psc_fifo_test.c ../psc/librtlinux.a
	$(CC) ${INCLUDE} ${USER_CFLAGS} -g -o psc_fifo_test psc_fifo_test.c -L../psc/ -lrtlinux -lpthread

rtlsigdeliv: rtlsigdeliv.c ../psc/librtlinux.a
	$(CC) -I../include -I../linux/include -g -o rtlsigdeliv rtlsigdeliv.c -L../psc -lrtlinux 
 
rtlsigdeliv-module.o: rtlsigdeliv-module.c
	$(CC) ${INCLUDE} ${CFLAGS} -c rtlsigdeliv-module.c
 
.PHONY: dummy

include $(RTL_DIR)/Rules.make
