File: Makefile

package info (click to toggle)
debian-history 2.19
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,044 kB
  • ctags: 9
  • sloc: makefile: 120
file content (110 lines) | stat: -rw-r--r-- 3,776 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#
# Makefile for the Debian History
#
# Should work both for a manual in the Debian Documentation Project
# manuals.sgml tree, and for $(MANUAL) package build.

# Basename for SGML
MANUAL := project-history

# this can and will be overriden by a higher level makefile
PUBLISHDIR := /org/www.debian.org/www/doc/manuals

all: html txt ps pdf

po-sources := $(wildcard po4a/po/??*.po)
sgml-from-po := $(patsubst po4a/po/%.po,$(MANUAL).%.sgml,$(po-sources))
sgml-sources := $(wildcard *.??*.sgml)
sources := $(sgml-sources) $(sgml-from-po)
# noncjk == no ps/pdf
sources_noncjk := $(filter-out project-history.ko.sgml,$(sources))

update-po $(sgml-from-po): $(MANUAL).sgml $(po-sources)
	touch po4a/po/$(MANUAL).pot
	po4a --force po4a/po4a.cfg

# generating HTML
# ugly because the normal stuff works only as PHONYs. :(
#$(MANUAL).%.html/index.%.html: $(MANUAL).%.sgml
#	debiandoc2html -c -l $* $<
html: $(sgml-from-po)
	@if [ ! -f $(MANUAL).en.html/index.en.html -o $(MANUAL).sgml -nt $(MANUAL).en.html/index.en.html ]; then \
          rm -r $(MANUAL).en.html; \
          echo debiandoc2html -C -l en.utf-8 $(MANUAL).sgml; \
	  debiandoc2html -C -l en.utf-8 $(MANUAL).sgml; \
          mv $(MANUAL).html $(MANUAL).en.html; \
        fi
	@for i in $(sources); do \
          nosuffix=$${i%.sgml}; \
	  lang=$${nosuffix#$(MANUAL).}; \
	if [ ! -f $(MANUAL).$$lang.html/index.$$lang.html -o $$i -nt $(MANUAL).$$lang.html/index.$$lang.html ]; then \
	    sgmlfile=$$nosuffix.sgml; \
	    echo debiandoc2html -C -l $$lang.utf-8 $$sgmlfile; \
            debiandoc2html -C -l $$lang.utf-8 $$sgmlfile; \
          fi; \
        done

# generating plain text
txt text: $(MANUAL).en.txt $(patsubst %.sgml,%.txt,$(sources))

$(MANUAL).en.txt: $(MANUAL).sgml
	debiandoc2text -l en.utf-8 $<
	mv $(MANUAL).txt $(MANUAL).en.txt

# NOTE: convert to koi8-r for correct text wrap with debiandoc2text, workaround #684276
$(MANUAL).ru.txt: $(MANUAL).ru.sgml
	iconv -f utf-8 -t koi8-r//translit $< \
		| debiandoc2text -l ru-ru.koi8-r - \
		| iconv -f koi8-r -t utf-8 -o $@

$(MANUAL).%.txt: $(MANUAL).%.sgml
	debiandoc2text -l $*.utf-8 $<

# generating PostScript
ps: $(MANUAL).en.ps $(patsubst %.sgml,%.ps,$(sources_noncjk))

$(MANUAL).en.ps: $(MANUAL).sgml
	debiandoc2latexps -l en.utf-8 $<
	mv $(MANUAL).ps $(MANUAL).en.ps

$(MANUAL).%.ps: $(MANUAL).%.sgml
	debiandoc2latexps -l $*.utf-8 $<

# generating Portable Document Format
pdf: $(MANUAL).en.pdf $(patsubst %.sgml,%.pdf,$(sources_noncjk))

$(MANUAL).en.pdf: $(MANUAL).sgml
	debiandoc2latexpdf -l en.utf-8 $<
	mv $(MANUAL).pdf $(MANUAL).en.pdf

$(MANUAL).%.pdf: $(MANUAL).%.sgml
	debiandoc2latexpdf -l $*.utf-8 $<

# publishing to the DDP web pages
publish: all
	test -d $(PUBLISHDIR)/$(MANUAL) || install -d -m 755 $(PUBLISHDIR)/$(MANUAL)
	rm -f $(PUBLISHDIR)/$(MANUAL)/*.html
	install -p -m 644 $(MANUAL)*.html/*.html $(PUBLISHDIR)/$(MANUAL)/
# possible non-POSIX syntax below.
	cd $(PUBLISHDIR)/$(MANUAL) && for file in *.en.html; do \
          ln -s $$file $${file%$${file#$${file%.en.html}}}.html; \
        done
	install -p -m 644 $(MANUAL)*.txt $(MANUAL)*.ps $(MANUAL)*.pdf $(PUBLISHDIR)/$(MANUAL)
	echo "AddCharset UTF-8 .txt" > $(PUBLISHDIR)/$(MANUAL)/.htaccess
	ln -sf $(MANUAL).en.txt $(PUBLISHDIR)/$(MANUAL)/$(MANUAL).txt
	ln -sf $(MANUAL).en.ps $(PUBLISHDIR)/$(MANUAL)/$(MANUAL).ps
	ln -sf $(MANUAL).en.pdf $(PUBLISHDIR)/$(MANUAL)/$(MANUAL).pdf

# validating SGML
validate:
	@set -x; for i in $(wildcard *.sgml); do nsgmls -ges -wall $$i; done

# cleaning up
clean distclean:
	for suffix in txt ps dvi pdf info* log tex aux toc out sasp* tpt; do \
	  rm -f $(MANUAL)*.$$suffix; \
	done
	rm -rf $(MANUAL)*.html head.tmp body.tmp *~ $(sgml-from-po) po4a/po/$(MANUAL).pot

.PHONY: all publish clean distclean validate
.SUFFIXES: