#**************************************************************************
#* LPRng IFHP Filter
#* Copyright 1994-1997 Patrick Powell, San Diego, CA <papowell@astart.com>
#*
#* Based on the CTI printer filters.
#*  See COPYRIGHT for details.
#*
#* $Id: Makefile.in,v 2.8 1997/12/18 09:48:06 papowell Exp papowell $
#


prefix=@prefix@
# where the filters are installed:
INSTDIR=${prefix}/lib/filters
# where the fonts are installed (this path should agree
# with the one in FONTPATH).
FONTDIR=${prefix}/lib/filters/fonts

# shell to use
SHELL=@SHELL@

#
# the compiler optimisation/debugging flags you wish to use.
# what C compiler to use.
#
CC=@CC@
CCOPTFLAGS =  @CFLAGS@
LDFLAGS    =  $(CCOPTFLAGS)
# add additional definitions here
DEFS=@DEFS@

# use FLAGS for additional flags
CFLAGS = $(CCOPTFLAGS) $(DEFS) $(FLAGS)

# libraries you will need (found by config), add more to end
LIBS=@LIBS@

INSTALLCMD=@INSTALL@
SHELL = @SHELL@

SRC=@srcdir@
@SET_MAKE@
RANLIB=@RANLIB@

######### - no changes by configure after here #############


MACHINESFONTS= -DMACHINESFONTS=\"host_fonts\"
# Accounting shell location
# ACCNTSH= -DACCNTSH=\"$(INSTDIR)/accounting.sh\"

# Font Path 
FONTPATH= -DFONTPATH=\"$(FONTDIR)\"
# Default font for the case that no entry exists for a 
# machine in previous file.
#DEFLTFONT= -DDEFLTFONT=\"elot-928/c1201c.10\"
# Default font to be downloaded is NONE

# OF FILTER NAME
OFHP= -DOFHP=\"ofhp\"

SRCDIRS=${SRC}/.
INCLUDE=.. ${SRC}/.
#GNU
VPATH=$(subst :, ,$(INCLUDE) $(SRCDIRS))
INCS=$(patsubst %,-I%,$(INCLUDE))
#
#BSD .PATH: $(INCLUDE) $(SRCDIRS)
#BSD INCS= $(INCLUDE:S/^/-I/g)

#if you want quiet operation, i.e. - only serious messages logged,
# uncomment out the following line
#QUIET=-DQUIET

# use FLAGS for additional flags

FLAGS=  ${ACCNTSH} ${MACHINESFONTS} ${FONTPATH} ${DEFLTFONT} ${OFHP} \
	$(QUIET) $(INCS)

# commands made by this script
COMMANDS= ifhp accounting.sh banner.sh psbanner.sh monitor

.SUFFIXES: .sh .sh_init

.sh_init.sh:
	sed -e 's:_INSTDIR_:$(INSTDIR):g' \
		-e 's:_SHELL_:$(SHELL):g' \
		$^ >$@
	chmod +x $@

all: ${COMMANDS}

.PHONY: all clean install lorder

#
# Object - Source  dependencies
#
IFOBJS = ifhp.o
LIB_OBJS = \
	args.o banner.o check_code.o check_job.o cleanup.o copyright.o \
	do_monitor.o doaccnt.o fexit.o file_read.o fonts.o get_info.o \
	get_num.o getcrstr.o log.o monitor.o open_device.o out_line.o \
	page_set.o port_read.o pr_pagecount.o pr_query.o \
	pr_synch.o readpipe.o sendfont.o sendjob.o setpcl_on.o setstatus.o \
	snprintf.o stty.o vars.o write_check.o writecn.o

lib_print.a: $(LIB_OBJS)
	ar ruv $@ $(LIB_OBJS)
	$(RANLIB) $@

ifhp:	$(IFOBJS) lib_print.a
	${CC} ${LDFLAGS} $^ ${LIBS} -o $@

$(IFOBJS) $(LIB_OBJS): hp4.h config.h common.h

monitor: monitor.o snprintf.o
	${CC} ${LDFLAGS} $^ ${LIBS} -o $@

#
# Installation of commands
#
install: all
	${SRC}/mkinstalldirs $(INSTDIR)
	for i in $(COMMANDS) ; do \
		$(INSTALLCMD) -m 755 $$i $(INSTDIR); \
	done ;
	cd $(INSTDIR); rm -f ofhp; ln -s ifhp ofhp

#
# Miscellaneous
#

clean:
	-rm -f $(COMMANDS) *.o *.a *.core core ? pfu tags

lorder: $(LIB_OBJS)
	lorder $(LIB_OBJS) | tsort

ci: 
	if test ! -d RCS ; then mkdir RCS; fi;
	for i in \
		*.[ch] Makefile* \
		accounting.sh_init banner.sh_init ellipse.ps psbanner.sh_init \
		testbanner testif testnostat testnw testof \
		; do \
		if [ -f $$i ]; then ci $(CI) -l -mUpdate -t-Initial $$i; fi; \
	done;

distclean:
	-rm -f Makefile Makefile.bsd

TAGS:
	ctags *.c *.h
