# Makefile

# destination for executables
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir	 = @bindir@
sbindir	= @sbindir@
libexecdir = @libexecdir@
libdir	 = @libdir@
filterdir = ${libdir}/filters/apsfilter

INSTALLCMD=@INSTALL@

SRC=@srcdir@

### - end of mods by configure - ###

VPATH=$(SRC)


INSTALLTARGET= apsfilter rewindstdin
MAKETARGET= apsfilter rewindstdin setup
ALLTARGET = $(MAKETARGET) test.apsfilter
all: $(ALLTARGET)
	chmod +x $(ALLTARGET)

.PHONY: all install targets clean reallyclean ci update dist

apsfilter: apsfilter.pl
	-rm -f $@
	sed -e 's,BINDIR,$(filterdir),' apsfilter.pl >$@
	chmod a+x $@

setup: setup.pl
	-rm -f $@
	sed -e 's,BINDIR,$(filterdir),' setup.pl >$@
	chmod a+x $@

rewindstdin: rewindstdin.c

install:all ${filterdir}
	for i in $(INSTALLTARGET); do \
	${INSTALLCMD} -m 755 $$i ${filterdir}; \
	done;

${filterdir}::
	${SRC}/mkinstalldirs $@

clean:
	rm -f $(MAKETARGET) *.setup *.conf *.template *.pl *.pcl *.ps status

realclean: clean
	rm -f config.* Makefile
CI=
CO=-kv
cifast ci:
	checkin() { \
		rcs -l $$1 ; \
		ci $(CI) -mUpdate -t-Initial $$1; \
		co $(CO) $$1; \
	}; \
	for i in *; do \
		if [ -d "$$i" ] ; then \
			case $$i in \
			RCS ) ;; \
			* ) if [ ! -d $$i/RCS ] ; then mkdir $$i/RCS ; fi ; \
				for j in $$i/*; do \
					if [ -f "$$j" ] ; then \
						checkin $$j; \
					fi; \
				done; \
				;; \
			esac; \
		fi; \
		if [ -f "$$i" ] ; then checkin $$i; fi; \
	done;

update:
	for i in VERSION patchlevel.h configure.in configure; do \
		rcs -l $$i; chmod +w $$i; \
	done;
	DIR=`pwd | sed 's,.*/,,' `; \
		echo "#define PATCHLEVEL " \"$$DIR\" >./patchlevel.h; \
		sleep 1; \
		echo $$DIR >VERSION ; \
		cp configure.in /tmp/configure.in; \
		D=`echo $$DIR | sed 's,.*-,,' ` ; \
		sed "s,VERSION=.*,VERSION=$$D," </tmp/configure.in >configure.in; \
		cp configure /tmp/configure; \
		sed "s,VERSION=.*,VERSION=$$D," </tmp/configure >configure ;

dist_list:
	echo RCS >/tmp/X
	for i in Makefile $(MAKETARGET) status ; do echo "*/$$i" >>/tmp/X; done
	echo '*.pl' >>/tmp/X;
	echo '*/config.*' >>/tmp/X;

dist: dist_list
	DIR=`pwd | sed 's,.*/,,' `; \
		cd ..; \
		tar zXcf /tmp/X $${DIR}.tgz $${DIR}; \
		md5 $${DIR}.tgz | pgp -fast -u papowell@astart > $${DIR}.tgz.md5
