Merge lp:~dsmythies/serverguide/makefile_changes into lp:~ubuntu-core-doc/serverguide/saucy

Proposed by Doug Smythies on 2013-09-01
Status: Merged
Merged at revision: 163
Proposed branch: lp:~dsmythies/serverguide/makefile_changes
Merge into: lp:~ubuntu-core-doc/serverguide/saucy
Diff against target: 130 lines (+92/-7)
1 file modified
Makefile (+92/-7)
To merge this branch: bzr merge lp:~dsmythies/serverguide/makefile_changes
Reviewer Review Type Date Requested Status
Benjamin Kerensa (community) 2013-09-01 Approve on 2013-09-13
Review via email: mp+183363@code.launchpad.net

Description of the change

Makefile changes and expansion so that all languages can be done in bulk.
Also includes another option to copy and change files for possible inclusion on help.ubuntu.com
I find Makefile and SED file syntax very finicky and this took me a very very long time to get working properly.

Review by another "doc committer" is desired.

I seem to have used the local name "makefile_changes" before, so I hope that doesn't cause any grief.

To post a comment you must log in.
Doug Smythies (dsmythies) wrote :

In the absence of any other review, I'll just merge this myself in about 24 hours.

Peter Matulis (petermatulis) wrote :

I don't know enough about this stuff to provide a valuable review.

Benjamin Kerensa (bkerensa) wrote :

Looks good to me.

review: Approve
Doug Smythies (dsmythies) wrote :

Thanks. As mentioned on the e-mail threads and in my post above, I was just going to push this myself. I just hadn't got around to it. I appreciate the peer review.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2013-05-28 22:13:27 +0000
3+++ Makefile 2013-09-01 18:10:20 +0000
4@@ -42,6 +42,12 @@
5 # Base gnome directories for output from processor
6 BASE=build/
7
8+# Space-separated list of language codes for documents. HTML and or PDF will
9+# only be built for those codes in the list
10+# PO_FILES = ace ar ast be bg bn bs ca cs da de el en_AU en_CA en_GB eo es et eu fa fi fr gl gu he hr hu id is it ja km ko ku lo lt lv mk ms nb nl oc pl ps pt_BR pt ro ru sk sl sq sr sv th tl tr ug uk ur vi zh_CN zh_TW
11+# Why bother to have the above list? Why not just build it from the available .po files?
12+PO_FILES = $(basename $(notdir $(wildcard serverguide/po/*.po)))
13+
14 clean:
15 rm -rf $(BASE)
16
17@@ -57,11 +63,11 @@
18 if [ $(LN) != "C" ]; then \
19 ./scripts/translate.sh -d serverguide -l $(LN); \
20 fi
21- if find serverguide/$(LN) -name "*.xml"; then \
22- mkdir -p build/serverguide/$(LN); \
23- yelp-build html -o build/serverguide/$(LN) -x $(UBUNTUXSL) serverguide/$(LN)/serverguide.xml; \
24- mkdir -p build/img; \
25- cp libs/img/* build/img/; \
26+ if find serverguide/$(LN) -name "serverguide.xml"; then \
27+ mkdir -p $(BASE)serverguide/$(LN); \
28+ yelp-build html -o $(BASE)serverguide/$(LN) -x $(UBUNTUXSL) serverguide/$(LN)/serverguide.xml; \
29+ mkdir -p $(BASE)img; \
30+ cp libs/img/* $(BASE)img/; \
31 lang=`echo $(LN) | $(SED) -e 's/[@_]/-/'`; \
32 if test "$$lang" = "C"; then lang=en; fi; \
33 if test "$$lang" = "gl"; then lang=gl-GL; fi; \
34@@ -70,7 +76,7 @@
35 $(SED) -i \
36 -e '1s/^/<!DOCTYPE html\>\n/' \
37 -e "s/<html>/<html lang="$$lang">/" \
38- build/serverguide/$(LN)/*.html; \
39+ $(BASE)serverguide/$(LN)/*.html; \
40 fi
41
42 serverguide-pdf:
43@@ -78,7 +84,86 @@
44 if [ $(LN) != "C" ]; then \
45 ./scripts/translate.sh -d serverguide -l $(LN); \
46 fi
47- if find serverguide/$(LN) -name "*.xml"; then \
48+ if find serverguide/$(LN) -name "serverguide.xml"; then \
49 xsltproc --xinclude -o $(BASE)serverguide/$(LN)/serverguide.fo $(UBUNTUPDFXSL) serverguide/$(LN)/serverguide.xml; \
50 fop -fo $(BASE)serverguide/$(LN)/serverguide.fo -pdf $(BASE)serverguide/$(LN)/serverguide.pdf; \
51 fi
52+
53+#
54+# Some multi langauage build routines
55+#
56+
57+serverguide-lang-trans:
58+# Builds the translations for all non C languages.
59+
60+ $(foreach lingua, $(PO_FILES), ./scripts/translate.sh -d serverguide -l $(lingua);)
61+
62+serverguide-lang-html:
63+# Builds the html serverguide for all non C languages.
64+# Prerequisite: serverguide-lang-trans
65+
66+ $(foreach lingua, $(PO_FILES), \
67+ if find serverguide/$(lingua) -name "serverguide.xml"; then \
68+ mkdir -p $(BASE)serverguide/$(lingua); \
69+ yelp-build html -o $(BASE)serverguide/$(lingua) -x $(UBUNTUXSL) serverguide/$(lingua)/serverguide.xml; \
70+ lang=`echo $(lingua) | $(SED) -e 's/[@_]/-/'`; \
71+ if test "$$lang" = "C"; then lang=en; fi; \
72+ if test "$$lang" = "gl"; then lang=gl-GL; fi; \
73+ if test "$$lang" = "ms"; then lang=ms-MS; fi; \
74+ if test "$$lang" = "pl"; then lang=pl-PL; fi; \
75+ $(SED) -i \
76+ -e '1s/^/<!DOCTYPE html\>\n/' \
77+ -e "s/<html>/<html lang="$$lang">/" \
78+ $(BASE)serverguide/$(lingua)/*.html; \
79+ fi;)
80+
81+serverguide-lang-pdf:
82+# Builds the PDF serverguide for all non C languages.
83+# Prerequisite: serverguide-lang-trans
84+
85+ $(foreach lingua, $(PO_FILES), \
86+ if find serverguide/$(lingua) -name "serverguide.xml"; then \
87+ xsltproc --xinclude -o $(BASE)serverguide/$(lingua)/serverguide.fo $(UBUNTUPDFXSL) serverguide/$(lingua)/serverguide.xml; \
88+ fop -fo $(BASE)serverguide/$(lingua)/serverguide.fo -pdf $(BASE)serverguide/$(lingua)/serverguide.pdf; \
89+ fi;)
90+
91+serverguide-lang-help:
92+# Builds a single directory of all languages html and PDF files, ready for possible copy and inclusion in the help.ubuntu.com branch
93+# Prerequisite: You must have already built the html and PDF's for all langauges, including the "C" ones.
94+# Notes: Currently the .css files are actually identical for all languages, so why not use just one file.
95+# Currently .png files are actually identical for all languages, so why not use just one set of files.
96+# Currently .js files are actually identical for all languages, so why not use just one set of files.
97+# Do not just copy the whole "C" directory or you will get the serverguuide.fo file, which you do not want.
98+# Language codes are normalized to IETF format, as opposed to glibc format.
99+# Does not create the ../../img directory, which is common across multiple releases. Local copy testing will need it.
100+
101+ rm -Rf $(BASE)help; \
102+ mkdir -p $(BASE)help; \
103+ $(foreach html_file, $(notdir $(wildcard $(BASE)serverguide/C/*.html)), \
104+ cp $(BASE)serverguide/C/$(html_file) $(BASE)help/$(html_file).en; \
105+ ) \
106+ cp $(BASE)serverguide/C/*.css $(BASE)help; \
107+ cp $(BASE)serverguide/C/*.png $(BASE)help; \
108+ cp $(BASE)serverguide/C/serverguide.pdf $(BASE)help/serverguide.pdf.en; \
109+
110+ $(foreach lingua, $(PO_FILES), \
111+ if find $(BASE)serverguide/$(lingua) -name "index.html"; then \
112+ lang=`echo $(lingua) | $(SED) -e 's/[@_]/-/'`; \
113+ if test "$$lang" = "gl"; then lang=gl-GL; fi; \
114+ if test "$$lang" = "ms"; then lang=ms-MS; fi; \
115+ if test "$$lang" = "pl"; then lang=pl-PL; fi; \
116+ $(foreach html_file, $(notdir $(wildcard $(BASE)serverguide/$(lingua)/*.html)), \
117+ cp $(BASE)serverguide/$(lingua)/$(html_file) $(BASE)help/$(html_file)."$$lang"; \
118+ ) \
119+ cp $(BASE)serverguide/$(lingua)/serverguide.pdf $(BASE)help/serverguide.pdf."$$lang"; \
120+ $(SED) -i 's/href="$(lingua).css"/href="en.css"/' $(BASE)help/*.html."$$lang"; \
121+ fi;)
122+
123+serverguide-lang-trans-clean:
124+# For now, remove tanslations directores, if they are there. For future, they shouldn't be built here in the first place as then they appear in the BZR unknown list.
125+# Using both the presence check and the rm force option is redundant, but whatever.
126+
127+ $(foreach lingua, $(PO_FILES), \
128+ if find serverguide/$(lingua) -name "serverguide.xml"; then \
129+ rm -rf serverguide/$(lingua); \
130+ fi;)

Subscribers

People subscribed via source and target branches