# HPDI32 - DocSrc - Linux - gcc
# $Workfile: makefile $
# $Revision: 1 $
# $Date: 4/03/07 9:43a $
# 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../../../../common/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 -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 $@



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

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

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

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

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

include ${DEP_FILE}

