Adapt man-page making for OpenSSL master / 3.0
[openssl-web.git] / Makefile
1 ##
2 ## Build procedure for www.openssl.org
3
4 ##  Checkouts.
5 CHECKOUTS = /var/cache/openssl/checkouts
6 ##  Snapshot directory
7 SNAP = $(CHECKOUTS)/openssl
8 ## Where releases are found.
9 RELEASEDIR = /var/www/openssl/source
10
11 ######################################################################
12 ##
13 ##  Release series.  These represent our release branches, and are
14 ##  our foundation for what should be built and how (often generated)
15 ##
16 ##  The numbers given here RULE
17 ##
18
19 ##  Current series
20 SERIES=1.1.1
21 ##  Older series.  The second type is for source listings
22 OLDSERIES=1.1.0 1.0.2 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6
23 OLDSERIES2=1.1.0 1.0.2 1.0.1 1.0.0 0.9.x
24 ##  Series for manual layouts
25 MANSERIES1=1.1.1
26 MANSERIES3=3.0
27
28 # All simple generated files.
29 SIMPLE = newsflash.inc sitemap.txt \
30          docs/faq.inc docs/fips.inc \
31          docs/OpenSSLStrategicArchitecture.html \
32          docs/OpenSSL300Design.html \
33          docs/manpages.html \
34          news/changelog.html \
35          $(foreach S,$(SERIES),news/openssl-$(S)-notes.inc) \
36          $(foreach S,$(SERIES),news/openssl-$(S)-notes.html) \
37          news/newsflash.inc \
38          news/vulnerabilities.inc \
39          news/vulnerabilities.html \
40          $(foreach S,$(SERIES) $(OLDSERIES),news/vulnerabilities-$(S).inc) \
41          $(foreach S,$(SERIES) $(OLDSERIES),news/vulnerabilities-$(S).html) \
42          source/.htaccess \
43          source/index.inc \
44          source/old/index.html
45 SRCLISTS = $(foreach S,$(SERIES) $(OLDSERIES2) fips,source/old/$(S)/index.inc source/old/$(S)/index.html)
46
47
48 .SUFFIXES: .md .html
49
50 .md.html:
51         @rm -f $@
52         ./bin/md-to-html5 $<
53
54 all: suball manmaster mancross
55
56 suball: $(SIMPLE) $(SRCLISTS)
57
58 relupd: suball manpages mancross
59
60 clean:
61         rm -f $(SIMPLE) $(SRCLISTS)
62
63 # Legacy targets
64 hack-source_htaccess: all
65 simple: all
66 generated: all
67 rebuild: all
68
69 ######################################################################
70 ##
71 ##  Man-page building section
72 ##
73 ##  This is quite a complex set of rules, because there are many
74 ##  things that need to be built:
75 ##
76 ##  -   The man-pages themselves
77 ##  -   Apropos-like listings
78 ##  -   Cross-references between man-pages in different OpenSSL
79 ##      versions
80 ##
81 ##  A lot of the work is made with generated rules.
82
83 # makemanpages1 and makemanpages3 creates rules for targets like man-pages-1.1.1,
84 # to build the set of man-pages.  makemanpages1 is used for pre-3.0 OpenSSL,
85 # while makemanpages3 is used for OpenSSL 3.0 and on.
86 # makemanapropos creates rules for targets like man-apropos-1.1.1, to build
87 # 'apropos' like indexes for all the manpages.
88 # makemanindexes creates rules for targets like man-index-1.1.1, to build the
89 # main HTML index for a set of man-pages.
90 #
91 # $(1) = input directory in CHECKOUTS, $(2) = release version
92
93 # This variant is for pre-3.0 documentation
94 define makemanpages1
95 man-pages-$(2):
96         @rm -rf docs/man$(2)
97         @mkdir -p docs/man$(2) \
98                   docs/man$(2)/man1 \
99                   docs/man$(2)/man3 \
100                   docs/man$(2)/man5 \
101                   docs/man$(2)/man7
102         ./bin/mk-manpages $(CHECKOUTS)/$(1)/doc $(2) docs/man$(2)
103 endef
104 # This variant is for 3.0 documentation
105 define makemanpages3
106 man-pages-$(2):
107         @rm -rf docs/man$(2)
108         @mkdir -p docs/man$(2) \
109                   docs/man$(2)/man1 \
110                   docs/man$(2)/man3 \
111                   docs/man$(2)/man5 \
112                   docs/man$(2)/man7
113         ./bin/mk-manpages3 $(CHECKOUTS)/$(1) $(2) docs/man$(2)
114 endef
115 define makemanapropos
116 man-apropos-$(2): man-pages-$(2)
117         ./bin/mk-apropos docs/man$(2)/man1 > docs/man$(2)/man1/index.inc
118         ./bin/mk-apropos docs/man$(2)/man3 > docs/man$(2)/man3/index.inc
119         ./bin/mk-apropos docs/man$(2)/man5 > docs/man$(2)/man5/index.inc
120         ./bin/mk-apropos docs/man$(2)/man7 > docs/man$(2)/man7/index.inc
121 endef
122 define makemanindexes
123 man-index-$(2):
124         ./bin/from-tt -d docs/man$(2)/man1 releases='$(SERIES)' release='$(2)' \
125                       < docs/sub-man1-index.html.tt > docs/man$(2)/man1/index.html
126         ./bin/from-tt -d docs/man$(2)/man3 releases='$(SERIES)' release='$(2)' \
127                       < docs/sub-man3-index.html.tt > docs/man$(2)/man3/index.html
128         ./bin/from-tt -d docs/man$(2)/man5 releases='$(SERIES)' release='$(2)' \
129                       < docs/sub-man5-index.html.tt > docs/man$(2)/man5/index.html
130         ./bin/from-tt -d docs/man$(2)/man7 releases='$(SERIES)' release='$(2)' \
131                       < docs/sub-man7-index.html.tt > docs/man$(2)/man7/index.html
132         ./bin/from-tt -d docs/man$(2) releases='$(SERIES)' release='$(2)' \
133                       < docs/sub-index.html.tt > docs/man$(2)/index.html
134 endef
135 define makemanuals1
136 $(eval $(call makemanpages1,$(1),$(2)))
137 $(eval $(call makemanapropos,$(1),$(2)))
138 $(eval $(call makemanindexes,$(1),$(2)))
139 endef
140 define makemanuals3
141 $(eval $(call makemanpages3,$(1),$(2)))
142 $(eval $(call makemanapropos,$(1),$(2)))
143 $(eval $(call makemanindexes,$(1),$(2)))
144 endef
145
146 # Now that we have the generating macros in place, let's use them!
147 #
148 # Start off with creating the 'manpages-master' target, taking the
149 # source from $(CHECKOUTS)/openssl/doc
150 $(eval $(call makemanuals3,openssl,master))
151 #$(foreach S,$(MANSERIES3),$(eval $(call makemanuals3,openssl-$(S),$(S))))
152
153 # Next, create 'manpages-x.y.z' for all current releases, taking the
154 # source from $(CHECKOUTS)/openssl-x.y.z-stable/doc
155 $(foreach S,$(MANSERIES1),$(eval $(call makemanuals1,openssl-$(S)-stable,$(S))))
156
157 manmaster: man-apropos-master man-index-master
158 manpages: $(foreach S,$(MANSERIES1),man-apropos-$(S) man-index-$(S))
159
160 mancross:
161         ./bin/mk-mancross master $(SERIES)
162
163 docs/manpages.html: docs/manpages.html.tt
164         @rm -f $@
165         ./bin/from-tt releases='master $(SERIES)' docs/manpages.html.tt
166
167 ######################################################################
168 ##
169 ##  $(SIMPLE) -- SIMPLE GENERATED FILES
170 ##
171 .PHONY: sitemap community/committers.inc community/otc.inc community/omc.inc community/omc-alumni.inc
172 newsflash.inc: news/newsflash.inc
173         @rm -f $@
174         head -7 $? >$@
175 sitemap sitemap.txt:
176         @rm -f sitemap.txt
177         ./bin/mk-sitemap master $(SERIES) > sitemap.txt
178
179 community/committers.inc:
180         @rm -f $@
181         wget -q https://api.openssl.org/0/Group/commit/Members
182         ./bin/mk-committers <Members >$@
183         @rm -f Members
184
185 community/otc.inc:
186         ./bin/mk-omc -n -t 'OTC Members' otc otc-inactive > $@
187 community/omc.inc:
188         ./bin/mk-omc -n -e -l -p -t 'OMC Members' omc omc-inactive > $@
189 community/omc-alumni.inc:
190         ./bin/mk-omc -n -l -t 'OMC Alumni' omc-alumni omc-emeritus > $@
191
192 docs/faq.inc: $(wildcard docs/faq-[0-9]-*.txt) bin/mk-faq
193         @rm -f $@
194         ./bin/mk-faq docs/faq-[0-9]-*txt >$@
195 docs/fips.inc: $(wildcard docs/fips/*) bin/mk-filelist
196         @rm -f $@
197         ./bin/mk-filelist docs/fips fips/ '*' >$@
198
199 news/changelog.inc: news/changelog.md bin/mk-changelog
200         @rm -f $@
201         (echo 'Table of contents'; sed -e '1,/^OpenSSL Releases$$/d' < $<) \
202                 | pandoc -t html5 -f commonmark | ./bin/post-process-html5 >$@
203 news/changelog.html: news/changelog.html.tt news/changelog.inc
204         @rm -f $@
205         ./bin/from-tt 'releases=$(SERIES)' $<
206 # Additionally, make news/changelog.html depend on clxyz.txt, where xyz
207 # comes from the release number x.y.z.  This permits it to be automatically
208 # recreated whenever there's a new major release.
209 news/changelog.html: $(foreach S,$(SERIES),news/cl$(subst .,,$(S)).txt)
210
211 # mknews_changelogtxt creates a target and ruleset for any changelog text
212 # file depending on the CHANGES file from the target release.
213 #
214 # $(1) = output file, $(2) = CHANGES files, relative to CHECKOUTS
215 define mknews_changelogtxt
216 news/$(1): $(CHECKOUTS)/$(2)
217         @rm -f $$@
218         cp $$? $$@
219 endef
220
221 # Create the target 'news/changelog.txt', taking the source from
222 # $(CHECKOUTS)/openssl/CHANGES.md
223 $(eval $(call mknews_changelogtxt,changelog.md,openssl/CHANGES.md))
224
225 # Create the targets 'news/clxyz.txt' for all current releases, taking the
226 # source from $(CHECKOUTS)/openssl-x.y.z-stable/CHANGES
227 $(foreach S,$(SERIES),\
228 $(eval $(call mknews_changelogtxt,cl$(subst .,,$(S)).txt,openssl-$(S)-stable/CHANGES)))
229
230 # mknews_noteshtml creates two targets and rulesets for creating notes from
231 # the NEWS file for each release.  One target is to create a wrapping HTML
232 # file from a template, the other is to create the inclusion file with the
233 # actual text.
234 #
235 # $(1) = release version, $(2) = NEWS file, relative to CHECKOUTS
236 define mknews_noteshtml
237 news/openssl-$(1)-notes.html: news/openssl-notes.html.tt
238         @rm -f $$@
239         ./bin/from-tt -d news -i $$< -o $$@ release='$(1)'
240 news/openssl-$(1)-notes.inc: $(CHECKOUTS)/$(2) bin/mk-notes
241         @rm -f $$@
242         ./bin/mk-notes $(1) < $(CHECKOUTS)/$(2) > $$@
243 endef
244
245 # Create the targets 'news/openssl-x.y.z-notes.html' and
246 # 'news/openssl-x.y.z-notes.inc' for each release number x.y.z, taking
247 # the source from the news file given as second argument.
248 $(foreach S,$(SERIES),\
249 $(eval $(call mknews_noteshtml,$(S),openssl-$(S)-stable/NEWS)))
250
251 news/newsflash.inc: news/newsflash.txt
252         sed <$? >$@ \
253             -e '/^#/d' \
254             -e 's@^@<tr><td class="d">@' \
255             -e 's@: @</td><td class="t">@' \
256             -e 's@$$@</td></tr>@'
257
258 # mknews_vulnerability creates two targets and rulesets for creating
259 # vulnerability lists for each release.  One target is to create a wrapping
260 # HTML file from a template, the other is to create the inclusion file with
261 # the actual text.
262 #
263 # $(1) = output file mod, $(2) = release version switch, $(3) = release version
264 define mknews_vulnerability
265 news/vulnerabilities$(1).inc: bin/mk-cvepage news/vulnerabilities.xml
266         @rm -f $$@
267         ./bin/mk-cvepage -i news/vulnerabilities.xml $(2) > $$@
268 news/vulnerabilities$(1).html: news/vulnerabilities.html.tt bin/from-tt
269         @rm -f $$@
270         ./bin/from-tt -d news vulnerabilitiesinc='vulnerabilities$(1).inc' < $$< > $$@
271 endef
272
273 # Create the main vulnerability index 'news/vulnerabilities.html' and
274 # 'news/vulnerabilities.inc'
275 $(eval $(call mknews_vulnerability,,))
276
277 # Create the vulnerability index 'news/vulnerabilities-x.y.z.html' and
278 # 'news/vulnerabilities-x.y.z.inc' for each release x.y.z
279 $(foreach S,$(SERIES) $(OLDSERIES),$(eval $(call mknews_vulnerability,-$(S),-b $(S))))
280
281 source/.htaccess: $(wildcard source/openssl-*.tar.gz) bin/mk-latest
282         @rm -f @?
283         ./bin/mk-latest source >$@
284 source/index.inc: $(wildcard $(RELEASEDIR)/openssl-*.tar.gz) bin/mk-filelist
285         @rm -f $@
286         ./bin/mk-filelist $(RELEASEDIR) '' 'openssl-*.tar.gz' >$@
287
288 ######################################################################
289 ##
290 ##  $(SRCLISTS) -- LISTS OF SOURCES
291 ##
292
293 # mkoldsourceindex creates two targets and rulesets for creating the
294 # list of update tarballs for each release.  One target is to create a
295 # wrapping HTML file from a template, the other is to create the
296 # inclusion file with the actual text.
297 #
298 # $(1) = release, $(2) = release title
299 define mkoldsourceindex
300 source/old/$(1)/index.inc: $(wildcard $(RELEASEDIR)/old/$(1)/*.gz) bin/mk-filelist
301         @rm -f $$@
302         ./bin/mk-filelist $(RELEASEDIR)/old/$(1) '' '*.gz' > $$@
303 source/old/$(1)/index.html: source/old/sub-index.html.tt bin/from-tt
304         @rm -f $$@
305         ./bin/from-tt -d source/old/$(1) \
306                       release='$(1)' releasetitle='Old $(2) Releases' \
307                       < $$< > $$@
308 endef
309
310 # Create the update tarball index 'source/old/x.y.z/index.html' and
311 # 'source/old/x.y.z/index.inc' for each release x.y.z.
312 # We also create a list specifically for the old FIPS module, carefully
313 # crafting an HTML title with an uppercase 'FIPS' while the subdirectory
314 # remains named 'fips'
315 $(foreach S,fips $(SERIES) $(OLDSERIES2),$(eval $(call mkoldsourceindex,$(S),$(patsubst fips,FIPS,$(S)))))
316
317 source/old/index.html: source/old/index.html.tt bin/from-tt
318         @rm -f $@
319         ./bin/from-tt releases='fips $(SERIES) $(OLDSERIES2)' $<
320
321 # Because these the indexes of old tarballs will inevitably be newer
322 # than the tarballs that are moved into their respective directory,
323 # we must declare them phony, or they will not be regenerated when
324 # they should.
325 .PHONY : $(SRCLISTS)