# $URL: http://subversion:8080/svn/gsc/trunk/drivers/LINUX/SIO4%20and%20SIO8/SIO4_Linux_1.x.x_GSC_DN/docsrc/makefile $
# $Rev: 10708 $
# $Date: 2011-04-04 02:57:07 -0500 (Mon, 04 Apr 2011) $

# Makefile for the SIO4 document sources.

default: all

CC			= gcc
CC_FLAGS	= -c -Wall
CC_FLAGS	+= -I../driver
DEP_FILE	= makefile.dep
TARGET		= sio4_dsl.a
VPATH		= . linux

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

OBJ_FILES	=							\
			async_setup.o				\
			async_setup_rx.o			\
			async_setup_tx.o			\
			board_init.o				\
			board_jumpers.o				\
			brg0_enable.o				\
			brg0_set_clock_source.o		\
			brg0_set_mode.o				\
			brg1_enable.o				\
			brg1_set_clock_source.o		\
			brg1_set_mode.o				\
			cable_config.o				\
			channel_command_send.o		\
			channel_init.o				\
			channel_reset.o				\
			close.o						\
			ctr0_set_clock_source.o		\
			ctr1_set_clock_source.o		\
			cts_cable_config.o			\
			dcd_cable_config.o			\
			dma_abort.o					\
			dma_read.o					\
			dma_set_options.o			\
			dma_write.o					\
			dmdma_read.o				\
			dmdma_write.o				\
			dpll_clear_status.o			\
			dpll_set_clock_source.o		\
			dpll_set_divisor.o			\
			dpll_set_mode.o				\
			dpll_set_resync.o			\
			driver_info.o				\
			feature_test.o				\
			fifo_read_status.o			\
			fifo_reset.o				\
			hdlc_sdlc_loop_setup_rx.o	\
			hdlc_setup_rx.o				\
			hdlc_setup_tx.o				\
			int_notify.o				\
			int_read_status.o			\
			ioctl.o						\
			isochr_setup_rx.o			\
			isochr_setup_tx.o			\
			last_error_get.o			\
			mp_config.o					\
			mp_info.o					\
			mp_init.o					\
			mp_reset.o					\
			mp_test.o					\
			no_function.o				\
			open.o						\
			osc_info.o					\
			osc_init.o					\
			osc_measure.o				\
			osc_program.o				\
			osc_reference.o				\
			osc_reset.o					\
			osc_test.o					\
			read.o						\
			reg_mod.o					\
			reg_read.o					\
			reg_read_raw.o				\
			reg_write.o					\
			reset_device.o				\
			rx_cable.o					\
			rx_fifo_ae.o				\
			rx_fifo_af.o				\
			rx_fifo_count.o				\
			rx_fifo_full_config.o		\
			rx_fifo_size.o				\
			rx_fifo_type.o				\
			rx_io_abort.o				\
			rx_io_mode.o				\
			rx_set_clock_source.o		\
			rxc_usc_config.o			\
			sync_byte_set.o				\
			timeout_set_read.o			\
			timeout_set_write.o			\
			tx_cable.o					\
			tx_cable_clock.o			\
			tx_cable_data.o				\
			tx_fifo_ae.o				\
			tx_fifo_af.o				\
			tx_fifo_count.o				\
			tx_fifo_size.o				\
			tx_fifo_type.o				\
			tx_io_abort.o				\
			tx_io_mode.o				\
			tx_set_clock_source.o		\
			txc_usc_config.o			\
			usc_reset.o					\
			write.o						\
			zilog_reset.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 ${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}
	@echo ==== Linking: $@
	@ld -r -o $@ ${OBJ_FILES}

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

include ${DEP_FILE}

