/
Makefile
62 lines (50 loc) · 1.67 KB
/
Makefile
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
RM ?= rm -f
PUBLISH := ./publish.rb
MARKDOWN_DOCS := index.text how-to-contribute.text
HTML_DOCS := $(subst .text,.html,$(MARKDOWN_DOCS))
HTML_ASSETS := style.css images
CATALOGS := ja.po
.PHONY: all clean upload update-po publish
.SUFFIXES: .text .html
all: publish
.text.html: $(PUBLISH)
$(PUBLISH) $<
upload: upload.bat
@(! [ -z "$${SF_USERNAME}" ] || (echo "Environmental variable 'SF_USERNAME', which is a username of sf.net, is required."; false))
sftp -b $< $${SF_USERNAME},twmode@web.sourceforge.net
upload.bat: $(HTML_DOCS) Makefile publish
files=$$(find -name "*.html"; \
find -name "*.html.??"; \
find -name ".htaccess"; \
find -name "*.css"; \
find -name "*.png"; \
find -name "*.jpg"); \
dirs=$$(echo $$files|xargs -n1 dirname|sort|uniq); \
(echo "cd htdocs"; \
echo $$dirs | xargs -n 1 echo "-mkdir"; \
for file in $$files; do echo "put $${file} $${file}"; done) > $@
twmode.pot: $(HTML_DOCS)
xml2po -k -o $@ $(HTML_DOCS)
for catalog in $(CATALOGS); do \
[ -f $$catalog ] || cp $@ $$catalog; \
done
update-po: twmode.pot Makefile
for catalog in $(CATALOGS); do \
xml2po -k -m xhtml -u $$catalog $(HTML_DOCS); \
done
publish: $(HTML_DOCS) $(CATALOGS)
for catalog in $(CATALOGS); do \
lang=$$(echo $$catalog|sed 's/.po$$//'); \
[ -d $$lang ] || mkdir $$lang; \
cp -t $$lang -r $(HTML_ASSETS); \
for text in $(MARKDOWN_DOCS); do \
html=$$(echo $$text|sed 's/.text$$/.html/'); \
$(PUBLISH) -l $$lang -o $$lang/$$html $$text; \
done; \
done
clean:
$(RM) *.html *.html upload.bat
for catalog in $(CATALOGS); do \
lang=$$(echo $$catalog|sed 's/.po$$//'); \
$(RM) $$lang/*.html; \
done