# $URL: http://subversion:8080/svn/gsc/trunk/drivers/LINUX/24DSI12WRCIEPE/24DSI12WRCIEPE_linux_1.x.x.x_gsc_dn/utils/makefile $
# $Rev: 52535 $
# $Date: 2023-03-02 14:55:56 -0600 (Thu, 02 Mar 2023) $

# 24DSI12WRCIEPE: Utilities: make file

default: all

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

.NOTPARALLEL: %.o

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

ifeq ("${GSC_LIB_COMP_FLAGS}","")
GSC_LIB_COMP_FLAGS_MSG=
else
GSC_LIB_COMP_FLAGS_MSG="  (added '${GSC_LIB_COMP_FLAGS}')"
endif

ifeq ("${GSC_LIB_LINK_FLAGS}","")
GSC_LIB_LINK_FLAGS_MSG=
else
GSC_LIB_LINK_FLAGS_MSG="  (added '${GSC_LIB_LINK_FLAGS}')"
endif

OBJ_FILES	:=		\
			close.o	\
			init.o	\
			ioctl.o	\
			open.o	\
			read.o	\
			\
			util_config_ai.o	\
			util_count.o		\
			util_fsamp_ai.o		\
			util_id.o			\
			util_reg.o			\
			\
			util_adc_mode.o				\
			util_ai_buf_clear.o			\
			util_ai_buf_enable.o		\
			util_ai_buf_fill_lvl.o		\
			util_ai_buf_overflow.o		\
			util_ai_buf_thr_sts.o		\
			util_ai_buf_thresh.o		\
			util_ai_buf_underflow.o		\
			util_ai_channel_tag.o		\
			util_ai_mode.o				\
			util_auto_cal.o				\
			util_auto_cal_sts.o			\
			util_aux_clk_ctl_mode.o		\
			util_aux_sync_ctl_mode.o	\
			util_burst_enable.o			\
			util_burst_rate_div.o		\
			util_burst_size.o			\
			util_burst_timer.o			\
			util_burst_trigger.o		\
			util_ch_grp_0_src.o			\
			util_ch_grp_1_src.o			\
			util_channels_ready.o		\
			util_clock_control_mode.o	\
			util_coupling_mode.o		\
			util_data_format.o			\
			util_data_width.o			\
			util_excitation_current.o	\
			util_ext_clk_src.o			\
			util_ext_sync_dir.o			\
			util_initialize.o			\
			util_input_comp.o			\
			util_irq_sel.o				\
			util_ndiv.o					\
			util_nref.o					\
			util_nvco.o					\
			util_query.o				\
			util_range.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_sync_control_mode.o	\
			util_wait_cancel.o			\
			util_wait_event.o			\
			util_wait_status.o

include ./gsc_util_makefile.inc
include ./gsc_util_makefile_pci.inc
include ./os_util_makefile.inc

# Sort object file list to compile most recentlty changed sources first.
OBJ_FILES:= $(shell ls -t $(patsubst %.o,%.c,${OBJ_FILES}))
OBJ_FILES:= $(patsubst %.c,%.o,${OBJ_FILES})

.c.o:
	@echo == Compiling: $<  ${GSC_LIB_COMP_FLAGS_MSG}
	@-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 $@ ${GSC_LIB_COMP_FLAGS}

all: ${GSC_TARGET} ${PLX_TARGET} ${OS_TARGET} ${TARGET}
	@echo ==== All Done

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

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

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

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

include ${DEP_FILE}
