[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

use of "=" or ":=" operators defining variables in Makefiles (expanding SUBLANG)



Dear all

I'm having a look at different Makefiles of the Debian website, to see
how the Chinese variants are being taken into account to generate
several pages.

I've seen a common pattern: if SUBLANG is not defined, the target is
usually file.$(LANGUAGE).html (e.g. index.es.html), but if SUBLANG is
defined, we need to expand the SUBLANG variable and then we'll have
multiple targets to be built with the corresponding rule (e.g.
index.zh-cn.html index.zh-tw.html index.zh-hk.html).

My question is about the lines defining the variable that will contain
the target(s): in some Makefiles the "=" operator is used, and in
others, the operator ":=" is used.

Specifically, see the exact lines (I grepped SUBLANG and removed the not
relevant lines from the output):

english/security/Makefile:22:DSARDF     := $(sort $(foreach
i,$(SUBLANG),$(subst dsa,dsa.$(LANGUAGE)-$(i),dsa.rdf)))
english/security/Makefile:23:DSALONGRDF := $(sort $(foreach
i,$(SUBLANG),$(subst dsa-long,dsa-long.$(LANGUAGE)-$(i),dsa-long.rdf)))
english/security/Makefile:24:DSAALLRDF := $(sort $(foreach
i,$(SUBLANG),$(subst dsa-all,dsa-all.$(LANGUAGE)-$(i),dsa-all.rdf)))
english/News/weekly/Makefile:27:  HTMLFILES := $(foreach i, $(SUBLANG), \
english/News/weekly/Makefile:29:  HTMLDESTFILES := $(foreach i,
$(SUBLANG), \
english/News/Makefile:22:NEWSRDF     := $(sort $(foreach
i,$(SUBLANG),$(subst news,news.$(LANGUAGE)-$(i),news.rdf)))
english/devel/website/stats/Makefile:20:STATS = $(sort $(foreach
i,$(SUBLANG),\
english/Makefile:24:SITEMAP = $(sort $(foreach i,$(SUBLANG),\
english/Makefile:27:SEARCHXML = $(sort $(foreach i,$(SUBLANG),$(subst
search,search.$(LANGUAGE)-$(i),search.xml)))
chinese/Make.lang:5:SUBLANG := cn hk tw
Makefile.common:47:HTMLFILES = $(sort $(foreach i,$(SUBLANG),\
Makefile.common:49:HTMLDESTFILES = $(sort $(foreach i,$(SUBLANG),\

For what I've read in
https://www.gnu.org/software/make/manual/make.html#Flavors and
https://www.gnu.org/software/make/manual/make.html#Using-Variables
(thanks friends for the pointers), I *think* that ":=" should be used
everywhere for these SUBLANG expansions, but I don't know if, for
example, would penalize in performance.

In any case, I'd like to know if there is a particular reason for
declaring these SUBLANG-affected targets differently (using different
operator) in different places in the website.

Best regards

-- 
Laura Arjona Reina
https://wiki.debian.org/LauraArjona



Reply to: