# $URL: http://subversion:8080/svn/gsc/trunk/drivers/LINUX/16AISS2AO2A2M/utils/makefile $
# $Rev: 45183 $
# $Date: 2019-07-01 16:58:19 -0500 (Mon, 01 Jul 2019) $

# 16AISS2AO2A2M: Utilities: make file

default: all

CC			= gcc
CC_FLAGS	= -c -Wall -I../include
DEP_FILE	= makefile.dep
TARGET		= ../lib/16aiss2ao2a2m_utils.a

.NOTPARALLEL: %.o

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

OBJ_FILES	=\
			close.o			\
			config_ai.o		\
			config_ao.o		\
			config_bdo.o	\
			count.o			\
			fsamp_ai.o		\
			fsamp_ao.o		\
			fsamp_bdo.o		\
			id.o			\
			init.o			\
			ioctl.o			\
			open.o			\
			read_ai.o		\
			reg.o			\
			write_ao.o		\
			write_bdo.o		\
			\
			ai_buf_clear.o			\
			ai_buf_enable.o			\
			ai_buf_level.o			\
			ai_buf_overflow.o		\
			ai_buf_underflow.o		\
			ai_burst_enable.o		\
			ai_burst_size.o			\
			ai_burst_status.o		\
			ai_chan_0_range.o		\
			ai_chan_1_range.o		\
			ai_chan_sel.o			\
			ai_io_abort.o			\
			ai_io_mode.o			\
			ai_io_overflow.o		\
			ai_io_timeout.o			\
			ai_io_underflow.o		\
			ai_mode.o				\
			ai_sw_clock.o			\
			ai_sw_trigger.o			\
			ai_thresh_lvl.o			\
			ai_thresh_sts.o			\
			ao_access_mode.o		\
			ao_buf_clear.o			\
			ao_buf_level.o			\
			ao_buf_load_req.o		\
			ao_buf_load_sts.o		\
			ao_buf_mode.o			\
			ao_buf_over_data.o		\
			ao_buf_over_frame.o		\
			ao_buf_status.o			\
			ao_burst_enable.o		\
			ao_burst_status.o		\
			ao_burst_sync_ai.o		\
			ao_chan_sel.o			\
			ao_clock_enable.o		\
			ao_clock_source.o		\
			ao_clock_status.o		\
			ao_enable.o				\
			ao_io_abort.o			\
			ao_io_mode.o			\
			ao_io_overflow.o		\
			ao_io_timeout.o			\
			ao_output_mode.o		\
			ao_range.o				\
			ao_sw_clock.o			\
			ao_sw_trigger.o			\
			ao_thresh_lvl.o			\
			ao_thresh_sts.o			\
			autocal_ai.o			\
			autocal_all.o			\
			autocal_sts.o			\
			bdo_access_mode.o		\
			bdo_buf_clear.o			\
			bdo_buf_enable.o		\
			bdo_buf_level.o			\
			bdo_buf_overflow.o		\
			bdo_buf_underflow.o		\
			bdo_clock_enable.o		\
			bdo_clock_source.o		\
			bdo_io_abort.o			\
			bdo_io_mode.o			\
			bdo_io_overflow.o		\
			bdo_io_timeout.o		\
			bdo_io_underflow.o		\
			bdo_rate_gen_enable.o	\
			bdo_rate_gen_ndiv.o		\
			bdo_sw_clock.o			\
			bdo_thresh_lvl.o		\
			bdo_thresh_sts.o		\
			cbl_in_clk_io.o			\
			cbl_io_clk_dir.o		\
			cbl_out_clk_io.o		\
			cbl_trig_io.o			\
			data_format.o			\
			dio_dir.o				\
			dio_read.o				\
			dio_write.o				\
			initialize.o			\
			irq_enable.o			\
			query.o					\
			rate_a_gen_enable.o		\
			rate_a_gen_ndiv.o		\
			rate_b_gen_enable.o		\
			rate_b_gen_ndiv.o		\
			rate_c_gen_enable.o		\
			rate_c_gen_ndiv.o		\
			reg_mod.o				\
			reg_read.o				\
			reg_write.o				\
			trigger_dir.o			\
			wait_cancel.o			\
			wait_event.o			\
			wait_status.o



include ./os_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 *.a *.o *.scc ${GSC_TARGET} ${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}
