#!/usr/bin/make -f

#export DH_VERBOSE=1

SHLIBS_LOCAL = debian/shlibs.local

define SHLIBS_LOCAL_TEXT
libGL                  1.2  imx-gpu-viv-f17-all | imx-gpu-viv-f18-all
libGLES_CL             1    imx-gpu-viv-f17-all | imx-gpu-viv-f18-all
libGLES_CM             1    imx-gpu-viv-f17-all | imx-gpu-viv-f18-all
libGLESv1_CL           1    imx-gpu-viv-f17-all | imx-gpu-viv-f18-all
libGLESv1_CM           1    imx-gpu-viv-f17-all | imx-gpu-viv-f18-all
libg2d                 1    imx-gpu-viv-f17-all | imx-gpu-viv-f18-all
libg2d                 1.1  imx-gpu-viv-f17-all | imx-gpu-viv-f18-all
libEGL                 1    imx-gpu-viv-f17-all | imx-gpu-viv-f18-all
libGLESv2              2    imx-gpu-viv-f17-all | imx-gpu-viv-f18-all
libwayland-viv         0    imx-gpu-viv-f17-all | imx-gpu-viv-f18-all
endef

export SHLIBS_LOCAL_TEXT

export DISTCC_DIR=/home/tele/.distcc/
export CC=/usr/lib/distcc/bin/gcc-9
export CXX=/usr/lib/distcc/bin/g++-9


WL_CONFIGS += --disable-libunwind
WL_CONFIGS += --libexec=/usr/lib/weston
WL_CONFIGS += --with-cairo=glesv2
WL_CONFIGS += CFLAGS=-Wno-error=format-security
#WL_CONFIGS += --enable-libinput-backend

EX_CONFIGS += --enable-setuid-install
EX_CONFIGS += --enable-rdp-compositor
EX_CONFIGS += --enable-clients
EX_CONFIGS += --enable-simple-clients
EX_CONFIGS += --enable-demo-clients-install
EX_CONFIGS += --enable-colord
EX_CONFIGS += --enable-egl
EX_CONFIGS += --enable-simple-egl-clients
EX_CONFIGS += --enable-fbdev-compositor
EX_CONFIGS += --disable-headless-compositor
EX_CONFIGS += --enable-drm-compositor
EX_CONFIGS += --enable-weston-launch
EX_CONFIGS += --enable-lcms
EX_CONFIGS += --with-pam
EX_CONFIGS += --enable-systemd-login
EX_CONFIGS += --disable-vaapi-recorder
EX_CONFIGS += --enable-wayland-compositor
EX_CONFIGS += --without-webp
EX_CONFIGS += --disable-imxg2d
#EX_CONFIGS += --disable-rpi-compositor
#EX_CONFIGS += --enable-devdocs
#EX_CONFIGS += --enable-systemd-notify
EX_CONFIGS += --enable-screen-sharing
#EX_CONFIGS += WESTON_NATIVE_BACKEND=fbdev-backend.so
#EX_CONFIGS += --disable-silent-rules
#EX_CONFIGS += --disable-dependency-tracking
EX_CONFIGS += --enable-remoting
EX_CONFIGS += --enable-autotools


ifeq ($(USE_XWAYLAND),y)
EX_CONFIGS += --enable-x11-compositor
EX_CONFIGS += --disable-xwayland-test
EX_CONFIGS += --enable-xwayland
else
EX_CONFIGS += --disable-x11-compositor
EX_CONFIGS += --disable-xwayland-test
EX_CONFIGS += --disable-xwayland
endif


override_dh_auto_configure:
	dh_auto_configure -- $(WL_CONFIGS) $(EX_CONFIGS)

override_dh_auto_test:
	# the test suite does not 100% pass in headless mode
	dh_auto_test || true


override_dh_missing:
	dh_missing --fail-missing -X.la


override_dh_makeshlibs:
	dh_makeshlibs -Xlibweston-6/ -- -c4

#override_dh_shlibdeps:
#	@echo "$${SHLIBS_LOCAL_TEXT}" > $(SHLIBS_LOCAL)
#	dh_shlibdeps -a

override_dh_fixperms:
	dh_fixperms -Xusr/bin/weston-launch

override_dh_strip:
#	dh_strip -a --no-automatic-dbgsym
	dh_strip -plibweston-6-0 --dbg-package=libweston-6-0-dbg
	dh_strip -pweston --dbg-package=weston-dbg

%:
	dh $@ --with quilt

# For maintainer use only, generate a tarball:
gentarball: SOURCE=$(shell dpkg-parsechangelog|awk '/^Source:/ {print $$2}')
gentarball: UV=$(shell dpkg-parsechangelog|awk '/^Version:/ {print $$2}'|sed 's/-.*$$//')
gentarball:
	git archive --format=tar upstream-unstable --prefix=$(SOURCE)-$(UV)/ | gzip -9 > ../$(SOURCE)_$(UV).orig.tar.gz
