#
#
# Copyright (C) 1993 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
#
#                                          Martin Wendel
#                                          UDAC	
#                                          Box 174
#                                          S-751 04 Uppsala
#                                          Sweden
#
#
#########################################################################
#                                          #
#   Start of user configurable parameters. #
#   These are set to reasonable defaults   #
#   so it is OK to leave them as they are. #
#                                          #
############################################


#
# You do want to use debugging initially so just leave these uncommented.
# The log level LOG_DEBUG, however, creates a lot of output
# Later on you perhaps can change LOG_DEBUG to LOG_ERR to reduce the amount
# of logging.
#
DODEBUG=-DEMILDEBUG
LOGLEVEL=LOG_DEBUG

#
# This defines the location of the logfile Emil will use
# Set it to anything you like
#
LOGFILE=/usr/local/emil.log

#
# This is a spool directory if used in standalone mode.
# Place it wherever you like. It's unused in sendmail mode.
#
SPOOLDIR=/tmp

#
# CFLAGS define where to find tcl.h
#
CFLAGS = -g -I/usr/local/include

#
# LDFLAGS define where to find libtcl.a
#
LDFLAGS = -g -L/usr/local/lib -L.

#
# prefix defines what prefix should be used when installing the
# configuration files
#
prefix = /usr/local
#########################################################################
#                                             #
#   End of user configurable parameters. You  #
#   shouldn't need to change anything below   #
#                                             #
###############################################

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

SHELL=		/bin/sh

EMILLIBDIR = $(libdir)/emil
DEBUG=$(DODEBUG) -DEmilLogFile=\\\"$(LOGFILE)\\\" -DEMILLOGLEVEL=$(LOGLEVEL)
LIB_FLAGS=-DEMILLIBDIR=\\\"$(EMILLIBDIR)\\\"
EMILTMPDIR=-DEMILTMPDIR=\\\"$(SPOOLDIR)\\\"
CHARFILE = $(libdir)/charset/charsets.cpl
ALL_CFLAGS= $(CFLAGS) $(DEBUG) $(LIB_FLAGS)


SRCS=	binary.c convert.c misc.c mkbuf.c sendmail.c MkCmd.c MkTcl.c \
	mkqueue.c syslog.c general.c
OBJS=	binary.o convert.o misc.o mkbuf.o sendmail.o MkCmd.o MkTcl.o \
	mkqueue.o syslog.o general.o
HDRS=	mk.h mkdef.h mkcdefs.h mkconf.h mkspec.h

DISTFILES = $(SRCS) $(HDRS) COPYING ChangeLog Makefile.in \
README COPYRIGHT INSTALL Manual.ps Sendmail-IDA.patch configure \
configure TODO


all: 
	@echo "Type './configure' before make"
	@echo ""
	@echo "Then specify one of the following:"
	@echo ""
	@echo "'make emil'		to make the standalone filter"
	@echo "'make sendmail8'		to make the sendmail8.6.4 library"
	@echo "'make sendmailIDA'	to make the IDA sendmail library"
	@echo "'make man'		to make the man page"
	@echo "'make install'		to install everything"

sendmailIDA :
	make -f emakefile sendmailIDA UNIQUE="-DSENDMAIL -I../../src" \
	ALL_CFLAGS="$(ALL_CFLAGS)"  LDFLAGS="$(LDFLAGS)" \
	CHARFILE="$(CHARFILE)" \
	bindir="$(bindir)" libdir="$(libdir)" mandir="$(mandir)" \
	manext="$(manext)"

sendmail8 :
	make -f emakefile sendmail8 UNIQUE="-DSENDMAIL_8 -I../src"  \
	ALL_CFLAGS="$(ALL_CFLAGS)"  LDFLAGS="$(LDFLAGS)" \
	CHARFILE="$(CHARFILE)" \
	bindir="$(bindir)" libdir="$(libdir)" mandir="$(mandir)" \
	manext="$(manext)"


emil :
	make -f emakefile emil UNIQUE="$(EMILTMPDIR)" \
	ALL_CFLAGS="$(ALL_CFLAGS)" LDFLAGS="$(LDFLAGS)" \
	CHARFILE="$(CHARFILE)" \
	bindir="$(bindir)" libdir="$(libdir)" mandir="$(mandir)" \
	manext="$(manext)"

man :
	make -f emakefile man  \
	ALL_CFLAGS="$(ALL_CFLAGS)"  LDFLAGS="$(LDFLAGS)" \
	CHARFILE="$(CHARFILE)" \
	bindir="$(bindir)" libdir="$(libdir)" mandir="$(mandir)" \
	manext="$(manext)"


install: all man
	make -f emakefile install
	cp emil.$(manext) $(mandir)/man$(manext)
clean:
	make -f emakefile clean

distclean:
	make -f emakefile distclean
