#!/usr/bin/make -f

MOZ_PKG_BASENAME	:= firefox

include $(CURDIR)/debian/build/config.mk

MOZ_APP			:= browser
MOZ_VENDOR		:= Mozilla
MOZ_MOZDIR		:=

MOZ_APP_SUBDIR	:= browser

MOZ_BRANDING		:= $(CHANNEL)
ifneq (,$(filter release beta, $(MOZ_BRANDING)))
MOZ_BRANDING		:= official
endif
ifeq (1,$(MOZ_FORCE_UNOFFICIAL_BRANDING))
ifneq (,$(filter official aurora, $(MOZ_BRANDING)))
MOZ_BRANDING		:= unofficial
endif
endif
MOZ_BRANDING_DIR 	:= $(MOZ_APP)/branding/$(MOZ_BRANDING)
ifeq (official,$(MOZ_BRANDING))
MOZ_BRANDING_OPTION	:= --enable-official-branding
else
MOZ_BRANDING_OPTION	:= --with-branding=$(MOZ_BRANDING_DIR)
endif

MOZ_PKGNAME_SUBST_FILES = \
	debian/usr.bin.$(MOZ_PKG_NAME) \
	debian/README.Debian \
	debian/$(MOZ_PKG_BASENAME).sh \
	debian/apport/blacklist \
	debian/apport/native-origins \
	debian/apport/source_$(MOZ_PKG_NAME).py \
	$(NULL)

MOZ_APPNAME_SUBST_FILES = \
	debian/$(MOZ_APP_NAME).1 \
	$(NULL)

ifeq (1,${MOZ_OFFICIAL_BUILD})
export MOZILLA_OFFICIAL=1
endif
ifeq (1,${MOZ_ENABLE_TELEMETRY})
export MOZ_TELEMETRY_REPORTING=1
export MOZ_SOURCE_REPO=${MOZILLA_REPO}
export MOZ_SOURCE_CHANGESET=$(shell cat $(DEB_SRCDIR)/SOURCE_CHANGESET)
endif

include $(CURDIR)/debian/build/rules.mk

debian/usr.bin.firefox.in:
	if [ '$(DISTRIB_VERSION_MAJOR)$(DISTRIB_VERSION_MINOR)' -ge '1410' ]; then \
		cp $(CURDIR)/debian/usr.bin.firefox.apparmor.14.10 $(CURDIR)/debian/usr.bin.firefox.in ; \
	fi

WRITE_SUBSTVARS = $(shell echo "$(2)=$(3)" | sed 's/[ \t\n]\+/ /g' >> debian/$(1).substvars)

ifeq (firefox, $(MOZ_PKG_NAME))
install/firefox::
	$(call WRITE_SUBSTVARS,firefox,transitional:Replaces,kubuntu-firefox-installer)
endif

clean::
	rm -f debian/usr.bin.firefox.in config.log
