# junkfilter
# a junk email filter system for procmail
# Copyright 1997-2002 Gregory Sutter <gsutter@zer0.org>
#
# $Id: Makefile,v 1.7 2002/05/07 02:42:53 gsutter Exp $
#
# Please read the file "README" and the page
# http://junkfilter.zer0.org/ before using junkfilter.

# JFDIR is where junkfilter is installed on your system.
# JFUSERDIR is where the user lists are. 
JFDIR?=			/usr/local/etc/junkfilter
JFUSERDIR?=		${HOME}/.procmail/

# JFLISTSRC is where the default list files (bodychk, headers, etc) live.
# JFLISTINST is where the compiled versions are placed.
JFLISTSRC?=		${JFDIR}
JFLISTINST?=		${JFDIR}

# JFUSERSRC is where the user list files (bodychk-user, domains-user, etc.)
# reside, and JFUSERINST is where the compiled versions will be placed.
JFUSERSRC?=		${JFUSERDIR}
JFUSERINST?=		${JFUSERDIR}

CAT_REGEX='s/\012(.)/\|$$1/g; s/\015//g; s/\|{2,}/\|/g'
DOT_REGEX='s/\./\\./g'
DOMAINS_REGEX='s/[	 ]+//g; y/[A-Z]/[a-z]/; s/\015//g'

RE_FILES=bodychk addresses ip dialups headers white domains/[a-z]*
USER_RE_FILES=bodychk-user addresses-user ip-user dialups-user headers-user white-user domains-user
JF_FILES=jf-bodychk jf-addresses jf-ip jf-dialups jf-headers jf-white jf-domains
USER_JF_FILES=jf-bodychk-user jf-addresses-user jf-ip-user jf-dialups-user jf-headers-user jf-domains-user jf-white-user

all:	${JF_FILES} ${USER_JF_FILES}
	@echo "Done. $@ built."

lists:	${JF_FILES}
	@echo "Done. $@ built."

user-lists:	${USER_JF_FILES}
	@echo "Done. $@ built."

test:	${RE_FILES} ${USER_RE_FILES}
	@echo ${CAT_REGEX}
	@for i in ${RE_FILES} ${USER_RE_FILES}; do echo Testing $$i...; done

create:	bodychk-user addresses-user ip-user dialups-user headers-user white-user domains-user

jf-bodychk::${JFLISTSRC}/bodychk
	@cat ${JFLISTSRC}/bodychk |\
	egrep -v '^#' |\
	sort |\
	perl -p0e ${CAT_REGEX} > ${JFLISTINST}/jf-bodychk

jf-bodychk-user:${JFUSERSRC}/bodychk-user
	@cat ${JFUSERSRC}/bodychk-user |\
	egrep -v '^#' |\
	sort |\
	perl -p0e ${CAT_REGEX} > ${JFUSERINST}/jf-bodychk-user

bodychk-user:
	@touch ${JFUSERSRC}/$@

jf-addresses:${JFLISTSRC}/addresses
	@cat ${JFLISTSRC}/addresses |\
	egrep -v '^#' |\
	sort |\
	perl -p0e ${CAT_REGEX} > ${JFLISTINST}/jf-addresses

jf-addresses-user:${JFUSERSRC}/addresses-user
	@cat ${JFUSERSRC}/addresses-user |\
	egrep -v '^#' |\
	sort |\
	perl -p0e ${CAT_REGEX} > ${JFUSERINST}/jf-addresses-user

addresses-user:
	@touch ${JFUSERSRC}/$@

jf-ip:${JFLISTSRC}/ip
	@cat ${JFLISTSRC}/ip |\
	egrep -v '^#' |\
	sort |\
	perl -p0e ${CAT_REGEX} |\
	perl -p0e ${DOT_REGEX} > ${JFLISTINST}/jf-ip

jf-ip-user:${JFUSERSRC}/ip-user
	@cat ${JFUSERSRC}/ip-user |\
	egrep -v '^#' |\
	sort |\
	perl -p0e ${CAT_REGEX} |\
	perl -p0e ${DOT_REGEX} > ${JFUSERINST}/jf-ip-user

ip-user:
	@touch ${JFUSERSRC}/$@

jf-dialups:${JFLISTSRC}/dialups
	@cat ${JFLISTSRC}/dialups |\
	egrep -v '^#' |\
	sort |\
	perl -p0e ${CAT_REGEX} |\
	perl -p0e ${DOT_REGEX} > ${JFLISTINST}/jf-dialups

jf-dialups-user:${JFUSERSRC}/dialups-user
	@cat ${JFUSERSRC}/dialups-user |\
	egrep -v '^#' |\
	sort |\
	perl -p0e ${CAT_REGEX} |\
	perl -p0e ${DOT_REGEX} > ${JFUSERINST}/jf-dialups-user

dialups-user:
	@touch ${JFUSERSRC}/$@

jf-headers:${JFLISTSRC}/headers
	@cat ${JFLISTSRC}/headers |\
	egrep -v '^#' |\
	sort |\
	perl -p0e ${CAT_REGEX} > ${JFLISTINST}/jf-headers

jf-headers-user:${JFUSERSRC}/headers-user
	@cat ${JFUSERSRC}/headers-user |\
	egrep -v '^#' |\
	sort |\
	perl -p0e ${CAT_REGEX} > ${JFUSERINST}/jf-headers-user

headers-user:
	@touch ${JFUSERSRC}/$@

jf-white:${JFLISTSRC}/white
	@cat ${JFLISTSRC}/white |\
	egrep -v '^#' |\
	sort |\
	perl -p0e ${CAT_REGEX} > ${JFLISTINST}/jf-white

jf-white-user:${JFUSERSRC}/white-user
	@cat ${JFUSERSRC}/white-user |\
	egrep -v '^#' |\
	sort |\
	perl -p0e ${CAT_REGEX} > ${JFUSERINST}/jf-white-user

white-user:
	@touch ${JFUSERSRC}/$@

jf-domains:${JFLISTSRC}/domains/[a-z]* domains/[a-z]* 
	@cat ${JFLISTSRC}/domains/[a-z]* domains/[a-z]* |\
	egrep -v '^#' |\
	perl -pe ${DOMAINS_REGEX} |\
	egrep -v '^$$' |\
	sort | uniq |\
	perl -p0e ${CAT_REGEX} |\
	perl -p0e ${DOT_REGEX} > ${JFLISTINST}/jf-domains

jf-domains-user:${JFUSERSRC}/domains-user
	@cat ${JFUSERSRC}/domains-user |\
	egrep -v '^#' |\
	perl -pe ${DOMAINS_REGEX} |\
	egrep -v '^$$' |\
	sort | uniq |\
	perl -p0e ${CAT_REGEX} |\
	perl -p0e ${DOT_REGEX} > ${JFUSERINST}/jf-domains-user

domains-user:
	@touch ${JFUSERSRC}/$@

force: ;

