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

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

CORE_ABIVERSION := $(shell sed -rn 's/^\#define[[:space:]]+CORE_ABIVERSION[[:space:]]+//p' /usr/include/compiz/core/core.h )


override_dh_auto_configure:
	dh_auto_configure -- -DCOMPIZ_BUILD_WITH_RPATH=FALSE -DCOMPIZ_PACKAGING_ENABLED=TRUE -DCOMPIZ_PLUGIN_INSTALL_TYPE=package -DUSE_GSETTINGS=OFF -DCOMPIZ_DISABLE_GS_SCHEMAS_INSTALL=ON

override_dh_gencontrol:
	dh_gencontrol -- -Vcoreabiversion=$(CORE_ABIVERSION)

override_dh_install:
	# cmake findcompiz_install use COMPIZ_DESTDIR and using COMPIZ_DESTDIR
	# and DESTDIR together is completely broken upstream
	# So, doing the same in debian/rules to find a way to install things in the
	# right place, sorry for the kittens
	cmake_dir=`cmake --system-information 2> /dev/null | grep "^CMAKE_ROOT " | sed -e 's/.*"\(.*\)"/\1/'` && \
    mkdir -p debian/tmp$${cmake_dir}/Modules && cp cmake/FindCompizConfig.cmake debian/tmp$${cmake_dir}/Modules

	dh_install --fail-missing

%:
	dh $@

