aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile.common
blob: d0bab02710e11e73a4e64fe37fd8f7c4e8e599fc (plain) (blame)
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# Nothing in here should require any modification. If you feel you need to
# modify something first send mail to debian-www explaining why.

CUR_YEAR := $(shell date +%Y)

# Turn this on to stop ignoring errors in various places
STRICT_ERROR_CHECKS = 0
ifeq ($(STRICT_ERROR_CHECKS), 0)
IGNORE = -
else
IGNORE =
endif

# Turn this on to use (small) sample files for data that generated from
# cronjobs on the official website.
USE_SAMPLE_FILES := 0

ENGLISHSRCDIR := $(WMLBASE)/../english
ENGLISHDIR := $(ENGLISHSRCDIR)
# ^ just an alias ^

TEMPLDIR := $(ENGLISHDIR)/template/debian
RELHTMLBASE := ../../www
HTMLDIR = $(WMLBASE)/$(RELHTMLBASE)/$(CUR_DIR)
VCSREVCACHE = $(WMLBASE)/../.git-revs-cache.db

LOCALEDIR := $(WMLBASE)/../locale/$(LANGUAGE)/LC_MESSAGES
essential-locale-files := templates countries langs date
ifeq "$(LANGUAGE)" "en"
locale = $(addsuffix .pot, $(addprefix $(ENGLISHDIR)/po/, $(1)))
$(ENGLISHDIR)/po/%.pot:
	touch $@ # because of $(?F)
else
locale = $(addsuffix .mo, $(addprefix $(LOCALEDIR)/, $(1)))
$(LOCALEDIR)/%.mo:
	touch $@ # because of $(?F)
endif
GETTEXTDEP := $(call locale, $(essential-locale-files) )

ifneq "$(LANGUAGE)" "en"
ifneq "$(GETTEXTFILES)" ""
GETTEXTDEP += $(addprefix $(LOCALEDIR)/,$(GETTEXTFILES))
endif
endif

WMLRCDEP := $(WMLBASE)/../.wmlrc $(WMLBASE)/.wmlrc

LANGUAGECAP = $(shell echo $(LANGUAGE) | tr "a-z" "A-Z")
WMLOPTIONS := -q -D CUR_YEAR=$(CUR_YEAR)
WMLOUTFILE = $(@F)
WMLPROLOG :=
WMLEPILOG :=
WML = wml $(WMLOPTIONS) -o UNDEFu$(LANGUAGECAP):$(WMLOUTFILE)@g+w $(WMLPROLOG) $(WMLEPILOG)

WMLFILES = $(sort $(wildcard *.wml))
ifndef SUBLANG
HTMLFILES = $(patsubst %.wml,%.$(LANGUAGE).html,$(WMLFILES))
HTMLDESTFILES = $(patsubst %.wml,$(HTMLDIR)/%.$(LANGUAGE).html,$(WMLFILES))
else
HTMLFILES = $(sort $(foreach i,$(SUBLANG),\
	$(patsubst %.wml,%.$(LANGUAGE)-$(i).html,$(WMLFILES))))
HTMLDESTFILES = $(sort $(foreach i,$(SUBLANG),\
	$(patsubst %.wml,$(HTMLDIR)/%.$(LANGUAGE)-$(i).html,$(WMLFILES))))
endif

OTHERFILES := $(sort $(wildcard *.ps.gz *.eps *.pdf *.css))
OTHERFILES += $(sort $(wildcard *.jpg *.jpeg *.gif *.png *.fig *.xcf *.xcf.gz *.ppm *.svg *.eot *.ttf *.woff *.woff2))
OTHERDESTFILES := $(patsubst %,$(HTMLDIR)/%,$(OTHERFILES))

existing-SUBS := $(shell for dir in $(sort $(wildcard $(SUBS))) ''; do test -d $$dir && echo $$dir; done)
existing-SUBS-install := $(addsuffix -install,$(existing-SUBS))
existing-SUBS-clean := $(addsuffix -clean,$(existing-SUBS))
existing-SUBS-cleandest := $(addsuffix -cleandest,$(existing-SUBS))

# rules
all:: $(HTMLFILES) $(existing-SUBS)

$(existing-SUBS):
	$(IGNORE)$(MAKE) -C $@

install:: $(HTMLDESTFILES) $(OTHERDESTFILES) $(existing-SUBS-install)

$(existing-SUBS-install):
	$(IGNORE)$(MAKE) -C $(patsubst %-install,%,$@) install

clean::
	rm -f *.$(LANGUAGE).html *~ *.forced
ifeq "$(LANGUAGE)" "en"
	rm -f *.en-us.html *.en-gb.html
endif
clean:: $(existing-SUBS-clean)

$(existing-SUBS-clean):
	$(IGNORE)$(MAKE) -C $(patsubst %-clean,%,$@) clean

cleandest::
	rm -f $(HTMLDIR)/*.$(LANGUAGE).html
ifeq "$(LANGUAGE)" "en"
	rm -f $(HTMLDIR)/*.en-us.html $(HTMLDIR)/*.en-gb.html
endif
cleandest:: $(existing-SUBS-cleandest)

$(existing-SUBS-cleandest):
	$(IGNORE)$(MAKE) -C $(patsubst %-cleandest,%,$@) cleandest

$(VCSREVCACHE): $(WMLBASE)/../.git/index
	(cd $(WMLBASE)/.. && ./build_vcs_cache.pl)

# the rule for every wml file
ifndef NOGENERICDEP

ifeq "$(LANGUAGE)" "en"
     EXTRAWMLDEP := $(WMLRCDEP) $(GETTEXTDEP) $(TEMPLDIR)/template.wml $(TEMPLDIR)/languages.wml
else
     EXTRAWMLDEP := $(WMLRCDEP) $(GETTEXTDEP) $(TEMPLDIR)/template.wml $(TEMPLDIR)/languages.wml $(TEMPLDIR)/translation-check.wml
endif

# The "| $(VCSREVCACHE)" here is an order-only prerequisite - always
# check that the prerequisite exists and is up to date, but don't
# rebuild everything whenever it's updated - see
# https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html
%.$(LANGUAGE).html : %.wml $(EXTRAWMLDEP) | $(VCSREVCACHE)
	$(WML) $(<F)
ifeq "$(LANGUAGE)" "en"
	$(IGNORE)$(WMLBASE)/../touch_translations.pl $(CURDIR)/$(<F) $(LANGUAGE)
else
ifneq "$(findstring international,$(CUR_DIR))" ""
	$(IGNORE)$(WMLBASE)/../touch_translations.pl $(CURDIR)/$(<F) $(LANGUAGE)
endif
endif

endif

ifndef NOGENERICINSTDEP
$(HTMLDIR)/%.$(LANGUAGE).html: %.$(LANGUAGE).html
	@test -d $(HTMLDIR) || mkdir -m g+w -p $(HTMLDIR)
	@echo copying $(@F) to $(HTMLDIR)
	$(IGNORE)@install -m 664 -p $(@F) $(HTMLDIR)
ifeq "$(LANGUAGE)" "nb"
	@echo making a link $(@D)/$(*F).no.html -\> $(@F)
	@ln -sf $(@F) $(@D)/$(*F).no.html
endif
ifeq "$(LANGUAGE)" "en"
	@echo making a link $(@D)/$(*F).html -\> $(@F)
	@ln -sf $(@F) $(@D)/$(*F).html
endif
endif

LOCALEDESTFILES := $(patsubst $(ENGLISHDIR)/po/%.pot,$(LOCALEDIR)/%.mo,$(sort $(wildcard $(ENGLISHDIR)/po/*.pot)))

ifneq "$(LANGUAGE)" "en"
#    Ensure that MO files do exist
#    Translators have to run make under webwml/<lang>/po if they
#    want it updated, it cannot be automatically performed.
$(LOCALEDESTFILES): $(LOCALEDIR)/%.mo: $(WMLBASE)/po/%.$(LANGUAGE).po
	$(MAKE) -C $(WMLBASE)/po install-$*.mo
else
# English doesn't generate those .mo files, so just fake them
$(LOCALEDESTFILES): $(LOCALEDIR)/%.mo: $(ENGLISHDIR)/po/%.pot
endif

$(OTHERDESTFILES): $(HTMLDIR)/%: %
	@test -d $(HTMLDIR) || mkdir -m g+w -p $(HTMLDIR)
	install -m 664 -p $< $(HTMLDIR)
ifeq "$(LANGUAGE)" "en"
# probably doesn't work for *.gz files, FIXME
	[ -f "$(HTMLDIR)/$(basename $(basename $<))$(suffix $<)" ] || ln -s $< $(HTMLDIR)/$(basename $(basename $<))$(suffix $<)
endif

# template dependencies
$(TEMPLDIR)/%.wml:
ifeq "$(LANGUAGE)" "en"
	touch $@ # because of $(?F)
else
	@if [ "$(findstring .mo,$(?F))" = "" ]; then \
	  touch $@; echo "touch $@ # because of $(?F)"; \
	fi
endif

gendep:
	@for f in $(TEMPLDIR)/*.wml \
		  $(TEMPLDIR)/weeklynews/*.wml \
		  $(TEMPLDIR)/projectnews/*.wml; \
	do \
	  grep -q '^#use wml::debian' $$f || continue; \
	  ../gendep.pl "$$f" |\
	    sed -e 's,X$(TEMPLDIR),X\$$(TEMPLDIR),' |\
	    fold -b -s -w 70 |\
	    sed -e 's/^\$$/  \$$/' -e 's/^X//' -e 's/callX/call /g' -e '$$!s/$$/\\/'; \
	done

#  this dependency cannot be automatically computed
$(TEMPLDIR)/basic.wml: $(TEMPLDIR)/navbar.wml

#  dependencies below are generated by gendep and manually checked
$(TEMPLDIR)/basic.wml: $(TEMPLDIR)/common_translation.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/language_names.wml \
  $(TEMPLDIR)/footer.wml
$(TEMPLDIR)/blend.wml: $(TEMPLDIR)/template.wml
$(TEMPLDIR)/cdimage.wml: $(TEMPLDIR)/common_translation.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/languages.wml \
  $(TEMPLDIR)/links.tags.wml $(TEMPLDIR)/basic.wml \
  $(call locale,cdimage)
$(TEMPLDIR)/common_translation.wml: $(TEMPLDIR)/common_tags.wml
$(TEMPLDIR)/consultant.wml: $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/basic.wml $(TEMPLDIR)/languages.wml \
  $(call locale,consultants)
$(TEMPLDIR)/countries.wml: $(TEMPLDIR)/common_tags.wml \
  $(call locale,countries)
$(TEMPLDIR)/ctime.wml: $(TEMPLDIR)/common_tags.wml \
  $(call locale,date)
$(TEMPLDIR)/ddp.wml: $(TEMPLDIR)/basic.wml \
  $(TEMPLDIR)/common_translation.wml $(TEMPLDIR)/languages.wml
$(TEMPLDIR)/event.wml: $(TEMPLDIR)/events_common.wml \
  $(TEMPLDIR)/basic.wml $(TEMPLDIR)/languages.wml
$(TEMPLDIR)/events_common.wml: $(TEMPLDIR)/common_translation.wml \
  $(call locale,newsevents)
$(TEMPLDIR)/fixes_link.wml: $(TEMPLDIR)/common_tags.wml
$(TEMPLDIR)/footer.wml: $(TEMPLDIR)/ctime.wml \
  $(TEMPLDIR)/links.tags.wml $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/release_info.wml
$(TEMPLDIR)/installer.wml: $(TEMPLDIR)/release_info.wml
$(TEMPLDIR)/language_names.wml: $(TEMPLDIR)/common_tags.wml \
  $(call locale,langs)
$(TEMPLDIR)/languages.wml: $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/language_names.wml $(TEMPLDIR)/countries.wml
$(TEMPLDIR)/legal.wml: $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/common_translation.wml $(TEMPLDIR)/languages.wml \
  $(TEMPLDIR)/ctime.wml $(TEMPLDIR)/submenu.wml \
  $(TEMPLDIR)/legal_tags.wml $(TEMPLDIR)/basic.wml $(call locale,legal)
$(TEMPLDIR)/legal_lists.wml: $(TEMPLDIR)/ctime.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/legal_tags.wml
$(TEMPLDIR)/legal_tags.wml: $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/common_translation.wml $(call locale,legal)
$(TEMPLDIR)/links.tags.wml: $(TEMPLDIR)/common_tags.wml
$(TEMPLDIR)/mainpage.wml: $(TEMPLDIR)/common_translation.wml \
  $(TEMPLDIR)/basic.wml $(TEMPLDIR)/links.tags.wml \
  $(TEMPLDIR)/languages.wml $(TEMPLDIR)/release_info.wml
$(TEMPLDIR)/navbar.wml: $(TEMPLDIR)/common_translation.wml \
  $(TEMPLDIR)/events_common.wml $(TEMPLDIR)/links.tags.wml \
  $(TEMPLDIR)/stats_tags.wml $(TEMPLDIR)/common_tags.wml
$(TEMPLDIR)/news.wml: $(TEMPLDIR)/common_translation.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/languages.wml \
  $(TEMPLDIR)/ctime.wml $(TEMPLDIR)/basic.wml $(call locale,newsevents)
$(TEMPLDIR)/past_event.wml: $(TEMPLDIR)/events_common.wml \
  $(TEMPLDIR)/basic.wml $(TEMPLDIR)/languages.wml
$(TEMPLDIR)/profiles.wml: $(TEMPLDIR)/common_translation.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/languages.wml \
  $(TEMPLDIR)/faqs.wml $(TEMPLDIR)/basic.wml
$(TEMPLDIR)/recent_list.wml: $(TEMPLDIR)/ctime.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/legal_tags.wml
$(TEMPLDIR)/recent_list_security.wml: $(TEMPLDIR)/ctime.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/recent_list_common.wml
$(TEMPLDIR)/release_images.wml: $(TEMPLDIR)/installer.wml \
  $(TEMPLDIR)/release_info.wml
$(TEMPLDIR)/release_info.wml: $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/ctime.wml
$(TEMPLDIR)/release.wml: $(TEMPLDIR)/languages.wml
$(TEMPLDIR)/security.wml: $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/common_translation.wml $(TEMPLDIR)/fixes_link.wml \
  $(TEMPLDIR)/languages.wml $(TEMPLDIR)/ctime.wml \
  $(TEMPLDIR)/securityreferences.wml $(TEMPLDIR)/basic.wml \
  $(call locale,security)
$(TEMPLDIR)/stats_tags.wml: $(TEMPLDIR)/common_tags.wml \
  $(call locale,stats)
$(TEMPLDIR)/template.wml: $(TEMPLDIR)/basic.wml \
  $(TEMPLDIR)/languages.wml
$(TEMPLDIR)/translation-check.wml: $(TEMPLDIR)/languages.wml \
  $(TEMPLDIR)/common_tags.wml
$(TEMPLDIR)/url.wml: $(TEMPLDIR)/common_tags.wml
$(TEMPLDIR)/users.wml: $(TEMPLDIR)/common_translation.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/languages.wml \
  $(TEMPLDIR)/basic.wml
$(TEMPLDIR)/users_list.wml: $(TEMPLDIR)/common_tags.wml
$(TEMPLDIR)/votebar.wml: $(TEMPLDIR)/languages.wml \
  $(TEMPLDIR)/common_tags.wml $(call locale,vote)
$(TEMPLDIR)/wnpp.wml: $(TEMPLDIR)/common_tags.wml $(call locale,wnpp)
$(TEMPLDIR)/weeklynews/footer.wml: $(TEMPLDIR)/common_tags.wml \
  $(call locale,newsevents)
$(TEMPLDIR)/weeklynews/header.wml: $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/ctime.wml $(TEMPLDIR)/links.tags.wml \
  $(TEMPLDIR)/template.wml
$(TEMPLDIR)/projectnews/boilerplates.wml: \
  $(TEMPLDIR)/common_tags.wml $(call locale,newsevents)
$(TEMPLDIR)/projectnews/footer.wml: $(TEMPLDIR)/common_tags.wml \
  $(call locale,newsevents)
$(TEMPLDIR)/projectnews/header.wml: $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/ctime.wml $(TEMPLDIR)/links.tags.wml $(TEMPLDIR)/toc.wml \
  $(TEMPLDIR)/projectnews/boilerplates.wml $(TEMPLDIR)/template.wml

$(TEMPLDIR)/navbar.wml: $(ENGLISHSRCDIR)/logos/openlogo-nd-50.png

.SUFFIXES: 
.PHONY: all $(existing-SUBS) install $(existing-SUBS-install)
.PHONY: clean $(existing-SUBS-clean) cleandest $(existing-SUBS-cleandest)

© 2014-2024 Faster IT GmbH | imprint | privacy policy