#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

CMAKE_OPTS=-DCONTRIBUTORS=$(CURDIR)/doc/CONTRIBUTORS \
					 -DFORCE_VERSION=internal \
					 -DWANT_QT5=1 \
					 -DWANT_CARLA=0
ifneq ($(DEB_HOST_ARCH_OS),linux)
CMAKE_OPTS+=-DWANT_ALSA=0
endif

# Re-enable after wine is properly built
# Disabled for Qt 5.12.4 transition on 2022-06-14
# Also check debian/control build-dependency
# ###############################################
#ifeq ($(DEB_HOST_ARCH),i386)
#export PATH := $(PATH):/usr/lib/wine
#WINE_PATH := /usr/lib/$(DEB_HOST_MULTIARCH)/wine
#CMAKE_OPTS+= -DWINE_CXX_FLAGS=-Wl,--enable-new-dtags,-rpath=$(WINE_PATH)
#else
#CMAKE_OPTS+= -DWANT_VST_NOWINE=1 \
#	-DREMOTE_VST_PLUGIN_FILEPATH=../../i386-linux-gnu/lmms/RemoteVstPlugin
#endif
CMAKE_OPTS+= -DWANT_VST_NOWINE=1 \
	-DREMOTE_VST_PLUGIN_FILEPATH=../../$(DEB_HOST_MULTIARCH)/lmms/RemoteVstPlugin
#################################################


# Define NDEBUG. This helps with reproducible builds.
export DEB_CPPFLAGS_MAINT_APPEND=-DNDEBUG
# Add -Wno-error=format-truncation because truncation is expected in snprintf.
DEB_CXXFLAGS_MAINT_APPEND=-Wno-error=format-truncation
ifeq ($(DEB_HOST_ARCH),ppc64el)
# -Wno-maybe-uninitialized needed on Ubuntu ppc64el to avoid FTBFS (LP: 1816459)
DEB_CXXFLAGS_MAINT_APPEND+=-Wno-maybe-uninitialized
endif
export DEB_CXXFLAGS_MAINT_APPEND
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- $(CMAKE_OPTS)
