Makefile

DOC=selfdocbook
MAIN=$(DOC).sgml
SECTS=intro.sgml tools.sgml structure.sgml tips.sgml \
        source.sgml fdl.sgml
DSSSL=$(DOC).dsl
FIGS=simple.fig
PNGS=$(FIGS:.fig=.png)
EPSS=$(FIGS:.fig=.eps)
SRC=$(MAIN) $(SECTS) $(MAIN).sed $(addsuffix .sed,$(SECTS)) \
        Makefile.sed $(addsuffix .sed,$(DSSSL)) jadetex.cfg.sed builddat
e \
        $(DOC).css.sed

STYLESHEET_IMAGES=/usr/share/sgml/docbook/dsssl-stylesheets/images

all: $(DOC).pdf $(DOC).ps $(DOC)

$(DOC).ps: $(SRC) $(EPSS)
        docbook2ps -d "$(DSSSL)#print" $(MAIN)

$(DOC).pdf: $(SRC) $(PNGS)
        docbook2pdf -d "$(DSSSL)#print" $(MAIN)

# There is currently a bug in docbook2html, which we work around here.
# See <URL:https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=53546>.
$(DOC): $(SRC) $(PNGS)
        -$(RM) -r $(DOC)
        docbook2html -d "$$(pwd)/$(DSSSL)#html" -o $(DOC) $(MAIN)
        cp -a $(STYLESHEET_IMAGES) $(DOC)/stylesheet-images
        cp $(PNGS) $(DOC).css $@

# Since this file would be parsed for SGML markup, we have to
# make a safe version (with &, < and > converted to SGML entities)
# In addition, tabs get ignored for some reason, so for the
# Makefile we have to convert them to spaces.
%.sed: %
        fold -w 72 $< | \
                sed -e "s/$$(echo x | tr x \\t)/        /g" \
                    -e "s/&/\\&amp;/g" \
                    -e "s/</\\&lt;/g" \
                    -e "s/>/\\&gt;/g" > $@

builddate:
        echo -n $$(date "+%e %B %Y") > $@

clean:
        -$(RM) *.log *.dvi *.aux *.tex *.sed *.out
        -$(RM) $(GENERATED_IMG) builddate
        -$(RM) -r $(DOC) $(DOC).ps $(DOC).pdf

distclean: clean
        -$(RM) *~ $(DOC).tar.gz docbook.tar.gz
        -$(RM) -r docbook

$(DOC).tar.gz: distclean
        (cd ..; tar zcf /tmp/$(DOC).tar.gz $(DOC) )
        mv /tmp/$(DOC).tar.gz .

docbook: $(DOC).tar.gz all
        -$(RM) -r $@
        mkdir $@
        cp $(DOC).tar.gz $(DOC).ps $(DOC).pdf $@
        tar cf - $(DOC) | (cd $@; tar xf -)

docbook.tar.gz: docbook
        tar zcf docbook.tar.gz docbook

# Make encapsulated PostScript from xfig
%.eps: %.fig
        fig2dev -Leps $< $@

# Make png from xfig
%.png: %.fig
        fig2dev -Lpng $< $@

.PHONY: distclean clean all builddate