# Utils - HPDI32 - Linux - gcc
# $URL: http://subversion:8080/svn/gsc/trunk/drivers/LINUX/HPDI32/HPDI32_Linux_sdk_6.x.x_GSC_DN/utils/makefile $
# $Rev: 23665 $
# $Date: 2013-10-31 16:20:26 -0500 (Thu, 31 Oct 2013) $

DEVICE		= hpdi32
default: all

CC			= gcc
CC_FLAGS	= -c -Wall
CC_FLAGS	+= -I../api
#CC_FLAGS	+= -I../docsrc
#CC_FLAGS	+= -I../driver
DEP_FILE	= makefile.dep
TARGET		= ${DEVICE}_utils.a
VPATH		=

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

OBJ_FILES	=								\
			util_cable_command_mode_0.o		\
			util_cable_command_mode_1.o		\
			util_cable_command_mode_2.o		\
			util_cable_command_mode_3.o		\
			util_cable_command_mode_4.o		\
			util_cable_command_mode_5.o		\
			util_cable_command_mode_6.o		\
			util_close.o					\
			util_count.o					\
			util_favor_tx.o					\
			util_file.o						\
			util_format.o					\
			util_host.o						\
			util_id.o						\
			util_init.o						\
			util_issues.o					\
			util_label.o					\
			util_open.o						\
			util_reg.o						\
			util_rx_enable.o				\
			util_rx_fifo_ae_level.o			\
			util_rx_fifo_af_level.o			\
			util_rx_io_buffer_size.o		\
			util_rx_io_data_size.o			\
			util_rx_io_dma_channel_sel.o	\
			util_rx_io_dma_control_mode.o	\
			util_rx_io_dma_priority.o		\
			util_rx_io_mode.o				\
			util_rx_io_overlap_enable.o		\
			util_rx_io_pio_threshold.o		\
			util_rx_io_single_cycle.o		\
			util_rx_io_timeout.o			\
			util_rx_overrun.o				\
			util_select.o					\
			util_sleep.o					\
			util_status.o					\
			util_string.o					\
			util_time.o						\
			util_tx_auto_start.o			\
			util_tx_auto_stop.o				\
			util_tx_clock_divider.o			\
			util_tx_enable.o				\
			util_tx_fifo_ae_level.o			\
			util_tx_fifo_af_level.o			\
			util_tx_io_buffer_pointer.o		\
			util_tx_io_buffer_size.o		\
			util_tx_io_data_size.o			\
			util_tx_io_dma_channel_sel.o	\
			util_tx_io_dma_control_mode.o	\
			util_tx_io_dma_priority.o		\
			util_tx_io_mode.o				\
			util_tx_io_overlap_enable.o		\
			util_tx_io_pio_threshold.o		\
			util_tx_io_single_cycle.o		\
			util_tx_io_timeout.o			\
			util_tx_line_valid_off_count.o	\
			util_tx_line_valid_on_count.o	\
			util_tx_remote_throttle.o		\
			util_tx_rx_tri_state.o			\
			util_tx_status_valid_count.o	\
			util_tx_status_valid_mirror.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 *.o
	@echo ==== release Done

clean:
	@echo ==== Cleaning ${TARGET} ...
	@rm -f *.o ${TARGET}
	@echo > ${DEP_FILE}
	@chmod 666 ${DEP_FILE}

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

${TARGET}: ${OBJ_FILES}
	@echo ==== Linking: $@
	@ld -r -o $@ ${OBJ_FILES}

include ${DEP_FILE}


