Makefile.common 11.3 KB
Newer Older
Josip Rodin's avatar
Josip Rodin committed
1 2 3
# Nothing in here should require any modification. If you feel you need to
# modify something first send mail to debian-www explaining why.

4 5
CUR_YEAR := $(shell date +%Y)

6
# Turn this on to stop ignoring errors in various places
7
STRICT_ERROR_CHECKS = 0
8 9 10 11 12 13
ifeq ($(STRICT_ERROR_CHECKS), 0)
IGNORE = -
else
IGNORE =
endif

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

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

22
TEMPLDIR := $(ENGLISHDIR)/template/debian
23
RELHTMLBASE := ../../www
Josip Rodin's avatar
Josip Rodin committed
24
HTMLDIR = $(WMLBASE)/$(RELHTMLBASE)/$(CUR_DIR)
25
VCSREVCACHE = $(WMLBASE)/../.git-revs-cache.db
Josip Rodin's avatar
Josip Rodin committed
26

27
LOCALEDIR := $(WMLBASE)/../locale/$(LANGUAGE)/LC_MESSAGES
28 29 30 31 32 33 34 35 36 37 38 39
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) )

40
ifneq "$(LANGUAGE)" "en"
41 42 43
ifneq "$(GETTEXTFILES)" ""
GETTEXTDEP += $(addprefix $(LOCALEDIR)/,$(GETTEXTFILES))
endif
44 45
endif

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

Josip Rodin's avatar
Josip Rodin committed
48
LANGUAGECAP = $(shell echo $(LANGUAGE) | tr "a-z" "A-Z")
49
WMLOPTIONS := -q -D CUR_YEAR=$(CUR_YEAR)
Josip Rodin's avatar
Josip Rodin committed
50 51 52 53 54
WMLOUTFILE = $(@F)
WMLPROLOG :=
WMLEPILOG :=
WML = wml $(WMLOPTIONS) -o UNDEFu$(LANGUAGECAP):$(WMLOUTFILE)@g+w $(WMLPROLOG) $(WMLEPILOG)

55
WMLFILES = $(sort $(wildcard *.wml))
56
ifndef SUBLANG
Josip Rodin's avatar
Josip Rodin committed
57 58
HTMLFILES = $(patsubst %.wml,%.$(LANGUAGE).html,$(WMLFILES))
HTMLDESTFILES = $(patsubst %.wml,$(HTMLDIR)/%.$(LANGUAGE).html,$(WMLFILES))
59
else
60 61 62 63 64
HTMLFILES = $(sort $(foreach i,$(SUBLANG),\
	$(patsubst %.wml,%.$(LANGUAGE)-$(i).html,$(WMLFILES))))
HTMLDESTFILES = $(sort $(foreach i,$(SUBLANG),\
	$(patsubst %.wml,$(HTMLDIR)/%.$(LANGUAGE)-$(i).html,$(WMLFILES))))
endif
65

66 67
OTHERFILES := $(sort $(wildcard *.ps.gz *.eps *.pdf *.css))
OTHERFILES += $(sort $(wildcard *.jpg *.jpeg *.gif *.png *.fig *.xcf *.xcf.gz *.ppm *.svg))
68
OTHERDESTFILES := $(patsubst %,$(HTMLDIR)/%,$(OTHERFILES))
Josip Rodin's avatar
Josip Rodin committed
69

70
existing-SUBS := $(shell for dir in $(sort $(wildcard $(SUBS))) ''; do test -d $$dir && echo $$dir; done)
71 72 73
existing-SUBS-install := $(addsuffix -install,$(existing-SUBS))
existing-SUBS-clean := $(addsuffix -clean,$(existing-SUBS))
existing-SUBS-cleandest := $(addsuffix -cleandest,$(existing-SUBS))
Josip Rodin's avatar
Josip Rodin committed
74

75
# rules
Josip Rodin's avatar
Josip Rodin committed
76 77 78
all:: $(HTMLFILES) $(existing-SUBS)

$(existing-SUBS):
79
	$(IGNORE)$(MAKE) -C $@
Josip Rodin's avatar
Josip Rodin committed
80

81
install:: $(HTMLDESTFILES) $(OTHERDESTFILES) $(existing-SUBS-install)
Josip Rodin's avatar
Josip Rodin committed
82 83

$(existing-SUBS-install):
84
	$(IGNORE)$(MAKE) -C $(patsubst %-install,%,$@) install
Josip Rodin's avatar
Josip Rodin committed
85 86

clean::
Josip Rodin's avatar
Josip Rodin committed
87
	rm -f *.$(LANGUAGE).html *~ *.forced
88 89 90
ifeq "$(LANGUAGE)" "en"
	rm -f *.en-us.html *.en-gb.html
endif
Josip Rodin's avatar
Josip Rodin committed
91 92 93
clean:: $(existing-SUBS-clean)

$(existing-SUBS-clean):
94
	$(IGNORE)$(MAKE) -C $(patsubst %-clean,%,$@) clean
Josip Rodin's avatar
Josip Rodin committed
95 96 97

cleandest::
	rm -f $(HTMLDIR)/*.$(LANGUAGE).html
98 99 100
ifeq "$(LANGUAGE)" "en"
	rm -f $(HTMLDIR)/*.en-us.html $(HTMLDIR)/*.en-gb.html
endif
Josip Rodin's avatar
Josip Rodin committed
101 102 103
cleandest:: $(existing-SUBS-cleandest)

$(existing-SUBS-cleandest):
104
	$(IGNORE)$(MAKE) -C $(patsubst %-cleandest,%,$@) cleandest
Josip Rodin's avatar
Josip Rodin committed
105

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

Josip Rodin's avatar
Josip Rodin committed
109
# the rule for every wml file
110
ifndef NOGENERICDEP
111

112 113 114 115 116 117
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

118 119 120 121 122
# 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)
Josip Rodin's avatar
Josip Rodin committed
123
	$(WML) $(<F)
124
ifeq "$(LANGUAGE)" "en"
125
	$(IGNORE)$(WMLBASE)/../touch_translations.pl $(CURDIR)/$(<F) $(LANGUAGE)
126 127
else
ifneq "$(findstring international,$(CUR_DIR))" ""
128
	$(IGNORE)$(WMLBASE)/../touch_translations.pl $(CURDIR)/$(<F) $(LANGUAGE)
129
endif
130
endif
Josip Rodin's avatar
Josip Rodin committed
131

132 133
endif

134
ifndef NOGENERICINSTDEP
135 136
$(HTMLDIR)/%.$(LANGUAGE).html: %.$(LANGUAGE).html
	@test -d $(HTMLDIR) || mkdir -m g+w -p $(HTMLDIR)
Josip Rodin's avatar
Josip Rodin committed
137
	@echo copying $(@F) to $(HTMLDIR)
138
	$(IGNORE)@install -m 664 -p $(@F) $(HTMLDIR)
139 140 141
ifeq "$(LANGUAGE)" "nb"
	@echo making a link $(@D)/$(*F).no.html -\> $(@F)
	@ln -sf $(@F) $(@D)/$(*F).no.html
142
endif
143
ifeq "$(LANGUAGE)" "en"
Josip Rodin's avatar
Josip Rodin committed
144
	@echo making a link $(@D)/$(*F).html -\> $(@F)
145
	@ln -sf $(@F) $(@D)/$(*F).html
Josip Rodin's avatar
Josip Rodin committed
146
endif
147
endif
Josip Rodin's avatar
Josip Rodin committed
148

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

ifneq "$(LANGUAGE)" "en"
152 153 154
#    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.
155 156 157 158 159 160
$(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
161

162
$(OTHERDESTFILES): $(HTMLDIR)/%: %
163
	@test -d $(HTMLDIR) || mkdir -m g+w -p $(HTMLDIR)
164
	install -m 664 -p $< $(HTMLDIR)
165
ifeq "$(LANGUAGE)" "en"
166
# probably doesn't work for *.gz files, FIXME
167
	[ -f "$(HTMLDIR)/$(basename $(basename $<))$(suffix $<)" ] || ln -s $< $(HTMLDIR)/$(basename $(basename $<))$(suffix $<)
168
endif
Josip Rodin's avatar
Josip Rodin committed
169 170

# template dependencies
171
$(TEMPLDIR)/%.wml:
172 173 174 175 176 177 178
ifeq "$(LANGUAGE)" "en"
	touch $@ # because of $(?F)
else
	@if [ "$(findstring .mo,$(?F))" = "" ]; then \
	  touch $@; echo "touch $@ # because of $(?F)"; \
	fi
endif
Josip Rodin's avatar
Josip Rodin committed
179

180
gendep:
181 182 183 184
	@for f in $(TEMPLDIR)/*.wml \
		  $(TEMPLDIR)/weeklynews/*.wml \
		  $(TEMPLDIR)/projectnews/*.wml; \
	do \
185
	  grep -q '^#use wml::debian' $$f || continue; \
186 187
	  ../gendep.pl "$$f" |\
	    sed -e 's,X$(TEMPLDIR),X\$$(TEMPLDIR),' |\
188
	    fold -b -s -w 70 |\
189
	    sed -e 's/^\$$/  \$$/' -e 's/^X//' -e 's/callX/call /g' -e '$$!s/$$/\\/'; \
190 191 192 193 194 195
	done

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

#  dependencies below are generated by gendep and manually checked
196
$(TEMPLDIR)/basic.wml: $(TEMPLDIR)/common_translation.wml \
197 198 199
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/language_names.wml \
  $(TEMPLDIR)/footer.wml
$(TEMPLDIR)/blend.wml: $(TEMPLDIR)/template.wml
200 201
$(TEMPLDIR)/cdimage.wml: $(TEMPLDIR)/common_translation.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/languages.wml \
202 203
  $(TEMPLDIR)/links.tags.wml $(TEMPLDIR)/basic.wml \
  $(call locale,cdimage)
204 205
$(TEMPLDIR)/common_translation.wml: $(TEMPLDIR)/common_tags.wml
$(TEMPLDIR)/consultant.wml: $(TEMPLDIR)/common_tags.wml \
206 207
  $(TEMPLDIR)/basic.wml $(TEMPLDIR)/languages.wml \
  $(call locale,consultants)
208
$(TEMPLDIR)/countries.wml: $(TEMPLDIR)/common_tags.wml \
209
  $(call locale,countries)
210
$(TEMPLDIR)/ctime.wml: $(TEMPLDIR)/common_tags.wml \
211
  $(call locale,date)
212 213 214 215
$(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
216
$(TEMPLDIR)/events_common.wml: $(TEMPLDIR)/common_translation.wml \
217
  $(call locale,newsevents)
218
$(TEMPLDIR)/fixes_link.wml: $(TEMPLDIR)/common_tags.wml
219
$(TEMPLDIR)/footer.wml: $(TEMPLDIR)/ctime.wml \
220 221 222
  $(TEMPLDIR)/links.tags.wml $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/release_info.wml
$(TEMPLDIR)/installer.wml: $(TEMPLDIR)/release_info.wml
223 224
$(TEMPLDIR)/language_names.wml: $(TEMPLDIR)/common_tags.wml \
  $(call locale,langs)
225
$(TEMPLDIR)/languages.wml: $(TEMPLDIR)/common_tags.wml \
226
  $(TEMPLDIR)/language_names.wml $(TEMPLDIR)/countries.wml
227 228 229
$(TEMPLDIR)/legal.wml: $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/common_translation.wml $(TEMPLDIR)/languages.wml \
  $(TEMPLDIR)/ctime.wml $(TEMPLDIR)/submenu.wml \
230
  $(TEMPLDIR)/legal_tags.wml $(TEMPLDIR)/basic.wml $(call locale,legal)
Frank Lichtenheld's avatar
Frank Lichtenheld committed
231 232 233
$(TEMPLDIR)/legal_lists.wml: $(TEMPLDIR)/ctime.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/legal_tags.wml
$(TEMPLDIR)/legal_tags.wml: $(TEMPLDIR)/common_tags.wml \
234
  $(TEMPLDIR)/common_translation.wml $(call locale,legal)
235 236 237
$(TEMPLDIR)/links.tags.wml: $(TEMPLDIR)/common_tags.wml
$(TEMPLDIR)/mainpage.wml: $(TEMPLDIR)/common_translation.wml \
  $(TEMPLDIR)/basic.wml $(TEMPLDIR)/links.tags.wml \
238
  $(TEMPLDIR)/languages.wml $(TEMPLDIR)/release_info.wml
239
$(TEMPLDIR)/navbar.wml: $(TEMPLDIR)/common_translation.wml \
240 241
  $(TEMPLDIR)/events_common.wml $(TEMPLDIR)/links.tags.wml \
  $(TEMPLDIR)/stats_tags.wml $(TEMPLDIR)/common_tags.wml
242 243
$(TEMPLDIR)/news.wml: $(TEMPLDIR)/common_translation.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/languages.wml \
244
  $(TEMPLDIR)/ctime.wml $(TEMPLDIR)/basic.wml $(call locale,newsevents)
245 246
$(TEMPLDIR)/past_event.wml: $(TEMPLDIR)/events_common.wml \
  $(TEMPLDIR)/basic.wml $(TEMPLDIR)/languages.wml
247 248 249
$(TEMPLDIR)/profiles.wml: $(TEMPLDIR)/common_translation.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/languages.wml \
  $(TEMPLDIR)/faqs.wml $(TEMPLDIR)/basic.wml
Frank Lichtenheld's avatar
Frank Lichtenheld committed
250 251
$(TEMPLDIR)/recent_list.wml: $(TEMPLDIR)/ctime.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/legal_tags.wml
252 253
$(TEMPLDIR)/recent_list_security.wml: $(TEMPLDIR)/ctime.wml \
  $(TEMPLDIR)/common_tags.wml $(TEMPLDIR)/recent_list_common.wml
254
$(TEMPLDIR)/release_images.wml: $(TEMPLDIR)/installer.wml \
255 256 257 258
  $(TEMPLDIR)/release_info.wml
$(TEMPLDIR)/release_info.wml: $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/ctime.wml
$(TEMPLDIR)/release.wml: $(TEMPLDIR)/languages.wml
259 260 261
$(TEMPLDIR)/security.wml: $(TEMPLDIR)/common_tags.wml \
  $(TEMPLDIR)/common_translation.wml $(TEMPLDIR)/fixes_link.wml \
  $(TEMPLDIR)/languages.wml $(TEMPLDIR)/ctime.wml \
262 263
  $(TEMPLDIR)/securityreferences.wml $(TEMPLDIR)/basic.wml \
  $(call locale,security)
264 265
$(TEMPLDIR)/stats_tags.wml: $(TEMPLDIR)/common_tags.wml \
  $(call locale,stats)
266 267 268 269
$(TEMPLDIR)/template.wml: $(TEMPLDIR)/basic.wml \
  $(TEMPLDIR)/languages.wml
$(TEMPLDIR)/translation-check.wml: $(TEMPLDIR)/languages.wml \
  $(TEMPLDIR)/common_tags.wml
270
$(TEMPLDIR)/url.wml: $(TEMPLDIR)/common_tags.wml
271 272 273 274
$(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
275
$(TEMPLDIR)/votebar.wml: $(TEMPLDIR)/languages.wml \
276 277
  $(TEMPLDIR)/common_tags.wml $(call locale,vote)
$(TEMPLDIR)/wnpp.wml: $(TEMPLDIR)/common_tags.wml $(call locale,wnpp)
278 279
$(TEMPLDIR)/weeklynews/footer.wml: $(TEMPLDIR)/common_tags.wml \
  $(call locale,newsevents)
280
$(TEMPLDIR)/weeklynews/header.wml: $(TEMPLDIR)/common_tags.wml \
281 282
  $(TEMPLDIR)/ctime.wml $(TEMPLDIR)/links.tags.wml \
  $(TEMPLDIR)/template.wml
283 284 285 286 287 288 289
$(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
290

David Prévot's avatar
David Prévot committed
291
$(TEMPLDIR)/navbar.wml: $(ENGLISHSRCDIR)/logos/openlogo-nd-50.png
292 293 294 295 296

$(TEMPLDIR)/votebar.wml: $(ENGLISHSRCDIR)/Pics/blue-upperleft.png \
  $(ENGLISHSRCDIR)/Pics/blue-upperright.png \
  $(ENGLISHSRCDIR)/Pics/blue-lowerleft.png \
  $(ENGLISHSRCDIR)/Pics/blue-lowerright.png
Josip Rodin's avatar
Josip Rodin committed
297 298 299 300

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