#!/usr/bin/make -f

# Full RELRO in addition to the default hardening flags.
export DEB_BUILD_MAINT_OPTIONS := hardening=+bindnow

# Nearly everything is built by nested CMake projects started through
# ExternalProject_Add(). They are configured while the build step runs, that
# is after dh_auto_configure, where debhelper folds CPPFLAGS into
# CFLAGS/CXXFLAGS. CMake itself ignores CPPFLAGS (see #653916), so without
# this the hardening flags would be missing from every nested project.
export CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
export CFLAGS := $(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS)
export CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) $(CPPFLAGS)
# The bindnow flag lives in LDFLAGS, which the nested projects need as well.
export LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)

%:
	dh $@


override_dh_auto_configure:
	dh_auto_configure -- \
	-DTRITON_ENABLE_GPU=OFF \
	-DTRITON_ENABLE_METRICS_GPU=OFF \
	-DTRITON_ENABLE_SERVER=ON \
	-DTRITON_ENABLE_CLIENT=ON \
	-DTRITON_ENABLE_CC_HTTP=ON \
	-DTRITON_ENABLE_CC_GRPC=ON \
	-DTRITON_ENABLE_EXAMPLES=OFF \
	-DTRITON_ENABLE_TESTS=OFF \
	-DTRITON_ENABLE_PYTHON_BACKEND=ON \
	-DTRITON_ENABLE_ENSEMBLE=ON \
	-DCMAKE_LIBRARY_ARCHITECTURE=$(DEB_HOST_MULTIARCH)

#override_dh_auto_build:
#	cd obj-x86_64-linux-gnu && make -j16 "INSTALL=install --strip-program=true" VERBOSE=1

override_dh_shlibdeps:
	dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
