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

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

BLDDIR = debian/cmake
TMPDIR = debian/tmp
DIST := $(shell dpkg-parsechangelog | awk '/^Distribution: / {print $$2}')

EXTRA_FLAGS = -DEXTRA_OSLEXEC_LIBRARIES:STRING="tinfo"

%:
	dh $@ -Scmake -B$(BLDDIR) --parallel

override_dh_auto_configure:
	# Note: currently all tests pass on OS X but a few tests fail on Linux
	#  strictly for floating point precision reasons, not because anything
	#  is really broken.
	# Note2: graphics driver based on Gallium3D also uses LLVM, so we needs
	#  to use LLVM static library to avoid symbol conflicts.
	dh_auto_configure -- \
		-DLLVM_STATIC:BOOL=ON\
		-DLLVM_VERSION:STRING=6.0\
		-DCMAKE_CXX_FLAGS="-std=c++11"\
		-DSTOP_ON_WARNING=OFF \
		-DBUILD_TESTING:BOOL=OFF \
		-DBUILDSTATIC=OFF\
		-DOSL_BUILD_PLUGINS=OFF\
		-DUSE_SIMD=sse2 \
		-DOSL_BUILD_CPP11=1 \
		$(EXTRA_FLAGS)
	# A patch 020_fix_implicit_include changes the implicit include path to
	# stdosl.h from DESTDIR/shaders to DESTDIR/share/OSL/shaders.
	#mkdir -p $(BLDDIR)/src/share/OSL
	#ln -sf ../../shaders $(BLDDIR)/src/share/OSL

override_dh_shlibdeps:
	dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

# override_dh_auto_install:
	# dh_auto_install
	# CMAKE_SKIP_RPATH cannot be used because it causes build failure.
	# chrpath -d $(TMPDIR)/usr/bin/* $(TMPDIR)/usr/lib/lib*.so

