#!/usr/bin/make -f
# -*- makefile -*-

#export DH_VERBOSE=1

ifeq ($(DEB_HOST_ARCH),arm64)
arm64=YES
else
arm64=NO
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		-DVMCS_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DARM64=$(arm64)

TEST_BINARIES := \
	vcsmem \
	vchiq_test \
	mmal_vc_diag

override_dh_install:
	dh_install
	# Remove all the small (largely undocumented) test binaries with
	# rather generic names
	rm -f debian/libraspberrypi-bin/usr/bin/containers_*
	mkdir -p debian/libraspberrypi-bin/usr/lib/userland
	for file in $(TEST_BINARIES); do \
		if [ -f debian/libraspberrypi-bin/usr/bin/$${file} ]; then \
			mv debian/libraspberrypi-bin/usr/bin/$${file} \
				debian/libraspberrypi-bin/usr/lib/userland/ ; \
		fi ; \
	done

override_dh_installexamples:
	dh_installexamples
	# Remove the Vera.ttf font and just symlink to the one in
	# ttf-bitstream-vera
	ln -sf /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf \
		debian/libraspberrypi-dev/usr/share/doc/libraspberrypi-dev/examples/hello_pi/hello_font/Vera.ttf

override_dh_compress:
	# Don't compress any of the source code in the examples; it's more
	# important for the examples to be easily useful
	dh_compress -Xusr/share/doc/libraspberrypi-dev/examples/
