source: branches/help/HELP_SOURCE/Makefile

Last change on this file was 18800, checked in by westram, 3 years ago
  • validate .xml before conversion (not after generation).
    • allows to keep invalid .xml (for inspection; as before)
    • calling 'make' again after validation error:
      • previously caused conversion of that invalid .xml.
      • now again displays validation error.
  • Note: make help fails
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 KB
Line 
1
2.SUFFIXES: .o .c .cxx .source .hlp .xml .dtd .html .depend .ps.gz .pdf.gz
3.PHONY: prepare all dirs generated xml dump ps pdf nonhlp_formats
4.PHONY: delzerohtml interdepends google_logo html help clean tools depends depend.init
5
6# --------------------------------------------------------------------------------
7
8TEST_ONE:=0# default is 0; if 1 -> only one .hlp file is processed. see below .@TEST_ONE
9ONLY_DO_UNITTEST:=0# default is 0; if 1 -> only unittest.hlp is processed (to make unit-test auto-update work) #@@@ set to 0 before checkin
10
11# --------------------------------------------------------------------------------
12# directories of source/destination files:
13
14HLP_SOURCE=source
15HLP_GENERATED=genhelp
16XML_LOCATION=Xml
17HTML_LOCATION=../lib/help_html
18HLP_DEST=../lib/help
19HELP_INDEX_NAME = help_index
20DOTMAP=./help_map.dot
21GIFMAP=./help_map.gif
22
23# needed tools:
24TOOL_OBJECTS = \
25         arb_help2xml.o
26
27BINARIES = $(TOOL_OBJECTS:%.o=$(ARBHOME)/bin/%)
28
29QUIETLY = ./quietly.pl
30
31# using xsltproc and XMLLINT:
32XSLTPROC = ./arb_xslt.sh
33VALIDATE = $(QUIETLY) XMLLINT
34
35# --------------------------------------------------------------------------------
36
37$(MAIN) : all
38
39prepare: date generated dirs tools nonhlp_formats delzerohtml
40
41all: prepare
42                @echo --------------------------------------------------- [old hlp 2 xml]
43                time $(MAKE) xml
44                @echo --------------------------------------------------- [interdependencies]
45                time $(MAKE) interdepends
46                @echo --------------------------------------------------- [xml 2 hlp]
47                time $(MAKE) "USE_GENERATED_DEPENDS=1" help
48                $(MAKE) $(HLP_DEST)/FORM.hlp
49                @echo --------------------------------------------------- [xml 2 html]
50                time $(MAKE) "USE_GENERATED_DEPENDS=1" html
51
52$(HLP_DEST)/FORM.hlp: $(HLP_SOURCE)/FORM.hlp
53                cp -p $< $@
54
55
56dirs:
57                mkdir -p $(XML_LOCATION)
58                mkdir -p $(XML_LOCATION)/prompt
59
60                mkdir -p $(HTML_LOCATION)
61                mkdir -p $(HTML_LOCATION)/prompt
62
63                mkdir -p $(HLP_DEST)
64                mkdir -p $(HLP_DEST)/prompt
65
66                @ln -s ../arb_help.dtd $(XML_LOCATION) || true
67                @ln -s ../../arb_help.dtd $(XML_LOCATION)/prompt || true
68
69HELP2XML=$(ARBHOME)/bin/arb_help2xml
70
71# --------------------------------------------------------------------------------
72# Generate help files in $(HLP_GENERATED):
73
74generated: dirs
75                @echo ---------------------------------------------------
76                @echo ------------ Generating some help files:
77                (cd $(HLP_GENERATED);$(MAKE) all)
78
79# --------------------------------------------------------------------------------
80
81HELP_INDEX_XML = $(XML_LOCATION)/$(HELP_INDEX_NAME).xml
82
83ifeq ($(ONLY_DO_UNITTEST),1)
84OLD_HELP_ALL= $(HLP_SOURCE)/unittest.hlp
85else
86OLD_HELP_ALL= \
87                $(HLP_SOURCE)/arb.hlp \
88                $(wildcard \
89                                $(HLP_GENERATED)/*.hlp \
90                                $(HLP_SOURCE)/*.hlp \
91                                $(HLP_SOURCE)/prompt/*.hlp \
92                )
93endif
94
95ifeq ($(TEST_ONE),1)
96#OLD_HELP=$(HLP_SOURCE)/arb.hlp $(HLP_SOURCE)/version.hlp $(HLP_SOURCE)/translate_dna_2_pro.hlp $(HLP_SOURCE)/species_join.hlp
97OLD_HELP=$(HLP_SOURCE)/version.hlp
98#OLD_HELP=$(HLP_SOURCE)/arb.hlp
99else
100OLD_HELP=$(OLD_HELP_ALL:$(HLP_SOURCE)/FORM.hlp=)# remove FORM.hlp (this is just a default file)
101endif
102
103XML_TMP=$(OLD_HELP:%.hlp=%.xml)
104XML_TMP2=$(XML_TMP:$(HLP_SOURCE)/%=$(XML_LOCATION)/%)
105XML=$(XML_TMP2:$(HLP_GENERATED)/%=$(XML_LOCATION)/%)
106
107XML_DEPEND=xml.stamp# xml files are rebuild if this stamp is recreated
108DTD=arb_help.dtd
109
110$(XML) : $(XML_DEPEND) Makefile $(QUIETLY)
111
112$(HELP_INDEX_XML): $(OLD_HELP_ALL) $(XML) ./generate_index.pl Makefile
113        ./generate_index.pl $(XML_LOCATION) $(HELP_INDEX_NAME).xml $(DOTMAP) > $@
114        -dot -Tgif -o$(GIFMAP) $(DOTMAP)
115        rm $(DOTMAP)
116
117xml : $(XML) $(HELP_INDEX_XML)
118
119dump:
120                echo $(XML)
121
122$(XML_LOCATION)/%.xml : $(HLP_SOURCE)/%.hlp $(DTD)
123                @test \! -f $(HLP_GENERATED)/$(<F) || \
124                                ( echo $<:1: exists twice -- only one existence allowed; \
125                                  echo $(HLP_GENERATED)/$(<F):1: other occurrence \
126                                  && false )
127                @$(HELP2XML) $< $@ || (rm -f $@ && echo "Error: generation of $@ failed" && false)
128
129$(XML_LOCATION)/%.xml : $(HLP_GENERATED)/%.hlp $(DTD)
130                @test \! -f $(HLP_SOURCE)/$(<F) || \
131                                ( echo $<:1: exists twice -- only one existence allowed; \
132                                  echo $(HLP_SOURCE)/$(<F):1: other occurrence \
133                                  && false )
134                @$(HELP2XML) $< $@ || (rm -f $@ && echo "Error: generation of $@ failed" && false)
135
136$(XML_LOCATION)/%.validate : $(XML_LOCATION)/%.xml
137                @$(VALIDATE) $<
138
139$(HTML_LOCATION)/help_index.html : $(HELP_INDEX_XML)
140
141HTML_TMP=$(XML:%.xml=%.html)
142HTML=$(HTML_TMP:$(XML_LOCATION)/%=$(HTML_LOCATION)/%)
143
144HELP_TMP=$(XML:%.xml=%.hlp)
145HELP=$(HELP_TMP:$(XML_LOCATION)/%=$(HLP_DEST)/%)
146
147# --------------------------------------------------------------------------------
148
149PS_SRC=$(wildcard $(HLP_SOURCE)/*.ps.gz)
150PDF_SRC=$(wildcard $(HLP_SOURCE)/*.pdf.gz)
151
152PS_DEST=$(PS_SRC:$(HLP_SOURCE)/%=$(HLP_DEST)/%)
153PDF_DEST=$(PDF_SRC:$(HLP_SOURCE)/%=$(HLP_DEST)/%)
154
155ps: $(PS_DEST)
156
157pdf: $(PDF_DEST)
158
159$(PS_DEST) : dirs
160$(PDF_DEST) : dirs
161
162nonhlp_formats: ps pdf
163
164$(HLP_DEST)/%.ps.gz : $(HLP_SOURCE)/%.ps.gz
165        cp -p $< $@
166
167$(HLP_DEST)/%.pdf.gz : $(HLP_SOURCE)/%.pdf.gz
168        cp -p $< $@
169
170# --------------------------------------------------------------------------------
171
172delzerohtml:
173                -if [ -d $(HTML_LOCATION) ] ; then find $(HTML_LOCATION) -name "*.html" -size -1 -exec rm {} \; ; fi
174
175date :
176        $(MAKE) date.xsl.tmp
177        ../SOURCE_TOOLS/mv_if_diff date.xsl.tmp date.xsl
178
179date.xsl.tmp :
180                cat date.xsl.header >$@
181                bash -c "(export LC_ALL=C;date '+%d. %b %Y')" >>$@
182                cat date.xsl.footer >>$@
183
184date.xsl : date
185
186# --------------------------------------------------------------------------------
187
188STYLE_HTML=to_html.xsl
189STYLE_HELP=to_help.xsl
190STYLE_DEPENDS=to_depends.xsl
191
192XSLTPROC_ARGS=--nonet --nomkdir --stringparam xml_location "$(XML_LOCATION)"
193
194# --------------------------------------------------------------------------------
195
196INTERDEPENDS=.depends
197INTERDEPENDS_SOURCE=$(XML)
198XML2DEPENDS=./xml_2_depends.pl
199
200$(INTERDEPENDS): $(INTERDEPENDS_SOURCE) $(XML2DEPENDS) Makefile $(STYLE_DEPENDS)
201        @( ( echo "$(INTERDEPENDS_SOURCE)" | $(XML2DEPENDS) $(XSLTPROC) $(STYLE_DEPENDS) $(XSLTPROC_ARGS) >$@ ) 2>interdep.err && \
202           ( $(XML2DEPENDS) CHECK $@ ) 2>>interdep.err && \
203           rm interdep.err ) || \
204         (cat interdep.err; false)
205
206interdepends: $(INTERDEPENDS)
207
208ifdef USE_GENERATED_DEPENDS
209 ifeq ($(USE_GENERATED_DEPENDS),1)
210  include $(INTERDEPENDS)
211 endif
212endif
213
214# --------------------------------------------------------------------------------
215
216$(HELP) : $(STYLE_HELP) $(DTD) Makefile
217
218$(HLP_DEST)/%.hlp : $(XML_LOCATION)/%.xml $(XML_LOCATION)/%.validate
219                @-rm -f $@
220                @$(XSLTPROC) --output $@ $(XSLTPROC_ARGS) --stringparam myname "$(subst $(XML_LOCATION)/,,$<)" $(STYLE_HELP) $< || rm $@
221                @test -f $@ || (echo "$<:0: did not compile to $@" && false)
222
223# --------------------------------------------------------------------------------
224
225$(HTML) : $(STYLE_HTML) $(DTD) Makefile
226
227# Google logo
228google_logo: $(HTML_LOCATION)/Logo_25wht.gif
229$(HTML_LOCATION)/Logo_25wht.gif : Logo_25wht.gif
230                cp -p $< $@
231                @test -f $@
232
233$(HTML_LOCATION)/%.html : $(XML_LOCATION)/%.xml $(XML_LOCATION)/%.validate
234                @-rm -f $@
235                @$(XSLTPROC) --output $@ $(XSLTPROC_ARGS) --stringparam myname "$(subst $(XML_LOCATION)/,,$<)" $(STYLE_HTML) $< || (rm $@ && test -f $@)
236                @test -f $@ || (echo "$<:0: did not compile to $@" && false)
237
238# --------------------------------------------------------------------------------
239
240html : $(HTML) google_logo $(HTML_LOCATION)/$(HELP_INDEX_NAME).html
241
242help : $(HELP)
243
244# --------------------------------------------------------------------------------
245
246clean:
247        -rm -f $(TOOL_OBJECTS) $(BINARIES)
248        -rm -f $(XML_DEPEND) dummy date.xsl
249        -rm -rf $(XML_LOCATION) $(HLP_DEST) $(HTML_LOCATION) $(INTERDEPENDS)
250        $(MAKE) -C $(HLP_GENERATED) clean
251
252# --------------------------------------------------------------------------------
253
254tools: $(BINARIES)
255
256LIBS=../XML/XML.a
257
258$(HELP2XML): $(LIBS)
259
260$(XML_DEPEND) : arb_help2xml.cxx
261        touch $(XML_DEPEND)
262
263%.o: %.cxx
264        $(A_CXX) $(cflags) $(cxxflags) -c $< $(CXX_INCLUDES) $(POST_COMPILE) $<
265
266$(HELP2XML): arb_help2xml.o $(LIBS) $(use_ARB_main)
267        $(LINK_EXECUTABLE) $@ $(use_ARB_main) $< $(LIBS) $(LIBPATH) $(CORE_LIB)
268
269
270DEPENDS = $(TOOL_OBJECTS:.o=.depend)
271depends: $(DEPENDS)
272        @cat $(DEPENDS) | grep -v '^#' >>Makefile
273        @rm $(DEPENDS)
274$(DEPENDS): depend.init
275depend.init:
276        $(MAKEDEPEND) $(MAKEDEPENDFLAGS) 2>/dev/null # remove dependencies
277.c.depend:
278        $(MAKEDEPEND) -f- $(MAKEDEPENDFLAGS) $< 2>/dev/null >$@
279.cxx.depend:
280        $(MAKEDEPEND) -f- $(MAKEDEPENDFLAGS) $< 2>/dev/null >$@
281
282# DO NOT DELETE
283
284# Do not add dependencies manually - use 'make depend' in $ARBHOME
285# For formatting issues see SOURCE_TOOLS/fix_depends.pl (from main)
286
287arb_help2xml.o: $(ARBHOME)/INCLUDE/arb_assert.h
288arb_help2xml.o: $(ARBHOME)/INCLUDE/arb_core.h
289arb_help2xml.o: $(ARBHOME)/INCLUDE/arb_defs.h
290arb_help2xml.o: $(ARBHOME)/INCLUDE/arb_diff.h
291arb_help2xml.o: $(ARBHOME)/INCLUDE/arb_file.h
292arb_help2xml.o: $(ARBHOME)/INCLUDE/arb_msg.h
293arb_help2xml.o: $(ARBHOME)/INCLUDE/arbtools.h
294arb_help2xml.o: $(ARBHOME)/INCLUDE/attributes.h
295arb_help2xml.o: $(ARBHOME)/INCLUDE/cxxforward.h
296arb_help2xml.o: $(ARBHOME)/INCLUDE/dupstr.h
297arb_help2xml.o: $(ARBHOME)/INCLUDE/gccver.h
298arb_help2xml.o: $(ARBHOME)/INCLUDE/static_assert.h
299arb_help2xml.o: $(ARBHOME)/INCLUDE/test_global.h
300arb_help2xml.o: $(ARBHOME)/INCLUDE/test_unit.h
301arb_help2xml.o: $(ARBHOME)/INCLUDE/xml.hxx
Note: See TracBrowser for help on using the repository browser.