# Makefile for the   GNU Emacs Lisp Reference Manual.
#
# Feb 2 1996

# Redefine `TEX' if `tex' does not invoke plain TeX. For example:
# TEX=platex

#TEX=tex
TEX=/usr/local/nbin/jtex

makeinfo=mule -batch -load texinfmt -funcall batch-texinfo-format

# Where the TeX macros are kept:
texmacrodir = /usr/local/lib/tex/macros

# Where the Emacs hierarchy lives ($EMACS in the INSTALL document for Emacs.)
# For example: 
# emacslibdir = /usr/local/gnu/lib/emacs

# Directory where Emacs is installed, by default:
emacslibdir = /usr/local/emacs

# Unless you have a nonstandard Emacs installation, these shouldn't have to 
# be changed.
prefix = /usr/local
infodir = ${prefix}/info

# The name of the manual:

VERSION=2.4-jp2.0
manual = elisp-manual-19-$(VERSION)

# List of all the texinfo files in the manual:

fig_srcs = lists-fig1.tex lists-fig2.tex lists-fig3.tex lists-fig4.tex \
  lists-fig5.tex lists-fig6.tex lists-fig7.tex lists-fig8.tex \
  lists-fig9.tex lists-fig10.tex \
  objects-fig1.tex objects-fig2.tex objects-fig3.tex \
  objects-fig4.tex objects-fig5.tex objects-fig6.tex \
  sequences-jp-fig.tex text-fig.tex

fig_incs = fig-lbox-def.pic fig-sbox-def.pic

srcs = elisp-jp.texi back-jp.texi \
  abbrevs-jp.texi anti-jp.texi backups-jp.texi locals-jp.texi buffers-jp.texi \
  calendar-jp.texi commands-jp.texi compile-jp.texi control-jp.texi \
  debugging-jp.texi display-jp.texi edebug-jp.texi errors-jp.texi \
  eval-jp.texi files-jp.texi frames-jp.texi functions-jp.texi \
  help-jp.texi hooks-jp.texi internals-jp.texi intro-jp.texi \
  keymaps-jp.texi lists-jp.texi loading-jp.texi macros-jp.texi \
  maps-jp.texi markers-jp.texi minibuf-jp.texi modes-jp.texi \
  numbers-jp.texi objects-jp.texi os-jp.texi positions-jp.texi \
  processes-jp.texi searching-jp.texi \
  sequences-jp.texi streams-jp.texi strings-jp.texi symbols-jp.texi \
  syntax-jp.texi text-jp.texi tips-jp.texi variables-jp.texi \
  windows-jp.texi \
  wordlist-jp.texi elisp-jp.wd \
  index-jp.unperm

.PHONY: elisp.dvi clean

.SUFFIXES: .tex .pic
.pic.tex:
	gpic -t $*.pic > $@

elisp.dvi: $(srcs) $(fig_srcs) index-jp.texi texindex
	# Avoid losing old contents of aux file entirely.
	-mv elisp.aux elisp.oaux
	# First shot to define xrefs:
	$(TEX) elisp-jp.texi
	if [ a${permuted_index} != a ]; \
	then \
	  ./permute-index; \
	  mv permuted.fns elisp-jp.fns; \
	else \
	  ./texindex elisp-jp.??; \
	fi
	$(TEX) elisp-jp.texi

index-jp.texi:
	if [ a${permuted_index} != a ]; \
	then \
	  ln -s index-jp.perm index-jp.texi; \
	else \
	  ln -s index-jp.unperm index-jp.texi; \
	fi

elisp-jp.wd: wordlist.dat
	sed 's/\(.*\):\(.*\):\(.*\)/\\entry {\3}{\1}{\2}/' wordlist.dat > $@

# The info file is named `elisp'.

elisp-jp: $(srcs) index-jp.texi
	rm -f elisp-jp-*
	$(makeinfo) elisp-jp.texi

install: elisp-jp elisp-jp.dvi
	mv elisp-jp elisp-jp-* $(infodir)
	@echo also add the line for elisp to $(infodir)/dir.

installall: install
	install -c texinfo.tex texi-jp.tex $(texmacrodir)

clean:
	rm -f *.toc *.aux *.log *.cp *.cps *.fn *.fns *.tp *.tps \
              *.vr *.vrs *.pg *.pgs *.ky *.kys
	rm -f make.out core 
	rm -f makeinfo.o makeinfo getopt.o getopt1.o
	rm -f index-jp.texi
	rm -f $(fig_srcs) elisp-jp.wd

maintainer-clean: clean
	rm -f elisp-jp elisp-jp-*

dist:
	-mkdir temp
	-mkdir temp/$(manual)
	-ln README-jp Makefile $(srcs) $(fig_srcs) \
	$(fig_srcs:%.tex=%.pic) $(fig_incs) \
   wordlist.dat texinfo.tex texi-jp.tex getopt.c getopt1.c getopt.h \
   elisp-jp.dvi elisp-jp.aux elisp-jp.??s elisp-jp elisp-jp-[0-9] \
   elisp-jp-[0-9][0-9] temp/$(manual)
	-rm -f temp/$(manual)/texindex.c
	cp texindex.c temp/$(manual)
	(cd temp/$(manual); rm -f *~)
	(cd temp; tar chf - $(manual)) | gzip > $(manual).tar.gz
	-rm -rf temp
