#
# $Id: Makefile,v 1.14 2010/09/24 12:17:03 he Exp $
#

CONFS=	zino-config.pl

SCRIPTS=daily-clean.sh daily.sh daily.pl dst-shift.pl \
	find-err-dev.pl find-err-dev.sh \
	fixup-data.pl fixup-data.sh startup.sh onlyone.sh \
	compress-data.pl split-new-data.pl move-to copy-to \
	convert-data.pl

SUBST=	${.CURDIR}/../../subst

all:

install:
	@for s in ${SCRIPTS}; do \
		base=`basename $$s .sh`; \
		dst=${BINDIR}/$$base; \
		tmp=/tmp/jtmp.$$$$; \
		echo sed -f ${SUBST} '<' $$s '>' $$tmp; \
		sed -f ${SUBST} < $$s > $$tmp; \
		: -- Check for two-or-more %-sequences; \
		if egrep '%[A-Z_][A-Z_][A-Z_]*%' $$tmp; then \
			echo "Remaining substitution in $$s" >&2; \
			echo "May need to update top-level Makefile.inc" >&2; \
			rm -f $$tmp; \
			exit 1; \
		fi; \
		echo install -c -m 555 $$tmp $$dst; \
		install -c -m 555 $$tmp $$dst; \
		echo rm -f $$tmp; \
		rm -f $$tmp; \
	done
	@for s in ${CONFS}; do \
		dst=${CONFDIR}/$$s; \
		tmp=/tmp/jtmp.$$$$; \
		echo sed -f ${SUBST} '<' $$s '>' $$tmp; \
		sed -f ${SUBST} < $$s > $$tmp; \
		if egrep '%[A-Z_][A-Z_]*%' $$tmp; then \
			echo "Missing substitution pattern!" >&2; \
			exit 1; \
		fi; \
		echo install -c -m 444 $$tmp $$dst; \
		install -c -m 444 $$tmp $$dst; \
		echo rm -f $$tmp; \
		rm -f $$tmp; \
	done

obj:
clean:
cleandir:

.include "../../Makefile.inc"
