# This software is covered by the GNU GENERAL PUBLIC LICENSE (GPL).
# $Revision: 6 $
# $Date: 1/25/05 3:42p $
# Makefile for the HPDI32 documentation sources
# 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 -I. -I../driver
DEP_FILE	= makefile.dep
TARGET		= HPDI32DocSrcLib.a

OBJ_FILES	=		\
		async_setup.o	\
		close.o		\
		debug_read.o	\
		driver_info.o	\
		int_notify.o	\
		int_status.o	\
		io_config.o	\
		ioctl.o		\
		mmap.o		\
		mmap_info.o	\
		munmap.o	\
		no_command.o	\
		open.o		\
		read.o		\
		reg_mod.o	\
		reg_read.o	\
		reg_write.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 ${TARGET}
	@echo > ${DEP_FILE}

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

include ${DEP_FILE}

