# $URL: http://subversion:8080/svn/gsc/trunk/drivers/LINUX/18AI32SSC1M/sbtest/makefile $
# $Rev: 13275 $
# $Date: 2011-12-19 16:23:25 -0600 (Mon, 19 Dec 2011) $

DEVICE		= 18ai32ssc1m
default:	all

CC			= gcc
CC_FLAGS	= -c -Wall
CC_FLAGS	+= -I.
CC_FLAGS	+= -I../driver
CC_FLAGS	+= -I../docsrc
CC_FLAGS	+= -I../utils
DEP_FILE	= makefile.dep
LIB_FILES	=  ../utils/${DEVICE}_utils.a
LIB_FILES	+= ../docsrc/${DEVICE}_dsl.a
LIB_FILES	+= ../utils/gsc_utils.a
TARGET		= sbtest
VPATH		=

ECHO	:= ${shell ls /bin/echo 2>/dev/null | wc -l}
ifeq ("${ECHO}","1")
ECHO	:= /bin/echo
else
ECHO	:= echo
endif

OBJ_FILES	=					\
			main.o				\
			service.o			\
								\
			reg_read.o			\
			reg_write.o			\
			reg_mod.o			\
			query.o				\
			initialize.o		\
			auto_calibrate.o	\
			auto_cal_bg.o		\
			rx_io_abort.o		\
			rx_io_mode.o		\
			rx_io_overflow.o	\
			rx_io_timeout.o		\
			rx_io_underflow.o	\
			ain_buf_clear.o		\
			ain_buf_level.o		\
			ain_buf_overflow.o	\
			ain_buf_thr_lvl.o	\
			ain_buf_thr_sts.o	\
			ain_buf_underflow.o	\
			ain_mode.o			\
			ain_range.o			\
			burst_busy.o		\
			burst_size.o		\
			burst_sync.o		\
			chan_active.o		\
			chan_first.o		\
			chan_last.o			\
			chan_single.o		\
			clock_enable.o		\
			data_format.o		\
			data_packing.o		\
			data_width.o		\
			input_sync.o		\
			io_inv.o			\
			irq0_sel.o			\
			irq1_sel.o			\
			rag_enable.o		\
			rag_nrate.o			\
			rbg_clk_src.o		\
			rbg_enable.o		\
			rbg_nrate.o			\
			samp_clk_src.o		\
			scan_marker.o		\
			aux_clk_mode.o		\
			aux_in_pol.o		\
			aux_noise.o			\
			aux_out_pol.o		\
			aux_sync_mode.o		\
			pretrig.o			\
			pretrig_latch.o		\
			pretrig_delay.o		\
			vpd_read.o			\
			wait_cancel.o		\
			wait_event.o		\
			wait_status.o

.c.o:
	@echo == Compiling: $<
	@-chmod +rw ${DEP_FILE}
	@# Get the dependency list for this module.
	@-${CC} -MM ${CC_FLAGS} $< > .tmp1
	@# Remove the trailing white space and backslash.
	@-sed -e "s/[ ]*[\\\\]//g" < .tmp1 > .tmp2
	@# Put everything on seperate lines.
	@-tr [:space:] \\n < .tmp2 > .tmp3
	@# Remove all of the system include files.
	@-grep -v "^[ ]*/" < .tmp3 > .tmp4
	@# Remove all empty lines.
	@-grep [[:alnum:]] < .tmp4 > .tmp5
	@# Put everything on the same line.
	@-tr '\n' '\040' < .tmp5 > .tmp6
	@-${ECHO} -e '\012' >> .tmp6
	@# Add all of the other dependencies to the end of this file.
	@-echo >> ${DEP_FILE}
	@-grep -v "^[ ]*$@" < ${DEP_FILE} >> .tmp6
	@# Remove blank lines from the list.
	@-grep "[[:alnum:]]" < .tmp6 > .tmp7
	@# Sort the list and put it in the dependency file.
	@-sort < .tmp7 > ${DEP_FILE}
	@# Cleanup.
	@rm -f ${DEP_FILE}.tmp* .tmp*
	@# Compile the module.
	@${CC} ${CC_FLAGS} $< -o $@



all: ${TARGET}
	@echo ==== All Done

release: ${TARGET}
	@rm -f *.a *.o ${OBJ_FILES}
	@echo ==== Release Done

clean::
	@echo ==== Cleaning ${TARGET} ...
	@rm -f *.a *.o *.scc ${TARGET}
	@-chmod +rw ${DEP_FILE}
	@echo > ${DEP_FILE}

${TARGET}: ${OBJ_FILES} ${LIB_FILES}
	@echo ==== Linking: $@
	@${CC} ${OBJ_FILES} ${LIB_FILES} -lm -lpthread -o $@

${DEP_FILE}:
	@echo ==== Creating: $@
	@echo > ${DEP_FILE}

include ${DEP_FILE}
