/ docs / src / Submakefile
Submakefile
  1  .PHONY: docs docsclean checkref checkref_en checkref_es checkref_fr checkref_vi
  2  .PHONY: pdfdocs htmldocs install-doc install-doc-pdf install-doc-html
  3  
  4  DOC_DIR=../docs
  5  DOC_SRCDIR=../docs/src
  6  
  7  LOC_HL_DIR=../docs/src/source-highlight
  8  LOC_LANG_MAP=$(LOC_HL_DIR)/local/lang.map
  9  
 10  
 11  GENERATED_MANPAGES += ../docs/man/man1/linuxcnc.1
 12  ifeq ($(BUILD_DOCS),yes)
 13  GENERATED_MANPAGES += $(patsubst ../docs/src/man/%.txt, ../docs/man/%, $(wildcard ../docs/src/man/*/*.txt))
 14  endif
 15  
 16  MAN_SRCS = $(sort \
 17  	$(wildcard $(DOC_DIR)/man/man1/*.1) \
 18  	$(wildcard $(DOC_DIR)/man/man3/*.3*) \
 19  	$(wildcard $(DOC_DIR)/man/man9/*.9) \
 20  	$(GENERATED_MANPAGES))
 21  
 22  ../docs/man/man1/linuxcnc.1: $(DOC_SRCDIR)/man/man1/linuxcnc.1.in config.status
 23  	./config.status --file=$@:$<
 24  
 25  ifneq ($(MANDB),)
 26  default: $(DOC_DIR)/man/index.db
 27  $(DOC_DIR)/man/index.db: $(MAN_SRCS)
 28  	@echo "Updating 'whatis' database"
 29  	$(Q)$(MANDB) $(DOC_DIR)/man
 30  endif
 31  
 32  ifeq ($(BUILD_DOCS),yes)
 33  DOC_SRCS_EN := \
 34  	code/code-notes.txt \
 35  	code/style-guide.txt \
 36  	code/nml-messages.txt \
 37  	code/rs274.txt \
 38  	code/adding-configs.txt \
 39  	code/contributing-to-linuxcnc.txt \
 40  	code/building-linuxcnc.txt \
 41  	common/emc-history.txt \
 42  	common/glossary.txt \
 43  	common/gpld-copyright.txt \
 44  	common/overleaf.txt \
 45  	config/core-components.txt \
 46  	config/ini-config.txt \
 47  	config/ini-homing.txt \
 48  	config/integrator-concepts.txt \
 49  	config/lathe-config.txt \
 50  	config/moveoff.txt \
 51  	config/pncconf.txt \
 52  	config/python-interface.txt \
 53  	config/stepconf.txt \
 54  	config/stepper-diagnostics.txt \
 55  	config/stepper.txt \
 56  	config/stepper-quickstart.txt \
 57  	drivers/ax5214h.txt \
 58  	drivers/vfs11.txt \
 59  	drivers/mitsub_vfd.txt \
 60  	drivers/gm.txt \
 61  	drivers/gs2.txt \
 62  	drivers/hostmot2.txt \
 63  	drivers/mb2hal.txt \
 64  	drivers/motenc.txt \
 65  	drivers/opto22.txt \
 66  	drivers/pico-ppmc.txt \
 67  	drivers/pluto-p.txt \
 68  	drivers/servo-to-go.txt \
 69  	drivers/shuttle.txt \
 70  	examples/gcode.txt \
 71  	examples/gs2-example.txt \
 72  	examples/mpg.txt \
 73  	examples/pci-parallel-port.txt \
 74  	examples/spindle.txt \
 75  	gcode/coordinates.txt \
 76  	gcode/g-code.txt \
 77  	gcode/machining-center.txt \
 78  	gcode/m-code.txt \
 79  	gcode/o-code.txt \
 80  	gcode/other-code.txt \
 81  	gcode/overview.txt \
 82  	gcode/rs274ngc.txt \
 83  	gcode/tool-compensation.txt \
 84  	getting-started/about-linuxcnc.txt \
 85  	getting-started/getting-linuxcnc.txt \
 86  	common/linux-faq.txt \
 87  	getting-started/running-linuxcnc.txt \
 88  	getting-started/system-requirements.txt \
 89  	getting-started/updating-linuxcnc.txt \
 90  	gui/axis.txt \
 91  	gui/gladevcp.txt \
 92  	gui/gmoccapy.txt \
 93  	gui/gmoccapy-hu.txt \
 94  	gui/gscreen.txt \
 95  	gui/qtvcp.txt \
 96  	gui/qtvcp_widgets.txt \
 97  	gui/qtvcp_libraries.txt \
 98  	gui/qtvcp_custom_widgets.txt \
 99  	gui/qtvcp_code_snippets.txt \
100  	gui/qtvcp_development.txt \
101  	gui/panelui.txt \
102  	gui/halui.txt \
103  	gui/image-to-gcode.txt \
104  	gui/ngcgui.txt \
105  	gui/tklinuxcnc.txt \
106  	gui/tooledit.txt \
107  	gui/touchy.txt \
108  	gui/GStat.txt \
109  	gui/vismach.txt \
110  	hal/basic-hal.txt \
111  	hal/canonical-devices.txt \
112  	hal/comp.txt \
113  	hal/components.txt \
114  	hal/general-ref.txt \
115  	hal/hal-examples.txt \
116  	hal/halmodule.txt \
117  	hal/halshow.txt \
118  	hal/haltcl.txt \
119  	hal/halui-examples.txt \
120  	hal/intro.txt \
121  	hal/parallel-port.txt \
122  	gui/pyvcp.txt \
123  	gui/pyvcp-examples.txt \
124  	hal/rtcomps.txt \
125  	hal/tools.txt \
126  	hal/tutorial.txt \
127  	hal/twopass.txt \
128  	install/latency-test.txt \
129  	integrator/steppers.txt \
130  	integrator/stepper-timing.txt \
131  	integrator/wiring.txt \
132  	ladder/classic-ladder.txt \
133  	ladder/ladder-examples.txt \
134  	ladder/ladder-intro.txt \
135  	lathe/lathe-user.txt \
136  	motion/kinematics.txt \
137  	motion/pid-theory.txt \
138  	motion/tweaking-steppers.txt \
139  	motion/5-axis-kinematics.txt \
140  	motion/external-offsets.txt \
141  	plasma/plasmac-user-guide.txt \
142  	plasma/plasma-cnc-primer.txt \
143  	remap/remap.txt \
144  	user/starting-linuxcnc.txt \
145  	user/user-concepts.txt \
146  	user/user-foreword.txt \
147  	user/user-intro.txt \
148  	Master_Getting_Started.txt \
149  	Master_Documentation.txt \
150  	Master_Developer.txt
151  
152  DOC_SRCS_FR := \
153  	common/Glossary_fr.txt \
154  	common/GPLD_Copyright_fr.txt \
155  	common/Integrator_Concepts_fr.txt \
156  	common/outdated-notice_fr.txt \
157  	common/overleaf_fr.txt \
158  	common/Stepper_Diagnostics_fr.txt \
159  	config/linuxcnc2hal_fr.txt \
160  	config/ini_config_fr.txt \
161  	config/ini_homing_fr.txt \
162  	config/lathe_config_fr.txt \
163  	config/stepper_fr.txt \
164  	drivers/AX5214H_fr.txt \
165  	drivers/GS2_fr.txt \
166  	drivers/hostmot2_fr.txt \
167  	drivers/motenc_fr.txt \
168  	drivers/opto22_fr.txt \
169  	drivers/pico_ppmc_fr.txt \
170  	drivers/pluto_p_fr.txt \
171  	drivers/servo_to_go_fr.txt \
172  	examples/gcode_fr.txt \
173  	examples/gs2_example_fr.txt \
174  	examples/misc_fr.txt \
175  	examples/mpg_fr.txt \
176  	examples/pci_parallel_port_fr.txt \
177  	examples/spindle_fr.txt \
178  	gcode/coordinates_fr.txt \
179  	gcode/gcode_fr.txt \
180  	gcode/machining_center_fr.txt \
181  	gcode/m-code_fr.txt \
182  	gcode/o-code_fr.txt \
183  	gcode/other-code_fr.txt \
184  	gcode/overview_fr.txt \
185  	gcode/rs274ngc_fr.txt \
186  	gcode/tool_compensation_fr.txt \
187  	gui/axis_fr.txt \
188  	gui/gladevcp_fr.txt \
189  	gui/image-to-gcode_fr.txt \
190  	gui/ngcgui_fr.txt \
191  	gui/tklinuxcnc_fr.txt \
192  	gui/tooledit_fr.txt\
193  	gui/touchy_fr.txt \
194  	hal/basic_hal_fr.txt \
195  	hal/comp_fr.txt \
196  	hal/components_fr.txt \
197  	hal/general_ref_fr.txt \
198  	hal/hal-examples_fr.txt \
199  	hal/halmodule_fr.txt \
200  	hal/halshow_fr.txt \
201  	hal/haltcl_fr.txt \
202  	hal/halui_fr.txt \
203  	hal/intro_fr.txt \
204  	hal/parallel_port_fr.txt \
205  	gui/pyvcp_fr.txt \
206  	gui/pyvcp_examples_fr.txt \
207  	hal/rtcomps_fr.txt \
208  	hal/tutorial_fr.txt \
209  	install/Latency_Test_fr.txt \
210  	ladder/classic_ladder_fr.txt \
211  	ladder/ladder_examples_fr.txt \
212  	ladder/ladder_intro_fr.txt \
213  	lathe/lathe-user_fr.txt \
214  	motion/kinematics_fr.txt \
215  	motion/pid_theory_fr.txt \
216  	motion/tweaking_steppers_fr.txt \
217  	user/user-concepts-fr.txt \
218  	user/user-foreword-fr.txt \
219  	user/user-intro-fr.txt \
220  	Master_Getting_Started_fr.txt \
221  	getting-started/index-fr.txt \
222  	Master_User_fr.txt \
223  	Master_HAL_fr.txt \
224  	Master_Integrator_fr.txt \
225  
226  DOC_SRCS_ES := \
227  	getting-started/about-linuxcnc-es.txt \
228  	getting-started/getting-linuxcnc-es.txt \
229  	common/linux-faq-es.txt \
230  	getting-started/running-linuxcnc-es.txt \
231  	config/stepconf-es.txt \
232  	config/stepper-quickstart-es.txt \
233  	getting-started/system-requirements-es.txt \
234  
235  DOC_SRCS = $(DOC_SRCS_EN) $(DOC_SRCS_FR) $(DOC_SRCS_ES)
236  
237  DOC_SRCS_TXT := $(patsubst %.txt, %.txt, $(DOC_SRCS))
238  
239  DOC_SRCS_ES_SMALL := $(filter-out Master_%,$(DOC_SRCS_ES))
240  DOC_SRCS_FR_SMALL := $(filter-out Master_%,$(DOC_SRCS_FR))
241  DOC_SRCS_EN_SMALL := $(filter-out Master_%,$(DOC_SRCS_EN))
242  
243  DOC_SRCS_HTML := $(patsubst %.txt, %.html, $(filter-out Master_%, $(DOC_SRCS)))
244  DOC_TARGETS_HTML := $(addprefix $(DOC_DIR)/html/,$(DOC_SRCS_HTML)) #$(subst /,_,$(DOC_SRCS_HTML)))
245  DOC_TARGETS_XML := $(patsubst $(DOC_DIR)/html/%.html, objects/%.xml, $(DOC_TARGETS_HTML))
246  
247  DOC_TARGETS_XML_ES := $(filter %_es.xml, $(DOC_TARGETS_XML))
248  DOC_TARGETS_XML_FR := $(filter %_fr.xml, $(DOC_TARGETS_XML))
249  DOC_TARGETS_XML_EN := $(filter-out $(DOC_TARGETS_XML_ES), $(filter-out $(DOC_TARGETS_XML_FR), $(DOC_TARGETS_XML)) )
250  DOC_TARGETS_HTML_ES := $(filter %_es.html, $(DOC_TARGETS_HTML))
251  DOC_TARGETS_HTML_FR := $(filter %_fr.html, $(DOC_TARGETS_HTML))
252  DOC_TARGETS_HTML_VI := $(filter %_vi.html, $(DOC_TARGETS_HTML))
253  DOC_TARGETS_HTML_EN := $(filter-out $(DOC_TARGETS_HTML_ES), $(filter-out $(DOC_TARGETS_HTML_FR), $(filter-out $(DOC_TARGETS_HTML_VI), $(DOC_TARGETS_HTML))) )
254  
255  MAN_HTML_TARGETS = $(patsubst $(DOC_DIR)/man/%, $(DOC_DIR)/html/man/%.html, $(MAN_SRCS))
256  
257  PDF_TARGETS_EN := $(addprefix $(DOC_DIR)/, \
258  	LinuxCNC_Getting_Started.pdf \
259  	LinuxCNC_Documentation.pdf \
260  	LinuxCNC_Developer_Manual.pdf \
261  	LinuxCNC_Manual_Pages.pdf \
262  	LinuxCNC_Integrator.pdf \
263  	)
264  
265  PDF_TARGETS_FR := $(addprefix $(DOC_DIR)/, \
266  	LinuxCNC_Getting_Started_fr.pdf \
267  	LinuxCNC_User_Manual_fr.pdf \
268  	LinuxCNC_HAL_Manual_fr.pdf \
269  	LinuxCNC_Integrator_Manual_fr.pdf \
270  	)
271  
272  PDF_TARGETS_ES := $(addprefix $(DOC_DIR)/, \
273  	LinuxCNC_Getting_Started_es.pdf \
274  	LinuxCNC_Documentation_es.pdf \
275  	)
276  
277  PDF_TARGETS := $(PDF_TARGETS_EN) $(PDF_TARGETS_FR) $(PDF_TARGETS_ES)
278  
279  # It's better to keep the above on separate lines for troubleshooting by swapping
280  
281  HTML_TARGETS := \
282  	$(DOC_TARGETS_HTML) \
283  	$(MAN_HTML_TARGETS) \
284  	$(DOC_DIR)/html/index.html \
285  	$(DOC_DIR)/html/index_es.html \
286  	$(DOC_DIR)/html/index_fr.html \
287  
288  A2X = a2x --xsltproc-opts "--nonet \
289  			   --stringparam toc.section.depth 3 \
290  			   --stringparam toc.max.depth 2 \
291  			   --stringparam generate.section.toc.level 2 \
292  			   --stringparam generate.toc 'book toc,title chapter toc'" \
293  	  -a "scriptdir=$(DOC_SRCDIR)/" \
294  	  --asciidoc-opts "-f $(DOC_SRCDIR)/docbook.conf -f $(DOC_SRCDIR)/asciidoc-dont-replace-arrows.conf" \
295  	  --dblatex-opts "-P doc.publisher.show=0 -P latex.output.revhistory=0 -s $(DOC_SRCDIR)/emc2.sty \
296  			  -P latex.hyperparam=colorlinks,linkcolor=blue,filecolor=blue,urlcolor=blue,citecolor=blue \
297                            $(A2X_LATEX_ENCODING)"
298  
299  ifeq ($(TRIVIAL_BUILD),no)
300  -include $(patsubst %.txt, depends/%.d, $(DOC_SRCS_TXT))
301  Makefile: $(patsubst %.txt, depends/%.d, $(DOC_SRCS_TXT))
302  endif
303  
304  docs: manpages
305  manpages: $(GENERATED_MANPAGES)
306  
307  clean: clean-manpages
308  clean-manpages:
309  	-rm -f $(GENERATED_MANPAGES)
310  
311  
312  ifeq ($(BUILD_DOCS_PDF),yes)
313  docs: pdfdocs
314  install-doc: install-doc-pdf
315  endif
316  ifeq ($(BUILD_DOCS_HTML),yes)
317  docs: htmldocs
318  install-doc: install-doc-html
319  endif
320  pdfdocs: $(PDF_TARGETS)
321  htmldocs: .htmldoc-stamp checkref
322  
323  .htmldoc-stamp: copy_asciidoc_files $(HTML_TARGETS) .html-images-stamp
324  	touch $@
325  
326  .PHONY: copy_asciidoc_files
327  copy_asciidoc_files:
328  	cp -f /etc/asciidoc/stylesheets/*.css $(DOC_DIR)/html
329  	cp -f /etc/asciidoc/javascripts/*.js $(DOC_DIR)/html
330  
331  checkref: checkref_en checkref_fr checkref_es checkref_vi
332  
333  checkref_en: $(DOC_TARGETS_HTML_EN) $(DOC_DIR)/html/index.html $(DOC_DIR)/html/gcode.html .htmldoc-stamp
334  	@$(DOC_SRCDIR)/checkref English $^
335  
336  checkref_fr: $(DOC_TARGETS_HTML_FR) $(DOC_DIR)/html/gcode_fr.html .htmldoc-stamp
337  	@$(DOC_SRCDIR)/checkref French $^
338  
339  checkref_es: $(DOC_TARGETS_HTML_ES) .htmldoc-stamp
340  	@$(DOC_SRCDIR)/checkref Spanish $^
341  
342  checkref_vi: $(DOC_TARGETS_HTML_VI) $(DOC_DIR)/html/gcode_vi.html .htmldoc-stamp
343  	@$(DOC_SRCDIR)/checkref Vietnamese $^
344  
345  MAN_SRCS_NOSO = $(patsubst $(DOC_DIR)/man/%,%, \
346  			$(shell grep -L '^\.so ' $(sort $(MAN_SRCS))))
347  
348  PDF_MAN_ORDER := man1/linuxcnc.1 $(filter-out %/linuxcnc.1, $(filter man1/%, $(MAN_SRCS_NOSO))) \
349  	man3/intro.3hal $(filter-out %/undocumented.3hal %/intro.3hal, $(filter man3/%.3hal, $(MAN_SRCS_NOSO))) \
350  	man3/undocumented.3hal man3/intro.3rtapi $(filter-out %/undocumented.3rtapi %/intro.3rtapi, $(filter man3/%.3rtapi, $(MAN_SRCS_NOSO))) \
351  	man3/undocumented.3rtapi $(filter man9/%, $(MAN_SRCS_NOSO)) 
352  
353  $(DOC_DIR)/LinuxCNC_Manual_Pages.pdf: $(MAN_SRCS) objects/var-PDF_MAN_ORDER
354  	@echo Formatting manual pages as PDF
355  	(cd $(DOC_DIR)/man; groff -t -rC1 -rD1 -Tps -man $(PDF_MAN_ORDER)) \
356  		| ps2pdf - $@
357  
358  $(DOC_DIR)/LinuxCNC_Getting_Started.pdf: $(DOC_SRCDIR)/Master_Getting_Started.pdf
359  	@ln -f $< $@
360  $(DOC_DIR)/LinuxCNC_Getting_Started_es.pdf: $(DOC_SRCDIR)/Master_Getting_Started_es.pdf
361  	@ln -f $< $@
362  $(DOC_DIR)/LinuxCNC_Getting_Started_fr.pdf: $(DOC_SRCDIR)/Master_Getting_Started_fr.pdf
363  	@ln -f $< $@
364  $(DOC_DIR)/LinuxCNC_Documentation.pdf: $(DOC_SRCDIR)/Master_Documentation.pdf
365  	@ln -f $< $@
366  $(DOC_DIR)/LinuxCNC_Integrator.pdf: $(DOC_SRCDIR)/Master_Integrator.pdf
367  	@ln -f $< $@
368  $(DOC_DIR)/LinuxCNC_Documentation_es.pdf: $(DOC_SRCDIR)/Master_Documentation_es.pdf
369  	@ln -f $< $@
370  $(DOC_DIR)/LinuxCNC_User_Manual_fr.pdf: $(DOC_SRCDIR)/Master_User_fr.pdf
371  	@ln -f $< $@
372  $(DOC_DIR)/LinuxCNC_HAL_Manual_fr.pdf: $(DOC_SRCDIR)/Master_HAL_fr.pdf
373  	@ln -f $< $@
374  $(DOC_DIR)/LinuxCNC_Integrator_Manual_fr.pdf: $(DOC_SRCDIR)/Master_Integrator_fr.pdf
375  	@ln -f $< $@
376  $(DOC_DIR)/LinuxCNC_Developer_Manual.pdf: $(DOC_SRCDIR)/Master_Developer.pdf
377  	@ln -f $< $@
378  
379  $(DOC_DIR)/html/man/%.html: $(DOC_DIR)/man/%
380  	@echo Formatting $(notdir $<) as HTML
381  	@mkdir -p $(dir $@)
382  	@(cd $(DOC_DIR)/man; groff -Thtml -man $(patsubst $(DOC_DIR)/man/%,%,$<)) > $@
383  
384  SA := <p><a onclick=\"return toggle('man_
385  SB := ')\"><img id=\"man_
386  SC := _image\" src=\"plus.png\" alt=\"plus\" style=\"border:0;margin-right:5px;vertical-align:middle\"/>
387  
388  SD := <div id=\"man_
389  SE := \" style=\"-moz-column-width: 25ex; \
390  	-moz-column-gap: 4ex; \
391  	-webkit-column-width: \
392  	25ex; -webkit-column-gap: 4ex;\">
393  
394  #
395  # This function appends a section to the "manpages" HTML fragment called
396  # index.incl, listing all the specified manpages.  It takes 2 arguments:
397  #     * the part of the manpage space, for example "1" or "3rtapi"
398  #     * the manpage section title
399  #
400  ADD_HTML_MANPAGES = \
401  	@echo "Adding manpages: man$(strip $(1)): $(strip $(2))"; \
402  	echo "$(SA)$(strip $(1))$(SB)$(strip $(1))$(SC)$(strip $(2))</a></p>" >> objects/index.incl; \
403  	echo "$(SD)$(strip $(1))$(SE)" >> objects/index.incl; \
404  	echo "<ul>" >> objects/index.incl; \
405  	for HTML_FILE in $(filter %.$(strip $(1)).html, $(MAN_HTML_TARGETS)); do \
406  		BASENAME=$$(basename $$HTML_FILE .html); \
407  		echo "<li><a href=\"$${HTML_FILE\#$(DOC_DIR)/html/}\">$${BASENAME%.*}</a></li>"; \
408  	done >> objects/index.incl; \
409  	echo "</ul></div>" >> objects/index.incl
410  
411  
412  objects/index.incl: $(GENERATED_MANPAGES) objects/var-MAN_HTML_TARGETS $(DOC_SRCDIR)/Submakefile
413  	rm -f $@
414  	$(call ADD_HTML_MANPAGES, 1, Commands and userspace components)
415  	$(call ADD_HTML_MANPAGES, 9, Realtime components and kernel modules)
416  	$(call ADD_HTML_MANPAGES, 3hal, API calls: HAL)
417  	$(call ADD_HTML_MANPAGES, 3rtapi, API calls: RTAPI)
418  	$(call ADD_HTML_MANPAGES, 3hm2,  API calls: Hostmot2)
419  	$(call ADD_HTML_MANPAGES, 3, API calls: General)
420  	
421  	# now make sure all manpages made it into the html index
422  	FAIL=0; \
423  	for F in $$(find $(DOC_DIR)/man/man? -type f); do \
424  		B=$$(basename $$F); \
425  		if ! grep -q $$B $@; then \
426  			echo stray manpage not added to index: $$B; \
427  			FAIL=1; \
428  		fi; \
429  	done; \
430  	if [ $$FAIL -ne 0 ]; then false; fi
431  
432  $(DOC_DIR)/html/index_%.html: $(DOC_SRCDIR)/index_%.tmpl ../VERSION $(DOC_SRCDIR)/index.foot
433  	cat $(filter-out ../VERSION, $^) | \
434  		sed "s/@VERSION@/`cat ../VERSION`/" > $@	
435  
436  $(DOC_DIR)/html/index.html: $(DOC_SRCDIR)/index.tmpl objects/index.incl $(DOC_SRCDIR)/index.foot ../VERSION $(DOC_SRCDIR)/Submakefile
437  	(cat $(DOC_SRCDIR)/index.tmpl objects/index.incl $(DOC_SRCDIR)/index.foot) | sed "s/@VERSION@/`cat ../VERSION`/" > $@	
438  
439  $(DOC_SRCDIR)/%.pdf: $(DOC_SRCDIR)/%.txt
440  	$(ECHO) Building $@
441  	@rm -f $@
442  	$(A2X) -L -d book -vf pdf $< || (X=$$?; rm $@; exit $$X)
443  	@test -f $@
444  
445  depends/%.d: $(DOC_SRCDIR)/%.txt $(DOC_SRCDIR)/asciideps
446  	$(ECHO) Depending $<
447  	@mkdir -p $(dir $@)
448  	$(Q)$(DOC_SRCDIR)/asciideps $< > $@.tmp
449  	@mv $@.tmp $@
450  
451  objects/%.links-stamp: $(DOC_SRCDIR)/%.txt $(DOC_SRCDIR)/links.xslt
452  	@mkdir -p `dirname $@`
453  	asciidoc -f $(DOC_SRCDIR)/attribute-colon.conf -a "scriptdir=$(DOC_SRCDIR)/" -d book -o- -b docbook $< | xsltproc $(DOC_SRCDIR)/links.xslt - > $@.tmp || (X=$$?; rm $@; exit $$X)
454  	sh move-if-change $@.tmp $(patsubst %-stamp,%,$@)
455  	touch $@
456  
457  objects/%.links: objects/%.links-stamp
458  	@:
459  
460  # Secondary is not working here.
461  # See http://www.gnu.org/software/make/manual/make.html#Chained-Rules
462  .PRECIOUS: objects/%.links-stamp
463  
464  objects/xref_en.links: $(patsubst %.txt,objects/%.links,$(DOC_SRCS_EN_SMALL))
465  	$(PYTHON) $(DOC_SRCDIR)/links_db_gen.py objects/ $^ > $@
466  
467  objects/xref_es.links: $(patsubst %.txt,objects/%.links,$(DOC_SRCS_ES_SMALL))
468  	$(PYTHON) $(DOC_SRCDIR)/links_db_gen.py objects/ $^ > $@
469  
470  objects/xref_fr.links: $(patsubst %.txt,objects/%.links,$(DOC_SRCS_FR_SMALL))
471  	$(PYTHON) $(DOC_SRCDIR)/links_db_gen.py objects/ $^ > $@
472  
473  $(DOC_TARGETS_HTML): $(DOC_DIR)/html/%.html: $(DOC_SRCDIR)/%.html
474  	@d=`dirname $*`; \
475  	mkdir -p $(shell dirname $@)
476  	@cp $< $@
477  
478  .html-images-stamp: $(DOC_TARGETS_HTML)
479  	set -e; for HTML_FILE in $^; do \
480  		HTML_DIR=$$(basename $$(dirname $$HTML_FILE)); \
481  		for IMAGE_FILE in $$(xsltproc --novalid --nonet $(DOC_SRCDIR)/html-images.xslt $$HTML_FILE); do \
482  			IMAGE_DIR=$$(dirname $$IMAGE_FILE); \
483  			mkdir -p $(DOC_DIR)/html/$$HTML_DIR/$$IMAGE_DIR; \
484  			cp -f $(DOC_SRCDIR)/$$HTML_DIR/$$IMAGE_FILE $(DOC_DIR)/html/$$HTML_DIR/$$IMAGE_FILE; \
485  		done; \
486  		mkdir -p objects/image-cache; \
487  		HTML_LATEX_CACHE=objects/image-cache $(DOC_SRCDIR)/html-latex-images $$HTML_FILE || (X=$$?; rm $$HTML_FILE; exit $$X); \
488  	done
489  	touch $@
490  
491  # Define a target-specific variable called STYLES_SCRIPTS_DIR, which has
492  # the relative path from this html target to the root of the generated
493  # document tree (docs/html in the git repo).  This is where the CSS files
494  # and javascript files will be installed.
495  $(DOC_SRCDIR)/%.html: STYLES_SCRIPTS=$(shell \
496      D=$$(python -c "print '../' * '$*'.count('/')"); \
497      if [ ! -z $$D ]; then \
498          echo "-a 'scriptsdir=$$D' -a 'stylesdir=$$D'"; \
499      fi \
500  )
501  
502  $(patsubst %.txt,$(DOC_SRCDIR)/%.html,$(DOC_SRCS_EN_SMALL)): $(DOC_SRCDIR)/%.html: $(DOC_SRCDIR)/%.txt objects/xref_en.links $(LOC_LANG_MAP)
503  	asciidoc -f $(DOC_SRCDIR)/xhtml11.conf \
504  		 -f $(DOC_SRCDIR)/asciidoc-dont-replace-arrows.conf \
505  		 -f $(LOC_HL_DIR)/emc-langs-source-highlight.conf \
506  		 -a "source_highlight_dir=$(LOC_HL_DIR)/local" \
507  		 -a linkcss \
508  		 $(STYLES_SCRIPTS) \
509  	         -a "scriptdir=$(DOC_SRCDIR)/" \
510  	         -a "relindir=$(shell dirname $*)" \
511  	         -a "linksfile=objects/xref_en.links" \
512  		 -a stylesheet=linuxcnc.css \
513  		 -d book -a toc -a numbered -b xhtml11 $< || (X=$$?; rm $@; exit $$X)
514  
515  $(patsubst %.txt,$(DOC_SRCDIR)/%.html,$(DOC_SRCS_FR_SMALL)): $(DOC_SRCDIR)/%.html: $(DOC_SRCDIR)/%.txt objects/xref_fr.links $(LOC_LANG_MAP)
516  	asciidoc -f $(DOC_SRCDIR)/xhtml11.conf \
517  		 -f $(DOC_SRCDIR)/asciidoc-dont-replace-arrows.conf \
518  		 -f $(LOC_HL_DIR)/emc-langs-source-highlight.conf \
519  		 -a "source_highlight_dir=$(LOC_HL_DIR)/local" \
520  		 -a linkcss \
521  		 $(STYLES_SCRIPTS) \
522  	         -a "scriptdir=$(DOC_SRCDIR)/" \
523  	         -a "relindir=$(shell dirname $*)" \
524  	         -a "linksfile=objects/xref_fr.links" \
525  		 -a stylesheet=linuxcnc.css \
526  		 -d book -a toc -a numbered -b xhtml11 $< || (X=$$?; rm $@; exit $$X)
527  
528  $(patsubst %.txt,$(DOC_SRCDIR)/%.html,$(DOC_SRCS_ES_SMALL)): $(DOC_SRCDIR)/%.html: $(DOC_SRCDIR)/%.txt objects/xref_es.links $(LOC_LANG_MAP)
529  	asciidoc -f $(DOC_SRCDIR)/xhtml11.conf \
530  		 -f $(DOC_SRCDIR)/asciidoc-dont-replace-arrows.conf \
531  		 -a linkcss \
532  		 $(STYLES_SCRIPTS) \
533  	         -a "scriptdir=$(DOC_SRCDIR)/" \
534  	         -a "relindir=$(shell dirname $*)" \
535  	         -a "linksfile=objects/xref_es.links" \
536  		 -a stylesheet=linuxcnc.css \
537  		 -d book -a toc -a numbered -b xhtml11 $< || (X=$$?; rm $@; exit $$X)
538  
539  default: docs
540  $(DOC_DIR)/html/xref_fr.html: objects/xref_fr.xml $(DOC_SRCDIR)/xref.xsl $(DOC_SRCDIR)/docs.xml $(DOC_SRCDIR)/terms.xml
541  	$(ECHO) Converting $< to HTML
542  	@xsltproc --stringparam docname "xref_fr" --stringparam language french --path objects -o $@ $(DOC_SRCDIR)/xref.xsl $<
543  
544  $(DOC_DIR)/html/xref_es.html: objects/xref_es.xml $(DOC_SRCDIR)/xref.xsl $(DOC_SRCDIR)/docs.xml $(DOC_SRCDIR)/terms.xml
545  	$(ECHO) Converting $< to HTML
546  	@xsltproc --stringparam docname "xref_es" --stringparam language spanish --path objects -o $@ $(DOC_SRCDIR)/xref.xsl $<
547  
548  default: docs
549  
550  install-doc-pdf:
551  	$(DIR) $(DESTDIR)$(docsdir)
552  	$(FILE) $(PDF_TARGETS) $(DESTDIR)$(docsdir)
553  
554  install-doc-html:
555  	$(DIR) $(DESTDIR)$(docsdir)
556  	cp -a $(DOC_DIR)/html $(DESTDIR)$(docsdir)
557  install-kernel-indep: install-doc
558  
559  docclean:
560  	-rm -f $(DOC_DIR)/LinuxCNC_Getting_Started.pdf
561  	-rm -f $(DOC_DIR)/LinuxCNC_Getting_Started_es.pdf
562  	-rm -f $(DOC_DIR)/LinuxCNC_Getting_Started_fr.pdf
563  	-rm -f $(DOC_DIR)/LinuxCNC_Documentation.pdf
564  	-rm -f $(DOC_DIR)/LinuxCNC_Integrator.pdf
565  	-rm -f $(DOC_DIR)/LinuxCNC_Documentation_es.pdf
566  	-rm -f $(DOC_DIR)/LinuxCNC_User_Manual_fr.pdf
567  	-rm -f $(DOC_DIR)/LinuxCNC_HAL_Manual_fr.pdf
568  	-rm -f $(DOC_DIR)/LinuxCNC_Integrator_Manual_fr.pdf
569  	-rm -f $(DOC_DIR)/LinuxCNC_Developer_Manual.pdf
570  	-rm -f $(DOC_DIR)/LinuxCNC_Manual_Pages.pdf
571  	-rm -f $(DOC_SRCDIR)/*.d
572  	-rm -f $(DOC_SRCDIR)/*.pdf
573  	-rm -f $(DOC_SRCDIR)/*/*.html
574  	-rm -f $(DOC_DIR)/html/code/*.*
575  	-rm -f $(DOC_DIR)/html/common/images/*.*
576  	-rm -f $(DOC_DIR)/html/config/images/*.*
577  	-rm -f $(DOC_DIR)/html/drivers/images/*.*
578  	-rm -f $(DOC_DIR)/html/examples/images/*.*
579  	-rm -f $(DOC_DIR)/html/gcode/images/*.*
580  	-rm -f $(DOC_DIR)/html/getting-started/images/*.*
581  	-rm -f $(DOC_DIR)/html/gui/images/*.*
582  	-rm -f $(DOC_DIR)/html/hal/images/*.*
583  	-rm -f $(DOC_DIR)/html/install/images/*.*
584  	-rm -f $(DOC_DIR)/html/ladder/images/*.*
585  	-rm -f $(DOC_DIR)/html/lathe/images/*.*
586  	-rm -f $(DOC_DIR)/html/motion/images/*.*
587  	-rm -f $(DOC_DIR)/html/plasma/images/*.*
588  	-rm -f $(DOC_DIR)/html/remap/images/*.*
589  	-rm -f $(DOC_DIR)/html/man/man1/*.*
590  	-rm -f $(DOC_DIR)/html/man/man3/*.*
591  	-rm -f $(DOC_DIR)/html/man/man9/*.*
592  	-rm -f $(DOC_TARGETS_HTML) $(DOC_DIR)/html/xref*.html $(DOC_DIR)/html/index*.html $(DOC_DIR)/*.png $(DOC_DIR)/man/*.png
593  	-rm -f .htmldoc-stamp
594  	-rm -f .html-images-stamp
595  
596  
597  MAN_DEPS := $(patsubst $(DOC_DIR)/man/%, depends/%.d, $(MAN_SRCS))
598  $(MAN_DEPS): depends/%.d: $(DOC_DIR)/man/%
599  	@echo Depending $(notdir $<)
600  	@mkdir -p $(dir $@)
601  	$(Q)echo -n "$(DOC_DIR)/html/man/$*.html: $<" > $@.tmp
602  	$(Q)grep '^\.so ' $< | awk '{printf " \\\n\t$(DOC_DIR)/man/%s", $$2}' >> $@.tmp
603  	$(Q)echo >> $@.tmp
604  	$(Q)mv -f $@.tmp $@
605  
606  ifeq ($(TRIVIAL_BUILD),no)
607  -include $(MAN_DEPS)
608  Makefile: $(MAN_DEPS)
609  endif
610  
611  %.png: %.dot
612  	dot -Tpng -o$@ $<
613  
614  %.svg: %.dot
615  	dot -Tsvg -o$@ $<
616  
617  %.png:; $(error Required image file $@ does not exist)
618  %.jpg:; $(error Required image file $@ does not exist)
619  %.svg:; $(error Required image file $@ does not exist)
620  %.dxf:; $(error Required image file $@ does not exist)
621  %.ps:; $(error Required image file $@ does not exist)
622  %.eps:; $(error Required image file $@ does not exist)
623  
624  # make manpages from all the asciidoc manpage-sources
625  # Note that in some versions of asciidoc, including the one in Debian Jessie,
626  # a2x spuriously warns that this --destination-dir is ignored.  It is *NOT*
627  # ignored, don't remove it trying to fix the diagnostic.
628  # For more information, see https://github.com/asciidoc/asciidoc/issues/44
629  GENERATED_MANPAGES += $(patsubst $(DOC_DIR)/src/man/%.txt, $(DOC_DIR)/man/%, $(wildcard $(DOC_DIR)/src/man/man?/*.txt))
630  $(DOC_DIR)/man/%: $(DOC_DIR)/src/man/%.txt
631  	@mkdir -p `dirname $@`
632  	a2x -v --doctype manpage \
633  		--format manpage \
634  		--destination-dir `dirname $@` \
635  		--xsltproc-opts --nonet \
636  		-a mansource=LinuxCNC \
637  		-a manmanual='LinuxCNC Documentation' \
638  		$<
639  
640  else
641  docclean:
642  	@:
643  
644  docs:
645  	$(error Cannot build documents, missing AsciiDoc or some other required program, or explicitly disabled in configure)
646  
647  endif