#!/usr/bin/make -f

export DESTDIR := $(CURDIR)/debian/tmp
export CLIENT_SAMPLES_DIR := $(DESTDIR)/usr/share/doc/orthanc/OrthancClientSamples

%:
	dh $@ --parallel --builddirectory=Build

CMAKE_EXTRA_FLAGS += \
	-DCMAKE_SKIP_RPATH=ON \
	-DSTATIC_BUILD:BOOL=OFF \
	-DSTANDALONE_BUILD:BOOL=ON \
	-DUSE_SYSTEM_MONGOOSE:BOOL=OFF \
	-DUSE_GTEST_DEBIAN_SOURCE_PACKAGE:BOOL=ON \
	-DDCMTK_DICTIONARY_DIR:PATH=/usr/share/libdcmtk2 \
	-DCMAKE_BUILD_TYPE=""   # The build type must be left empty, see #711515

override_dh_auto_configure:
        # Put 3rd party packages where the cmake build system expects them
	mkdir -p ThirdPartyDownloads
	( cd ThirdPartyDownloads; cp ../debian/ThirdPartyDownloads/* . )
	dh_auto_configure -- $(CMAKE_EXTRA_FLAGS)

override_dh_auto_test:
	( cd Build; ./UnitTests )

override_dh_clean:
	rm -rf ThirdPartyDownloads
	dh_clean

override_dh_auto_install:
        # Move the samples of the Orthanc Client
	mkdir -p $(CLIENT_SAMPLES_DIR)
	cp -r Resources/Samples/OrthancClient/* $(CLIENT_SAMPLES_DIR)

	dh_auto_install

        # Move the Orthanc binaries to "/usr/sbin"
	dh_install Build/Orthanc usr/sbin

override_dh_installchangelogs:
	dh_installchangelogs -k NEWS

get-orig-source:
	uscan --verbose --force-download --rename
