Remove redundancy: generate vulnerabilities indexes from templates
[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 ##  Current series
12 SERIES=1.1.1 1.1.0 1.0.2
13 ##  Older series
14 OLDSERIES=1.0.1 1.0.0 0.9.8 0.9.7 0.9.6
15 OLDSERIES2=1.0.1 1.0.0 0.9.x
16 ##  Current series with newer and older manpage layout
17 ##  (when the number of old man layout releases drop to none, this goes away)
18 NEWMANSERIES=1.1.1
19 OLDMANSERIES=1.1.0 1.0.2
20
21 # All simple generated files.
22 SIMPLE = newsflash.inc sitemap.txt \
23          community/committers.inc \
24          community/omc.inc community/omc-alumni.inc \
25          docs/faq.inc docs/fips.inc \
26          docs/OpenSSLStrategicArchitecture.html \
27          docs/OpenSSL300Design.html \
28          docs/manpages.html \
29          news/changelog.html \
30          $(foreach S,$(SERIES),news/openssl-$(S)-notes.inc) \
31          $(foreach S,$(SERIES),news/openssl-$(S)-notes.html) \
32          news/newsflash.inc \
33          news/vulnerabilities.inc \
34          news/vulnerabilities.html \
35          $(foreach S,$(SERIES) $(OLDSERIES),news/vulnerabilities-$(S).inc) \
36          $(foreach S,$(SERIES) $(OLDSERIES),news/vulnerabilities-$(S).html) \
37          source/.htaccess \
38          source/index.inc \
39          source/old/index.html
40 SRCLISTS = $(foreach S,$(SERIES) $(OLDSERIES2) fips,source/old/$(S)/index.inc source/old/$(S)/index.html)
41
42
43 .SUFFIXES: .md .html
44
45 .md.html:
46         @rm -f $@
47         ./bin/md-to-html5 $<
48
49 all: suball manmaster mancross
50
51 suball: $(SIMPLE) $(SRCLISTS)
52
53 relupd: suball manpages mancross
54
55 clean:
56         rm -f $(SIMPLE) $(SRCLISTS)
57
58 # Legacy targets
59 hack-source_htaccess: all
60 simple: all
61 generated: all
62 rebuild: all
63
64 # $(1) = input directory in CHECKOUTS, $(2) = release version
65 define makemanpages
66 manpages-$(2):
67         @rm -rf docs/man$(2)
68         @mkdir -p docs/man$(2) \
69                   docs/man$(2)/man1 \
70                   docs/man$(2)/man3 \
71                   docs/man$(2)/man5 \
72                   docs/man$(2)/man7
73         ./bin/mk-manpages $(CHECKOUTS)/$(1)/doc $(2) docs/man$(2)
74         ./bin/mk-apropos docs/man$(2)/man1 > docs/man$(2)/man1/index.inc
75         ./bin/mk-apropos docs/man$(2)/man3 > docs/man$(2)/man3/index.inc
76         ./bin/mk-apropos docs/man$(2)/man5 > docs/man$(2)/man5/index.inc
77         ./bin/mk-apropos docs/man$(2)/man7 > docs/man$(2)/man7/index.inc
78         ./bin/from-tt -d docs/man$(2)/man1 releases='$(SERIES)' release='$(2)' \
79                       < docs/sub-man1-index.html.tt > docs/man$(2)/man1/index.html
80         ./bin/from-tt -d docs/man$(2)/man1 releases='$(SERIES)' release='$(2)' \
81                       < docs/sub-man3-index.html.tt > docs/man$(2)/man3/index.html
82         ./bin/from-tt -d docs/man$(2)/man1 releases='$(SERIES)' release='$(2)' \
83                       < docs/sub-man5-index.html.tt > docs/man$(2)/man5/index.html
84         ./bin/from-tt -d docs/man$(2)/man1 releases='$(SERIES)' release='$(2)' \
85                       < docs/sub-man7-index.html.tt > docs/man$(2)/man7/index.html
86         ./bin/from-tt -d docs/man$(2) releases='$(SERIES)' release='$(2)' \
87                       < docs/sub-index.html.tt > docs/man$(2)/index.html
88 endef
89 # $(1) = release version
90 define makeoldmanmap
91 manmap-$(1):
92         ./bin/mk-manmap docs/man$(1) > docs/man$(1)/.htaccess
93 endef
94
95 $(eval $(call makemanpages,openssl,master))
96 $(foreach S,$(SERIES),$(eval $(call makemanpages,openssl-$(S)-stable,$(S))))
97 $(foreach S,$(OLDMANSERIES),$(eval $(call makeoldmanmap,$(S))))
98
99 manmaster: manpages-master
100 manpages: $(foreach S,$(NEWMANSERIES),manpages-$(S)) \
101           $(foreach S,$(OLDMANSERIES),manpages-$(S) manmap-$(S))
102
103 mancross:
104         ./bin/mk-mancross master $(SERIES)
105
106 docs/manpages.html: docs/manpages.html.tt
107         @rm -f $@
108         ./bin/from-tt releases='master $(SERIES)' docs/manpages.html.tt
109
110 ## $(SIMPLE) -- SIMPLE GENERATED FILES
111 .PHONY: sitemap community/committers.inc community/omc.inc community/omc-alumni.inc
112 newsflash.inc: news/newsflash.inc
113         @rm -f $@
114         head -7 $? >$@
115 sitemap sitemap.txt:
116         @rm -f sitemap.txt
117         ./bin/mk-sitemap master $(SERIES) > sitemap.txt
118
119 community/committers.inc:
120         @rm -f $@
121         wget -q https://api.openssl.org/0/Group/commit/Members
122         ./bin/mk-committers <Members >$@
123         @rm -f Members
124
125 community/omc.inc:
126         ./bin/mk-omc -n -e -l -p -t 'OMC Members' omc omc-inactive > $@
127 community/omc-alumni.inc:
128         ./bin/mk-omc -n -l -t 'OMC Alumni' omc-alumni omc-emeritus > $@
129
130 docs/faq.inc: $(wildcard docs/faq-[0-9]-*.txt) bin/mk-faq
131         @rm -f $@
132         ./bin/mk-faq docs/faq-[0-9]-*txt >$@
133 docs/fips.inc: $(wildcard docs/fips/*) bin/mk-filelist
134         @rm -f $@
135         ./bin/mk-filelist docs/fips fips/ '*' >$@
136
137 news/changelog.inc: news/changelog.txt bin/mk-changelog
138         @rm -f $@
139         ./bin/mk-changelog <news/changelog.txt >$@
140 news/changelog.html: news/changelog.html.tt news/changelog.inc
141         @rm -f $@
142         ./bin/from-tt 'releases=$(SERIES)' $<
143 news/changelog.html: $(foreach S,$(SERIES),news/cl$(subst .,,$(S)).txt)
144
145 # $(1) = output file, $(2) = source directory in CHECKOUTS
146 define mknews_changelogtxt
147 news/$(1): $(CHECKOUTS)/$(2)/CHANGES
148         @rm -f $$@
149         cp $$? $$@
150 endef
151 $(eval $(call mknews_changelogtxt,changelog.txt,openssl))
152 $(foreach S,$(SERIES),\
153 $(eval $(call mknews_changelogtxt,cl$(subst .,,$(S)).txt,openssl-$(S)-stable)))
154
155 # $(1) = release version
156 define mknews_noteshtml
157 news/openssl-$(1)-notes.html: news/openssl-notes.html.in
158         @rm -f $$@
159         sed -e 's|@VERSION@|$(1)|g' < $$< > $$@
160 news/openssl-$(1)-notes.inc: $(CHECKOUTS)/openssl-$(1)-stable/NEWS bin/mk-notes
161         @rm -f $$@
162         ./bin/mk-notes $(1) < $(CHECKOUTS)/openssl-$(1)-stable/NEWS > $$@
163 endef
164 $(foreach S,$(SERIES),$(eval $(call mknews_noteshtml,$(S))))
165
166 news/newsflash.inc: news/newsflash.txt
167         sed <$? >$@ \
168             -e '/^#/d' \
169             -e 's@^@<tr><td class="d">@' \
170             -e 's@: @</td><td class="t">@' \
171             -e 's@$$@</td></tr>@'
172
173 # $(1) = output file mod, $(2) = release version switch, $(3) = release version
174 define mknews_vulnerability
175 news/vulnerabilities$(1).inc: bin/mk-cvepage news/vulnerabilities.xml
176         @rm -f $$@
177         ./bin/mk-cvepage -i news/vulnerabilities.xml $(2) > $$@
178 news/vulnerabilities$(1).html: news/vulnerabilities.html.tt bin/from-tt
179         @rm -f $$@
180         ./bin/from-tt -d news vulnerabilitiesinc='vulnerabilities$(1).inc' < $$< > $$@
181 endef
182 $(eval $(call mknews_vulnerability,,))
183 $(foreach S,$(SERIES) $(OLDSERIES),$(eval $(call mknews_vulnerability,-$(S),-b $(S))))
184
185 source/.htaccess: $(wildcard source/openssl-*.tar.gz) bin/mk-latest
186         @rm -f @?
187         ./bin/mk-latest source >$@
188 source/index.inc: $(wildcard $(RELEASEDIR)/openssl-*.tar.gz) bin/mk-filelist
189         @rm -f $@
190         ./bin/mk-filelist $(RELEASEDIR) '' 'openssl-*.tar.gz' >$@
191
192 ## $(SRCLISTS) -- LISTS OF SOURCES
193 # $(1) = release, $(2) = release title
194 define mkoldsourceindex
195 source/old/$(1)/index.inc: $(wildcard $(RELEASEDIR)/old/$(1)/*.gz) bin/mk-filelist
196         @rm -f $$@
197         ./bin/mk-filelist $(RELEASEDIR)/old/$(1) '' '*.gz' > $$@
198 source/old/$(1)/index.html: source/old/sub-index.html.tt bin/from-tt
199         @rm -f $$@
200         ./bin/from-tt -d source/old/$(1) \
201                       release='$(1)' releasetitle='Old $(2) Releases' \
202                       < $$< > $$@
203 endef
204 $(foreach S,fips $(SERIES) $(OLDSERIES2),$(eval $(call mkoldsourceindex,$(S),$(patsubst fips,FIPS,$(S)))))
205 source/old/index.html: source/old/index.html.tt bin/from-tt
206         @rm -f $@
207         ./bin/from-tt releases='fips $(SERIES) $(OLDSERIES2)' $<
208
209 # Because these the indexes of old tarballs will inevitably be newer
210 # than the tarballs that are moved into their respective directory,
211 # we must declare them phony, or they will not be regenerated when
212 # they should.
213 .PHONY : $(SRCLISTS)