#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/simple-patchsys.mk
include /usr/share/cdbs/1/rules/utils.mk

# Version inforamtion
VA_MAJOR_VERSION := $(shell echo $(DEB_UPSTREAM_VERSION) | cut -d'.' -f1)
VA_MINOR_VERSION := $(shell echo $(DEB_UPSTREAM_VERSION) | cut -d'.' -f2)

# Optimisation flags
CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif

# Allow SMP build
ifeq ($(DEBIAN_BUILD_NCPUS),)
	DEBIAN_BUILD_NCPUS = $(shell /usr/bin/getconf _NPROCESSORS_ONLN)
endif
ifneq ($(DEBIAN_BUILD_NCPUS),)
	EXTRA_MAKE_FLAGS += -j$(DEBIAN_BUILD_NCPUS)
endif
MAKE += $(EXTRA_MAKE_FLAGS)

# Extra configure flags
DEB_CONFIGURE_SCRIPT_ENV += LDFLAGS="-Wl,-z,defs"
DEB_CONFIGURE_USER_FLAGS += --disable-i965-driver

update-config:: run-autoreconf
common-binary-predeb-arch:: list-missing

run-autoreconf: stamp-autoreconf
stamp-autoreconf:
	autoreconf -i
	touch $@

# Compatibility with older packaging (and SONAME)
install/libva1::
	echo ".text"|gcc -xassembler - -o debian/tmp/usr/lib/libva.so.0.29 -shared -Wl,-soname,libva.so.0 -Ldebian/tmp/usr/lib -lva-compat
	echo ".text"|gcc -xassembler - -o debian/tmp/usr/lib/libva.so.1.0.0 -shared -Wl,-soname,libva.so.1 -Ldebian/tmp/usr/lib -lva-x11
	/sbin/ldconfig -n debian/tmp/usr/lib
