#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

ifeq ($(DEB_BUILD_ARCH), amd64)
	FAKELIBDIR = /usr/lib/virtualgl/fakelib/64
else
	FAKELIBDIR = /usr/lib/virtualgl/fakelib
endif
%:
	dh $@ 

override_dh_auto_configure:
	cmake -G "Unix Makefiles" \
	-DTJPEG_LIBRARY=/usr/lib/$(DEB_HOST_MULTIARCH)/libturbojpeg.so.0 \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DVGL_FAKELIBDIR=$(FAKELIBDIR) \
	-DVGL_DOCDIR=/usr/share/doc/virtualgl -DVGL_INCLUDEDIR=/usr/include \
	-DVGL_LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) -DVGL_BINDIR=/usr/bin \
	-DCMAKE_LIBRARY_PATH=/usr/lib/$(DEB_HOST_MULTIARCH)

override_dh_auto_install:
	make install DESTDIR=$(CURDIR)/debian/tmp
override_dh_strip:
	dh_strip --dbg-package=virtualgl-dbg -X usr/lib
	dh_strip --dbg-package=virtualgl-libs-dbg -X usr/bin
