# --- FWEB MAKE FILE (v. 1.30) FOR USER MANUAL ---

# BEFORE USING THIS MAKEFILE:  
#  Read and execute the instructions at the beginning of the main Makefile.

# PLEASE REPORT ANY DIFFICULTIES WITH USING THIS MAKE FILE OR WITH ANY
# OTHER ASPECT OF COMPILING OR RUNNING FWEB:  krommes@princeton.edu.

# You should PREFACE ALL MAJOR OPERATIONS with

#	make -n ...

# This tells you what will happen without actually performing the operations.


# --- PRINCIPAL ENTRY POINTS ---

# The principal entry points to this make file can be determined by saying
# ``make help''.  (See the help: target below.)


# --- INCLUDING FILES into the Makefile ---

# The file defaults.mk customizes the operation of Makefile for your
# compiler environment.
# NOTE: Not all makes include files in identical ways; you may need to
# modify the next line:

include ../web/defaults.mk # Unix
# ! include "../web/defaults.mk" # Borland/Microsoft

# --------------------- DON'T CHANGE ANYTHING BELOW HERE --------------------

# --- Name of the manual  and reference guide---
MAN = fwebman
GUIDE = guide

# To run this make file, we must always be in the manual subdirectory.
MANUAL = .

# USER ENTRY POINT:  ``make all''
all: manual guide

# --- Dependent files for the manual ---
COMMON_INPUTS = $(MANUAL)/fmanmacs.tex $(MANUAL)/fmanrefs.tex \
	$(MANUAL)/indexing.tex\
	$(MANUAL)/dots.tex

MAN_INPUTS = $(COMMON_INPUTS) $(MANUAL)/guide0.tex

GUIDE_INPUTS = $(COMMON_INPUTS) $(STL_INPUTS)

STL_INPUTS = $(MANUAL)/equiv.tex\
	$(MANUAL)/index.stl\
	$(MANUAL)/modules.stl\
	$(MANUAL)/contents.stl\
	$(MANUAL)/subs.stl\
	$(MANUAL)/formats.stl\
	$(MANUAL)/wmisc.stl\
	$(MANUAL)/t.stl\
	$(MANUAL)/wtmisc.stl\
	$(MANUAL)/auto.stl\
	$(MANUAL)/colors.stl\
	$(MANUAL)/ccodes.stl

DEMOS = $(MANUAL)/demo0.tex\
	$(MANUAL)/demo1.tex\
	$(MANUAL)/demo2.tex\
	$(MANUAL)/demo3.tex\
	$(MANUAL)/demo4.tex\
	$(MANUAL)/f0to_web.tex\
	$(MANUAL)/f_to_web.tex $(MANUAL)/f_to_web.f\
	$(MANUAL)/f90_cpp.tex
 
demos: $(DEMOS) $(MANUAL)/demos.sty

$(MANUAL)/fwebmac.sty: $(MANUAL)/fwebmac.web
	ftangle $(MANUAL)/fwebmac -# -=$(@)

$(MANUAL)/fwebmacL.sty: $(MANUAL)/fwebmacL.web
	ftangle $(MANUAL)/fwebmacL -# -=$(@)

$(MANUAL)/demo0.tex: $(MANUAL)/demo0.web $(MANUAL)/fwebmac.sty
	fweave $(MANUAL)/demo0 -zdemos.sty -=$(@)

$(MANUAL)/demo1.tex: $(MANUAL)/demo1.web $(MANUAL)/fwebmac.sty
	fweave $(MANUAL)/demo1 -zdemos.sty -=$(@)

$(MANUAL)/demo2.tex: $(MANUAL)/demo2.web $(MANUAL)/fwebmac.sty
	fweave $(MANUAL)/demo2 -zdemos.sty -=$(@)

$(MANUAL)/demo3.tex: $(MANUAL)/demo3.web $(MANUAL)/fwebmac.sty
	fweave $(MANUAL)/demo3 -zdemos.sty -=$(@)

$(MANUAL)/demo4.tex: $(MANUAL)/demo4.web $(MANUAL)/fwebmac.sty
	fweave $(MANUAL)/demo4 -zdemos.sty -=$(@)

$(MANUAL)/f0to_web.tex: $(MANUAL)/f0to_web.web $(MANUAL)/fwebmac.sty
	fweave $(MANUAL)/f0to_web -zdemos.sty -=$(@)

$(MANUAL)/f_to_web.tex: $(MANUAL)/f_to_web.web $(MANUAL)/fwebmac.sty
	fweave $(MANUAL)/f_to_web -zdemos.sty -=$(@)

$(MANUAL)/f_to_web.f: $(MANUAL)/f_to_web.web
	ftangle $(MANUAL)/f_to_web -zdemos.sty -=$(@)

$(MANUAL)/f90_cpp.tex: $(MANUAL)/f90_cpp.web $(MANUAL)/fwebmac.sty
	fweave $(MANUAL)/f90_cpp -zdemos.sty -=$(@)

# USER ENTRY POINT:  ``make guide''
guide: $(GUIDE).body $(GUIDE).index

$(GUIDE).body: $(MANUAL)/$(GUIDE).tex $(MANUAL)/$(GUIDE)0.tex\
		$(COMMON_INPUTS) $(GUIDE_INPUTS)
	tex $(MANUAL)/$(GUIDE) 
	$(MV) $(MANUAL)/$(GUIDE).dvi $(MANUAL)/$(GUIDE)1.dvi
	$(PRINT_DVI) $(MANUAL)/$(GUIDE)1.dvi

$(GUIDE).index: $(GUIDE).body $(GUIDE).ind $(MANUAL)/$(GUIDE).ind
	latex $(MANUAL)/$(GUIDE).ind
	$(PRINT_DVI) $(MANUAL)/$(GUIDE).dvi

$(GUIDE).ind: $(GUIDE).body 
	makeindex -s mx.sty -p any $(MANUAL)/$(GUIDE).idx

# USER ENTRY POINT:  ``make manual''
manual $(MAN): tch_man $(MAN)0

tch_man:
	$(TOUCH)  $(MANUAL)/*.sty $(MANUAL)/*.tex $(MANUAL)/*.f

manual0 $(MAN)0: $(MAN).body $(MAN).index

# After tex is run on the manual body, the dvi file is moved to
# fwebman1.dvi, so subsequent processing of the index doesn't overwrite that.
manual.body $(MAN).body: $(MANUAL)/$(MAN).tex\
		$(MAN_INPUTS)\
		$(MANUAL)/fwebmac.sty $(MANUAL)/fwebmac.tex\
		$(MANUAL)/fwebmacL.sty $(MANUAL)/fwebmacL.tex\
		$(DEMOS) $(MANUAL)/f0to_web.src
	tex $(MANUAL)/$(MAN) 
	$(MV) $(MANUAL)/$(MAN).dvi $(MANUAL)/$(MAN)1.dvi
	$(PRINT_DVI) $(MANUAL)/$(MAN)1.dvi

manual.index $(MAN).index: $(MAN).body $(MAN).ind $(MANUAL)/$(MAN).ind
	latex $(MANUAL)/$(MAN).ind
	$(PRINT_DVI) $(MANUAL)/$(MAN).dvi

$(MAN).ind: $(MAN).body 
	makeindex -s mx.sty -p any $(MANUAL)/$(MAN).idx
	


# --- INSTALLATION GUIDE ---

# Name of the installation guide.
INSTALL_GUIDE = INSTALL_FWEB

install_guide $(INSTALL_GUIDE): $(INSTALL_GUIDE).body $(INSTALL_GUIDE).index

install_guide.body $(INSTALL_GUIDE).body: $(MANUAL)/$(INSTALL_GUIDE).tex\
		$(MANUAL)/fmanmacs.tex $(MANUAL)/indexing.tex
	tex $(MANUAL)/$(INSTALL_GUIDE)
	$(MV) $(INSTALL_GUIDE).dvi $(INSTALL_GUIDE)1.dvi
	$(PRINT_DVI) $(MANUAL)/$(INSTALL_GUIDE)1.dvi

install_guide.index $(INSTALL_GUIDE).index: $(INSTALL_GUIDE).body \
		$(INSTALL_GUIDE).ind $(MANUAL)/$(INSTALL_GUIDE).ind
	latex $(MANUAL)/$(INSTALL_GUIDE).ind
	$(PRINT_DVI) $(MANUAL)/$(INSTALL_GUIDE).dvi

$(INSTALL_GUIDE).ind: $(INSTALL_GUIDE).body 
	makeindex -s mx.sty -p any $(MANUAL)/$(INSTALL_GUIDE).idx



# --- INSTALLATION of the manual ---

install: $(MANUAL)/$(MAN)1.dvi $(MANUAL)/$(GUIDE)1.dvi \
		$(MANUAL)/$(MAN).dvi $(MANUAL)/$(GUIDE).dvi
	@echo ""
	@echo "If any changes need to be made to the default directories,"
	@echo "please edit ../web/defaults.mk.in, then rerun ../configure."
	@echo ""
	-test ! -d $(manualdir) && mkdir $(manualdir)
	$(INSTALL_DATA) $(MANUAL)/$(MAN).tex $(MANUAL)/$(GUIDE).tex \
		$(manualdir)/
	$(INSTALL_DATA) $(MAN_INPUTS) $(STL_INPUTS) \
		$(manualdir)/
	$(INSTALL_DATA) $(MANUAL)/$(MAN).ind $(MANUAL)/$(GUIDE).ind \
		$(manualdir)

uninstall: 
	$(RM) -r $(manualdir)


# --- CLEANUP ---

clean:
	$(RM) -f *.idx *.ind *.aux *.ilg *.log *.dvi

mostlyclean: clean

distclean: clean

realclean: distclean

# --- HELP ---

help:
	@echo "Important targets for this Makefile:"
	@echo ""
	@echo " all           --- The user manual as well as reference guide (does not print)."
	@echo " clean         --- Removes *.idx, *.ind, *.aux, *.ilg, *.log, and *.dvi."
	@echo " guide         --- Short REFERENCE GUIDE (several appendices from"
	@echo "                   complete user manual)."
	@echo " install       --- Permanently install the manual."
	@echo " install_guide --- Detailed INSTALLATION GUIDE and explanation of FWEB files."
	@echo " manual        --- The complete (long!) USER MANUAL."
	@echo " manual.body   --- Manual text only."
	@echo " manual.index  --- Manual index only."
	@echo " *.dvi         --- DOCUMENTS an FWEB source; runs fweave and TeX."

