#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --with autoreconf

override_dh_clean:
	dh_clean
	$(RM) -r scripts/Makefile src/Makefile tech/Makefile config.log config.status Makefile
	$(RM) -r tech/osu018/Makefile tech/osu035/Makefile tech/osu050/Makefile
	$(RM) -r tech/osu035_redm4/Makefile tech/osu035_redm4/osu035_redm4.magicrc


override_dh_auto_install:
	dh_auto_install
	# delete non-script from scripts directory:
	$(RM) debian/tmp/usr/lib/qflow/scripts/qflow_help.txt

ifeq (big,$(shell dpkg-architecture -qDEB_TARGET_ARCH_ENDIAN))
override_dh_auto_configure:
	@echo; echo;
	@echo 'Yosys is considered "unusably broken" by upstream on big-endian arches,'
	@echo "so qflow can't possibly work here."
	@echo "See https://github.com/YosysHQ/yosys/issues/2645"
	@echo "Failing build artificially."
	exit 1
endif
