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