#!/usr/bin/make -f

# Enable verbose build by default, disable when terse is specified.
ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
VERBOSE=1
else
VERBOSE=0
endif

%:
	dh $@

override_dh_auto_build:
	# Always set CROSS_COMPILE, which also works for native builds.
	# Strip binaries, since dh_strip may not be called for arch:all.
	for target in generic sifive/fu540 ; do \
		CROSS_COMPILE=riscv64-linux-gnu- make \
			V=$(VERBOSE) \
			FW_PAYLOAD=n \
			PLATFORM=$${target} ; \
		for elffile in build/platform/$${target}/firmware/fw_*.elf ; do \
			riscv64-linux-gnu-strip --remove-section=.comment \
				--remove-section=.note \
				$${elffile} ; \
		done ; \
	done

override_dh_installdocs:
	dh_installdocs --exclude=doxygen.cfg
