### Makefile - for compiled e-lisp of ESS distribution.
###
### File: $Revision: 5.54 $.
###

## Before making changes here, please take a look at Makeconf
include ../Makeconf

## For noweb extraction of code and documentation.

NOTANGLE=notangle -L
#NOTANGLE=notangle for no indexing.
NOWEAVE=noweave

## SUFFIXES are in ../Makeconf :
.nw.html: ;     $(NOWEAVE) -filter l2h -index -html $*.nw > $*.html
.nw.tex: ;      $(NOWEAVE) -index -delay $*.nw | cpif $*.tex
.nw.el:  ;      $(NOTANGLE) -R$*.el | cpif $*.el
##.nw.c:  ;       $(NOTANGLE) -R$*.c | cpif $*.c
##.nw.h:  ;       $(NOTANGLE) -R$*.h | cpif $*.h
.tex.dvi: ;     latex '\scrollmode \input '"$*"; while grep -s 'Rerun to get cross-references right' $*.log; do latex '\scrollmode \input '"$*"; done

# have to preload the files that contain macro definitions or the
# byte compiler will compile everything that references them
# incorrectly.  also preload a file that sets byte compiler options.
PRELOADS = -l ./ess-comp.el


## files that contain key macro definitions.  almost everything
## depends on them because the byte-compiler inlines macro expansions.
## everything also depends on the byte compiler options file since
## this might do odd things like turn off certain compiler
## optimizations.  When these change, RECOMPILE.
CORE = ess.elc ess-site.elc

ELC = ess-cust.elc $(CORE) \
	ess-emcs.elc ess-utils.elc \
	ess-inf.elc ess-iw32.elc \
	ess-mode.elc ess-trns.elc ess-help.elc \
	ess-comp.elc \
	ess-menu.elc ess-mous.elc mouseme.elc \
	essl-s.elc essd-s3.elc essd-s4.elc \
	essd-sp3.elc essd-sp4.elc essd-sp5.elc essd-sp6.elc \
	essd-r.elc \
	essd-els.elc \
	essl-lsp.elc essd-xls.elc essd-vst.elc essd-arc.elc \
	essl-sas.elc essd-sas.elc essa-sas.elc \
	essl-sta.elc essd-sta.elc make-regexp.elc \
	essl-omg.elc essd-omg.elc \
	essl-bug.elc \
	ess-noweb.elc noweb-mode.elc noweb-font-lock-mode.elc \
	ess-font-lock.elc \
	essa-r.elc ess-toolbar.elc\
	essddr.elc

### Targets

all: $(ELC)

install: $(ELC)
	-$(INSTALLDIR) $(LISPDIR)
	$(INSTALL) *.elc $(LISPDIR)
#	test "$(LISPDIR)" = "." || $(INSTALL) *.elc $(LISPDIR)

dist: ess-cust.el
	@touch dist
## svn committing happens in ../Makefile

clean:
	rm -f $(ELC)

distclean: clean
# and potentially more


### Targets below here are only for developers.

### Replace Version numbers (as in ../doc/Makefile !):
ess-cust.el: ../VERSION
#	perl -pi -e 's/".*"/"$(shell cat $^)"/ if /ess-version/' $@
	cp -p ess-cust.el ess-temp.el
	$(SED) -e "s/(defvar ess-version \".*\"/(defvar ess-version \"$(ESSVERSION)\"/" ess-temp.el > ess-cust.el
	rm ess-temp.el

### File Dependencies

.el.elc:
	$(EMACSBATCH) $(PRELOADS) -f batch-byte-compile $<


ess-cust.elc:	ess-cust.el
	$(EMACSBATCH) $(PRELOADS) -f batch-byte-compile ess-cust.el

ess.elc: ess.el ess-cust.elc
	$(EMACSBATCH) $(PRELOADS) -l ess-cust.elc -f batch-byte-compile ess.el

ess-site.elc: ess-site.el ess.elc

ess-inf.elc: ess-inf.el $(CORE)
	@echo " "
	@echo "For the next compile, please disregard the messages"
	@echo " ** the function set-keymap-parent is not known to be defined."
	@echo " ** assignment to free variable comint-last-input-end"
	@echo "from the byte compiler if they occur. It is completely normal."
	$(EMACSBATCH) $(PRELOADS) -f batch-byte-compile ess-inf.el


ess-mode.elc: ess-mode.el $(CORE)
	@echo " "
	@echo "For the next compile, please disregard the message"
	@echo " ** the function set-keymap-parent is not known to be defined."
	@echo " ** variable last-sexp bound but not referenced"
	@echo "from the byte compiler if they occur. It is completely normal."
	$(EMACSBATCH) $(PRELOADS) -f batch-byte-compile ess-mode.el

ess-trns.elc: ess-trns.el $(CORE)
	@echo " "
	@echo "For the next compile, please disregard the message"
	@echo " ** the function set-keymap-parent is not known to be defined."
	@echo "from the byte compiler if it occurs. It is completely normal."
	$(EMACSBATCH) $(PRELOADS) -f batch-byte-compile ess-trns.el

ess-help.elc: ess-help.el $(CORE)

## S languages

essl-s.elc : essl-s.el ess.elc

essd-sas.elc : essd-sas.el ess.elc

essd-s3.elc : essd-s3.el essl-s.elc ess.elc

essd-sp3.elc : essd-sp3.el essl-s.elc ess.elc

essd-s4.elc : essd-s4.el essl-s.elc ess.elc

essd-r.elc : essd-r.el essl-s.elc ess.elc

## Lisp Languages

essl-lsp.elc : essl-lsp.el ess.elc

essd-xls.elc : essd-xls.el essl-lsp.elc ess.elc

essd-vst.elc : essd-vst.el essl-lsp.elc ess.elc

## SAS

essl-sas.elc : essl-sas.el ess.elc

essd-sas.elc : essd-sas.el essl-sas.elc ess.elc

## Stata

essl-sta.elc : essl-sta.el ess.elc

essd-sta.elc : essd-sta.el ess.elc

# Ignore this.
#(defun S-insert-make-rule (file)
#  (interactive "sFile:")
#  (insert (format "%s.elc:  %s.el $(CORE)\n\t@echo compiling %s.el...\n\t@$(EMACSBATCH) $(PRELOADS) -f batch-byte-compile %s.el" file file file file)))