# HPDI32 - Application - Linux - gcc
# $Workfile: makefile $
# $Revision: 1 $
# $Date: 9/16/08 10:42a $



CC			= gcc
CC_FLAGS	=-c -O2 -Wall -DLINUX
CC_FLAGS	+= -I../../../../common/api
CC_FLAGS	+= -I../../../../common/api/linux
CC_FLAGS	+= -I../../../api
CC_FLAGS	+= -I../../../utils
CC_FLAGS	+= -I../../../utils/linux
CC_FLAGS	+= ${DEBUG}
DEP_FILE	= makefile.dep
TARGET		= jumpers
VPATH		=
VPATH		+= ../..
VPATH		+= ../../../utils
VPATH		+= ../../../utils/linux

LIB_FILES	=				\
		util.a				\
		../../../docsrc/linux/gcc/hpdi32_dsl.a

OBJ_FILES	=		\
		jumpers.o	\
		main.o

OBJ_UTILS	=		\
		util_close.o	\
		util_count.o	\
		util_host.o	\
		util_id.o	\
		util_label.o	\
		util_open.o	\
		util_reg.o	\
		util_select.o	\
		util_status.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:
	@make -s DEBUG=-g ${TARGET}
	@echo ==== All Done

release:
	@make -s "DEBUG=-DNDEBUG" ${TARGET}
	@rm -f *.a *.o ${DEP_FILE}
	@echo "" > ${DEP_FILE}
	@echo ==== Release Done

${TARGET}: util.a ${OBJ_FILES}
	@echo ==== Linking: $@
	@${CC} ${OBJ_FILES} ${LIB_FILES} -lhpdi32_api -o $@

util.a: ${OBJ_UTILS}
	@echo ==== Linking: $@
	@ld -r -o $@ ${OBJ_UTILS}

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

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

include ${DEP_FILE}

