#!/usr/bin/make -f

DRMMODES = exynos pl111
COMMON_CONFIGURE_FLAGS = $(shell dpkg-buildflags --export=configure)

%:
	dh $@ --with autoreconf,quilt,xsf

# create m4 directory before running autoreconf
override_dh_autoreconf:
	mkdir -p m4
	NOCONFIGURE=1 dh_autoreconf ./autogen.sh

# remove m4 directory after autoreconf cleanup
override_dh_autoreconf_clean:
	dh_autoreconf_clean
	rm -rf m4

override_dh_auto_configure: $(DRMMODES:%=doconfigure-%)

doconfigure-%:
	DH_VERBOSE=1 dh_auto_configure --builddirectory=build/$* -- $(COMMON_CONFIGURE_FLAGS) --with-drmmode=$*

override_dh_auto_build: $(DRMMODES:%=dobuild-%)

dobuild-%:
	dh_auto_build --builddirectory=build/$*

override_dh_auto_install: $(DRMMODES:%=doinstall-%)

doinstall-%:
	dh_auto_install --builddirectory=build/$* --destdir=debian/xserver-xorg-video-armsoc-$*
	find debian/xserver-xorg-video-armsoc-$* -name "*.la" -delete

override_dh_strip: $(DRMMODES:%=dostrip-%)

dostrip-%:
	dh_strip -pxserver-xorg-video-armsoc-$* --dbg-package=xserver-xorg-video-armsoc-$*-dbg

# use appropriate warning level for a plugin
override_dh_shlibdeps:
	dh_shlibdeps -- --warnings=6
