#!/usr/bin/make -f

# Prevent host Linux compiler flags from entering Cortex-M3 builds.
export CFLAGS =
export CPPFLAGS =
export CXXFLAGS =
export LDFLAGS =

# The pkg.avd-fw.all-codecs build profile implies the avd-fw-all-codecs option.
ifneq (,$(filter pkg.avd-fw.all-codecs,$(DEB_BUILD_PROFILES)))
DEB_BUILD_OPTIONS += avd-fw-all-codecs
endif

# Select codecs: all with avd-fw-all-codecs, royalty-free otherwise.
# The archive build uses the royalty-free default (see README.Debian).
ifneq (,$(filter avd-fw-all-codecs,$(DEB_BUILD_OPTIONS)))
VIDEO_CODECS = all
else
VIDEO_CODECS = all_free
endif

%:
	dh $@ --buildsystem=meson

override_dh_auto_configure:
	dh_auto_configure --buildsystem=meson -- \
		--buildtype=debug \
		--cross-file=$(CURDIR)/llvm.ini \
		-Dvideo-codecs=$(VIDEO_CODECS) \
		-Dfirmwaredir=firmware

execute_after_dh_fixperms:
	chmod 644 debian/firmware-apple-avd/usr/lib/firmware/apple/*.bin
