#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# Some variables:
DEB_HOST_ARCH_OS  ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)

%:
	dh $@ --with python3 --exclude=.la

override_dh_auto_configure:
	dh_auto_configure -- \
		--enable-tools=yes \
		--enable-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 -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/*
