File: rules

package info (click to toggle)
firefox-esr 60.6.1esr-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,721,384 kB
  • sloc: cpp: 5,254,155; ansic: 2,334,778; python: 586,271; asm: 342,462; java: 329,371; xml: 193,533; sh: 83,344; makefile: 22,791; perl: 16,226; cs: 4,725; objc: 3,768; yacc: 1,766; ada: 1,681; lex: 1,364; pascal: 1,264; exp: 527; php: 436; lisp: 258; ruby: 157; awk: 152; sed: 53; csh: 27
file content (361 lines) | stat: -rwxr-xr-x 13,976 bytes parent folder | download | duplicates (2)
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#!/usr/bin/make -f
TESTDIR = $(shell dh_testdir || echo no)
ifeq (,$(TESTDIR))
include debian/make.mk
# Use dpkg-buildflags to get hardening flags, exclude non-hardening flags,
# and disable read-only relocations.
dpkg_buildflags = $(and $(1),$(shell DEB_BUILD_MAINT_OPTIONS=hardening=-relro DEB_CFLAGS_MAINT_STRIP="$(shell DEB_BUILD_MAINT_OPTIONS=hardening=-all dpkg-buildflags --get $(1))" 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_HOST_ARCH,$$(shell dpkg-architecture -qDEB_HOST_ARCH))
$(call lazy,DEB_HOST_ARCH_ENDIAN,$$(shell dpkg-architecture -qDEB_HOST_ARCH_ENDIAN))

PYTHON := python -B

PRODUCT := browser
include debian/upstream.mk

SYSTEM_LIBS = zlib bz2 ffi
ifeq (,$(filter wheezy jessie stretch,$(DIST)))
SYSTEM_LIBS += hunspell nspr nss sqlite libevent
endif
ifeq (,$(filter wheezy jessie,$(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))))

ifeq ($(DIST),wheezy)
CC := /usr/lib/gcc-mozilla/bin/gcc
CXX := /usr/lib/gcc-mozilla/bin/g++
endif

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 wheezy jessie stretch,$(DIST)))
TRANSITION = 1
endif
endif

BRANDING_CONFIGURE_FLAG = $(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)

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

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

LDFLAGS := -Wl,--as-needed

# Disable debug symbols when building on mips and mipsel machines,
# because the rust compiler can't deal with it in the available address
# space.
ifeq (,$(filter wheezy jessie stretch,$(DIST)))
ifneq (,$(filter mips mipsel,$(DEB_HOST_ARCH)))
	CONFIGURE_FLAGS += --disable-debug-symbols
endif
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

# Work around FTBFS from conflicting __sync_* symbols between libgcc
# and rust's compiler_builtins
ifeq (armel,$(DEB_HOST_ARCH))
LDFLAGS += -Wl,-z,muldefs
endif

AUTOCONF_DIRS := build/autoconf

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

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

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

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

ifneq (,$(findstring gcc,$(CC)))
ifeq (,$(filter 4.% 5.%,$(shell $(CC) -dumpversion)))
CFLAGS += -fno-schedule-insns2 -fno-lifetime-dse -fno-delete-null-pointer-checks
ifneq (,$(filter armel armhf,$(DEB_HOST_ARCH)))
CFLAGS += -fno-schedule-insns
endif
endif
endif

CXXFLAGS = $(CFLAGS)

ifeq ($(DEB_HOST_ARCH_ENDIAN),big)
ICU_VERSION := $(shell echo U_ICU_VERSION_MAJOR_NUM | cpp -P -include $(CURDIR)/intl/icu/source/common/unicode/uvernum.h)
ICU_DATA_FILE = icudt$(ICU_VERSION)b.dat
endif

EXPORTS := CC CXX CFLAGS CXXFLAGS CPPFLAGS LDFLAGS MOZILLA_OFFICIAL ICU_DATA_FILE
$(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
	$(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) python/mozbuild/mozbuild/preprocessor.py --marker % -Fsubstitution $(foreach var,$(VARS),-D$(var)="$($(var))" )$< > $@

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:

stamps/prepare-configure:: stamps/dummy
	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
	cp -f configure.in configure && chmod +x configure
	cp -f js/src/configure.in js/src/configure && chmod +x js/src/configure

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))
ifeq ($(DEB_HOST_ARCH_ENDIAN),big)
	echo mk_add_options MOZ_OBJDIR=build-$(PRODUCT) > build-$(PRODUCT)/mozconfig.icu
	cd build-$(PRODUCT) && \
	MOZCONFIG=mozconfig.icu \
	$(CONFIGURE_ENV) \
	../mach python ../intl/icu_sources_data.py "$(CURDIR)"
endif
	cd build-$(PRODUCT) && \
	MOZCONFIG=$(CURDIR)/debian/$($(PRODUCT)).mozconfig \
	ASFLAGS="-g" \
	$(CONFIGURE_ENV) \
	../configure --target=$(DEB_HOST_GNU_TYPE) --host=$(DEB_BUILD_GNU_TYPE) --prefix=/usr $(CONFIGURE_FLAGS) \
		$(BRANDING_CONFIGURE_FLAG)
	sed -i "/MOZ_APP_REMOTINGNAME/s/'[^']*',/'$(MOZ_APP_REMOTINGNAME)',/" build-$(PRODUCT)/config.status

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)

stamps/configure-l10n:: stamps/prepare-configure
	$(if $(wildcard build-l10n),,mkdir build-l10n)
	$(if $(wildcard l10n),,mkdir -p l10n)
	cd build-l10n && \
	MOZCONFIG=$(CURDIR)/debian/$($(PRODUCT)).mozconfig \
	$(CONFIGURE_ENV) \
	../configure --target=$(DEB_HOST_GNU_TYPE) --host=$(DEB_BUILD_GNU_TYPE) --prefix=/usr $(CONFIGURE_FLAGS) \
		--with-l10n-base=$(CURDIR)/l10n \
		$(BRANDING_CONFIGURE_FLAG)
	$(MAKE) -C build-l10n config/host CURRENT_TIER=compile

$(L10N_BUILD_STAMPS):: stamps/build-l10n-%: stamps/configure-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 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 configure js/src/configure old-configure js/src/old-configure
	rm -rf stamps l10n
	debian/rules debian/control TESTDIR=

ifeq ($(DEB_HOST_ARCH_ENDIAN),big)
	rm -f config/external/icu/data/$(ICU_DATA_FILE)
endif

	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

	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_clean:
	dh_clean -XCargo.toml.orig

override_dh_auto_install: stamps/install-$(PRODUCT)

stamps/install-$(PRODUCT)::
ifneq (,$(filter mips,$(DEB_HOST_ARCH)))
	sed -i '/"javascript.options.\(baselinejit\|ion\)"/s/true/false/' build-$(PRODUCT)/dist/bin/greprefs.js
endif
	dh_auto_install --builddirectory=build-$(PRODUCT) -- installdir=$(LIB_DIR) \
		MOZ_APP_BASE_VERSION=$(GRE_VERSION) \
		MOZ_PKG_MANIFEST=$(CURDIR)/debian/installer/package-manifest.$(PRODUCT) \
		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/

GENERATED_FILES += debian/$($(PRODUCT))-symbolic.svg
debian/$($(PRODUCT))-symbolic.svg: browser/extensions/onboarding/content/img/watermark.svg
	cat $< > $@

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: stamps/dh_install

override_dh_strip:
ifneq (,$(filter wheezy jessie,$(DIST)))
	dh_strip -a --dbg-package=$($(PRODUCT))-dbg
else
	dh_strip --dbgsym-migration='$($(PRODUCT))-dbg (<< 49.0-4~)'
endif

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

ifdef TRANSITION
override_dh_gencontrol:
	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

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

binary binary-indep: stamps/dh_install-l10n

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

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

.NOTPARALLEL:

$(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