#!/usr/bin/make -f
export DH_OPTIONS
export REPACK_SH=$(CURDIR)/debian/repack.sh
export CC=gcc-4.9
export CXX=g++-4.9

INSTDIR=debian/tmp

ifeq ($(DEB_HOST_ARCH_CPU),amd64)
export DEB_CXXFLAGS_MAINT_APPEND := -fPIC
endif

export DEB_LDFLAGS_MAINT_APPEND := -latomic

%:
	dh $@ --buildsystem=cmake \
		  --builddirectory=build \
		  --parallel

override_dh_auto_configure:
	dh_auto_configure -- \
		-DCMAKE_SKIP_RPATH=ON \
		-DUSE_FIELD3D=OFF \
		-DUSE_PYTHON=OFF

override_dh_auto_build:
	dh_auto_build
ifneq (armel,$(DEB_HOST_ARCH))
	$(MAKE) -C $(CURDIR)/src/doc/
endif

override_dh_auto_install:
	dh_auto_install \
		--buildsystem=cmake \
		--destdir=$(INSTDIR)

override_dh_auto_test:

override_dh_install:
	rm -f debian/tmp/usr/share/doc/openimageio/CHANGES
	rm -f debian/tmp/usr/share/doc/openimageio/LICENSE
	dh_install
ifneq (armel,$(DEB_HOST_ARCH))
	mkdir -p debian/libopenimageio-dev/usr/share/doc/libopenimageio-dev/
	cp src/doc/openimageio.pdf debian/libopenimageio-dev/usr/share/doc/libopenimageio-dev/
endif

get-orig-source:
	uscan --force-download
