# This software is covered by the GNU GENERAL PUBLIC LICENSE (GPL).
# $Revision: 2 $
# $Date: 8/21/06 10:33a $

ifeq ("${COMP_DEBUG}","")
COMP_DEBUG	= -DDEBUG -g2
endif

CC			= gcc
CC_FLAGS	=-c -Wall -I. -I../lib -I../../driver
CC_FLAGS	+= ${COMP_DEBUG}
DEP_FILE	= makefile.dep
TARGET		= hpdi32_dp2_dsl.a

OBJ_FILES	=						\
			bcr_clear.o				\
			board_reset.o			\
			gpio_dir_init.o			\
			gpio_dir_show.o			\
			gpio_lwlb_low.o			\
			gpio_rx.o				\
			gpio_tx.o				\
			loop_back_enable.o		\
			loop_back_show.o		\
			predrive_show.o			\
			predrive_init.o			\
			rx_config_reset.o		\
			rx_config_show.o		\
			rx_fifo_almost_init.o	\
			rx_fifo_almost_show.o	\
			rx_fifo_clear.o			\
			rx_msg_size_show.o		\
			tx_config_reset.o		\
			tx_config_show.o		\
			tx_fifo_almost_init.o	\
			tx_fifo_almost_show.o	\
			tx_fifo_clear.o			\
			tx_msg_size_show.o		\
			tx_start.o				\
			tx_started.o			\
			version.o



.c.o:
	@echo == Compiling: $<
	@-chmod +rw ${DEP_FILE}
	@# Get the dependency list for this module.
	@-${CC} -MM ${CC_FLAGS} $< >  .tmp1
	@# Remove trailing white space and backslash, if present.
	@-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 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 .tmp*
	@# Compile the module.
	@${CC} ${CC_FLAGS} $< -o $@



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

all:
	@make -s "COMP_DEBUG=-DNDEBUG -g0" "LINK_DEBUG=-s" ${TARGET}
	@echo ==== All Done

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

debug:
	@make -s "COMP_DEBUG=-DDEBUG -g2" "LINK_DEBUG=" ${TARGET}
	@echo ==== debug Done

release:
	@make -s "COMP_DEBUG=-DNDEBUG -g0" "LINK_DEBUG=-s" ${TARGET}
	@rm -f *.o
	@echo ==== Release Done

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

include ${DEP_FILE}

