#!/usr/bin/make -f

SOVERSION = 0

include /usr/share/dpkg/architecture.mk

# ignore symbol mismatches on non-amd64, C++ symbols change too often
ifneq ($(DEB_HOST_ARCH),amd64)
export DPKG_GENSYMBOLS_CHECK_LEVEL = 0
endif

# ignore test failure on i386, the failure doesn't affect the actual library (TODO: fix this)
ifeq ($(DEB_HOST_ARCH),i386)
I = -
endif

override_dh_auto_clean:
	$(MAKE) -C src -f Makefiles/Makefile_linux_shared clean
	$(MAKE) -C examples -f Makefiles/Makefile_linux clean
	rm -f examples/*.o examples/libdds.so

override_dh_auto_build:
	dh_auto_build --buildsystem=makefile --sourcedirectory=src -- -f Makefiles/Makefile_linux_shared

override_dh_auto_test:
ifeq (, $(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	ln -sf ../src/libdds.so.$(SOVERSION) examples/libdds.so
	$(MAKE) -C examples -f Makefiles/Makefile_linux DealerPar
	$(I)LD_LIBRARY_PATH=src examples/DealerPar
endif

override_dh_auto_install:
	install -m644 -D src/libdds.so.$(SOVERSION) debian/libdds$(SOVERSION)/usr/lib/$(DEB_HOST_MULTIARCH)/libdds.so.$(SOVERSION)
	install -d debian/libdds-dev/usr/lib/$(DEB_HOST_MULTIARCH)
	ln -s libdds.so.$(SOVERSION) debian/libdds-dev/usr/lib/$(DEB_HOST_MULTIARCH)/libdds.so

%:
	dh $@
