#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=+lto abi=+time64
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic

%:
ifeq ($(filter nopython,$(DEB_BUILD_PROFILES)),)
	dh $@ --with python3 --exclude=.la
else
	dh $@ --exclude=.la
endif

override_dh_auto_configure:
	dh_auto_configure -- \
		--enable-tools=yes \
		--$(if $(filter nopython,$(DEB_BUILD_PROFILES)),dis,en)able-bindings-python \
		--enable-bindings-cxx \
		$(NULL)

# Architecture: all only: build the doxygen documentation
override_dh_auto_build-indep:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	dh_auto_build -- doc
endif

# doxygen documentation is installed using dh_installdocs
override_dh_auto_install-indep:

override_dh_auto_install:
	dh_auto_install
	rm -rf debian/tmp/usr/local/lib/*/dist-packages/gpiod*.egg-info
	rm -f debian/tmp/usr/lib/*/site-packages/gpiod.a

override_dh_installdocs:
	# fix lintian useless-autogenerated-doxygen-file
	dh_installdocs -X.md5

override_dh_clean:
	dh_clean
	rm -rf confdefs.h
	rm -rf doc/*