# Makefile for  PGPsendmail  by  Richard Gooch
# The SENDMAIL line should be uncommented if you don't have privilege to
# replace  /usr/lib/sendmail  .You will then need to manually install
# PGPsendmail somewhere and make sure your Mail User Agent is told to use
# PGPsendmail instead of  /usr/lib/sendmail
# For EMACS ViewMail, you might add the following to your  ~/.emacs  file:
# (setq sendmail-program "/user/fred/pgp/bin/pgpsendmail")
# If you do have privilege, make sure the SENDMAIL line is commented out,
# otherwise your machine will be rooted (ask an Australian what that means;-).
# Check this for every new version of PGPsendmail/Unix
# Note also: you may need to change "/usr/lib/sendmail" to "/usr/sbin/sendmail"
# on some systems.
#

MANDIR = /usr/man

DEFINES =

CC = cc
COPTIMISE = -O
CFLAGS = $(DEFINES) -Iinclude $(COPTIMISE)

LDFLAGS = -s $(COPTIMISE) -Llib -lpgpsendmail

TARGETS =	dummy pgpsendmail pgpdaemon sendpgppass pgppipe \
		pgpsign extract-addrs match-email-addr reminder

all:	$(TARGETS) clean

lib/libpgpsendmail.a:
	(cd lib; make)

dummy:
	(cd lib; make)


pgpsendmail.o:	pgpsendmail.c
	$(CC) $(CFLAGS) -c pgpsendmail.c

pgpsendmail:	pgpsendmail.o lib/libpgpsendmail.a
	$(CC) -o pgpsendmail pgpsendmail.o $(LDFLAGS)
	@echo ""
	@echo "***WARNING***"
	@echo ""
	@echo -n "PGPsendmail will expect that the real sendmail is "
	@echo "`fgrep PATH_SENDMAIL /usr/include/paths.h |cut -d'"' -f 2`.real"
	@echo "If this is not true, you will have problems!"
	@echo ""


pgpdaemon:	pgpdaemon.o lib/libpgpsendmail.a
	$(CC) -o pgpdaemon pgpdaemon.o $(LDFLAGS)


sendpgppass:	sendpgppass.o lib/libpgpsendmail.a
	$(CC) -o sendpgppass sendpgppass.o $(LDFLAGS)


pgppipe:	pgppipe.o lib/libpgpsendmail.a
	$(CC) -o pgppipe pgppipe.o $(LDFLAGS)


pgpsign:	pgpsign.o lib/libpgpsendmail.a
	$(CC) -o pgpsign pgpsign.o $(LDFLAGS)


extract-addrs:	extract-addrs.o lib/libpgpsendmail.a
	$(CC) -o extract-addrs extract-addrs.o $(LDFLAGS)


match-email-addr:	match-email-addr.o lib/libpgpsendmail.a
	$(CC) -o match-email-addr match-email-addr.o $(LDFLAGS)


install: dummy pgpsendmail pgpdaemon sendpgppass pgppipe pgpsign extract-addrs\
		match-email-addr install.man
	./install pgpsendmail
	./install pgpdaemon
	./install sendpgppass
	./install pgppipe
	./install pgpsign
	./install extract-addrs
	./install match-email-addr

install.man: clean
	cp -rp man/* $(MANDIR)


reminder:
	@echo ""
	@echo "REMEMBER to do 'make install'"
	@echo ""


clean:
	rm -f *.BAK *.log *.sed .#* *~ *.bak */*.bak */tmp* */*~ */*/*~
	-chmod u+rw,go-w * 2> /dev/null

distclean:
	rm -f *.BAK *.log *.sed .#* *~ */*~ */*/*~ *.bak */*.bak */tmp* .*defaults
	rm -f $(TARGETS) *.o lib/*.o lib/libpgpsendmail.a
	-chmod u+rw,go-w * 2> /dev/null

treesum:
	@make distclean > /dev/null
	@cat `find . -type f -print | sort` | md5sum

# Dependencies
pgpdaemon.o:	     include/pgpsendmail.h include/karma.h include/version.h
pgppipe.o:	     include/pgpsendmail.h include/karma.h include/version.h
pgpsendmail.o:	     include/pgpsendmail.h include/karma.h include/version.h
pgpsign.o:	     include/pgpsendmail.h include/karma.h include/version.h
sendpgppass.o:	     include/pgpsendmail.h include/karma.h
extract-addrs.o:     include/pgpsendmail.h include/karma.h
match-email-addr.o:  include/pgpsendmail.h include/karma.h
