# Makefile for generating DJGPP FAQ list in a variety of formats

SOURCES = djgppfaq.txi faqmacro.txi faq-addr.txi faq-vers.txi

# Set to --djtitles='DJGPP FAQ' on DJ's server
DJTITLES =

CFLAGS = -Wall -O2 -s 

# In case they don't have "." in their TEXINPUTS variable
ifdef COMSPEC
export TEXINPUTS := .;$(TEXINPUTS)
else
export TEXINPUTS := .:$(TEXINPUTS)
endif

TEX   = tex
DVIPS = dvips
DVILJ = dvilj4

%.ps: %.dvi
	$(DVIPS) -o $@ $<

%.lj: %.dvi
	$(DVILJ) $<

all: djgppfaq.info djgppfaq.html djgppfaq.txt djgppfaq.dvi djgppfaq.ps djgppfaq.lj

djgppfaq.inf: djgppfaq.info

djgppfaq.info: djgppfaq.txi
	makeinfo --no-split --footnote-style=separate --fill-column=78 --number-sections -o $@ $<

faq.htm: faq.html

faq.html: djgppfaq.html htmsplit
	./htmsplit $(DJTITLES) djgppfaq.html faq

djgppfaq.htm: djgppfaq.html

djgppfaq.html: djgppfaq.txi
	makeinfo --html --no-split --number-sections -o $@ $<

htmsplit: htmsplit.c
	gcc $(CFLAGS) -o $@ $<

djgppfaq.txt: djgppfaq.txi
	makeinfo --no-split --no-headers --number-sections --fill-column 78 -Dtext -o $@ $<

djgppfaq.dvi: djgppfaq.exp texinfo.tex
	texi2dvi $<

djgppfaq.exp: $(SOURCES)
	makeinfo --no-split -E $@ -o /dev/null $<

macro.exp: djgppfaq.txi
	makeinfo --no-split -E $@ -o /dev/null $<

clean:
ifdef COMSPEC
	command > nul /c for %f in (*.exe *.num htmsplit djgppfaq.html *.exp) do if exist %f del %f
else
	rm -f *.exe *.num htmsplit djgppfaq.htm* *.exp
endif

distclean: clean

realclean: distclean
ifdef COMSPEC
	command > nul /c for %f in (*.htm *.html *.inf *.ps *.dvi *.txt *.lj) do if exist %f del %f
else
	rm -f *.htm* *.inf* *.ps *.dvi *.txt *.lj
endif
love:
	@echo 'Not war!'

coffee:
	@echo 'Not yet.  Maybe in v3.x...'
