# Generated automatically from Makefile.in by configure.
#
#
# Copyright (C) 1994 Swedish University Network (SUNET)
#
#
# This program is developed by UDAC, Uppsala University by commission
# of the Swedish University Network (SUNET). 
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITTNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#                                          Martin.Wendel@udac.uu.se
#					   Torbjorn.Wictorin@udac.uu.se
#
#                                          UDAC	
#                                          P.O. Box 174
#                                          S-751 04 Uppsala
#                                          Sweden
#
# Start of user defines
#######################

prefix = /usr/local
exec_prefix = $(prefix)
binprefix =
manprefix =

bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
mandir = $(prefix)/man
manext = 8

MAINCF = $(libdir)/emil.cf
CHARFILE = $(libdir)/charsets.cpl
SENDMAILPATH = /usr/lib/sendmail
SENDMAILPROG = sendmail
SENDERFLAG = -f
LOG_FACILITY = LOG_LOCAL1

# End of user defines
#####################

srcdir = .
CC = gcc -g -funsigned-char
CPPFLAGS=-I.
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

cffile = \"$(MAINCF)\"
charsetsfile = \"$(CHARFILE)\"
sendmailpath = \"$(SENDMAILPATH)\"
sendmailprog = \"$(SENDMAILPROG)\"
senderflag = \"$(SENDERFLAG)\"
MFLAGS = "CHARFILE=$(CHARFILE)"

DEFS = -DHAVE_CONFIG_H -DMAINCF=$(cffile) -DCHARFILE=$(charsetsfile) -DSENDMAILPATH=$(sendmailpath) -DSENDMAILPROG=$(sendmailprog) -DSENDERFLAG=$(senderflag) -DLOG_FACILITY=$(LOG_FACILITY)
LIBS =  -lm
RANLIB = ranlib
YACC = bison -y
LEX = flex
AR=		ar
SHELL=		/bin/sh

CHARDIR = $(srcdir)/charset


SRCS=	applefile.c base64.c binary.c binhex.c convert.c filenames.c forks.c \
	format.c hbase64.c header.c hqp.c load.c logger.c mailtool.c main.c \
	message.c mime.c out.c qp.c rfc1522.c rfc822.c uuencode.c \
	7bit.c
OBJS=	applefile.o base64.o binary.o binhex.o convert.o filenames.o forks.o \
	format.o hbase64.o header.o hqp.o load.o logger.o mailtool.o main.o \
	message.o mime.o out.o qp.o rfc1522.o rfc822.o uuencode.o \
	7bit.o
HDRS=	emil.h acconfig.h

DISTFILES = $(SRCS) $(HDRS) COPYING ChangeLog Makefile.in emil.cf \
README.FIRST README COPYRIGHT INSTALL configure.in mkinstalldirs emil.man \
emil.cf.man getoption.l getoption.y configure config.h.in TODO BUGS \
charset.c charset/*.[ch] charset/*.req charset/*.def charset/*.doc \
charset/*.in charset/*.cm

all: emil man finish

finish:
	@echo ""
	@echo "Now type 'make install' to install the necessery files"

.c.o:   emil.h
	$(CC) -c $(CPPFLAGS) $(DEFS) -I$(srcdir) $(ALL_CFLAGS) $(UNIQUE) $<

CHARSET: emil.h
	cd $(CHARDIR); $(MAKE) $(MFLAGS) all

charset.o: charset.c emil.h $(CHARDIR)/strncnv.c
	$(CC) -c -I$(CHARDIR) $(DEFS) -DEMIL -I$(srcdir) $(ALL_CFLAGS) $(UNIQUE) charset.c


emil: CHARSET emilx


emilx: $(OBJS) charset.o getoption.o $(CHARDIR)/dfopen.o emil.h
	$(CC) -o emil $(LDFLAGS) $(OBJS) charset.o getoption.o $(CHARDIR)/dfopen.o

getoption.o:		y.tab.c lex.yy.c emil.h
			$(CC) -c $(DEFS) -o getoption.o y.tab.c

y.tab.c:		getoption.y
			$(YACC) -l -v getoption.y
	
lex.yy.c:		getoption.l
			flex  -i getoption.l


man: 
	cp emil.man emil.$(manext)
	cp emil.cf.man emil.cf.$(manext)
	@rm -f config.ed
	@echo "1,\$$s'^MAINCF'$(MAINCF)'g" > config.ed
	@echo "w"		>> config.ed
	@echo "q"		>> config.ed
	ed emil.cf.$(manext) <config.ed
	@rm -f config.ed
	@echo "1,\$$s'^MAINCF'$(MAINCF)'g" > config.ed
	@echo "1,\$$s'^CHARFILE'$(CHARFILE)'g"	>> config.ed
	@echo "w"		>> config.ed
	@echo "q"		>> config.ed
	ed emil.$(manext) <config.ed

manprint: man
	psroff -man emil.$(manext)
	psroff -man emil.cf.$(manext)

install: installdirs
	@if test -f emil ; then \
		if test -f $(bindir)/emil ; then \
			echo "Saving $(bindir)/emil in $(bindir)/emil.bak ; \
			mv $(bindir)/emil $(bindir)/emil.bak ; \
		fi ; \
		cp emil $(bindir) ; \
		chown root $(bindir)/emil ; \
	fi ;\
	if test -f emil.cf ; then \
		if test -f $(MAINCF) ; then \
			echo "Keeping $(MAINCF) as is" ; \
			echo "You should check the Match lines and include" ;\
			echo "the ones not in the original emil.cf." ; \
		else \
			 cp emil.cf $(MAINCF); \
		fi ; \
	fi ;\
	if test -f charset/charsets.cpl ; then \
		if test -f $(CHARFILE) ; then \
			echo "Keeping $(CHARFILE) as is" ; \
		else \
			 cp charset/charsets.cpl $(CHARFILE); \
		fi ; \
	fi ;\
	if test -f emil.$(manext) ; then \
		 cp emil.$(manext) $(mandir)/man$(manext); \
	fi ;\
	if test -f emil.cf.$(manext) ; then \
		 cp emil.cf.$(manext) $(mandir)/man$(manext); \
	fi
installdirs:
	$(srcdir)/mkinstalldirs $(bindir) $(libdir)

uninstall: 
	if test -f $(bindir)/emil ; then \
		rm $(bindir)/emil ; \
	fi ;\
	if test -f $(MAINCF) ; then \
		 rm $(MAINCF); \
	fi ;\
	if test -f $(CHARFILE) ; then \
		 rm $(CHARFILE); \
	fi ;\
	if test -f $(mandir)/man$(manext)/emil.$(manext) ; then \
		 rm $(mandir)/man$(manext)/emil.$(manext); \
	fi ;\
	if test -f $(mandir)/man$(manext)/emil.cf.$(manext) ; then \
		 em $(mandir)/man$(manext)/emil.cf.$(manext) ; \
	fi

	
Makefile: Makefile.in config.status
	$(SHELL) config.status

config.status: configure
	$(SHELL) config.status --recheck

configure: configure.in
	cd $(srcdir); autoconf

config.h.in: configure.in
	cd $(srcdir); autoheader

TAGS: $(SRCS)
	etags $(SRCS)

clean:
	rm -f *.o emil y.tab.c lex.yy.c getoption.o getoption.c core ; \
	cd charset; make clean

mostlyclean: clean

distclean: clean
	rm -f Makefile config.status config.h;\
	cd charset; make distclean

realclean: distclean
	rm -f TAGS

dist: $(DISTFILES)
	if test ! -d emil-2.0.1; then \
		mkdir emil-2.0.1; \
	fi ; \
	tar cvf - $(DISTFILES) | (cd emil-2.0.1; tar xf -) ; \
	tar cf - emil-2.0.1 | gzip > emil-2.0.1.tar.gz

