#!/usr/bin/make -f
####################################################################
##### This file is automatically generated -- edit at your own risk
#####
##### file: /etc/mail/Makefile
##### generated via: /usr/share/sendmail/parsemc 
##### by: root@Infwali
##### on: Fri Jul 12 15:55:09 CEST 2002
##### in: /etc/mail
#####
##### Makefile for Sendmail databases
#####
####################################################################
SHELL=/bin/sh

# flag used to ensure only one newaliases command is run
newaliases_run=0

#
# all, the default target will update everything
#
all: \
	sendmail.cf \
	users.db \
	aliases.db
#
# clean target, remove sendmail.cf and databases
#
clean: 
	rm -f sendmail.cf
	rm -f users.db
	rm -f aliases.db
 
#
# Individual targets
#
sendmail.cf:	sendmail.mc dialup.m4 provider.m4
	echo "Generating /etc/mail/sendmail.cf ..."
	m4 \
		/usr/share/sendmail/sendmail.cf/m4/cf.m4 \
		/etc/mail/sendmail.mc \
		> /etc/mail/sendmail.cf.new \
		2> /etc/mail/sendmail.cf.errors
	chown root.mail /etc/mail/sendmail.cf.new
	chmod 0644 /etc/mail/sendmail.cf.new
	if [ ! -s /etc/mail/sendmail.cf.errors ]; then \
		rm /etc/mail/sendmail.cf.errors; \
	else \
		cat /etc/mail/sendmail.cf.errors; \
		echo ""; \
		fi;
	# Can't tell if the errors are fatal or not ;-{
	mv -f /etc/mail/sendmail.cf.new /etc/mail/sendmail.cf;
 
users.db:	users
	rm -f /etc/mail/users.db
	if [ -s /etc/mail/users ] && \
	   egrep -qe "^[[:space:]]*[^$$\#]" /etc/mail/users; then \
		makemap -d btree /etc/mail/users.db < /etc/mail/users; \
		chown root.mail /etc/mail/users.db; \
		chmod 0664 /etc/mail/users.db; \
		fi;
 
aliases.db:	aliases
	if [ $(newaliases_run) -eq 0 ]; then \
		newaliases_run=1; \
		newaliases; \
		fi
	chown root.mail /etc/mail/aliases.db
	chmod 0664 /etc/mail/aliases.db
#
# Optional targets... Will be touched if they don't exist.
#
local-host-names:
	touch /etc/mail/local-host-names
	chmod 0664 /etc/mail/local-host-names
	chown root.mail /etc/mail/local-host-names
 
trusted-users:
	touch /etc/mail/trusted-users
	chmod 0664 /etc/mail/trusted-users
	chown root.mail /etc/mail/trusted-users
 
relay-domains:
	touch /etc/mail/relay-domains
	chmod 0664 /etc/mail/relay-domains
	chown root.mail /etc/mail/relay-domains
 
users:
	touch /etc/mail/users
	chmod 0664 /etc/mail/users
	chown root.mail /etc/mail/users

#
# A few special targets that may not exists...
#

# dialup.m4 - created/updated by /etc/ppp/ip-up.d/sendmail
#             used to provide the true, hopefully resolvable
#	      hostname (from the ISP nameservers)
#         
#             To activate, put this in /etc/mail/sendmail.mc:
#		 include(`/etc/mail/dialup.m4')dnl
dialup.m4:
	touch /etc/mail/dialup.m4
	chmod 0664 /etc/mail/dialup.m4
	chown root.mail /etc/mail/dialup.m4

# provider.m4 - created by the user, or /etc/ppp/ip-up.d/sendmail
#               used to provide ISP information (masquerade_as, etc.)
#               If its a link, it will *not* be overwritten
#
#	        To activate, put this in /etc/mail/sendmail.mc:
#		   include(`/etc/mail/provider.m4')dnl
provider.m4:
	touch /etc/mail/provider.m4
	chmod 0664 /etc/mail/provider.m4
	chown root.mail /etc/mail/provider.m4

