1## -----------------------------------------------------------------------
2##
3##   Copyright 2012 Gene Cumm
4##
5##   Some logic from win32/Makefile:
6##     Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
7##     Copyright 2010 Intel Corporation; author: H. Peter Anvin
8##
9##   This program is free software; you can redistribute it and/or modify
10##   it under the terms of the GNU General Public License as published by
11##   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
12##   Boston MA 02111-1307, USA; either version 2 of the License, or
13##   (at your option) any later version; incorporated herein by reference.
14##
15## -----------------------------------------------------------------------
16
17##
18## AsciiDoc documentation for syslinux
19##
20
21topdir = ..
22MAKEDIR = $(topdir)/mk
23# include $(MAKEDIR)/embedded.mk
24
25VPATH = $(SRC)
26
27A2X_OPTS	 = -k
28# A2X_OPTS	+= -v
29A2X_MAN_OPTS	 = -D man -f manpage
30
31DOCS 		 = syslinux.txt syslinux-cli.txt syslinux.cfg.txt \
32		   isolinux.txt pxelinux.txt
33MAN_DOCS	 = man/syslinux.1 man/syslinux-cli.1 man/syslinux.cfg.5 \
34		   man/isolinux.1 man/pxelinux.1
35HTML_DOCS	:= $(patsubst %.txt,html/%.html,$(DOCS))
36XHTML_DOCS	:= $(patsubst %.txt,%.html,$(DOCS))
37# MAN_DOCS	:= $(patsubst %.txt,man/%.1,$(DOCS1)) $(patsubst %.txt,man/%.5,$(DOCS5))
38TEXT_DOCS	:= $(patsubst %.txt,%.text,$(DOCS))
39PDF_DOCS	:= $(patsubst %.txt,%.pdf,$(DOCS))
40TARGETS		 =
41
42# ASCIIDOC_OK := $(shell which asciidoc 2>&1 ; echo $$?)
43ASCIIDOC_OK	:= $(shell which asciidoc > /dev/null ; echo $$?)
44A2X_XML_OK	:= $(shell a2x $(A2X_OPTS) -f docbook hello.txt 2>&1 ; echo $$?)
45ifeq ($(A2X_XML_OK),0)
46A2X_MAN_OK	:= $(shell [ ! -d man ] && mkdir man ; a2x $(A2X_MAN_OPTS) hello.txt 2>&1 ; echo $$?)
47A2X_XHTML_OK	:= $(shell a2x $(A2X_OPTS) -f xhtml hello.xml 2>&1 ; echo $$?)
48A2X_TEXT_OK	:= $(shell a2x $(A2X_OPTS) -f text hello.xml 2>&1 ; echo $$?)
49endif
50
51ifeq ($(ASCIIDOC_OK),0)
52TARGETS		+= $(HTML_DOCS)
53endif
54ifeq ($(A2X_MAN_OK),0)
55TARGETS		+= $(MAN_DOCS)
56endif
57ifeq ($(A2X_XHTML_OK),0)
58TARGETS		+= $(XHTML_DOCS)
59endif
60ifeq ($(A2X_TEXT_OK),0)
61TARGETS		+= $(TEXT_DOCS)
62endif
63
64# $(HTML_DOCS) $(MAN_DOCS) $(XHTML_DOCS) $(TEXT_DOCS)
65all:	$(TARGETS)
66
67syslinux.cfg.txt:	com-bug.txt com-rpt.txt
68
69# During 'make all', *.xml is kept but deleted at the end; do we _really_
70#	need the XML longer?
71.PRECIOUS:	%.xml
72
73# %.html:	%.txt
74# 	asciidoc -D html $<
75
76# Mark as .PHONY so they're ignored if found in VPATH
77.PHONY: html/ man/ text/ xhtml/
78
79html/ man/ text/ xhtml/:
80	mkdir -p $@
81
82html/%.html:	%.txt	| html/
83	asciidoc -o $@ $<
84
85# As of AsciiDoc-8.5.2, altering the output filename for a2x does not appear possible
86# xhtml/%.html:	%.txt
87# 	a2x $(A2X_OPTS) -D xhtml -f xhtml $<
88# text/%.text:	%.xml %.txt
89# 	a2x $(A2X_OPTS) -D text -f text $<
90
91%.xml:	%.txt
92	a2x $(A2X_OPTS) -f docbook $<
93
94# when %.xml is missing, an update to %.txt must force regeneration
95%.html:	%.xml %.txt
96	a2x $(A2X_OPTS) -f xhtml $<
97
98man/%.1:	%.txt	| man/
99	a2x $(A2X_MAN_OPTS) $<
100
101man/%.5:	%.txt	| man/
102	a2x $(A2X_MAN_OPTS) $<
103
104%.text:	%.xml %.txt
105	a2x $(A2X_OPTS) -f text $<
106
107%.pdf:	%.xml %.txt
108	a2x $(A2X_OPTS) -f pdf $<
109
110tidy dist:
111	rm -f *~ *.xml *.text.html text/*.text.html text/*.xml xhtml/*.xml
112
113clean: tidy
114
115spotless: clean
116	rm -f *.1 *.5 *.css *.html *.text html/*.html man/*.1 man/*.5 text/*.text xhtml/*.html xhtml/*.css
117
118-include .*.d
119