# The preproff program was developed at Hitachi Computer Products (America),
# Inc., in its Open Systems Division, which is responsible for porting and
# adapting OSF offerings.  Hitachi Computer Products has given the program to
# OSF so it can use and distribute it as part of its documentation build
# tools.  In addition, OSF licensees can adapt the program to the needs of
# their sites.  The program is offered as is, with no warranty attached, and
# so forth and so on.

.SUFFIXES : .o_dbg

FINAL_OBJ = filter_driver.o filter.o define_stack.o global_var.o site_specific.o
DBG_OBJ = ${FINAL_OBJ:.o=.o_dbg}
HEADERS =  filter.h site_specific.h
# Replace the following BINDIR definition with the directory where you want to
# install the final executable file.  Instead of using BINDIR, you could define
# EXEC_NAME as a full pathname, but that's a little less safe.
BINDIR = /nfs/gakusei/users/oram/roff/bin
EXEC_NAME = preproff

.c.o_dbg :
	$(CC) -g -c $<
	mv $*.o $@

# This is first dependency line in the file, so you can build a new executable
# simply by entering a "make" command.
${EXEC_NAME} : ${FINAL_OBJ} ${FRC}
	${CC} ${LDFLAGS} -o $@ ${FINAL_OBJ}

# This target ensures that all source files are recompiled, through the FRC
# macro.  It's called "final" because it's a good way to make the version you
# are going to install for the users -- you know all modules in it are up to
# date.
final :
	${MAKE} ${EXEC_NAME} FRC=FRC "CFLAGS=${CFLAGS}" "LDFLAGS=${LDFLAGS} -s"
	chmod 755 ${EXEC_NAME}
	mv ${EXEC_NAME} ${BINDIR}

dbg : ${DBG_OBJ} ${FRC}
	${CC} ${LDFLAGS} -g -o $@ ${DBG_OBJ} -ll

${FINAL_OBJ} ${DBG_OBJ} : ${HEADERS} ${FRC}

filter.o_dbg : lex.yy.o_dbg
	mv lex.yy.o_dbg $@
	- rm lex.yy.c

# The following should help you rebuild an executable after a C source
# file changes, without the VERY time-consuming job of rerunning lex.
# On the other hand, because the lex-to-C rules involve removing the lex.yy.c
# file, you usually have to rebuild it anyway.
lex.yy.c : filter.l ${HEADERS} ${FRC}
	lex filter.l

FRC:

clean:
	- rm -f *.o_dbg *.o dbg lex.yy.c *~ core

lint:
	lint lex.yy.c define_stack.c filter_driver.c global_var.c site_specific.c
