# $URL: http://subversion:8080/svn/gsc/trunk/drivers/LINUX/SIO4%20and%20SIO8/SIO4_Linux_1.x.x_GSC_DN/sbtest/makefile $
# $Rev: 10688 $
# $Date: 2011-04-04 01:55:37 -0500 (Mon, 04 Apr 2011) $

default:	all

CC			= gcc
CC_FLAGS	= -c -Wall
CC_FLAGS	+= -I.
CC_FLAGS	+= -I../driver
CC_FLAGS	+= -I../docsrc
CC_FLAGS	+= -I../utils
CC_FLAGS	+= -I../async/lib
CC_FLAGS	+= -I../sync/lib
DEP_FILE	= makefile.dep
LIB_FILES	=
LIB_FILES	+= ../docsrc/sio4_dsl.a
LIB_FILES	+= ../utils/sio4_utils.a
LIB_FILES	+= ../async/lib/sio4_async_lib.a
LIB_FILES	+= ../sync/lib/sio4_sync_lib.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						\
											\
			board_jumpers.o					\
			cable_config.o					\
			clear_dpll_status.o				\
			cts_cable_config.o				\
			dcd_cable_config.o				\
			enable_brg0.o					\
			enable_brg1.o					\
			feature_test.o					\
			get_driver_info.o				\
			init_board.o					\
			init_channel.o					\
			int_notify.o					\
			mod_register.o					\
			mp_config.o						\
			mp_info.o						\
			mp_init.o						\
			mp_reset.o						\
			mp_test.o						\
			no_function.o					\
			osc_info.o						\
			osc_init.o						\
			osc_measure.o					\
			osc_program.o					\
			osc_reference.o					\
			osc_reset.o						\
			osc_test.o						\
			read_int_status.o				\
			read_register.o					\
			read_register_raw.o				\
			reset_channel.o					\
			reset_device.o					\
			reset_fifo.o					\
			reset_usc.o						\
			reset_zilog_chip.o				\
			rx_cable_config.o				\
			rx_fifo_ae_config.o				\
			rx_fifo_af_config.o				\
			rx_fifo_count.o					\
			rx_fifo_full_config.o			\
			rx_fifo_size.o					\
			rx_io_abort.o					\
			rx_io_mode_config.o				\
			rxc_usc_config.o				\
			select_dpll_resync.o			\
			send_channel_command.o			\
			set_brg0_mode.o					\
			set_brg0_source.o				\
			set_brg1_mode.o					\
			set_brg1_source.o				\
			set_ctr0_source.o				\
			set_ctr1_source.o				\
			set_dpll_divisor.o				\
			set_dpll_mode.o					\
			set_dpll_source.o				\
			set_rcv_async_prot.o			\
			set_rcv_hdlc_prot.o				\
			set_rcv_isochr_prot.o			\
			set_read_timeout.o				\
			set_rx_clock_source.o			\
			set_sync_byte.o					\
			set_tx_clock_source.o			\
			set_usc_dma_options.o			\
			set_write_timeout.o				\
			set_xmt_async_prot.o			\
			set_xmt_hdlc_prot.o				\
			set_xmt_hdlc_sdlc_loop_prot.o	\
			set_xmt_isochr_prot.o			\
			tx_cable_clock_config.o			\
			tx_cable_config.o				\
			tx_cable_data_config.o			\
			tx_fifo_ae_config.o				\
			tx_fifo_af_config.o				\
			tx_fifo_count.o					\
			tx_fifo_size.o					\
			tx_io_abort.o					\
			tx_io_mode_config.o				\
			txc_usc_config.o				\
			write_register.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}
