f79972033eeb6c304195b7ddb96ef4f8d1ce48bd
[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 ##  OMC data directory
9 OMCDATA = $(CHECKOUTS)/data
10 ## Where releases are found.
11 RELEASEDIR = /srv/ftp/source
12
13 ## The OMC repository checkout can be used for dependencies.
14 ## By default, we don't assume it, as not everyone has access to it.
15 ## If you have it, do 'make PERSONDB=PATH/TO/omc/persondb.yaml' where
16 ## PATH/TO/omc is the checked out OMC repository.
17 ## We let it be FORCE by default...  This forces the production of files
18 ## that depend on this database, instead of just conditionally.
19 PERSONDB=FORCE
20
21 ######################################################################
22 ##
23 ##  Release series.  These represent our release branches, and are
24 ##  our foundation for what should be built and how (often generated)
25 ##
26 ##  The numbers given here RULE
27 ##
28
29 ##  Current series.  Variable names are numbered to indicate:
30 ##
31 ##  SERIES1     OpenSSL pre-3.0
32 ##  SERIES3     OpenSSL 3.0 and on
33 ##  SERIES      The concatenation of the above, for ease of use
34 ##
35 ##  We mostly use $(SERIES) further down, but there are places where we
36 ##  need to make the distinction, because certain files are produced
37 ##  differently.
38 SERIES1=
39 SERIES3=3.3 3.2 3.1 3.0
40 SERIES=$(SERIES3) $(SERIES1)
41 ##  Older series.  The second type is for source listings
42 OLDSERIES=1.1.1 1.1.0 1.0.2 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6
43 OLDSERIES2=1.1.1 1.1.0 1.0.2 1.0.1 1.0.0 0.9.x
44 ##  Series for manual layouts, named similar to SERIES1, SERIES3, SERIES
45 MANSERIES1=1.1.1 1.0.2
46 MANSERIES3=3.3 3.2 3.1 3.0
47 MANSERIES=$(MANSERIES3) $(MANSERIES1)
48
49 ##  Future series, i.e. a series that hasn't had any final release yet.
50 ##  This would typically be a major or minor version that's still only
51 ##  on the master branch, but that has come far enough for us to start
52 ##  to make alpha and beta releases.
53 ##  We distinguish them to avoid having to produce notes, vulnerability
54 ##  documents, ... but still being able to present tarballs.
55 FUTURESERIES=
56
57 # All simple generated files.
58
59 # The H_ variables hold renderings of .md files present in the local
60 # repository.  This does not include .md files taken from other repositories,
61 # they have their own special handling.
62 H_TOP = $(addsuffix .html,\
63           $(basename $(shell git ls-files -- *.md | grep -v '^README')) \
64           $(basename $(basename $(shell git ls-files -- *.md.tt))))
65 H_COMMUNITY = $(addsuffix .html,\
66                 $(basename $(shell git ls-files -- community/*.md)) \
67                 $(basename $(basename $(shell git ls-files -- community/*.md.tt))))
68 # We filter out any file starting with 'sub-'...  they get special treatment
69 H_DOCS = $(addsuffix .html,\
70            $(basename $(shell git ls-files -- docs/*.md \
71                                               docs/*.md.tt \
72                               | grep -v '/sub-')))
73 H_NEWS = $(addsuffix .html,\
74            $(basename $(shell git ls-files -- news/*.md)) \
75            $(basename $(basename $(shell git ls-files -- news/*.md.tt))))
76 H_POLICIES = $(addsuffix .html,\
77                $(basename $(shell git ls-files -- \
78                                   policies/*.md \
79                                   policies/general/*.md \
80                                   policies/technical/*.md \
81                                   policies/general-supplemental/*.md)) \
82                $(basename $(basename $(shell git ls-files -- \
83                                              policies/general/*.md.tt \
84                                              policies/technical/*.md.tt))))
85 # We filter out any file starting with 'sub-'...  they get special treatment
86 H_SOURCE= $(addsuffix .html,\
87             $(basename $(shell git ls-files -- source/*.md \
88                                                source/old/*.md \
89                                | grep -v '/sub-') \
90                        $(basename $(shell git ls-files -- source/*.md.tt \
91                                                           source/old/*.md.tt \
92                                           | grep -v '/sub-'))))
93 H_SUPPORT = $(addsuffix .html,$(basename $(shell git ls-files -- support/*.md)))
94
95 SIMPLE = $(H_TOP) \
96          $(H_COMMUNITY) \
97          $(foreach S,$(SERIES),news/openssl-$(S)-notes.html) \
98          $(H_NEWS) \
99          news/secadv \
100          news/secjson \
101          $(foreach S,$(SERIES) $(OLDSERIES),news/vulnerabilities-$(S).html) \
102          $(H_POLICIES) \
103          policies/glossary.html \
104          $(H_SOURCE) \
105          source/.htaccess \
106          $(H_SUPPORT)
107 SRCLISTS = $(foreach S,$(FUTURESERIES) $(SERIES) $(OLDSERIES2) fips,source/old/$(S)/index.html)
108
109 SIMPLEDOCS = $(H_DOCS) \
110              docs/OpenSSLStrategicArchitecture.html \
111              docs/OpenSSL300Design.html \
112              docs/manpages.html
113
114 GLOSSARY=$(CHECKOUTS)/general-policies/policies/glossary.md
115 all_GENERAL_POLICIES=$(wildcard $(CHECKOUTS)/general-policies/policies/*.md)
116 all_GENERAL_POLICY_SUPPL=$(wildcard $(CHECKOUTS)/general-policies/policy-supplemental/*.md)
117 all_TECHNICAL_POLICIES=$(wildcard $(CHECKOUTS)/technical-policies/policies/*.md)
118 GENERAL_POLICIES=$(filter-out $(CHECKOUTS)/general-policies/policies/README.md $(GLOSSARY),$(all_GENERAL_POLICIES))
119 GENERAL_POLICY_SUPPL=$(filter-out $(CHECKOUTS)/general-policies/policy-supplemental/README.md,$(all_GENERAL_POLICY_SUPPL))
120 TECHNICAL_POLICIES=$(filter-out $(CHECKOUTS)/technical-policies/policies/README.md,$(all_TECHNICAL_POLICIES))
121
122 .PHONY : FORCE
123
124 %.html : %.md bin/md-to-html5
125         @rm -f $@
126         ./bin/md-to-html5 $<
127 % : %.tt bin/from-tt
128         @rm -f $@
129         ./bin/from-tt $<
130
131 all: suball subdocs manmastertts mancross manhtml akamai-purge
132
133 suball: $(SIMPLE) $(SRCLISTS)
134
135 relupd: suball docs akamai-purge
136
137 docs: subdocs manpagetts mancross manhtml
138
139 subdocs: $(SIMPLEDOCS)
140
141 clean:
142         rm -rf $(SIMPLE) $(SIMPLEDOCS) $(SRCLISTS)
143
144 akamai-purge:
145
146 # Legacy targets
147 hack-source_htaccess: all
148 simple: all
149 generated: all
150 rebuild: all
151
152 # For our use of pandoc for full documents, we create a template suitable
153 # for us.
154 inc/pandoc-template.html5: inc/pandoc-header.html5 inc/pandoc-body-prologue.html5 inc/pandoc-body-epilogue.html5 bin/mk-pandoc-template Makefile
155         pandoc --print-default-template=html5 \
156                 | ./bin/mk-pandoc-template html5 > $@
157 # Make bin/md-to-html5 depend on inc/pandoc-template.html5
158 bin/md-to-html5: inc/pandoc-template.html5
159
160 ######################################################################
161 ##
162 ##  Man-page building section
163 ##
164 ##  This is quite a complex set of rules, because there are many
165 ##  things that need to be built:
166 ##
167 ##  -   The man-pages themselves
168 ##  -   Apropos-like listings
169 ##  -   Cross-references between man-pages in different OpenSSL
170 ##      versions
171 ##
172 ##  A lot of the work is made with generated rules.
173
174 # makemanpagetts1 and makemanpagetts3 creates rules for targets like man-pagetts-1.1.1,
175 # to build the set of man-page templates.  makemanpagetts1 is used for pre-3.0 OpenSSL,
176 # while makemanpagetts3 is used for OpenSSL 3.0 and on.
177 # makemanapropos creates rules for targets like man-apropos-1.1.1, to build
178 # 'apropos' like indexes for all the manpages.
179 # makemanindexes creates rules for targets like man-index-1.1.1, to build the
180 # main HTML index for a set of man-pages.
181 #
182 # $(1) = input directory in CHECKOUTS, $(2) = release version
183
184 # This variant is for pre-3.0 documentation
185 define makemanpagetts1
186 man-pagetts-$(2):
187         @rm -rf docs/man$(2)
188         @mkdir -p docs/man$(2) \
189                   docs/man$(2)/man1 \
190                   docs/man$(2)/man3 \
191                   docs/man$(2)/man5 \
192                   docs/man$(2)/man7
193         ./bin/mk-manpagetts $(CHECKOUTS)/$(1)/doc $(2) docs/man$(2)
194 endef
195 # This variant is for 3.0 documentation
196 define makemanpagetts3
197 man-pagetts-$(2):
198         @rm -rf docs/man$(2)
199         @mkdir -p docs/man$(2) \
200                   docs/man$(2)/man1 \
201                   docs/man$(2)/man3 \
202                   docs/man$(2)/man5 \
203                   docs/man$(2)/man7
204         ./bin/mk-manpagetts3 $(CHECKOUTS)/$(1) $(2) docs/man$(2)
205 endef
206 define makemanapropos
207 docs/man$(2)/man1/index.inc: bin/mk-apropos Makefile
208         ./bin/mk-apropos docs/man$(2)/man1 > $$@
209 docs/man$(2)/man3/index.inc: bin/mk-apropos Makefile
210         ./bin/mk-apropos docs/man$(2)/man3 > $$@
211 docs/man$(2)/man5/index.inc: bin/mk-apropos Makefile
212         ./bin/mk-apropos docs/man$(2)/man5 > $$@
213 docs/man$(2)/man7/index.inc: bin/mk-apropos Makefile
214         ./bin/mk-apropos docs/man$(2)/man7 > $$@
215 endef
216 define makemanindexes
217 docs/man$(2)/man1/index.md: docs/sub-man1-index.md.tt \
218                             docs/man$(2)/man1/index.inc \
219                             bin/from-tt Makefile
220         ./bin/from-tt -d docs/man$(2)/man1 \
221                       releases='$(MANSERIES)' release='$(2)' \
222                       < $$< > $$@
223 docs/man$(2)/man3/index.md: docs/sub-man3-index.md.tt \
224                             docs/man$(2)/man3/index.inc \
225                             bin/from-tt Makefile
226         ./bin/from-tt -d docs/man$(2)/man3 \
227                       releases='$(MANSERIES)' release='$(2)' \
228                       < $$< > $$@
229 docs/man$(2)/man5/index.md: docs/sub-man5-index.md.tt \
230                             docs/man$(2)/man5/index.inc \
231                             bin/from-tt Makefile
232         ./bin/from-tt -d docs/man$(2)/man5 \
233                       releases='$(MANSERIES)' release='$(2)' \
234                       < $$< > $$@
235 docs/man$(2)/man7/index.md: docs/sub-man7-index.md.tt \
236                             docs/man$(2)/man7/index.inc \
237                             bin/from-tt Makefile
238         ./bin/from-tt -d docs/man$(2)/man7 \
239                       releases='$(MANSERIES)' release='$(2)' \
240                       < $$< > $$@
241 docs/man$(2)/index.md: docs/sub-index.md.tt bin/from-tt Makefile
242         ./bin/from-tt -d docs/man$(2) \
243                       releases='$(MANSERIES)' release='$(2)' \
244                       < $$< > $$@
245 endef
246 define makemandirdata
247 docs/man$(2)/man1/dirdata.yaml: docs/sub-dirdata.yaml.tt bin/from-tt Makefile
248         ./bin/from-tt -d docs/man$(2)/man1 \
249                       releases='$(MANSERIES)' release='$(2)' sectnum=1 \
250                       < $$< > $$@
251 docs/man$(2)/man3/dirdata.yaml: docs/sub-dirdata.yaml.tt bin/from-tt Makefile
252         ./bin/from-tt -d docs/man$(2)/man3 \
253                       releases='$(MANSERIES)' release='$(2)' sectnum=3 \
254                       < $$< > $$@
255 docs/man$(2)/man5/dirdata.yaml: docs/sub-dirdata.yaml.tt bin/from-tt Makefile
256         ./bin/from-tt -d docs/man$(2)/man5 \
257                       releases='$(MANSERIES)' release='$(2)' sectnum=5 \
258                       < $$< > $$@
259 docs/man$(2)/man7/dirdata.yaml: docs/sub-dirdata.yaml.tt bin/from-tt Makefile
260         ./bin/from-tt -d docs/man$(2)/man7 \
261                       releases='$(MANSERIES)' release='$(2)' sectnum=7 \
262                       < $$< > $$@
263 docs/man$(2)/dirdata.yaml: docs/sub-dirdata.yaml.tt bin/from-tt Makefile
264         ./bin/from-tt -d docs/man$(2) \
265                       releases='$(MANSERIES)' release='$(2)' \
266                       < $$< > $$@
267 endef
268 define makemanuals1
269 $(eval $(call makemanpagetts1,$(1),$(2)))
270 $(eval $(call makemanapropos,$(1),$(2)))
271 $(eval $(call makemanindexes,$(1),$(2)))
272 $(eval $(call makemandirdata,$(1),$(2)))
273 endef
274 define makemanuals3
275 $(eval $(call makemanpagetts3,$(1),$(2)))
276 $(eval $(call makemanapropos,$(1),$(2)))
277 $(eval $(call makemanindexes,$(1),$(2)))
278 $(eval $(call makemandirdata,$(1),$(2)))
279 endef
280
281 # Now that we have the generating macros in place, let's use them!
282 #
283 # Start off with creating the 'manpages-master' target, taking the
284 # source from $(CHECKOUTS)/openssl/doc
285 $(eval $(call makemanuals3,openssl,master))
286
287 # Next, create 'manpages-x.y' for all current releases from 3.0 and on,
288 # taking the source from $(CHECKOUTS)/openssl-x.y/doc
289 $(foreach S,$(MANSERIES3),$(eval $(call makemanuals3,openssl-$(S),$(S))))
290
291 # Next, create 'manpages-x.y.z' for all current pre-3.0 releases, taking the
292 # source from $(CHECKOUTS)/openssl-x.y.z-stable/doc
293 $(foreach S,$(MANSERIES1),$(eval $(call makemanuals1,openssl-$(S)-stable,$(S))))
294
295 MANMASTER_DIRS = \
296         $(foreach SEC,1 3 5 7, docs/manmaster/man$(SEC))
297 MANMASTERTT_TARGETS = \
298         man-pagetts-master \
299         docs/manmaster/dirdata.yaml docs/manmaster/index.html \
300         $(foreach D,$(MANMASTER_DIRS), $(D)/dirdata.yaml $(D)/index.html)
301 manmastertts: $(MANMASTERTT_TARGETS)
302 MANPAGE_DIRS = \
303         $(foreach S,$(MANSERIES), \
304           $(foreach SEC,1 3 5 7, docs/man$(S)/man$(SEC)))
305 MANPAGETT_TARGETS = \
306         $(foreach S,$(MANSERIES), man-pagetts-$(S) \
307           docs/man$(S)/dirdata.yaml docs/man$(S)/index.html) \
308         $(foreach D,$(MANPAGE_DIRS), $(D)/dirdata.yaml $(D)/index.html)
309 manpagetts: manmastertts $(MANPAGETT_TARGETS)
310
311 mancross:
312         ./bin/mk-mancross master $(MANSERIES)
313
314 # We can't get all the files when make is started, but we can make the
315 # patterns for a for loop.
316 MANHTML_TTPATTERNS=$(foreach D,$(MANMASTER_DIRS) $(MANPAGE_DIRS), $(D)/*.md.tt)
317 manhtml:
318         ./bin/mk-manhtml '$(MANHTML_TTPATTERNS)'
319
320 docs/manpages.md: docs/manpages.md.tt Makefile bin/from-tt
321         @rm -f $@
322         ./bin/from-tt releases='master $(MANSERIES)' $<
323
324 docs/mansidebar.html: docs/mansidebar.html.tt Makefile bin/from-tt
325         @rm -f $@
326         ./bin/from-tt releases='master $(MANSERIES)' $<
327
328 ######################################################################
329 ##
330 ##  Policy page building section
331 ##
332
333 .PHONY: technical-policies
334 technical-policies: $(TECHNICAL_POLICIES) policies/technical/dirdata.yaml \
335                     bin/md-to-html5
336         mkdir -p policies/technical
337         for x in $(TECHNICAL_POLICIES); do \
338                 d=$$(dirname $$x); \
339                 f=$$(basename $$x .md); \
340                 cat "$$x" \
341                         | sed -E -e 's!https?://github\.com/openssl/(general|technical)-policies/blob/master/policies/(.*)\.md!../\1/\2.html!' \
342                         | sed -E -e 's!https?://github\.com/openssl/(general|technical)-policies/blob/master/policy-supplemental/(.*)\.md!../\1-supplemental/\2.html!' \
343                         | sed -E -e 's!\.\./general/glossary\.html!../glossary.html!' \
344                         | ./bin/md-to-html5 -o policies/technical/"$$f".html; \
345         done
346 policies/technical/index.inc: technical-policies bin/mk-md-titlelist Makefile
347         ./bin/mk-md-titlelist '' $(TECHNICAL_POLICIES) > $@
348 policies/technical/index.md: policies/technical/index.inc
349 policies/technical/dirdata.yaml: policies/technical/index.inc
350 policies/technical/index.html: policies/technical/index.md
351
352 .PHONY: general-policies
353 general-policies: $(GENERAL_POLICIES) policies/general/dirdata.yaml \
354                   bin/md-to-html5
355         mkdir -p policies/general
356         for x in $(GENERAL_POLICIES); do \
357                 d=$$(dirname "$$x"); \
358                 f=$$(basename "$$x" .md); \
359                 cat "$$x" \
360                         | sed -E -e 's!https?://github\.com/openssl/(general|technical)-policies/blob/master/policies/(.*)\.md!../\1/\2.html!' \
361                         | sed -E -e 's!https?://github\.com/openssl/(general|technical)-policies/blob/master/policy-supplemental/(.*)\.md!../\1-supplemental/\2.html!' \
362                         | sed -E -e 's!\.\./policy-supplemental/(.*)\.html!../general-supplemental/\1.html!' \
363                         | sed -E -e 's!\.\./general/glossary\.html!../glossary.html!' \
364                         | ./bin/md-to-html5 -o policies/general/"$$f".html; \
365         done
366 policies/general/index.inc: general-policies general-policy-supplemental bin/mk-md-titlelist Makefile
367         ./bin/mk-md-titlelist '' $(GENERAL_POLICIES) > $@
368 policies/general/index.md: policies/general/index.inc
369 policies/general/dirdata.yaml: policies/general/index.inc
370 policies/general/index.html: policies/general/index.md
371
372 .PHONY: general-policy-supplemental
373 general-policy-supplemental: $(GENERAL_POLICY_SUPPL) bin/md-to-html5
374         mkdir -p policies/general-supplemental
375         for x in $(GENERAL_POLICY_SUPPL); do \
376                 d=$$(dirname "$$x"); \
377                 f=$$(basename "$$x" .md); \
378                 cat "$$x" \
379                         | ./bin/md-to-html5 -o policies/general-supplemental/"$$f".html; \
380         done
381
382 policies/glossary.html: $(GLOSSARY) bin/md-to-html5 policies/dirdata.yaml
383         cat "$(GLOSSARY)" \
384                 | sed -E -e 's!https?://github\.com/openssl/(general|technical)-policies/blob/master/policies/(.*)\.md!\1/\2.html!' \
385                 | sed -E -e 's!general/glossary\.html!glossary.html!' \
386                 | ./bin/md-to-html5 -o policies/glossary.html
387
388 ######################################################################
389 ##
390 ##  $(SIMPLE) -- SIMPLE GENERATED FILES
391 ##
392 .PHONY:
393 newsflash.inc: news/newsflash.inc
394         @rm -f $@
395         head -7 $< >$@
396 index.md: newsflash.inc inc/legalities.md
397
398 community/committers.inc: $(PERSONDB) bin/mk-committers Makefile
399         @rm -f $@
400         wget -q https://api.openssl.org/0/Group/commit/Members
401         ./bin/mk-committers <Members >$@
402         @rm -f Members
403 community/committers.md: community/committers.inc
404
405 community/otc.inc: $(PERSONDB) bin/mk-omc Makefile
406         ./bin/mk-omc -n -p -t 'OTC Members' otc otc-inactive > $@
407 community/otc.md: community/otc.inc
408 community/omc.inc: $(PERSONDB) bin/mk-omc Makefile
409         ./bin/mk-omc -n -e -l -p -t 'OMC Members' omc omc-inactive > $@
410 community/omc.md: community/omc.inc
411 community/omc-alumni.inc: $(PERSONDB) bin/mk-omc Makefile
412         ./bin/mk-omc -n -l -t 'OMC Alumni' omc-alumni omc-emeritus > $@
413 community/omc-alumni.md: community/omc-alumni.inc
414
415 news/changelog.inc: news/changelog.txt bin/post-process-html5 Makefile
416         @rm -f $@
417         (echo 'Table of contents'; sed -e '1,/^OpenSSL Releases$$/d' < $<) \
418                 | pandoc -t html5 -f commonmark | ./bin/post-process-html5 >$@
419 news/changelog.md: news/changelog.md.tt news/changelog.inc \
420                    bin/from-tt Makefile
421         @rm -f $@
422         ./bin/from-tt 'releases=$(SERIES)' $<
423 # Additionally, make news/changelog.html depend on clxy[z].txt, where xy[z]
424 # comes from the release number x.y[.z].  This permits it to be automatically
425 # recreated whenever there's a new major release.
426 news/changelog.html: $(foreach S,$(SERIES),news/cl$(subst .,,$(S)).txt)
427
428 # mknews_changelogtxt creates a target and ruleset for any changelog text
429 # file depending on the CHANGES file from the target release.
430 #
431 # $(1) = output file, $(2) = CHANGES files, relative to CHECKOUTS
432 define mknews_changelogtxt
433 news/$(1): $(CHECKOUTS)/$(2)
434         @rm -f $$@
435         cp $$< $$@
436 endef
437
438 # Create the target 'news/changelog.txt', taking the source from
439 # $(CHECKOUTS)/openssl/CHANGES.md
440 # We use the .txt extension for multiple purposes:
441 # 1. So the web server maps to the MIME type text/plain
442 # 2. To ensure there's no need to publish any .md file (since they're all
443 #    supposed to be used to generate .html files)
444 # 3. Because it was changelog.txt before, a well known target.  Why change it?
445 $(eval $(call mknews_changelogtxt,changelog.txt,openssl/CHANGES.md))
446
447 # Create the target 'news/clxy.md' for all releases from 3.0 and on, taking
448 # the source from $(CHECKOUTS)/openssl-x.y/CHANGES.md
449 $(foreach S,$(SERIES3),\
450 $(eval $(call mknews_changelogtxt,cl$(subst .,,$(S)).txt,openssl-$(S)/CHANGES.md)))
451
452 # Create the targets 'news/clxyz.txt' for all current pre-3.0 releases,
453 # taking the source from $(CHECKOUTS)/openssl-x.y.z-stable/CHANGES
454 $(foreach S,$(SERIES1),\
455 $(eval $(call mknews_changelogtxt,cl$(subst .,,$(S)).txt,openssl-$(S)-stable/CHANGES)))
456
457 # mknews_noteshtml creates two targets and rulesets for creating notes from
458 # the NEWS file for each release.  One target is to create a wrapping HTML
459 # file from a template, the other is to create the inclusion file with the
460 # actual text.
461 #
462 # $(1) = release version, $(2) = NEWS file, relative to CHECKOUTS
463 define mknews_noteshtml
464 news/openssl-$(1)-notes.md: news/openssl-notes.md.tt \
465                             news/openssl-$(1)-notes.inc \
466                             bin/from-tt Makefile
467         @rm -f $$@
468         ./bin/from-tt -d news -i $$< -o $$@ release='$(1)'
469 news/openssl-$(1)-notes.inc: $(CHECKOUTS)/$(2) bin/mk-notes Makefile
470         @rm -f $$@
471         ./bin/mk-notes $(1) < $(CHECKOUTS)/$(2) > $$@
472 endef
473
474 # Create the targets 'news/openssl-x.y-notes.html' and
475 # 'news/openssl-x.y-notes.inc' for each release number x.y starting with 3.0,
476 # taking the source from the news file given as second argument.
477 $(foreach S,$(SERIES3),\
478 $(eval $(call mknews_noteshtml,$(S),openssl-$(S)/NEWS.md)))
479
480 # Create the targets 'news/openssl-x.y.z-notes.html' and
481 # 'news/openssl-x.y.z-notes.inc' for each pre-3.0 release number x.y.z,
482 # taking the source from the news file given as second argument.
483 $(foreach S,$(SERIES1),\
484 $(eval $(call mknews_noteshtml,$(S),openssl-$(S)-stable/NEWS)))
485
486 news/newsflash.inc: $(OMCDATA)/newsflash.txt Makefile
487         sed <$< >$@ \
488             -e '/^#/d' \
489             -e 's@^@<tr><td class="d">@' \
490             -e 's@: @</td><td class="t">@' \
491             -e 's@$$@</td></tr>@'
492
493 # mknews_vulnerability creates two targets and rulesets for creating
494 # vulnerability lists for each release.  One target is to create a wrapping
495 # HTML file from a template, the other is to create the inclusion file with
496 # the actual text.
497 #
498 # $(1) = output file mod, $(2) = release version switch, $(3) = release version
499 define mknews_vulnerability
500 news/vulnerabilities$(1).inc: bin/cvejsontohtml.py news/secjson Makefile
501         @rm -f $$@
502         python3 ./bin/cvejsontohtml.py -i news/secjson/ $(2) > $$@
503 news/vulnerabilities$(1).md: news/vulnerabilities.md.tt \
504                              news/vulnerabilities$(1).inc \
505                              bin/from-tt Makefile
506         @rm -f $$@
507         ./bin/from-tt -d news vulnerabilitiesinc='vulnerabilities$(1).inc' < $$< > $$@
508 endef
509
510 # Create the main vulnerability index 'news/vulnerabilities.html' and
511 # 'news/vulnerabilities.inc'
512 $(eval $(call mknews_vulnerability,,))
513
514 # Create the vulnerability index 'news/vulnerabilities-x.y[.z].html' and
515 # 'news/vulnerabilities-x.y[.z].inc' for each release x.y[.z]
516 $(foreach S,$(SERIES) $(OLDSERIES),\
517 $(eval $(call mknews_vulnerability,-$(S),-b $(S))))
518
519 source/.htaccess: $(wildcard source/openssl-*.tar.gz) bin/mk-latest Makefile
520         @rm -f @?
521         ./bin/mk-latest $(RELEASEDIR) >$@
522 source/index.inc: $(wildcard $(RELEASEDIR)/openssl-*.tar.gz) bin/mk-filelist Makefile
523         @rm -f $@
524         ./bin/mk-filelist $(RELEASEDIR) '' 'openssl-*.tar.gz' >$@
525
526 # mknews_secadv creates a target to copy a secadv file from $(OMCDATA)/secadv
527 # to news/secadv/.
528 # $(1) = file name
529 define mknews_secadv
530 news/secadv/$(1): $(OMCDATA)/secadv/$(1)
531         cp $$< $$@
532 endef
533
534 # mknews_secjson creates a target to copy a security json file from $(OMCDATA)/vulnerabilities-json
535 # to news/secjson/.
536 # $(1) = file name
537 define mknews_secjson
538 news/secjson/$(1): $(OMCDATA)/vulnerabilities-json/$(1)
539         cp $$< $$@
540 endef
541
542 # Get the set of files in $(OMCDATA)/secadv/
543 SECADV_FILES = $(shell cd $(OMCDATA)/secadv/; git ls-files)
544 $(foreach F,$(SECADV_FILES),$(eval $(call mknews_secadv,$(F))))
545
546 # Get the set of files in $(OMCDATA)/vulnerabilities-json/
547 SECJSON_FILES = $(shell cd $(OMCDATA)/vulnerabilities-json/; git ls-files)
548 $(foreach F,$(SECJSON_FILES),$(eval $(call mknews_secjson,$(F))))
549
550 mkdirnews_secadv: FORCE
551         mkdir -p news/secadv
552 news/secadv: mkdirnews_secadv $(addprefix news/secadv/,$(SECADV_FILES))
553 .PHONY: news/secadv mkdirnews_secadv
554
555 mkdirnews_secjson: FORCE
556         mkdir -p news/secjson
557 news/secjson: mkdirnews_secjson $(addprefix news/secjson/,$(SECJSON_FILES))
558 .PHONY: news/secjson mkdirnews_secjson
559
560 ######################################################################
561 ##
562 ##  $(SRCLISTS) -- LISTS OF SOURCES
563 ##
564
565 # mkoldsourceindex creates two targets and rulesets for creating the
566 # list of update tarballs for each release.  One target is to create a
567 # wrapping HTML file from a template, the other is to create the
568 # inclusion file with the actual text.
569 #
570 # $(1) = release, $(2) = release title
571 define mkoldsourceindex
572 source/old/$(1)/index.inc: $(RELEASEDIR)/old/$(1) bin/mk-filelist Makefile
573         @mkdir -p `dirname $$@`
574         @rm -f $$@
575         ./bin/mk-filelist $(RELEASEDIR)/old/$(1) '' '*.gz' > $$@
576 source/old/$(1)/index.md: source/old/sub-index.md.tt inc/legalities.md \
577                           source/old/$(1)/index.inc \
578                           bin/from-tt Makefile
579         @mkdir -p `dirname $$@`
580         @rm -f $$@
581         ./bin/from-tt -d source/old/$(1) \
582                       release='$(1)' releasetitle='Old $(2) Releases' \
583                       < $$< > $$@
584 endef
585 define mkoldsourcedirdata
586 source/old/$(1)/dirdata.yaml: source/old/sub-dirdata.yaml.tt bin/from-tt Makefile
587         @mkdir -p `dirname $$@`
588         @rm -f $$@
589         ./bin/from-tt -d source/old/$(1) \
590                       release='$(1)' releasetitle='Old $(2) Releases' \
591                       < $$< > $$@
592 source/old/$(1)/index.html: source/old/$(1)/dirdata.yaml
593 endef
594
595 # Create the update tarball index 'source/old/x.y.z/index.html' and
596 # 'source/old/x.y.z/index.inc' for each release x.y.z.
597 # We also create a list specifically for the old FIPS module, carefully
598 # crafting an HTML title with an uppercase 'FIPS' while the subdirectory
599 # remains named 'fips'
600 $(foreach S,fips $(FUTURESERIES) $(SERIES) $(OLDSERIES2),$(eval $(call mkoldsourceindex,$(S),$(patsubst fips,FIPS,$(S)))))
601 $(foreach S,fips $(FUTURESERIES) $(SERIES) $(OLDSERIES2),$(eval $(call mkoldsourcedirdata,$(S),$(patsubst fips,FIPS,$(S)))))
602
603 source/old/index.md: source/old/index.md.tt inc/legalities.md \
604                      Makefile bin/from-tt Makefile
605         @mkdir -p `dirname $@`
606         @rm -f $@
607         ./bin/from-tt releases='$(FUTURESERIES) $(SERIES) $(OLDSERIES2) fips' $<
608
609 # Extra inc -> markdown dependencies
610
611 news/newslog.md: news/newsflash.inc
612 news/pgpkey.md: news/openssl-security.asc
613 source/index.md: source/index.inc
614
615 # Extra HTML dependencies (apart from the markdown file it comes from)
616
617 # makehtmldepend creates a standard dependency for HTML files rendered from
618 # markdown files
619 # $(1) = HTML file
620 define makehtmldepend
621 $(1): bin/md-to-html5 $(dir $(1))dirdata.yaml
622 endef
623
624 # Generate standard dependencies for our known HTML outputs.
625 $(foreach H, \
626   $(H_TOP) \
627   $(H_COMMUNITY) \
628   $(H_DOCS) \
629   $(filter %.html,$(MANMASTER_TARGETS)) \
630   $(filter %.html,$(MANPAGES_TARGETS)) \
631   $(H_NEWS) \
632   $(H_POLICIES) \
633   $(H_SOURCE) \
634   $(H_SUPPORT) \
635 ,$(eval $(call makehtmldepend,$(H))))