###
### Makefile for byte-compile
###
### Author:  Fukae Seiji <fukae@hiroshima-u.ac.jp>
### Created: May 19, 2000
### Besed: the original Makefile written by Kazu Yamamoto
### <Kazu@Mew.org>

###
### (1) Set the following variables as you like.
### (2) make
### (3) make install
### (5) make install-info

################################################################
##
## EDIT THE FOLLOWINGS
##

#prefix = /usr
#xemacspackages = $(prefix)/lib/xemacs/xemacs-packages
#infodir =$(xemacspackages)/info
#infodir = $(prefix)/info

##
## Compile engines
##

#EMACS = emacs
#EMACS = xemacs
#EMACS = mule

#PERL=`which perl`
#PERL=/usr/local/bin/perl


##
## A directory where mew*.el[c] will be installed.
##

#elispdir  = $(xemacspackages)/lisp/mew
#elispdir = $(prefix)/share/emacs/site-lisp/mew
#elispdir = $(prefix)/lib/emacs

OBJS =	mew-refile-view.elc mew-nmz.elc mew-gnus.elc mew-toolbar-frame.elc

SRCS =	mew-refile-view.el mew-nmz.el mew-gnus.el mew-toolbar-frame.el

TEMPFILE = temp.el

CP = cp
RM = rm -f
MKDIR = mkdir -p

all: $(OBJS)
	@echo 'Compiling EL files of contribution packages ... '
	$(EMACS) -batch -q -no-site-file -l ./$(TEMPFILE) -f mew-compile
	@echo 'Compiling EL files of contribution packages ... done'

$(OBJS): $(TEMPFILE)

$(TEMPFILE):
	@echo '(setq load-path (cons "." load-path))' > $(TEMPFILE)
	@echo '(setq load-path (cons (expand-file-name "..") load-path))' >> $(TEMPFILE)
	@echo '(defun mew-compile () (mapcar (function (lambda (x) (byte-compile-file x))) (list ' >> $(TEMPFILE)
	@echo $(OBJS) | sed -e 's/\(mew[^ ]*\.el\)c/"\1"/g'  >> $(TEMPFILE)
	@echo ')))' >> $(TEMPFILE)


install: $(OBJS)
	-@if [ ! -d $(elispdir) ]; then \
		$(MKDIR) $(elispdir); \
	fi; \
	$(CP) $(SRCS) $(elispdir)
	$(CP) $(OBJS) $(elispdir)

clean:
	$(RM) $(OBJS) $(TEMPFILE)

##
## End of Makefile
##
