#!/usr/bin/make -f
#export DH_VERBOSE = 1

# see FEATURE AREAS in dpkg-buildflags(1)
# Disabling -Werror=format-security because it stops the build: the logger indeed has this weakness.
export DEB_BUILD_MAINT_OPTIONS=hardening=-format,+bindnow reproducible=+all
# export DEB_CXXFLAGS_MAINT_APPEND += -std=gnu++14

export QT_SELECT=qt5


DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

include /usr/share/dpkg/pkg-info.mk

%:
	dh $@

# Force using system libs where possible
# and, produce a file containing the version, instead of using compile date.
override_dh_auto_configure:
	dh_auto_configure -- \
	                     -DMESHLAB_ALLOW_BUNDLED_SOURCE_GLEW=OFF\
	                     -DMESHLAB_ALLOW_BUNDLED_EIGEN=OFF \
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_BOOST=OFF\
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_CGAL=OFF\
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_LIBE57=OFF\
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_EMBREE=OFF\
	                     -DMESHLAB_ALLOW_DOWNLOAD_DLL_EMBREE=OFF\
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_LEVMAR=OFF\
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_LIB3DS=OFF \
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_LIB3MF=OFF \
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_LIBIGL=OFF \
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_MUPARSER=OFF \
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_NEXUS=OFF \
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_OPENCTM=OFF \
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_QHULL=OFF \
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_STRUCTURE_SYNTH=OFF \
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_TINYGLTF=OFF \
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_U3D=OFF \
	                     -DMESHLAB_ALLOW_DOWNLOAD_SOURCE_XERCES=OFF

# Make plugins only "recommends"
override_dh_shlibdeps:
	dh_shlibdeps -l$(shell pwd)/debian/meshlab/usr/lib/$(DEB_HOST_MULTIARCH)/meshlab/ -Xplugins
	dh_shlibdeps -l$(shell pwd)/debian/meshlab/usr/lib/$(DEB_HOST_MULTIARCH)/meshlab/ -Xbin -Xmeshlab-common -- -ppluginshlibs -dRecommends
