summaryrefslogtreecommitdiffstats
path: root/doc/Makefile
blob: 768b9503acea6c8ae3ad4933c4b438606c911a9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#Path to this subsystem's root directory
SUBSYSROOT := $(shell pwd)

include init.mk

# ****************** SUPPORT FOR TARGETS ***************************
PATH_TARGETS   = $(SUBSYSROOT)/s_targets
#Git repositories to be cloned
NAME_TARGETS       := targets
#Path to the directory under which repos shall be cloned.
DOCBASEDIR=$(shell pwd)
REPODIR=$(DOCBASEDIR)/..
TMPCLONEROOT_TARGETS := $(TMPCLONEROOT)/$(NAME_TARGETS)
TARGETDEFAULTXMLS    := $(shell cd $(REPODIR); ls -1 */default.xml)
# URL and HASH of this manifest repository to be used by the repo tool
CURRENTHASH := $(shell git log -1 --pretty=format:%H 2>/dev/null)
CURRENTURL := $(shell git remote show origin | sed -n '/Fetch URL: /s/^.*URL: //p' 2>/dev/null)
.PHONY: inittargets
# ******************************************************************



# -----------------------------------------------------
#Path to DocBook make files and templates
DOCBOOKMAKE         = $(SUBSYSROOT)/s_docbuild/docmake
DOCBOOKTEMPLATE     = $(SUBSYSROOT)/s_docbuild/template

#Path to the OLINK database including leading part of file name (will add -$(FORMAT).db)
DOCBOOKOLINKDB_BASE = $(SUBSYSROOT)/s_docbuild/olinkdb/olink-targetdb-master

DOCBOOK_OLINKS ?= yes
DOCBOOK_FO_USEFOP ?= yes
DOCBOOK_TO_BOOKDIR ?= yes
DOCBOOK_CLEANTMP ?= yes

#Components in this subsystem
COMPONENTS := book-enea-linux-release-info book-enea-linux-open-source
# COMPONENTS += book-enea-linux-eclipse-open-source
# -----------------------------------------------------
#Release version, used in labels and text
REL_VER_EXT := $(shell perl -e \
'while(<>) {\
  if (/<!ENTITY ENEA_LINUX_REL_VER "([\d\.-\w]+)">/) { print $$1 ; exit; }\
}' \
< $(SUBSYSROOT)/docsrc_common/pardoc-distro.xml 2>/dev/null)
#$(info REL_VER_EXT = $(REL_VER_EXT))

ifneq ($(REL_VER_EXT),)
REL_VER ?= $(REL_VER_EXT)
else
REL_VER ?= undefined
endif
$(info REL_VER = $(REL_VER))

# -----------------------------------------------------


# --------------------------------------------------------------
ifeq ($(VERBOSE),yes)
VERB :=
else
VERB := @
endif
MAKEFLAGS += --no-print-directory
MAKEFLAGS += --directory $(SUBSYSROOT)
MAKEFLAGS += --no-builtin-rules --no-builting-variables

# Skip xml validation to make it possible to include xml files with unresolved
# links from book-enea-linux-users-guide
VALIDATE = no

# BL_LABEL is either given on make command line or using BOOK_VER or defaults to a timestamp

# ******************************************************************

# Export all parameters including those on the command line
export

.PHONY: doc books docusage


docusage:
	@echo 'make docusage                #Shows this help text'
	@echo '  DOCBOOK_TOOLS_VERSIONS=yes #Displays DocBook tools versions in this machine'
	@echo 'make doc                    #Builds the userdoc, does autoinit if needed'
	@echo 'make init                      #Init both below'
	@echo 'make initbuild                 #Init s_docbuild'
	@echo 'make inittargets               #Init s_targets using repo tool'
	@echo ' DOCBOOK_CLEANTMP=no           #Option to keep temp files in doc/ and tmp/'
	@echo ' BOOK_GLOBALCLONEROOT=yes      #Option for all init above to clone all outside the doc directory'
	@echo ' BOOK_GLOBALCLONEROOT=otherpath #Option for all init above to clone all'
	@echo              #Force rebuilding (ignore dependency on file times or BL_LABEL)'
	@echo '                            #   Dependency only works if common doc directory is kept'
	@echo '  BOOKCONDITION'make pullbuild                 #git pull in s_docbuild'
	@echo 'make pulltargets               #git pull in s_targets'
	@echo 'make clean                     #Clean. Also clean s_* but not any external clones'
	@echo 'The following directories are cloned via the init commands (s_* are symlinks to clones):'
	@echo '  s_docbuild                #Docbook build system and central files'
	@echo '  s_targets                 #targets in this distro with poky, for picking some parameters'
	@echo ''
	@echo 'Optional parameters for make doc:'
	@echo '  COMP=<book-directory>     #Component (book) to build. Book component names are book-*'
	@echo '                            #Default component/s:'
	@echo '    $(COMPONENTS)'
	@echo '  FORMAT=<format>           #One of: pdf, html, or eclipse (Default all are built)'
	@echo '  BL_LABEL=<baseline>       #Becomes footer in book (default: date + time)'
	@echo '  DOCBOOK_TO_BOOKDIR=no     #(default yes) Avoid moving result to book directory'
	@echo '                            #   and avoid erasing common doc and tmp directories'
	@echo '  BOOKFORCE=yes             #Force rebuilding (ignore dependency on file times or BL_LABEL)'
	@echo '                            #   Dependency only works if common doc directory is kept'
	@echo '  BOOKCONDITION="xx;yy;.."  #Include XML elements with condition any of xx or yy'
	@echo '                            #   (if rebuilding, BOOKFORCE=yes may be needed)'
	@echo '                            #   Empty=only default. none=none, all=everything.'
	@echo '  BOOKDEFAULTCONDITION      #Default conditions, if no BOOKCONDITION. Used in book-*/swcomp.mk'
	@echo '  SHOW_COMMENTS=yes         #For proofread. Unhide <remark>..</remark> comments Only PDF'
	@echo '  BOOKVERBOSE=yes           #Verbose info building books'
	@echo '  DOCBOOK_OLINKS=no         #Avoid the olink database in Makefile (in book not using it)'
	@echo '  DOCBOOK_OLINK_TARGETDB=only  #Build a target db for this book (for links into it)'
	@echo '  DOCBOOK_OLINK_TARGETDB=yes   #Build a target db AND build the book'
	@echo '                               #Master olinkdb defined in this Makefile, one per generated format, is:'
	@echo '                                $(DOCBOOKOLINKDB_BASE)_*.db'
	@echo '  Typical examples:'
	@echo '     make doc                          Creates all books, all formats'
	@echo '     make doc COMP=book-xxxx FORMAT=html'
	@echo '     make doc COMP=book-xxxx FORMAT=pdf'
	@echo '     make doc BL_LABEL="Version 1.2.3"  Creates all with version in footers and front'

	@echo '  Requires docbook-xsl-1.76.1 or later, docbook-xml 4.2, svg1.1, fop-1.0 + fop-hyph.jar'
	@echo '     fop + the separate fop-hyph can be found together in package "libfop-java"'
	@echo '     otherwise fetch fop-hyph.jar and place in same place as fop.jar'
	@echo '  Requires libxml2-2.7.8 or later, libxslt-1.1.26 or later'
	@echo '  Requires java machine to run fop (creating PDF). jar for optional FORMAT=eclipse'
	@echo '      Without jar, the optional EclipseHelp format can not be built'
	@echo '  tools_book_standalone.mk => libxml2, libxslt, and fop (and to catalog-el.xml)'
	@echo '  catalog-el.xml => svg, docbook-xml, docbook-xsl'
ifeq ($(DOCBOOK_TOOLS_VERSIONS),yes)
	$(VERB)$(MAKE) -f $(DOCBOOKMAKE)/tools_book_standalone.mk book_tools_versions
endif

init: initbuild inittargets
pullall: pullbuild pulltargets

# If no COMP, iterate over books-* in COMPONENTS with make doc
ifeq ($(COMP),)
doc:
ifneq ($(filter book-%, $(COMPONENTS)),)
	$(VERB)for comp in $(filter book-%, $(COMPONENTS)); do \
	  $(MAKE) doc COMP=$$comp; \
	done
endif

else
include $(SUBSYSROOT)/$(COMP)/swcomp.mk

doc: books
	@#
endif


# Default FORMATs
ifeq ($(FORMAT),)
FORMAT=html pdf eclipse
endif


books: initbuild inittargets
# BOOKPACKAGES is defined in all book-*/swcomp.mk
	$(VERB)for book in $(BOOKPACKAGES); do \
	  for format in $(FORMAT); do \
	    $(MAKE) -f $(DOCBOOKMAKE)/make_docbook_standalone.mk BOOK=$$book FORMAT=$$format books || exit 10; \
	  done ; \
	done
ifeq ($(DOCBOOK_TO_BOOKDIR),yes)
	$(VERB)rm -rf doc tmp
else
ifeq ($(DOCBOOK_CLEANTMP),yes)
#       keep only doc/pdf/book-*.pdf doc/eclipse/plugins/com.enea.doc.book-* but delete doc/eclipse/plugins/com.enea.doc.book-*/done*
	$(VERB)rm -rf tmp 2>/dev/null ; rm -rf doc/pdf/book-*/ ; rm -rf doc/eclipse/plugins/com.enea.doc.book-*/done* 2>/dev/null
endif
endif


clean:  cleaninit
	$(VERB)rm -rf doc tmp 2>/dev/null
ifneq ($(filter book-%, $(COMPONENTS)),)
	$(VERB)for comp in $(filter book-%, $(COMPONENTS)); do \
	  rm -rf $$comp/book*.pdf $$comp/html $$comp/eclipse 2>/dev/null; \
	done
	$(VERB)rm -rf doc tmp 2>/dev/null
endif


# ******************************************************************
# ****************** SUPPORT FOR TARGETS ***************************
inittargets:  s_targets
pulltargets:
	$(VERB)if [ ! -d s_targets ]; then echo "ERROR: No s_targets exists?" ; exit 10 ; fi
	$(VERB)cd s_targets; for targ in *; do ( cd $targ ; git pull )


# -----------------------------------------

# Use repo to auto-clone each target separately - VERY LARGE if there are many targets (5 targets => about 1.3 Gytes)

s_targets: $(TMPCLONEROOT_TARGETS)
	$(VERB)rm s_targets 2>/dev/null; ln -s $(TMPCLONEROOT_TARGETS) s_targets


$(TMPCLONEROOT_TARGETS):
	$(VERB)if [ ! -d "$(TMPCLONEROOT)" ] ; then mkdir -p "$(TMPCLONEROOT)" ; fi
	$(VERB)if [ ! -d $(TMPCLONEROOT_TARGETS) ]; then mkdir -p $(TMPCLONEROOT_TARGETS) ; fi
	@echo "Cloning all targets using repo tool into $(TMPCLONEROOT_TARGETS)"
	@echo "TARGETDEFAULTXMLS is <$(TARGETDEFAULTXMLS)>"
	$(VERB)for target_default_xml in $(TARGETDEFAULTXMLS); \
	  do \
	    TARGDIR=$(TMPCLONEROOT_TARGETS)/`dirname $$target_default_xml` ; \
	    echo "TARGDIR=<$$TARGDIR>" ; \
	    if [ ! -d $$TARGDIR ]; then mkdir -p $$TARGDIR ; fi ; \
	    ( cd $$TARGDIR ; \
	      echo "*** Doing repo init -u $(CURRENTURL) -b $(CURRENTHASH) -m $$target_default_xml ; repo sync"; \
	                      repo init -u $(CURRENTURL) -b $(CURRENTHASH) -m $$target_default_xml ; repo sync ; \
	    ) ; \
	  done
# ******************************************************************