#
#	@(#)Makefile	3.12 (motonori/WIDE) 4/22/94
#
#	Makefile for generation of sendmail.cf files
#

# if you have perl installed, perl will be used instead of sed.
PERL=		/usr/local/bin/perl

# sample.cf files
STDDIR=		Standards
OBJS=		${STDDIR}/sample-v1.cf ${STDDIR}/sample.cf \
		${STDDIR}/null-v1.cf ${STDDIR}/null.cf ${STDDIR}/nmtc.cf

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

PROTOS=		${MASTERDIR}/proto \
		${MASTERDIR}/proto.v1 \
		${MASTERDIR}/proto-null \
		${MASTERDIR}/proto-null.v1
FEATURES=	${MASTERDIR}/files \
		${MASTERDIR}/files.v1 \
		${MASTERDIR}/files-null \
		${MASTERDIR}/files-null.v1 \
		${MASTERDIR}/files.nmtc

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

# cf selector
CFSELECT=	cf_select

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

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

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

# sample definition files
SAMPLES=	${STDDIR}/sample.def \
		${STDDIR}/sample-v1.def \
		${STDDIR}/null.def \
		${STDDIR}/null-v1.def \
		${STDDIR}/nmtc.def

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

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

###

samples:	${SAMPLES}

tools:		${CONFIG} ${THECLEANUP}

all:	samples ${OBJS}

clean:
	rm -f ${OBJS} ${CONFIG} ${THECLEANUP} ${SAMPLES}

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

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

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

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

dist:	${VINFO}
	(cd ..; ${TAR} ${PACKAGE} | ${COMPRESS} > ${PACKAGE}${SUFFIX})

.SUFFIXES: .cf .def .in

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

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

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

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