#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_OPTIONS += noautodbgsym
export DEB_BUILD_MAINT_OPTIONS=optimize=-lto

include /usr/share/dpkg/architecture.mk
JOBS = -j$(shell nproc --ignore=1)

%:
	dh $@

override_dh_auto_clean:
	$(MAKE) distclean
	dh_auto_clean

override_dh_auto_configure:
	$(MAKE) features

override_dh_auto_build:
ifeq ($(DEB_BUILD_ARCH),amd64)
	$(MAKE) ${JOBS} posix64 wine64
	env CPPFLAGS= CFLAGS= CXXFLAGS= LDFLAGS= \
		$(MAKE) ${JOBS} win64 plugin-wine \
			AR=x86_64-w64-mingw32-ar CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++
endif
ifeq ($(DEB_BUILD_ARCH),i386)
	$(MAKE) ${JOBS} posix32 wine32
	env CPPFLAGS= CFLAGS= CXXFLAGS= LDFLAGS= \
		$(MAKE) ${JOBS} win32 plugin-wine \
			AR=i686-w64-mingw32-ar CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++
endif

override_dh_auto_install:
