#!/usr/bin/make -f
#export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all


# Both llama.cpp and the ggml it depends on are private for now
RPATH=/usr/lib/$(DEB_HOST_MULTIARCH)/ggml:/usr/lib/$(DEB_HOST_MULTIARCH)/llama.cpp

CMAKE_FLAGS = -DCMAKE_INSTALL_RPATH=$(RPATH) \
              -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=OFF \
	      -DCMAKE_BUILD_TYPE=RelWithDebInfo \
	      -DCMAKE_PREFIX_PATH=/usr/lib/$(DEB_HOST_MULTIARCH)/ggml/cmake-private \
	      -DLLAMA_USE_SYSTEM_GGML=ON


%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure -- $(CMAKE_FLAGS)

# No tests for now, as many need some kind of model we don't have
override_dh_auto_test:
	:

override_dh_auto_install:
	# We want this in debian/tmp, even though it's a single package
	dh_auto_install --destdir=debian/tmp
	mkdir -p debian/tmp/usr/bin
	mv debian/tmp/usr/bin/convert_hf_to_gguf.py debian/tmp/usr/bin/convert_hf_to_gguf

execute_after_dh_auto_clean:
	rm -f common/build-info.cpp
