#!/usr/bin/make -f

export CC=gcc-15
export CXX=g++-15

%:
	dh $@ --parallel

override_dh_auto_configure:
	dh_auto_configure \
	  --buildsystem=cmake+ninja -- \
	  -DCMAKE_CXX_STANDARD=23 \
	  -DMAYAFLUX_SHIP_DEV=ON

override_dh_auto_build-arch:
	dh_auto_build

override_dh_auto_build-indep:
	doxygen doxyconf

override_dh_auto_test:
	:

override_dh_shlibdeps:
	dh_shlibdeps -l$(CURDIR)/debian/mayaflux-edge/usr/lib -- -xmayaflux-edge

override_dh_auto_install:
	dh_auto_install
	install -d debian/mayaflux-edge/etc/profile.d
	printf '#!/bin/sh\nexport MAYAFLUX_ROOT="/usr"\nexport CMAKE_PREFIX_PATH="/usr:$${CMAKE_PREFIX_PATH}"\nexport PATH="/usr/lib/llvm-21/bin:$${PATH}"\n' > debian/mayaflux-edge/etc/profile.d/mayaflux.sh
	chmod 755 debian/mayaflux-edge/etc/profile.d/mayaflux.sh
	install -d debian/mayaflux-edge/etc/security/limits.d
	printf '@mayaflux\t-\trtprio\t\t95\n@mayaflux\t-\tmemlock\tunlimited\n@mayaflux\t-\tnice\t\t-19\n' \
	  > debian/mayaflux-edge/etc/security/limits.d/50-mayaflux.conf

	install -d debian/mayaflux-edge-doc/usr/share/doc/mayaflux-edge/html
	if [ -d docs/html ]; then \
	  cp -r docs/html/* debian/mayaflux-edge-doc/usr/share/doc/mayaflux-edge/html/; \
	fi

override_dh_auto_clean:
	dh_auto_clean
	rm -rf docs/html
