#
#  Makefile - Makefile for af.
#  Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 Malc Arnold.
#
#  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, 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 FITNESS 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.  */
#
#
##############################################################################
# RCS Info
#
# $Id: Makefile.in,v 2.0 1997/09/06 12:00:58 malc Rel $
#
##############################################################################
# Where do things go?
BINDIR=@BINDIR@
LIBDIR=@LIBDIR@

# Required programs
SHELL=/bin/sh
INSTALL=@INSTALL@
INSTALLDIR=../install.sh

# Compiler options
CC=@CC@
CFLAGS=@CFLAGS@ -I../lib
LDFLAGS=@LDFLAGS@
LINT=lint
LINTFLAGS=-Dlint -I../lib

# Install options
AFINSTOPTS=@IAFOPTS@
BININSTOPTS=@IBINOPTS@
SCRINSTOPTS=@ISCROPTS@
MBXINSTOPTS=@IMBXOPTS@
DIRINSTOPTS=@IDIROPTS@

# The files generated by configure
CONFIG=Makefile config.h

# The name of the af library
LIBAF=../lib/libaf.a

# What we must make
TARGETS=@TARGETS@ afconfig

# Sources, objects and libraries for af
AFSRC=address.c af.c alias.c atom.c buf_cmd.c buffer.c commands.c \
complete.c conf_cmd.c date.c display.c exec.c file_cmd.c files.c \
format.c functions.c help_cmd.c help.c io.c keymaps.c keyseq.c \
killbuf.c load.c @LOCK_C@ macros.c mail_cmd.c mailbox.c mailsort.c \
makemail.c mark_cmd.c mime.c misc_cmd.c misc.c mode.c move_cmd.c \
@NETMAIL_C@ parsemail.c readline.c screen.c sendmail.c srch_cmd.c \
tag_cmd.c tags.c term.c typeout.c variable.c win_cmd.c window.c

AFOBJ=address.o af.o alias.o atom.o buf_cmd.o buffer.o commands.o \
complete.o conf_cmd.o date.o display.o exec.o file_cmd.o files.o \
format.o functions.o help_cmd.o help.o io.o keymaps.o keyseq.o \
killbuf.o load.o @LOCK_O@ macros.o mail_cmd.o mailbox.o mailsort.o \
makemail.o mark_cmd.o mime.o misc_cmd.o misc.o mode.o move_cmd.o \
@NETMAIL_O@ parsemail.o readline.o screen.o sendmail.o srch_cmd.o \
tag_cmd.o tags.o term.o typeout.o variable.o win_cmd.o window.o

LIBS=$(LIBAF) @LIBS@

# Sources and objects for afack
AFACKSRC=address.c afack.c alias.c atom.c misc.c
AFACKOBJ=addressck.o afack.o aliasck.o atom.o misc.o

# The source for Rnaf, Afinfo, and afconfig
RNAFSRC=Rnaf.sh
AFINSRC=Afinfo.sh
AFCSRC=afconfig.sh

# Sources and objects for the mailbox access programs
RMBOXSRC=readmbox.c lock.c
RMBOXOBJ=readmbox.o lock.o

WMBOXSRC=writembox.c lock.c
WMBOXOBJ=writembox.o lock.o

# How to make it
all:	$(TARGETS)

af:	$(AFOBJ) $(LIBAF)
	$(CC) $(LDFLAGS) $(AFOBJ) $(LIBS) -o $@

afack:	$(AFACKOBJ) $(LIBAF)
	$(CC) $(LDFLAGS) $(AFACKOBJ) $(LIBS) -o $@

Rnaf:	$(RNAFSRC)
	cp $(RNAFSRC) $@

Afinfo:	$(AFINSRC)
	cp $(AFINSRC) $@

afconfig:	$(AFCSRC)
	cp $(AFCSRC) $@

readmbox: $(RMBOXOBJ) $(LIBAF)
	$(CC) $(LDFLAGS) $(RMBOXOBJ) $(LIBS) -o $@

writembox: $(WMBOXOBJ) $(LIBAF)
	$(CC) $(LDFLAGS) $(WMBOXOBJ) $(LIBS) -o $@

$(LIBAF):
	cd ../lib; $(MAKE)

lint:
	$(LINT) $(LINTFLAGS) $(AFSRC)
	$(LINT) $(LINTFLAGS) -DAFACK $(AFACKSRC)
	$(LINT) $(LINTFLAGS) $(RMBOXSRC)
	$(LINT) $(LINTFLAGS) $(WMBOXSRC)

install: all
	$(INSTALL) $(AFINSTOPTS) af $(BINDIR)
	$(INSTALL) $(BININSTOPTS) afack $(BINDIR)
	$(INSTALL) $(SCRINSTOPTS) Rnaf afconfig $(BINDIR)
	$(INSTALLDIR) $(DIRINSTOPTS) $(LIBDIR)
	$(INSTALL) $(SCRINSTOPTS) Afinfo $(LIBDIR)
	test ! -f readmbox || $(INSTALL) $(MBXINSTOPTS) readmbox writembox $(LIBDIR)

clean:
	rm -f $(TARGETS) $(AFOBJ) $(AFACKOBJ) $(RMBOXOBJ) $(WMBOXOBJ) core

distclean: clean
	rm -f $(CONFIG)

# Everything depends on af.h and config.h
$(AFOBJ):	af.h config.h
$(AFACKOBJ):	af.h config.h
$(RMBOXOBJ):	af.h config.h
$(WMBOXOBJ):	af.h config.h

# Module-specific dependencies
address.o:	atom.h address.h ttable.h keyseq.h functions.h variable.h
af.o:		keyseq.h functions.h variable.h mode.h version.h
alias.o:	atom.h address.h alias.h
atom.o:		atom.h
buf_cmd.o:	keyseq.h functions.h commands.h mode.h complete.h
buffer.o:	keyseq.h functions.h variable.h mode.h complete.h io.h
commands.o:	keyseq.h functions.h commands.h keymaps.h macros.h
commands.o:	variable.h mode.h complete.h cmdlist.h misc.h
complete.o:	complete.h
conf_cmd.o:	keyseq.h functions.h commands.h variable.h mode.h complete.h
date.o:		atom.h date.h
display.o:	display.h keyseq.h functions.h variable.h mode.h
exec.o:		keyseq.h functions.h variable.h
file_cmd.o:	keyseq.h functions.h commands.h variable.h mode.h complete.h
files.o:	keyseq.h functions.h variable.h complete.h io.h misc.h
format.o:	format.h keyseq.h functions.h variable.h mode.h
format.o:	tags.h version.h
functions.o:	keyseq.h functions.h commands.h keymaps.h macros.h variable.h 
functions.o:	mode.h load.h complete.h funclist.h constlist.h version.h
help.o:		keyseq.h functions.h commands.h macros.h complete.h version.h
help_cmd.o:	keyseq.h functions.h commands.h keymaps.h macros.h
help_cmd.o:	variable.h mode.h complete.h
io.o:		keyseq.h functions.h variable.h complete.h io.h misc.h
keymaps.o:	keyseq.h functions.h commands.h keymaps.h macros.h
keymaps.o:	variable.h mode.h complete.h maplist.h
keyseq.o:	keyseq.h functions.h variable.h
killbuf.o:	killbuf.h keyseq.h functions.h variable.h tags.h
load.o:		load.h keyseq.h functions.h commands.h variable.h
lock.o:		misc.h
macros.o:	keyseq.h functions.h commands.h keymaps.h macros.h
macros.o:	variable.h complete.h io.h
mail_cmd.o:	keyseq.h functions.h commands.h variable.h mode.h
mail_cmd.o:	tags.h complete.h io.h
mailsort.o:	mailsort.h keyseq.h functions.h variable.h tags.h complete.h
makemail.o:	makemail.h sendmail.h keyseq.h functions.h variable.h
makemail.o:	misc.h version.h
mark_cmd.o:	keyseq.h functions.h commands.h mode.h complete.h
mime.o:		atom.h mime.h keyseq.h functions.h variable.h
misc.o:		misc.h
misc_cmd.o:	keyseq.h functions.h commands.h complete.h version.h
mode.o:		mode.h complete.h modelist.h
move_cmd.o:	keyseq.h functions.h commands.h variable.h mode.h complete.h
netmail.o:	sendmail.h netmail.h keyseq.h functions.h variable.h
netmail.o:	io.h misc.h
parsemail.o:	atom.h parsemail.h keyseq.h functions.h variable.h tags.h
readline.o:	keyseq.h functions.h commands.h variable.h
readline.o:	mode.h complete.h readline.h
screen.o:	termcntrl.h
sendmail.o:	keyseq.h functions.h sendmail.h variable.h
sendmail.o:	complete.h misc.h io.h
srch_cmd.o:	keyseq.h functions.h commands.h variable.h mode.h tags.h
tag_cmd.o:	keyseq.h functions.h commands.h mode.h tags.h complete.h
tags.o:		keyseq.h functions.h variable.h tags.h
term.o:		termcntrl.h
typeout.o:	keyseq.h functions.h commands.h variable.h mode.h complete.h
variable.o:	keyseq.h functions.h variable.h tags.h complete.h varlist.h
win_cmd.o:	keyseq.h functions.h commands.h

# Special rules for making addressck.o and aliasck.o.
addressck.o:	address.c address.h ttable.h
	cp address.c addressck.c
	$(CC) $(CFLAGS) -DAFACK -c addressck.c
	rm -f addressck.c

aliasck.o:	alias.c alias.h address.h atom.h
	cp alias.c aliasck.c
	$(CC) $(CFLAGS) -DAFACK -c aliasck.c
	rm -f aliasck.c
