#
#	@(#)Makefile	3.35 (motonori/WIDE) 24 Sep 1998
#
#	Makefile for generation of sendmail.cf files
#

# top directory
TOPDIR=		.

# your object files (*.cf)
MYOBJS=

# name of your perl: perl, perl4, perl5, jperl or ...
PERL=		perl

WHICH=		Master/Which
PERLPATH=	`${WHICH} ${PERL}`

# sample.cf files
STDDIR=		${TOPDIR}/Standards
OBJS=		${STDDIR}/smtpcheck-v7.cf \
		${STDDIR}/smtpcheck-v8.cf \
		${STDDIR}/sendmail-v1.cf \
		${STDDIR}/sendmail-v5.cf \
		${STDDIR}/sendmail-v6.cf \
		${STDDIR}/sendmail-v7.cf \
		${STDDIR}/sendmail-v8.cf \
		${STDDIR}/null-v1.cf \
		${STDDIR}/null-v5.cf \
		${STDDIR}/null-v6.cf \
		${STDDIR}/null-v7.cf \
		${STDDIR}/null-v8.cf \
		${STDDIR}/nmtc.cf

# prototypes
MASTERDIR=	${TOPDIR}/Master
OSTYPEDIR=	${MASTERDIR}/OSTYPE

PROTOS=		${MASTERDIR}/proto.check \
		${MASTERDIR}/proto.v1 \
		${MASTERDIR}/proto.v5 \
		${MASTERDIR}/proto.v6 \
		${MASTERDIR}/proto.v7 \
		${MASTERDIR}/proto.v8 \
		${MASTERDIR}/proto-null.v1 \
		${MASTERDIR}/proto-null.v5 \
		${MASTERDIR}/proto-null.v6 \
		${MASTERDIR}/proto-null.v7 \
		${MASTERDIR}/proto-null.v8
FEATURES=	${MASTERDIR}/files.c7 \
		${MASTERDIR}/files.c8 \
		${MASTERDIR}/files.v1 \
		${MASTERDIR}/files.v5 \
		${MASTERDIR}/files.v6 \
		${MASTERDIR}/files.v7 \
		${MASTERDIR}/files.v8 \
		${MASTERDIR}/files-null.v1 \
		${MASTERDIR}/files-null.v5 \
		${MASTERDIR}/files-null.v6 \
		${MASTERDIR}/files-null.v7 \
		${MASTERDIR}/files-null.v8 \
		${MASTERDIR}/files.nmtc

# filters
FILTERDIR=	${MASTERDIR}
MKFILT=		${FILTERDIR}/Mkfilter
MKSAMPLE=	${FILTERDIR}/Mksample

# cf selector
CFSELECT=	cf_select

# default configuration reader
DEFAULT=	default

# for getting making information
MKINFO=		Mkinfo
THEMKINFO=	${FILTERDIR}/${MKINFO}

# variable confilicts checker
CONFLICT=	Checkenv
THECONFLICT=	${MASTERDIR}/${CONFLICT}

# automatically generated files
TOOLDIR=	${TOPDIR}/Tools
CONFIG=		${TOOLDIR}/Configure
CLEANUP=	Cleanup
THECLEANUP=	${TOOLDIR}/${CLEANUP}

# sample definition files
SAMPLES=	${STDDIR}/smtpcheck-v7.def \
		${STDDIR}/smtpcheck-v8.def \
		${STDDIR}/sendmail-v1.def \
		${STDDIR}/sendmail-v5.def \
		${STDDIR}/sendmail-v6.def \
		${STDDIR}/sendmail-v7.def \
		${STDDIR}/sendmail-v8.def \
		${STDDIR}/null-v1.def \
		${STDDIR}/null-v5.def \
		${STDDIR}/null-v6.def \
		${STDDIR}/null-v7.def \
		${STDDIR}/null-v8.def \
		${STDDIR}/nmtc.def

# version information
VERSION=	${MASTERDIR}/version.v8
VINFO=		VERSION

# for packaging
PACKAGE=	`expr $$PWD : '.*/\([^/]*\)'`
#TAR=		/bin/tar cvfF -
TAR=		/usr/local/bin/tar --exclude-from=SCCS.dirs -cvf -
COMPRESS=	gzip
SUFFIX=		.tar.gz

SHELL=		/bin/sh

###

samples:	${SAMPLES}

tools:		${CONFIG} ${THECLEANUP}

all:		samples ${OBJS} ${MYOBJS}

clean:
	rm -f ${OBJS} ${MYOBJS}

cleantools:
	rm -f ${CONFIG} ${THECLEANUP}

cleanall:
	rm -f ${CONFIG} ${THECLEANUP} ${SAMPLES} ${OBJS} ${MYOBJS}

conflict:
	(cd ${MASTERDIR}; ./${CONFLICT})

mode:
	test -x ${MKFILT} || chmod +x ${MKFILT}
	test -x ${MKSAMPLE} || chmod +x ${MKSAMPLE}
	test -x ${THECONFLICT} || chmod +x ${THECONFLICT}
	test -x ${WHICH} || chmod +x ${WHICH}

${VINFO}:	mode samples ${OBJS}
	echo -n "version: " > ${VINFO}
	grep '^: $${VERSION=' ${VERSION} | sed 's/.*=\(.*\)}.*/\1/' >> ${VINFO}
	echo "package:" ${PACKAGE} >> ${VINFO}
	echo -n "packed: " >> ${VINFO}
	date >> ${VINFO}

${CONFIG} ${THECLEANUP}:	${MKFILT} ${PROTOS} \
		${MASTERDIR}/* ${OSTYPEDIR}/*
	MASTERDIR=${MASTERDIR} TOOLDIR=${TOOLDIR} CLEANUP=${CLEANUP} \
	CONFIG=${CONFIG} CFSELECT=${CFSELECT} MKINFO=${MKINFO} \
	DEFAULT=${DEFAULT} PERL=${PERLPATH} ${MKFILT} ${PROTOS}
	make conflict

dist:		${VINFO}
	(cd ..; ls -1d ${PACKAGE}/SCCS > SCCS.dirs)
	(cd ..; ls -1d ${PACKAGE}/*/SCCS >> SCCS.dirs)
	(cd ..; ls -1d ${PACKAGE}/*/*/SCCS >> SCCS.dirs)
	(cd ..; ${TAR} ${PACKAGE} | ${COMPRESS} > ${PACKAGE}${SUFFIX})

.SUFFIXES: .cf .def .in

.def.cf:
	MASTERDIR=${MASTERDIR} TOOLDIR=${TOOLDIR} \
	${CONFIG} $< > $@.tmp
	mv -f $@.tmp $@

.in.def:
	MASTERDIR=${MASTERDIR} TOOLDIR=${TOOLDIR} \
	${MKSAMPLE} $< > $@.tmp
	mv -f $@.tmp $@

${OBJS} ${MYOBJS}:	${CONFIG} ${THECLEANUP} ${THEMKINFO} ${PROTOS} \
			${MASTERDIR}/* ${OSTYPEDIR}/*

${SAMPLES}:	${PROTOS} ${FEATURES} ${MASTERDIR}/* ${OSTYPEDIR}/*

depend:
	mv -f Makefile Makefile.bak
	sed -n '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak > Makefile
	echo >> Makefile
	-(for i in ${MYOBJS} ; do\
		sed -n -e '/^$$/d' -e '/^#/d' -e 's/^.*FILE=//p' \
		`basename $$i .cf`.def | sed 's/#.*$$//' \
		| sed '/\/tmp\//d' \
		| sort -u | xargs echo $$i: >> Makefile ; \
	done)

# DO NOT DELETE THIS LINE -- make depend uses it

