# $URL: http://subversion:8080/svn/gsc/trunk/drivers/LINUX/HPDI32/HPDI32_Linux_2.x.x.x_GSC_DN/sbtest/makefile $
# $Rev: 13491 $
# $Date: 2011-12-20 16:30:59 -0600 (Tue, 20 Dec 2011) $

DEVICE		= hpdi32
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	=						\
			cable_cmd_mode_0.o		\
			cable_cmd_mode_1.o		\
			cable_cmd_mode_2.o		\
			cable_cmd_mode_3.o		\
			cable_cmd_mode_4.o		\
			cable_cmd_mode_5.o		\
			cable_cmd_mode_6.o		\
			cable_cmd_state_0.o		\
			cable_cmd_state_1.o		\
			cable_cmd_state_2.o		\
			cable_cmd_state_3.o		\
			cable_cmd_state_4.o		\
			cable_cmd_state_5.o		\
			cable_cmd_state_6.o		\
			initialize.o			\
			irq_config_edge.o		\
			irq_config_high.o		\
			irq_enable.o			\
			query.o					\
			reg_mod.o				\
			reg_read.o				\
			reg_write.o				\
			tristate_te_re.o		\
			rx_auto_start.o			\
			rx_enable.o				\
			rx_fifo_ae.o			\
			rx_fifo_af.o			\
			rx_fifo_overrun.o		\
			rx_fifo_reset.o			\
			rx_fifo_status.o		\
			rx_fifo_underrun.o		\
			rx_io_abort.o			\
			rx_io_data_size.o		\
			rx_io_mode.o			\
			rx_io_overrun.o			\
			rx_io_pio_threshold.o	\
			rx_io_timeout.o			\
			rx_io_underrun.o		\
			rx_line_count.o			\
			rx_status_count.o		\
			tx_auto_start.o			\
			tx_auto_stop.o			\
			tx_clock_divider.o		\
			tx_enable.o				\
			tx_fifo_ae.o			\
			tx_fifo_af.o			\
			tx_fifo_overrun.o		\
			tx_fifo_reset.o			\
			tx_fifo_status.o		\
			tx_flow_control.o		\
			tx_io_abort.o			\
			tx_io_data_size.o		\
			tx_io_mode.o			\
			tx_io_overrun.o			\
			tx_io_pio_threshold.o	\
			tx_io_timeout.o			\
			tx_line_val_off_cnt.o	\
			tx_line_val_on_cnt.o	\
			tx_remote_throttle.o	\
			tx_status_val_cnt.o		\
			tx_status_val_mir.o		\
			user_jumpers.o			\
			wait_cancel.o			\
			wait_event.o			\
			wait_status.o			\
									\
			main.o					\
			service.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}
