# DocSrc - HPDI32 - Linux - gcc
# $URL: http://subversion:8080/svn/gsc/trunk/drivers/LINUX/HPDI32/HPDI32_Linux_sdk_6.x.x_GSC_DN/docsrc/makefile $
# $Rev: 23672 $
# $Date: 2013-10-31 16:23:58 -0500 (Thu, 31 Oct 2013) $
# Makefile for the HPDI32 Documentation Sources Library.
# The purpose here is to verify that they compile without warnings or errors
# and to produce a linkable library module.

CC			= gcc
CC_FLAGS	=-c -Wall
CC_FLAGS	+= -I../api
#CC_FLAGS	+= -I../../../../common/api/linux
#CC_FLAGS	+= -I../../../api
DEP_FILE	= makefile.dep
TARGET		= hpdi32_dsl.a
#VPATH		= ../..

OBJ_FILES	=						\
			api_status.o			\
			board_count.o			\
			close.o					\
			gpio_0_mod.o			\
			gpio_read.o				\
			gpio_write.o			\
			init.o					\
			io_status_eval.o		\
			io_tx_to_get.o			\
			io_tx_to_reset.o		\
			io_tx_to_set.o			\
			io_tx_wait.o			\
			irq_fifo_full_wait.o	\
			open.o					\
			read.o					\
			reg_bcr_mod.o			\
			reg_bcr_read.o			\
			reg_bcr_write.o			\
			reset.o					\
			status_text.o			\
			version_get.o			\
			write.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 "" >> .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 $@



all: ${TARGET}
	@echo ==== All Done

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

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

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

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

include ${DEP_FILE}

