#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,-z,defs -Wl,--as-needed

include /usr/share/dpkg/default.mk

export DH_VERBOSE=1

%:
	dh $@ --with gnome,gir

override_dh_auto_configure:
	dh_auto_configure -- \
		--libdir=\$${prefix}/lib \
		--libexecdir=\$${prefix}/lib/gjs \
		--disable-Werror \
		--enable-installed-tests \
		--with-xvfb-tests \
		--with-dbus-tests

override_dh_girepository:
	dh_girepository -l $(CURDIR) /usr/lib/gjs/girepository-1.0

override_dh_install:
	find debian/tmp -name '*.la' -print -delete
	dh_install

override_dh_missing:
	dh_missing --fail-missing

override_dh_auto_test:
ifeq (, $(filter nocheck, $(DEB_BUILD_OPTIONS)))
	TZ=UTC DEB_HOST_ARCH=$(DEB_HOST_ARCH) debian/test.sh
endif

override_dh_makeshlibs:
	dh_makeshlibs -Xusr/lib/gjs-1.0/ -V'libgjs0g (>= $(DEB_VERSION_EPOCH_UPSTREAM))' -- -c4

# We don't actually use mozjs52 any more, but our ABI is compatible with
# the gjs that did.
#
# Yes, this really says libmozjs-52-0. Yes, this is intentional, even
# though we're now building against mozjs60. It's like this to avoid an
# unnecessary transition: programs built against gjs 1.52.x do not need
# to be rebuilt for 1.54.x.
override_dh_gencontrol:
	echo gjs:Provides=libgjs0-libmozjs-52-0 >> debian/libgjs0g.substvars
	dh_gencontrol
