#!/usr/bin/make -f
export DH_OPTIONS

INSTDIR=debian/tmp
PY3VERS = $(shell py3versions -dv)

export DEB_LDFLAGS_MAINT_APPEND := -latomic

ifeq (,$(filter $(DEB_HOST_ARCH),armel armhf))
	SETGL = ON
else
	SETGL = OFF
endif

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

override_dh_auto_configure:
	dh_auto_configure -- \
		-DROBINMAP_INCLUDE_DIR="/usr/include/" \
		-DCMAKE_SKIP_RPATH=ON \
		-DPYTHON_VERSION=$(PY3VERS) \
		-DSTOP_ON_WARNING=OFF \
		-DUSE_FIELD3D=OFF \
		-DUSE_OPENGL=$(SETGL)

override_dh_auto_build-arch:
	dh_auto_build

override_dh_auto_build-indep:
	dh_auto_build
	$(MAKE) -C $(CURDIR)/src/doc/

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.md
	rm -f debian/tmp/usr/share/doc/openimageio/LICENSE.md
	dh_install