#!/usr/bin/make -f

%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	sed -i "s/if (lb->compare(filenameWithoutPath, Qt::CaseInsensitive) == 0)/if (lb != filesOnDiskFilenamesOnlySorted.end() \&\& lb->compare(filenameWithoutPath, Qt::CaseInsensitive) == 0)/" src/dbupdater.cpp
	grep -q "lb != filesOnDiskFilenamesOnlySorted.end()" src/dbupdater.cpp || { echo "ERROR: dbupdater.cpp lower_bound end-deref patch did not apply"; exit 1; }
	sed -i "s/pkg_check_modules(TAGLIB IMPORTED_TARGET taglib)/pkg_check_modules(TAGLIB IMPORTED_TARGET taglib_openkj_bundled_marker)/" CMakeLists.txt
	dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DSPDLOG_USE_BUNDLED=true
