#!/usr/bin/make -f
# -*- makefile -*-

export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed

# do not strip
export SFLAGS=
# build with verbose output
export VERBOSE=1
# install into multiarch libdir
export LIBDIR=/usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
# disable check's timeout funtionality
export CK_DEFAULT_TIMEOUT=0
# use little endian mo files everywhere
export MSGFMTFLAGS=--endianness little

%:
	dh $@ --parallel

override_dh_auto_clean:
	set -e; for gtkver in 2 3 ; do \
		GIRARA_GTK_VERSION=$$gtkver $(MAKE) clean ; \
	done

override_dh_auto_build-arch:
	set -e; for gtkver in 2 3 ; do \
		GIRARA_GTK_VERSION=$$gtkver $(MAKE) ; \
	done

override_dh_auto_test-arch:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	xvfb-run -a sh -c 'set -e; for gtkver in 2 3 ; do \
		GIRARA_GTK_VERSION=$$gtkver $(MAKE) test ; \
	done'
endif

override_dh_auto_install-arch:
	set -e; for gtkver in 2 3 ; do \
		GIRARA_GTK_VERSION=$$gtkver $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp ; \
	done

override_dh_strip:
	dh_strip --dbg-package=libgirara-dbg

override_dh_auto_build-indep:
	# build documentation if doxygen is available and remove the copy of jquery
	# and replace it with the one from libjs-jquery
ifneq "$(wildcard /usr/bin/doxygen)" ""
	$(MAKE) doc ;
	rm -f doc/html/installdox
	rm doc/html/jquery.js
	ln -s /usr/share/javascript/jquery/jquery.js doc/html/jquery.js
endif

# no tests and install for indep
override_dh_auto_test-indep override_dh_auto_install-indep:
