| 1 |
#
|
| 2 |
# Makefile for the APT HOWTO
|
| 3 |
#
|
| 4 |
# Should work both for a manual in the Debian Documentation Project
|
| 5 |
# manuals.sgml tree, and for $(MANUAL) package build.
|
| 6 |
|
| 7 |
# Basename for SGML
|
| 8 |
MANUAL := apt-howto
|
| 9 |
|
| 10 |
# this can and will be overriden by a higher level makefile
|
| 11 |
PUBLISHDIR := /org/www.debian.org/www/doc/manuals
|
| 12 |
|
| 13 |
all: html txt ps pdf
|
| 14 |
|
| 15 |
# define $(locale) for the following targets
|
| 16 |
$(MANUAL).%.txt $(MANUAL).%.ps $(MANUAL).%.pdf: \
|
| 17 |
locale=$(subst pt-br,pt_BR,$*)
|
| 18 |
|
| 19 |
# generating HTML
|
| 20 |
# ugly because the normal stuff works only as PHONYs. :(
|
| 21 |
#$(MANUAL).%.html/index.%.html: $(MANUAL).%.sgml
|
| 22 |
# debiandoc2html -c -l $* $<
|
| 23 |
html:
|
| 24 |
@for i in *.??*.sgml; do \
|
| 25 |
j=$${i#$(MANUAL).}; lang=$${j%.sgml}; \
|
| 26 |
langfoo=`echo $$lang | tr 'A-Z_' 'a-z-'`; \
|
| 27 |
langbar=`echo $$lang | perl -pe 's/(\w\w)-(\w\w)/"$$1_".uc($$2)/e'`; \
|
| 28 |
if [ $$i -nt $(MANUAL).$$lang.html/index.$$langfoo.html ] || \
|
| 29 |
[ ! -e $(MANUAL).$$lang.html/index.$$langfoo.html ]; then \
|
| 30 |
echo debiandoc2html -c -l $$langbar $$i "($$langfoo)"; \
|
| 31 |
debiandoc2html -c -l $$langbar $$i; \
|
| 32 |
fi; \
|
| 33 |
done
|
| 34 |
|
| 35 |
# generating plain text
|
| 36 |
txt text: $(patsubst %.sgml,%.txt,$(wildcard *.??*.sgml))
|
| 37 |
|
| 38 |
$(MANUAL).%.txt: $(MANUAL).%.sgml
|
| 39 |
debiandoc2text -l $(locale) $<
|
| 40 |
|
| 41 |
# generating PostScript
|
| 42 |
#texfriendly := $(filter-out $(MANUAL).ko.sgml,$(wildcard *.??*.sgml))
|
| 43 |
texfriendly := $(wildcard *.??*.sgml)
|
| 44 |
ps: $(patsubst %.sgml,%.ps,$(texfriendly))
|
| 45 |
|
| 46 |
$(MANUAL).el.ps $(MANUAL).ta.ps: $(MANUAL).%.ps: $(MANUAL).%.sgml
|
| 47 |
@echo Locale '$*' not yet supported
|
| 48 |
|
| 49 |
$(MANUAL).%.ps: $(MANUAL).%.sgml
|
| 50 |
debiandoc2latexps -l $(locale) $<
|
| 51 |
|
| 52 |
# generating Portable Document Format
|
| 53 |
pdf: $(patsubst %.sgml,%.pdf,$(texfriendly))
|
| 54 |
|
| 55 |
$(MANUAL).el.pdf $(MANUAL).ta.pdf: $(MANUAL).%.pdf: $(MANUAL).%.sgml
|
| 56 |
@echo Locale '$*' not yet supported
|
| 57 |
|
| 58 |
$(MANUAL).%.pdf: $(MANUAL).%.sgml
|
| 59 |
debiandoc2latexpdf -l $(locale) $<
|
| 60 |
|
| 61 |
# publishing to the DDP web pages
|
| 62 |
publish: all
|
| 63 |
test -d $(PUBLISHDIR)/$(MANUAL) || install -d -m 755 $(PUBLISHDIR)/$(MANUAL)
|
| 64 |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.html
|
| 65 |
install -p -m 644 $(MANUAL).*.html/*.html $(PUBLISHDIR)/$(MANUAL)/
|
| 66 |
# possible non-POSIX syntax below. fuck POSIX.
|
| 67 |
cd $(PUBLISHDIR)/$(MANUAL) && for file in *.en.html; do \
|
| 68 |
ln -s $$file $${file%$${file#$${file%.en.html}}}.html; \
|
| 69 |
done
|
| 70 |
install -p -m 644 $(MANUAL)*.txt $(MANUAL)*.ps $(MANUAL)*.pdf $(PUBLISHDIR)/$(MANUAL)
|
| 71 |
ln -sf $(MANUAL).en.txt $(PUBLISHDIR)/$(MANUAL)/$(MANUAL).txt
|
| 72 |
ln -sf $(MANUAL).en.ps $(PUBLISHDIR)/$(MANUAL)/$(MANUAL).ps
|
| 73 |
ln -sf $(MANUAL).en.pdf $(PUBLISHDIR)/$(MANUAL)/$(MANUAL).pdf
|
| 74 |
|
| 75 |
# validating SGML
|
| 76 |
validate:
|
| 77 |
@set -x; for i in $(wildcard *.sgml); do nsgmls -ges -wall $$i; done
|
| 78 |
|
| 79 |
# cleaning up
|
| 80 |
clean distclean:
|
| 81 |
for ext in txt ps dvi pdf info\* log tex aux toc out sasp\* tpt; do rm -f $(MANUAL)*.$$ext *~; done
|
| 82 |
rm -rf $(MANUAL)*.html
|
| 83 |
|
| 84 |
.PHONY: all publish clean distclean validate
|
| 85 |
.SUFFIXES:
|