#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# esfmu assembly no longer builds on armhf
ifeq ($(DEB_HOST_ARCH),armhf)
export DEB_CPPFLAGS_MAINT_APPEND := -D_ESFMU_DISABLE_ASM_OPTIMIZATIONS
endif

%:
	dh $@

override_dh_auto_clean:
	dh_auto_clean -Bbuildtree-release
	dh_auto_clean -Bbuildtree-debug

override_dh_auto_configure:
	dh_auto_configure -Bbuildtree-release -- --enable-sdl2 --disable-avcodec
	dh_auto_configure -Bbuildtree-debug -- --enable-sdl2 --disable-avcodec --enable-debug=heavy

override_dh_auto_build:
# Re-create the CRC files
	pycrc --model crc-32 --symbol-prefix zipcrc_ --algorithm table-driven --generate h -o include/zipcrc.h
	pycrc --model crc-32 --symbol-prefix zipcrc_ --algorithm table-driven --generate c -o src/gui/zipcrc.c
	dh_auto_build -Bbuildtree-release
	dh_auto_build -Bbuildtree-debug

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	buildtree-debug/src/dosbox-x --test
endif

# The debugger might be non-redistributable (because debug_disasm.c is
# GPL-2.0-only, and parts of DOSBox-X are GPL-3.0); it is built for
# the test suite, but it isn't included in the binary packages.
override_dh_auto_install:
	dh_auto_install -Bbuildtree-release
