--- /dev/null
- # Multiarch pkgconfig
- mkdir -p $(install_lib_multiarch)/pkgconfig
- mv $(install_lib)/pkgconfig/*.pc $(install_lib_multiarch)/pkgconfig
-
+#!/usr/bin/make -f
+# See debhelper(7) (uncomment to enable)
+#export DH_VERBOSE = 1
+
+# multiarch
+include /usr/share/dpkg/architecture.mk
+
+build_multiarch=build/$(DEB_HOST_MULTIARCH)
+install_bin=debian/tmp/usr/bin
+install_lib=debian/tmp/usr/lib
+install_lib_multiarch=debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)
+install_libexec_multiarch=debian/tmp/usr/libexec/$(DEB_HOST_MULTIARCH)
+
+# parallelism
+DEB_BUILD_OPTIONS ?= parallel=8
+
+%:
+# Use build/ for output, so that it is in the .gitignore of upstream
+ dh $@ --buildsystem=cmake --builddirectory=$(build_multiarch)
+
+# FIXME we disable LLAMA_ALL_WARNINGS so that ggml_get_flags() CMake function do not get called
+# as it is available deep in GGML build scripts and not published
+override_dh_auto_configure:
+ dh_auto_configure -- \
+ -DCMAKE_LIBRARY_ARCHITECTURE="$(DEB_HOST_MULTIARCH)" \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_PROJECT_llama.cpp_INCLUDE=debian/cmake/debian-llama.cpp.cmake \
+ -DBUILD_SHARED_LIBS=ON \
+ -DGGML_BACKEND_DL=ON \
+ -DLLAMA_ALL_WARNINGS=OFF \
+ -DLLAMA_BUILD_TESTS=OFF \
+ -DLLAMA_BUILD_SERVER=ON \
+ -DLLAMA_CURL=ON \
+ -DLLAMA_SERVER_SSL=ON \
+
+override_dh_auto_install:
+ dh_auto_install
+
+ # Move executables to libexec, so that they can load the GGML backends
+ # and link them to bin
+ mkdir -p $(install_libexec_multiarch)/ggml
+ for file in $(install_bin)/llama-*; do \
+ mv $$file $(install_libexec_multiarch)/ggml/$$(basename "$$file"); \
+ ln -s --relative -t $(install_bin) $(install_libexec_multiarch)/ggml/$$(basename "$$file"); \
+ done
+
+override_dh_auto_test:
+ # tests which depends on remote location are failing
+ dh_auto_test || true