File: rules

package info (click to toggle)
firefox-esr 78.11.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,301,124 kB
  • sloc: cpp: 5,665,672; javascript: 4,798,422; ansic: 2,878,202; python: 976,963; asm: 270,347; xml: 181,456; java: 111,756; sh: 72,930; makefile: 21,819; perl: 13,380; cs: 4,725; yacc: 4,565; objc: 3,026; pascal: 1,787; lex: 1,720; ada: 1,681; exp: 505; php: 436; lisp: 260; awk: 152; ruby: 103; csh: 80; sed: 53; sql: 45
file content (344 lines) | stat: -rwxr-xr-x 13,298 bytes parent folder | download | duplicates (3)
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
#!/usr/bin/make -f
TESTDIR = $(shell dh_testdir || echo no)
ifeq (,$(TESTDIR))
include debian/make.mk
# Use dpkg-buildflags to get build flags, but exclude -g, that is dealt with
# via configure options.
dpkg_buildflags = $(and $(1),$(shell DEB_CFLAGS_MAINT_STRIP="-g" dpkg-buildflags --get $(1)))
$(call lazy,CFLAGS,$$(call dpkg_buildflags,CFLAGS))
$(call lazy,CPPFLAGS,$$(call dpkg_buildflags,CPPFLAGS))
$(call lazy,LDFLAGS,$$(call dpkg_buildflags,LDFLAGS))

$(call lazy,DEB_HOST_GNU_TYPE,$$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE))
$(call lazy,DEB_BUILD_GNU_TYPE,$$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE))
$(call lazy,DEB_BUILD_ARCH_BITS,$$(shell dpkg-architecture -qDEB_BUILD_ARCH_BITS))
$(call lazy,DEB_HOST_ARCH,$$(shell dpkg-architecture -qDEB_HOST_ARCH))

PYTHON := python3 -B

PRODUCT := browser
include debian/upstream.mk

SYSTEM_LIBS = zlib ffi
ifeq (,$(filter stretch buster,$(DIST)))
SYSTEM_LIBS += nspr nss
endif
ifeq (,$(filter stretch,$(DIST)))
SYSTEM_LIBS += libevent
endif
ifeq (,$(filter stretch buster,$(DIST)))
SYSTEM_LIBS += vpx
endif

define system_lib
USE_SYSTEM_$(1) ?= 1
SYSTEM_LIBS_VARS += $$(if $$(USE_SYSTEM_$(1)),USE_SYSTEM_$(1))
endef
$(foreach lib,$(sort $(call uc,$(SYSTEM_LIBS))),$(eval $(call system_lib,$(lib))))

OFFICIAL_BRANDING := browser/branding/official
MOZILLA_OFFICIAL := 1
# ESR, Beta and Releases use the official branding
ifneq (,$(filter release beta esr%,$(SHORT_SOURCE_CHANNEL)))
BRANDING ?= $(OFFICIAL_BRANDING)
else
ifneq (,$(filter aurora,$(SHORT_SOURCE_CHANNEL)))
BRANDING ?= browser/branding/aurora
else
ifneq (,$(filter central,$(SHORT_SOURCE_CHANNEL)))
BRANDING ?= browser/branding/nightly
else
$(error $(PRODUCT_NAME) branding for $(SOURCE_CHANNEL) is unsupported)
endif
endif
endif

ifeq (firefox-esr,$(DEBIAN_SOURCE))
ifneq (,$(filter stretch buster,$(DIST)))
TRANSITION = 1
endif
endif

COMMON_CONFIGURE_FLAGS += --target=$(DEB_HOST_GNU_TYPE)
COMMON_CONFIGURE_FLAGS += --host=$(DEB_BUILD_GNU_TYPE)
COMMON_CONFIGURE_FLAGS += --prefix=/usr
COMMON_CONFIGURE_FLAGS += --enable-project=$(PRODUCT)

COMMON_CONFIGURE_FLAGS += $(if $(filter $(BRANDING),$(OFFICIAL_BRANDING)),--enable-official-branding,--with-branding=$(BRANDING))

# Define PRODUCT, product and Product variables (replacing product with the
# actual value of $(PRODUCT))
$(PRODUCT) := $(call lc,$(PRODUCT_NAME))
uc_first = $(strip $(eval __tmp := $(1))$(foreach l,$(letters),$(eval __tmp := $(subst $(l),$(l) ,$(__tmp))))$(call uc,$(firstword $(__tmp)))$(1:$(firstword $(__tmp))%=%))
DISPLAY_NAME := $(call uc_first,$(PRODUCT_DOWNLOAD_NAME))$(if $(filter %-esr,$(PRODUCT_NAME)), ESR)
$(call uc,$(PRODUCT)) := $(call uc,$(DISPLAY_NAME))
Product := $(call uc_first,$(PRODUCT))
$(Product) := $(DISPLAY_NAME)

export MOZ_APP_REMOTINGNAME := $(call uc_first,$($(PRODUCT)))

LIB_DIR := /usr/lib/$($(PRODUCT))
SHARE_DIR := /usr/share/$($(PRODUCT))

# Work around https://github.com/rust-lang/cargo/issues/7147
export CARGO_HOME=$(CURDIR)/debian/.cargo

ifneq (,$(filter stretch,$(DIST)))
ifneq (,$(filter amd64 i386,$(DEB_HOST_ARCH)))
export NASM=/usr/lib/nasm-mozilla/bin/nasm
endif
export NODEJS=/usr/lib/nodejs-mozilla/bin/node
export PATH := /usr/lib/llvm-7/bin/:$(PATH)
export PATH := /usr/lib/gcc-mozilla/bin/:$(PATH)
LDFLAGS += -static-libstdc++
endif

LDFLAGS += -Wl,--as-needed
# Make the linker generate compressed debug sections. dh_strip would do
# the same anyways, but it allows elfhack to work in combination with
# unstripped binaries when they would normally be larger than 2GiB.
LDFLAGS += -Wl,--compress-debug-sections=zlib

# Disable debug symbols when building on 32-bits machines, because
# a) the rust compiler can't deal with it in the available address
# space, and b) the linker can't deal with it in the available address space
# either.
ifneq (64,$(DEB_BUILD_ARCH_BITS))
	CONFIGURE_FLAGS += --disable-debug-symbols
endif

# Reduce memory usage of the linker at the expense of processing time
# This should help on lower-end architectures like arm and mips, which
# spend an immense amount of time swapping.
LDFLAGS += -Wl,--reduce-memory-overheads
LDFLAGS += -Wl,--no-keep-memory
# Also add execution time and memory usage stats in the logs
LDFLAGS += -Wl,--stats

AUTOCONF_DIRS := build/autoconf

CONFIGURE_FLAGS += --enable-update-channel=$(CHANNEL)

ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
	CONFIGURE_FLAGS += --disable-optimize
endif

ifneq (,$(filter debug,$(DEB_BUILD_OPTIONS)))
	CONFIGURE_FLAGS += --enable-debug
endif
ifneq (,$(filter %i386 %amd64 armel armhf arm64,$(DEB_HOST_ARCH)))
	MOZ_FFVPX = 1
endif
ifneq (,$(filter i386 amd64 armel armhf,$(DEB_HOST_ARCH)))
	CRASH_REPORTER = 1
endif
ifneq (,$(filter mips%,$(DEB_HOST_ARCH)))
	CONFIGURE_FLAGS += --disable-webrtc
endif

ifeq (default,$(origin CC))
CC := gcc
endif
ifeq (default,$(origin CXX))
CXX := g++
endif

ifneq (,$(filter mips mipsel,$(DEB_HOST_ARCH)))
CONFIGURE_FLAGS += --disable-jit
endif

CXXFLAGS = $(CFLAGS)
RUSTFLAGS = --remap-path-prefix=$(CURDIR)=.

EXPORTS := CC CXX CFLAGS CXXFLAGS CPPFLAGS LDFLAGS MOZILLA_OFFICIAL RUSTFLAGS
$(call lazy,CONFIGURE_ENV,$$(foreach export,$(EXPORTS),$$(export)="$$($$(export))"))

IN_FILES := $(wildcard debian/*.in)
ifeq ($(PRODUCT_NAME),firefox)
IN_FILES := $(filter-out debian/browser.preinst.in debian/browser.postrm.in debian/$($(PRODUCT)).in,$(IN_FILES))
endif
preprocessed_filename = $(subst $(PRODUCT),$($(PRODUCT)),$(subst GRE_VERSION,$(GRE_VERSION),$(1:.in=)))
define preprocess
$(call preprocessed_filename,$(1)): $(1)
PREPROCESSED_FILES += $(call preprocessed_filename,$(1))
endef
$(foreach f,$(IN_FILES),$(eval $(call preprocess, $(f))))

GENERATED_FILES += $(PREPROCESSED_FILES) debian/l10n/$(PRODUCT)-l10n.control
debian/control: debian/rules debian/changelog debian/l10n/$(PRODUCT)-l10n.control

$(call lazy,L10N_PACKAGES,$$(foreach lang,$$(L10N_LANGS),$($(PRODUCT))-l10n-$$(call lc,$$(lang))))
$(call lazy,L10N_PACKAGES_DEPS,$$(shell echo $$(L10N_PACKAGES) | sed 's/ /, /g'))

debian/l10n/$(PRODUCT)-l10n.control: %: %.in
	PYTHONIOENCODING=utf-8 LC_ALL=C.UTF-8 $(PYTHON) debian/l10n/gen $(L10N_LANGS) > $@

$(call lazy,LIBAVCODEC,$$(shell awk -F\" '/libavcodec\.so/ { sub(/libavcodec\.so\./,"", $$$$2); p = "libavcodec" $$$$2 " | libavcodec-extra" $$$$2; if (d) { d = d " | " p } else { d = p } } END { print d }' dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp))

$(PREPROCESSED_FILES): VARS = GRE_VERSION $(PRODUCT) $(call uc,$(PRODUCT)) $(Product) MOZ_APP_REMOTINGNAME $(SYSTEM_LIBS_VARS) SHORT_SOURCE_CHANNEL DIST TRANSITION MOZ_FFVPX CRASH_REPORTER DEB_HOST_ARCH
debian/control: VARS += L10N_PACKAGES_DEPS PRODUCT LIBAVCODEC
$(PREPROCESSED_FILES):
	$(PYTHON) ./mach python --no-virtualenv python/mozbuild/mozbuild/preprocessor.py --marker % -Fsubstitution $(foreach var,$(VARS),-D$(var)="$($(var))" )$< -o $@

ifdef TRANSITION
MAINTSCRIPTS := $(addprefix debian/,$(addsuffix .maintscript,$(shell awk -F/ '$$1 != "searchplugins" { next } $$2 == "locale" && $$3 != "en-US" { p="iceweasel-l10n-" $$3 } $$2 == "common" || ($$2 "/" $$3 == "locale/en-US") { p="iceweasel" } !done[p] { print p; done[p] = 1 }' debian/removed_conffiles)))

GENERATED_FILES += $(MAINTSCRIPTS)

debian/iceweasel.maintscript: debian/removed_conffiles
	(grep -v searchplugins/locale $<; grep searchplugins/locale/en-US $<) | awk '{print "rm_conffile /etc/iceweasel/" $$0, "45.0esr-2~", "iceweasel"}' > $@

debian/iceweasel-l10n-%.maintscript: debian/removed_conffiles
	grep -i searchplugins/locale/$* $< | awk '{print "rm_conffile /etc/iceweasel/" $$0, "45.0esr-2~", "iceweasel-l10n-$*"}' > $@
endif

override_dh_auto_configure:

configure js/src/configure:
	cp -f $@.in $@ && chmod +x $@
	echo $@ >> debian/extra-clean

stamps/prepare-configure:: stamps/dummy configure js/src/configure
	for dir in $(AUTOCONF_DIRS); do \
		for file in config.guess config.sub; do \
			sed -i '2!b;/^#/ i\exec "/usr/share/misc/'$$file'" "$$@"' $$dir/$$file; \
		done; \
	done

stamps/configure-check-$(PRODUCT):: stamps/configure-$(PRODUCT)
# Ensure --{with,enable}-system options properly set expected variables
# according to the definitions in the mozconfig file.
	@awk -F' *# *| *$$' ' \
	BEGIN { confs="$(foreach f,autoconf.mk emptyvars.mk,$(CURDIR)/build-$(PRODUCT)/config/$(f))" } \
	$$1 ~ /system-/ { \
		if (! $$2) { \
			print FILENAME ": Missing variable for",$$1; \
			error=1; \
		} else { \
			split($$2,var,"="); \
			cmd = "grep -l " var[1] " " confs; \
			cmd | getline dir; \
			sub(/\/[^\/]*$$/, "", dir); \
			cmd = "$(MAKE) -C " dir " --no-print-directory echo-variable-" var[1]; \
			cmd | getline value; \
			if (value != var[2]) { print $$1, "triggered", var[1] "=" value,"instead of",$$2; error=1 } \
		} \
	} \
	END { if (error) { exit 1 }}' debian/$($(PRODUCT)).mozconfig

stamps/configure-$(PRODUCT):: stamps/prepare-configure debian/$($(PRODUCT)).mozconfig
	$(if $(wildcard build-$(PRODUCT)),,mkdir build-$(PRODUCT))
	cd build-$(PRODUCT) && \
	MOZCONFIG=$(CURDIR)/debian/$($(PRODUCT)).mozconfig \
	ASFLAGS="-g" \
	$(CONFIGURE_ENV) \
	$(CURDIR)/configure \
		$(COMMON_CONFIGURE_FLAGS) \
		$(CONFIGURE_FLAGS)

stamps/build-$(PRODUCT):: stamps/configure-check-$(PRODUCT)
	+dh_auto_build --parallel --builddirectory=build-$(PRODUCT) -- \
		LD_LIBS=-Wl,--no-gc-sections \
		_LEAKTEST_FILES=leaktest.py

L10N_BUILD_STAMPS = $(foreach lang,$(L10N_LANGS),stamps/build-l10n-$(lang))
stamps/build-l10n:: $(L10N_BUILD_STAMPS)

$(L10N_BUILD_STAMPS):: stamps/build-l10n-%: stamps/prepare-configure
	$(if $(wildcard build-l10n/$*),,mkdir -p build-l10n/$*)
	$(if $(wildcard l10n),,mkdir -p l10n)
	cd build-l10n/$* && \
	$(CONFIGURE_ENV) \
	$(CURDIR)/configure \
		$(COMMON_CONFIGURE_FLAGS) \
		--disable-compile-environment \
		--with-l10n-base=$(CURDIR)/l10n

	$(if $(wildcard l10n/$*),,ln -sf ../l10n-$* l10n/$*)
	-cd $(CURDIR)/build-l10n/$* && PYTHONIOENCODING=utf-8 $(CURDIR)/mach compare-locales --merge $(CURDIR)/build-l10n/$*/l10n $(CURDIR)/$(PRODUCT)/locales/l10n.toml $(CURDIR)/l10n $*
	$(MAKE) -C build-l10n/$*/$(PRODUCT)/locales langpack-$* MOZ_CHROME_FILE_FORMAT=flat MOZ_LANGPACK_EID=langpack-$*@$($(PRODUCT)).mozilla.org PKG_LANGPACK_BASENAME='$$(MOZ_LANGPACK_EID)' PKG_LANGPACK_PATH=xpi/ LOCALE_MERGEDIR=$(CURDIR)/build-l10n/$*/l10n

override_dh_auto_build-arch: stamps/build-$(PRODUCT)

override_dh_auto_build-indep: stamps/build-l10n

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
# Disable tests on stable-security
ifeq (,$(findstring ~deb,$(DEBIAN_RELEASE)))
# Disable tests until they're fixed
#include debian/test.mk
endif
endif

override_dh_auto_clean::
	rm -f $(filter-out debian/control,$(GENERATED_FILES))
	rm -f $$(cat debian/extra-clean 2>/dev/null) debian/extra-clean old-configure js/src/old-configure
	rm -rf stamps l10n $(CARGO_HOME)
	debian/rules debian/control TESTDIR=

	dh_auto_clean --builddirectory=build-$(PRODUCT)
	dh_auto_clean --builddirectory=build-l10n
	find . -name "*.pyc" -o -name "*.pyo" | xargs --no-run-if-empty rm -f
	rm -rf obj-*/.mozbuild

override_dh_clean:
	dh_clean -XCargo.toml.orig
	for dir in $(AUTOCONF_DIRS); do \
		for file in config.guess config.sub; do \
			sed -i '2!b;/^exec "/ d' $$dir/$$file; \
		done; \
	done

override_dh_auto_install-arch: stamps/install-$(PRODUCT)
override_dh_auto_install-indep:

stamps/install-$(PRODUCT)::
	dh_auto_install --builddirectory=build-$(PRODUCT) -- installdir=$(LIB_DIR) \
		MOZ_APP_BASE_VERSION=$(GRE_VERSION) \
		TAR_CREATE_FLAGS="--exclude=.mkdir.done --hard-dereference -chf" \
		SIGN_NSS=

	-TZ=UTC unzip -d debian/tmp$(LIB_DIR)/browser debian/tmp$(LIB_DIR)/browser/omni.ja 'defaults/preferences/*'

L10N_DH_INSTALL_STAMPS = $(foreach lang,$(L10N_LANGS),stamps/dh_install-l10n-$(lang))
stamps/dh_install-l10n:: $(L10N_DH_INSTALL_STAMPS)

$(L10N_DH_INSTALL_STAMPS):: stamps/dh_install-l10n-%: stamps/build-l10n-%
	dh_install -p$($(PRODUCT))-l10n-$(call lc,$*) build-l10n/$*/dist/xpi/langpack-$*@$($(PRODUCT)).mozilla.org.xpi $(LIB_DIR)/browser/extensions/

stamps/dh_install:: debian/noinstall debian/$($(PRODUCT))-symbolic.svg
	awk '{print "debian/tmp/" $$1 }' < debian/noinstall | xargs rm -r
	dh_install --fail-missing

override_dh_install-arch: stamps/dh_install
override_dh_install-indep: stamps/dh_install-l10n

override_dh_strip:
	dh_strip --dbgsym-migration='$($(PRODUCT))-dbg (<< 49.0-4~)'

override_dh_strip_nondeterminism:

override_dh_shlibdeps:
	dh_shlibdeps -a -l$(CURDIR)/debian/tmp$(LIB_DIR) -- -xlibgtk2.0-0

ifdef TRANSITION
override_dh_gencontrol-indep:
	dh_gencontrol$(foreach pkg,$(subst $($(PRODUCT)),iceweasel,$(L10N_PACKAGES)) iceweasel-l10n-all, -p$(pkg)) -- -v1:$(DEBIAN_VERSION)
	dh_gencontrol$(foreach pkg,$(subst $($(PRODUCT)),iceweasel,$(L10N_PACKAGES)) iceweasel-l10n-all, -N$(pkg))
endif

# We're dealing with this manually and we don't want config.* files being touched under third_party/rust.
override_dh_update_autotools_config:

install binary binary-arch binary-indep: $(filter-out %.pc,$(GENERATED_FILES))

binary binary-arch binary-indep build build-arch build-indep clean install:
	debian/dh $@

.PHONY: build clean binary-indep binary-arch binary install

$(eval ALL_STAMPS := $(shell awk -F:: '$$1 ~ /^stamps\// && !/%/ { print $$1 }' debian/rules) stamps/dummy $(L10N_BUILD_STAMPS) $(L10N_DH_INSTALL_STAMPS))
$(ALL_STAMPS)::
	@mkdir -p stamps
	$(if $(wildcard $@),,touch $@)
endif