#!/usr/bin/make -f
# debhelper-7 [debian/rules] for xserver-xorg-video-geode
#
# COPYRIGHT © 2007-2019 Martin-Éric Racine <martin-eric.racine@iki.fi>
#
# LICENSE
# GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
#
export CC       := $(shell dpkg-architecture --query DEB_HOST_GNU_TYPE)-gcc
export CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
export CFLAGS   := $(shell dpkg-buildflags --get CFLAGS)
export LDFLAGS  := $(shell dpkg-buildflags --get LDFLAGS)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-bindnow
# Append flags for Long File Support
# LFS_CPPFLAGS is non-existent
export DEB_CFLAGS_MAINT_APPEND  +=$(shell getconf LFS_CFLAGS) $(HARDENING_CFLAGS)
export DEB_LDFLAGS_MAINT_APPEND +=$(shell getconf LFS_LDFLAGS) $(HARDENING_LDFLAGS)

override_dh_auto_configure:
	dh_auto_configure -- --disable-silent-rules --libdir=\$${exec_prefix}/lib

override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp

override_dh_installdocs:
	dh_installdocs --link-doc=xserver-xorg-video-geode NEWS README TODO

override_dh_install: xdepends
	find debian/tmp -name '*.la' -delete
	dh_install --fail-missing

override_dh_shlibdeps:
	dh_shlibdeps -- --warnings=6

%:
	dh $@ --with autoreconf --builddirectory=build/

# Check for xserver-xorg-dev (<< 1.7) Depends: xserver-xorg-core.
XMINVERS = $(shell cat /usr/share/xserver-xorg/serverminver 2>/dev/null)
# Check for xserver-xorg-dev (<< 1.9) Provides: ABI.
VIDEOABI = $(shell cat /usr/share/xserver-xorg/videoabiver 2>/dev/null)
# Check for xserver-xorg-dev (>= 1.8) Depends: ABI, xserver-xorg-core.
VIDEODEP = $(shell cat /usr/share/xserver-xorg/videodrvdep 2>/dev/null)

xdepends:
ifneq ($(XMINVERS),)
	# Building against xserver-xorg-dev (<< 1.7) Depends: xserver-xorg-core.
	echo "xviddriver:Depends=xserver-xorg-core (>= $(XMINVERS))" >> debian/xserver-xorg-video-geode.substvars
endif
ifneq ($(VIDEOABI),)
	# Building against xserver-xorg-dev (<< 1.9) Provides: ABI.
	echo "xviddriver:Provides=xserver-xorg-video-$(VIDEOABI)" >> debian/xserver-xorg-video-geode.substvars
endif
ifneq ($(VIDEODEP),)
	# Building against xserver-xorg-dev (>= 1.8) Depends: ABI, xserver-xorg-core.
	echo "xviddriver:Depends=$(VIDEODEP)" >> debian/xserver-xorg-video-geode.substvars
endif
.PHONY: xdepends
#EOF
