#!/usr/bin/make -f

include /usr/share/gnome-pkg-tools/1/rules/gnome-get-source.mk

# Use recursive variables since this variable must not be expanded until 
# files have been installed.
#LIBMOZJS = $(shell objdump -p debian/tmp/usr/lib/libgjs.so | awk '$$1=="NEEDED" && $$2~/^libmozjs/ { print $$2 }' | sed s/\\.so\\./-/ )
# Hard code the mozjs version here since the above line didn't seem to work
LIBMOZJS = libmozjs-38-0

%:
	dh $@ --with gnome

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

override_dh_install:
	dh_install --fail-missing -X.la

override_dh_auto_test:
	dh_auto_test || true

override_dh_makeshlibs:
	dh_makeshlibs -Xusr/lib/gjs-1.0/ -V'libgjs0f (>= $(DEB_UPSTREAM_VERSION)), libgjs0-$(LIBMOZJS)' -- -c4

override_dh_gencontrol:
	echo gjs:Provides=libgjs0-$(LIBMOZJS) >> debian/libgjs0f.substvars
	dh_gencontrol
