# $Id: Makefile,v 1.9 2002/01/24 15:11:44 psg Exp $
#
# Makefile for mh-e.
#
# Note: most changes to this file should also be mirrored in the Makefiles in
# $(TOP)/doc and $(TOP)/contrib.
#
TOP		= ..

ifndef EMACS_HOME
EMACS_HOME	= $(TOP)/emacs
endif

EMACS		= emacs -batch --no-site-file --multibyte

MH-E-SRC	=			\
        mh-comp.el                      \
        mh-e.el                         \
        mh-funcs.el                     \
        mh-mime.el                      \
        mh-pick.el                      \
        mh-seq.el                       \
        mh-utils.el			\
	mh-xemacs-compat.el

MH-E-OBJ =  $(MH-E-SRC:.el=.elc)

MH-E-IMG	=			\
	execute.pbm			\
	execute.xpm			\
	page-down.pbm			\
	page-down.xpm			\
	refile.pbm			\
	refile.xpm			\
	repack.pbm			\
	repack.xpm			\
	rescan.pbm			\
	rescan.xpm			\
	show.pbm			\
	show.xpm			\
	widen.pbm			\
	widen.xpm			\

MH-E-IMG2	=			\
	mail/reply2.pbm			\
	mail/reply2.xpm

MH-E-ETC        = 			\
	MH-E-NEWS			\
	ChangeLog

MH-E-ETC-ETC	= COPYING

# Default rule is just to compile.
all: compile

# Compile mh-e. See $EMACS_HOME/lisp/Makefile for commentary.
compile: $(MH-E-OBJ)

# Remove everything we make.
clean:
	rm -rf $(MH-E-OBJ)

#
# The following targets are only of interest to maintainers.
#

# Create a distribution suitable for installing at SourceForge.
dist: compile
	@echo "Determining release..."
	@TAG=`cvs stat Makefile | awk '/Sticky Tag/{print $$3}'`; \
        if [ "$$TAG" = "(none)" ]; then \
            echo "No sticky tags here. Do a 'cvs update -rmh-e-M_N'."; \
            exit 1; \
        fi; \
        RELEASE=`echo $$TAG | sed 's/_/./g'`; \
	echo "Building $$RELEASE..."; \
        rm -rf $$RELEASE; \
        mkdir $$RELEASE $$RELEASE/mail; \
        cp $(MH-E-SRC) $(MH-E-ETC) $(MH-E-ETC-ETC) $(MH-E-OBJ) $(MH-E-IMG) \
           $$RELEASE; \
        cp $(MH-E-IMG2) $$RELEASE/mail; \
        tar -czhf $$RELEASE.tgz $$RELEASE

# Install the source into the Emacs source.
install-emacs:
	cp $(MH-E-ETC) $(EMACS_HOME)/etc
	cp $(MH-E-SRC) $(EMACS_HOME)/lisp/mail

# Imports Emacs changes.
import-emacs:
	import-emacs

# Compiles an individual lisp file.
%.elc: %.el
	$(EMACS) -f batch-byte-compile $<
