#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
	dh $@ --buildsystem=cmake


override_dh_auto_configure:
	dh_auto_configure -- \
		-DUSE_SCIP=OFF \
		-DBUILD_DEPS=OFF \
		-DBUILD_TESTING=OFF \
		-DBUILD_EXAMPLES=OFF \
		-DBUILD_DOC=ON \
		-DBUILD_PYTHON=ON

override_dh_auto_build:
	dh_auto_build

ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),)
	python3 tools/doc/gen_ref_doc.py
endif

override_dh_auto_install:
	dh_auto_install

	mkdir -p debian/tmp/usr/share/doc/ortools/
	cp -Rf examples debian/tmp/usr/share/doc/ortools/examples

	find debian/tmp -depth -empty -delete
	find debian/tmp -type d -name __pycache__ -exec rm -Rf {} +
	rm -Rf debian/tmp/usr/lib/python3/dist-packages/ortools/.libs

override_dh_fixperms:
	dh_fixperms

ifneq ($(wildcard debian/ortools-examples),)
	find debian/ortools-examples/usr/share/doc/ortools/examples/data \
		-type f -perm 0755 -exec chmod -x {} +
endif
