~dinda/+junk/intro-branch-error

« back to all changes in this revision

Viewing changes to Makefile

  • Committer: Belinda Lopez
  • Date: 2011-02-28 21:50:02 UTC
  • Revision ID: dinda@ubuntu.com-20110228215002-lba73t00vul7hlmo
fixed docbook & old  html css files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# See launchpad.net/doctemplate-user-guide for documentation
2
 
 
3
 
include environment
4
 
 
5
 
include content.Makefile
6
 
 
7
 
#The following requires user to download the jar file from
8
 
#http://sourceforge.net/projects/offo/
9
 
#unzip it, and place the fop-hyph.jar in /usr/share/java
10
 
#Without this, pdfs build, but there is no hyphenation and there are SEVERE
11
 
#warnings in the output of Apache FOP
12
 
export FOP_HYPHENATION_PATH=/usr/share/java/fop-hyph.jar
13
 
 
14
 
#These are user-configurable files for lanauages and various customizations
15
 
LINGUAS=$(shell if test -r LINGUAS; then grep -v "^\#" LINGUAS; fi)
16
 
 
17
 
DOCBOOKPARAMS_FILE=docbook-customization/DOCBOOKPARAMS
18
 
DOCBOOKPARAMS=$(shell if test -r $(DOCBOOKPARAMS_FILE); then grep -v "^\#" $(DOCBOOKPARAMS_FILE); fi)
19
 
 
20
 
HTMLPARAMS_FILE=html-customization/HTMLPARAMS
21
 
HTMLPARAMS=$(shell if test -r $(HTMLPARAMS_FILE); then grep -v "^\#" $(HTMLPARAMS_FILE); fi)
22
 
 
23
 
FOPARAMS_FILE=fop-customization/FOPARAMS
24
 
export FOPARAMS=$(shell if test -r $(FOPARAMS_FILE); then grep -v "^\#" $(FOPARAMS_FILE); fi)
25
 
 
26
 
EPUBPARAMS_FILE=epub-customization/EPUBPARAMS
27
 
EPUBPARAMS=$(shell if test -r $(EPUBPARAMS_FILE); then grep -v "^\#" $(EPUBPARAMS_FILE); fi)
28
 
 
29
 
 
30
 
HTMLXSL = html-site-customization/html-site.xsl
31
 
export LIB=/usr/share/doctemplate/lib
32
 
export XSLTPROC = /usr/bin/xsltproc
33
 
export FOP = /usr/bin/fop
34
 
XML2PO = /usr/bin/xml2po
35
 
XMLLINT = /usr/bin/xmllint
36
 
BASENAME = /usr/bin/basename
37
 
DIRNAME = /usr/bin/dirname
38
 
MSGMERGE = /usr/bin/msgmerge
39
 
export BXML=build/xml/$(LANG)
40
 
BXMLOMF=build/xml-omf
41
 
BHTML=build/html/$(LANG)
42
 
BHTMLOMF=build/html-omf
43
 
BHTMLSITE=build/html-site/$(LANG)
44
 
export BPDF=build/pdf/$(LANG)
45
 
BEPUB=build/epub/$(LANG)
46
 
 
47
 
all:
48
 
        @echo "See the README file for usage instructions."
49
 
 
50
 
%/stamp: %/
51
 
        @$(MAKE) CURDIR=$(CURDIR) -f $(CURDIR)/Makefile -C $<
52
 
        
53
 
epub: localize common-customization epub-target
54
 
 
55
 
html: localize common-customization html-target
56
 
        echo $(TYPE)
57
 
 
58
 
html-site: localize common-customization html-site-target
59
 
 
60
 
pdf: localize common-customization pdf-target
61
 
 
62
 
xml: localize common-customization
63
 
 
64
 
localize: localize-images localize-xml
65
 
 
66
 
omf-html:
67
 
        @echo "Creating localized OMF files for HTML in $(BHTMLOMF)."
68
 
        @mkdir -p $(BHTMLOMF)
69
 
        @if test -f $(TYPE)/po/$(LANG).po ; then \
70
 
                $(XML2PO) -p $(TYPE)/po/$(LANG).po -o $(BHTMLOMF)/$(DOC)-html-$(LANG).omf template.omf; \
71
 
        else \
72
 
                cp template.omf $(BHTMLOMF)/$(DOC)-html-$(LANG).omf; \
73
 
        fi
74
 
        @sed -i 's#$(URL)#$(URL)/$(DOC)-html/$(LANG)/index.html#g' $(BHTMLOMF)/$(DOC)-html-$(LANG).omf
75
 
        @sed -i 's#<language code=\"C\"/>#<language code=\"$(LANG)\"/>#g' $(BHTMLOMF)/$(DOC)-html-$(LANG).omf
76
 
        @sed -i 's#langcode#$(LANG)#g' $(BHTMLOMF)/$(DOC)-html-$(LANG).omf
77
 
        @sed -i 's_<!-- do NOT translate this in po files-->__g' $(BHTMLOMF)/$(DOC)-html-$(LANG).omf
78
 
        @sed -i 's_<!-- do translate this in po files-->__g' $(BHTMLOMF)/$(DOC)-html-$(LANG).omf
79
 
        @sed -i 's#series_id#$(SERIESID_HTML)#g' $(BHTMLOMF)/$(DOC)-html-$(LANG).omf
80
 
        @sed -i 's#text/xml#text/html#g' $(BHTMLOMF)/$(DOC)-html-$(LANG).omf
81
 
        @sed -i 's#dtd-needed#-//W3C//DTD XHTML 1.0 Strict//EN#g' $(BHTMLOMF)/$(DOC)-html-$(LANG).omf
82
 
        
83
 
 
84
 
 
85
 
omf-xml:
86
 
        @echo "Creating localized OMF files for DOCBOOK in $(BXMLOMF)."
87
 
        @mkdir -p $(BXMLOMF)
88
 
        @if test -f $(TYPE)/po/$(LANG).po ; then \
89
 
                $(XML2PO) -p $(TYPE)/po/$(LANG).po -o $(BXMLOMF)/$(DOC)-db-$(LANG).omf template.omf; \
90
 
        else \
91
 
                cp template.omf $(BXMLOMF)/$(DOC)-db-$(LANG).omf; \
92
 
        fi      
93
 
        @sed -i 's#$(URL)#$(URL)/$(DOC)-db/$(LANG)/$(DOC).xml#g' $(BXMLOMF)/$(DOC)-db-$(LANG).omf
94
 
        @sed -i 's#<language code=\"C\"/>#<language code=\"$(LANG)\"/>#g' $(BXMLOMF)/$(DOC)-db-$(LANG).omf
95
 
        @sed -i 's#langcode#$(LANG)#g' $(BXMLOMF)/$(DOC)-db-$(LANG).omf
96
 
        @sed -i 's_<!-- do NOT translate this in po files-->__g' $(BXMLOMF)/$(DOC)-db-$(LANG).omf
97
 
        @sed -i 's_<!-- do translate this in po files-->__g' $(BXMLOMF)/$(DOC)-db-$(LANG).omf
98
 
        @sed -i 's#series_id#$(SERIESID_XML)#g' $(BXMLOMF)/$(DOC)-db-$(LANG).omf
99
 
        @sed -i 's#dtd-needed#-//OASIS//DTD DocBook XML V4.1.2//EN#g' $(BXMLOMF)/$(DOC)-db-$(LANG).omf
100
 
 
101
 
 
102
 
localize-xml:
103
 
        @echo "Localizing xml/docbook in $(BXML)"
104
 
        @for doc in $(SHIPPEDDOCS) ; do \
105
 
                doc_name=`basename $$doc .xml`; \
106
 
                dir_name=`dirname "$$doc"`; \
107
 
#               echo "dir_name: $$dir_name"; \
108
 
#               echo "doc_name: $$doc_name"; \
109
 
                echo "\tFile: $$dir_name/$$doc_name.xml" ; \
110
 
                po_file=$$dir_name/po/$(LANG).po ; \
111
 
                if [ $$doc_name = $(DOC) ] ; then \
112
 
# phase1: if current DOC is article or book, we need to xinclude transform it and set language \
113
 
                        echo "\t$$dir_name/$$doc_name.xml is top-level project file. xinclude it and set lang attribute. Generating $(BXML)/$$doc_name.phase1.xml." ; \
114
 
                        $(XSLTPROC) --xinclude --stringparam language $(LANG) -o $(BXML)/$$doc_name.phase1.xml $(LIB)/set_lang.xsl $$dir_name/$$doc_name.xml ; \
115
 
                else \
116
 
                        echo "\t$$dir_name/$$doc_name.xml is not top-level project file. Copying $$dir_name/$$doc_name.xml to $(BXML)/$$doc_name.$(LANG).xml." ; \
117
 
                        cp $$dir_name/$$doc_name.xml $(BXML)/$$doc_name.phase1.xml ; \
118
 
                fi ; \
119
 
                if test -f $$po_file ; then \
120
 
# phase2: use po to translate or mv untranslated phase1 to lang-specific xml \
121
 
                        echo "\t$$po_file exists. Translate with it to generate $(BXML)/$$doc_name.phase2.xml"; \
122
 
                        $(XML2PO) -p $$po_file -o $(BXML)/$$doc_name.phase_loc-final.xml $(BXML)/$$doc_name.phase1.xml ; \
123
 
                else \
124
 
                        echo "\t$$po_file not found. Move $(BXML)/$$doc_name.phase1.xml to $(BXML)/$$doc_name.phase2.xml"; \
125
 
# Using untranslated $$dir_name/$$doc_name.xml." ; \
126
 
                        mv $(BXML)/$$doc_name.phase1.xml $(BXML)/$$doc_name.phase_loc-final.xml ; \
127
 
                fi ; \
128
 
        done
129
 
 
130
 
localize-images:
131
 
        @echo "Creating Localized Images."
132
 
        @mkdir -p $(BXML)
133
 
        @for chapter in $(CONTENTDIRS); do \
134
 
                        echo "\tCopying $$chapter/images to $(BXML)"; \
135
 
                        cp -R $$chapter/images/ $(BXML); \
136
 
                if test -d $$chapter/images-$(LANG) ; then \
137
 
                        echo "\tCopying $$chapter/images-$(LANG)/* to $(BXML)/images."; \
138
 
                        cp $$chapter/images-$(LANG)/* $(BXML)/images; \
139
 
                fi; \
140
 
        done
141
 
 
142
 
common-customization:
143
 
        @echo "Doing Common Customizations."
144
 
        @for doc in $(SHIPPEDDOCS) ; do \
145
 
                doc_name=`basename $$doc .xml`; \
146
 
                echo "\tCreate localized xml with stylesheet parameters in $(DOCBOOKPARAMS_FILE) file "; \
147
 
                echo "\tand with stylsheet customizations in docbook-customization/docbook-customization.xsl:"; \
148
 
                echo "\t$(DOCBOOKPARAMS)";\
149
 
                $(XSLTPROC) $(DOCBOOKPARAMS) -o $(BXML)/$$doc_name.xml docbook-customization/docbook-customization.xsl $(BXML)/$$doc_name.phase_loc-final.xml; \
150
 
                if test -f $(BXML)/$$doc_name.phase1.xml ; then \
151
 
                        rm $(BXML)/$$doc_name.phase1.xml; \
152
 
                fi ; \
153
 
                if test -f $(BXML)/$$doc_name.phase2.xml ; then \
154
 
                        rm $(BXML)/$$doc_name.phase2.xml; \
155
 
                fi ; \
156
 
                if test -f $(BXML)/$$doc_name.phase_loc-final.xml ; then \
157
 
                        rm $(BXML)/$$doc_name.phase_loc-final.xml; \
158
 
                fi ; \
159
 
        done
160
 
 
161
 
 
162
 
epub-target:
163
 
        @echo "Creating EPUB."
164
 
        @mkdir -p $(BEPUB)
165
 
        @echo "\tCopying $(BXML)/images to $(BEPUB)/OEBPS"
166
 
        @if [ ! -d $(BEPUB)/OEBPS ]; then \
167
 
                mkdir $(BEPUB)/OEBPS; \
168
 
        fi;
169
 
        @if [ -d $(BEPUB)/OEBPS/images ]; then \
170
 
                echo "deleting images=========="; \
171
 
                rm $ -rf $(BEPUB)/OEBPS/images; \
172
 
        fi;
173
 
        @mv $(BXML)/images $(BEPUB)/OEBPS
174
 
        @echo "\tXIncluding on root doc ($(BXML)/$(DOC).xml): generating: $(BEPUB)/index-xinclude.html "
175
 
        $(XSLTPROC) --xinclude -o $(BEPUB)/phase-xinclude.xml $(LIB)/xinclude.xsl $(BXML)/$(DOC).xml
176
 
        @echo "\tConverting to html with parameters in $(EPUBPARAMS_FILE) file: generating $(BEPUB)/phase-html.html"; 
177
 
        @echo "\t$(BEPUB)";
178
 
        @echo "\tCustomizing epub with epub-customization/epub-html-customization.xsl. Generating $(BEPUB)/index.html"; 
179
 
        $(XSLTPROC) $(EPUBPARAMS) -o $(BEPUB)/index.html epub-customization/epub-customization.xsl  $(BEPUB)/phase-xinclude.xml
180
 
        @cp style.css $(BEPUB)/ 
181
 
        @rm  $(BEPUB)/*phase*
182
 
 
183
 
html-target:
184
 
        @echo "Creating HTML."
185
 
        @mkdir -p $(BHTML)
186
 
        @echo "\tCopying $(BXML)/images to $(BHTML)"
187
 
        @cp -r $(BXML)/images $(BHTML)
188
 
        @echo "\tCopying $(LIB)/html-images/* to $(BHTML)/images"
189
 
        @cp $(LIB)/html-images/* $(BHTML)/images
190
 
        @echo "\tXIncluding on root doc ($(BXML)/$(DOC).xml): generating: $(BHTML)/index-xinclude.html "
191
 
        $(XSLTPROC) --xinclude -o $(BHTML)/phase-xinclude.xml $(LIB)/xinclude.xsl $(BXML)/$(DOC).xml
192
 
        @echo "\tConverting to html with parameters in $(HTMLPARAMS_FILE) file. Generating $(BHTML)/phase-html.html"; 
193
 
        @echo "\t$(HTMLPARAMS)";
194
 
        @echo "\tCustomizing html with html-customization/html-customization.xsl: generating $(BHTML)/index.html"; 
195
 
        $(XSLTPROC) $(HTMLPARAMS) -o $(BHTML)/index.html html-customization/html-customization.xsl  $(BHTML)/phase-xinclude.xml
196
 
        @cp style.css $(BHTML)/ 
197
 
        @rm  $(BHTML)/*phase*
198
 
 
199
 
html-site-target:
200
 
        @echo "Creating HTML-SITE."
201
 
        @mkdir -p $(BHTMLSITE)
202
 
        @echo "\tCopying $(BXML)/images to $(BHTMLSITE)"
203
 
        @cp -r $(BXML)/images $(BHTMLSITE)
204
 
        @echo "\tXInclude on root doc ($(BXML)/$(DOC).xml): generating: $(BHTMLSITE)/index-phase1.html "
205
 
        @$(XSLTPROC) --xinclude -o $(BHTMLSITE)/index-phase1.html $(LIB)/xinclude.xsl $(BXML)/$(DOC).xml
206
 
        @echo "\tCreate html from docbook: generating: $(BHTMLSITE)/index.html "
207
 
        @$(XSLTPROC) --xinclude -o $(BHTMLSITE)/index.html $(HTMLXSL) $(BHTMLSITE)/index-phase1.html
208
 
        @cp html-site.css $(BHTMLSITE)/ 
209
 
        @rm  $(BHTMLSITE)/*phase*
210
 
        @cp lib/navig/* $(BHTMLSITE)/images/
211
 
 
212
 
 
213
 
pdf-target:
214
 
        @echo "Creating PDF."
215
 
        @echo $(FOP_HYPHENATION_PATH)
216
 
        @mkdir -p $(BPDF)
217
 
        @cp $(LIB)/pdf.Makefile $(BPDF)/Makefile   
218
 
        @$(MAKE) -C $(BPDF)
219
 
 
220
 
 
221
 
 
222
 
# This target creates the POT templates and updates pos
223
 
update-po: $(SHIPPEDDOCS)
224
 
        @for doc in $(SHIPPEDDOCS) ; do \
225
 
                doc_name_stripped=`basename $$doc .xml`; \
226
 
                dir_name=`dirname $$doc`; \
227
 
                pot_name="`$(BASENAME) $$doc_name_stripped.pot| tr A-Z a-z`"; \
228
 
                $(XSLTPROC) --xinclude -o $$dir_name/po/xinclude.xml $(LIB)/xinclude.xsl $$doc; \
229
 
                $(XML2PO) -e -o $$dir_name/po/$$pot_name $$dir_name/po/xinclude.xml template.omf; \
230
 
                rm $$dir_name/po/xinclude.xml; \
231
 
                for lingua in $(LINGUAS) ; do \
232
 
                        if [ "$$lingua" != "en" ] ; then \
233
 
                                $(MSGMERGE) -U $$dir_name/po/$$lingua.po $$dir_name/po/$$pot_name; \
234
 
                        fi; \
235
 
                done; \
236
 
        done
237
 
 
238
 
linguas: 
239
 
        @for lingua in $(LINGUAS); do echo "LANG: $$lingua"; done
240
 
 
241
 
clean:
242
 
        @rm -f *.html *.pdf build/*/*phase*.xml build/*/*.fo */*.html */*.pdf */po/*.pot */*fo *.mo */*.mo .xml2po.mo
243
 
        @rm -rf build
244
 
 
245
 
#.PHONY: $(DIRTARGETS)