#
# Copyright (c) 1997 by Salvador Eduardo Tropea
#
# Make file to generate the documentation for SET's editor
# and the needed utilties
#

# set srcdir to the directory where the sources are
srcdir=.
# set this to the directory, where to search for @include
incdir=.
VPATH=$(srcdir)

# define here the wanted doc's
targets=editor sdg

# define here for each target the index commandline for
# sdh which is then used in $(sdh_ops) with $(index_$*)
# by replacing $* with the actual target
index_editor=-n "Index of key commands" kindex.idx kindex.tdx
index_sdg=-n "Index of variables and commands" vindex.idx vindex.tdx

# set the commandline options for sdh
sdh_ops=-c -n Index cindex.idx cindex.tdx $(index_$*) \
	-I $(srcdir) -I $(incdir)

all: all_docs

sdh: sdh.c
	gcc -o $@ -O2 $<

%.inf: %.tx
	./sdh -oi $(sdh_ops) -i $*

%.txt: %.tx
	./sdh -ot $(sdh_ops) -i $*

%.html: %.tx
	./sdh -oh $(sdh_ops) -i $*

%.dvi: %.tx
	./sdh -od $(sdh_ops) -i $*

%.ps: %.tx
	./sdh -op $(sdh_ops) -i $*

# this is only a theoretical suffix only used to produce
# .info .txt and .html with one rule
%.doc: %.tx
	./sdh -othi $(sdh_ops) -i $*

# this is only a theoretical suffix only used to produce
# all the available formats with one rule
%.all: %.tx
	./sdh -ohti $(sdh_ops) -i $*

info: $(addsuffix .inf,$(targets))
txt: $(addsuffix .txt,$(targets))
html: $(addsuffix .html,$(targets))
dvi: $(addsuffix .dvi,$(targets))
ps: $(addsuffix .ps,$(targets))

all_suffixes=all doc inf txt html dvi ps

$(foreach suffix,$(all_suffixes),$(addsuffix .$(suffix),$(targets))): sdh

text: txt

all_docs: $(addsuffix .all,$(targets))

doc: $(addsuffix .doc,$(targets))
