diff options
Diffstat (limited to 'librewolf/debian/rules')
-rwxr-xr-x | librewolf/debian/rules | 362 |
1 files changed, 362 insertions, 0 deletions
diff --git a/librewolf/debian/rules b/librewolf/debian/rules new file mode 100755 index 0000000..43ac8e7 --- /dev/null +++ b/librewolf/debian/rules @@ -0,0 +1,362 @@ +#!/usr/bin/make -f +export DEB_BUILD_HARDENING=1 +export DEB_BUILD_HARDENING_STACKPROTECTOR=1 +export DEB_BUILD_HARDENING_FORTIFY=1 +export DEB_BUILD_HARDENING_FORMAT=1 +export DEB_BUILD_HARDENING_PIE=1 +export CPP +export MOZ_NOSPAM=1 +export MACH_USE_SYSTEM_PYTHON=1 +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 bullseye,$(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 + +export MOZBUILD_STATE_PATH = $(CURDIR)/debian/.mozbuild + +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 arm64,$(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)=. +ifeq (,$(filter 1.43.% 1.44.%,$(shell rustc --version | awk '{print $$2}'))) +RUSTFLAGS += -Cembed-bitcode=yes +endif + +CPPFLAGS += -D_FORTIFY_SOURCE=2 +CFLAGS += -march=x86-64 -mtune=generic -O2 -pipe -fno-plt +CXXFLAGS += -march=x86-64 -mtune=generic -O2 -pipe -fno-plt +LDFLAGS += -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now +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): + MOZ_OBJDIR=debian/objdir MACH_USE_SYSTEM_PYTHON=1 $(PYTHON) ./mach python 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: + cp -pf debian/search-config.json services/settings/dumps/main/ + +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/$*) + MACH_USE_SYSTEM_PYTHON=1 $(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/ + +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 debian/objdir $(MOZBUILD_STATE_PATH) + +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 -rf + 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: + chmod +x debian/dh + 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 |