# $URL: http://subversion:8080/svn/gsc/trunk/drivers/LINUX/24DSI/24DSI_Linux_3.0.1.0_GSC_DN/utils/makefile $
# $Rev: 13534 $
# $Date: 2011-12-22 13:04:11 -0600 (Thu, 22 Dec 2011) $

DEVICE		= 24dsi
default: all

CC			= gcc
CC_FLAGS	= -c -Wall
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_adc_rate_out.o			\
			util_ain_buf_clear.o		\
			util_ain_buf_input.o		\
			util_ain_buf_overflow.o		\
			util_ain_buf_thresh.o		\
			util_ain_buf_underflow.o	\
			util_ain_coupling.o			\
			util_ain_filter.o			\
			util_ain_filter_sel.o		\
			util_ain_filter_00_03.o		\
			util_ain_filter_04_07.o		\
			util_ain_filter_08_11.o		\
			util_ain_filter_12_15.o		\
			util_ain_filter_16_19.o		\
			util_ain_filter_20_23.o		\
			util_ain_filter_24_27.o		\
			util_ain_filter_28_31.o		\
			util_ain_mode.o				\
			util_ain_range.o			\
			util_ain_range_00_03.o		\
			util_ain_range_04_07.o		\
			util_ain_range_08_11.o		\
			util_ain_range_12_15.o		\
			util_ain_range_16_19.o		\
			util_ain_range_20_23.o		\
			util_ain_range_24_27.o		\
			util_ain_range_28_31.o		\
			util_ain_range_sel.o		\
			util_auto_calibrate.o		\
			util_ch_grp_0_src.o			\
			util_ch_grp_1_src.o			\
			util_ch_grp_2_src.o			\
			util_ch_grp_3_src.o			\
			util_ch_grp_x_src.o			\
			util_channel_order.o		\
			util_channel_ready.o		\
			util_config.o				\
			util_data_format.o			\
			util_data_width.o			\
			util_ext_clk_src.o			\
			util_ext_trig.o				\
			util_fref.o					\
			util_fsamp.o				\
			util_gps_enable.o			\
			util_gps_locked.o			\
			util_gps_polarity.o			\
			util_gps_rate_locked.o		\
			util_gps_target_rate.o		\
			util_gps_tolerance.o		\
			util_id.o					\
			util_init_mode.o			\
			util_initialize.o			\
			util_irq_sel.o				\
			util_pll_ref_freq_hz.o		\
			util_query.o				\
			util_rate_div_0_ndiv.o		\
			util_rate_div_1_ndiv.o		\
			util_rate_div_x_ndiv.o		\
			util_rate_gen_a_nrate.o		\
			util_rate_gen_a_nref.o		\
			util_rate_gen_a_nvco.o		\
			util_rate_gen_b_nrate.o		\
			util_rate_gen_b_nref.o		\
			util_rate_gen_b_nvco.o		\
			util_rate_gen_x_nrate.o		\
			util_rate_gen_x_nref.o		\
			util_rate_gen_x_nvco.o		\
			util_reg.o					\
			util_reg_mod.o				\
			util_reg_read.o				\
			util_reg_write.o			\
			util_rx_io_abort.o			\
			util_rx_io_mode.o			\
			util_rx_io_overflow.o		\
			util_rx_io_timeout.o		\
			util_rx_io_underflow.o		\
			util_sw_sync.o				\
			util_sw_sync_mode.o			\
			util_thres_flag_cbl.o		\
			util_wait_cancel.o			\
			util_wait_event.o			\
			util_wait_status.o			\
			util_xcvr_type.o



GSC_COMMON	:= $(shell ls -d ../../../gsc_common/linux/utils 2>/dev/null | wc -l )

ifeq ("${GSC_COMMON}","1")

GSC_DIR		:= ../../../gsc_common/linux/utils

./gsc_util_makefile.inc: ./${GSC_DIR}/gsc_util_makefile.inc
	@echo == Getting: $@
	@rm -f $@
	@cp $< $@
	@chmod 444 $@

else

GSC_DIR		:= .

endif

include ./gsc_util_makefile.inc



.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: ${GSC_TARGET} ${TARGET}
	@echo ==== All Done

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

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

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

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

include ${DEP_FILE}
