--- /dev/null
+
+GGML_CHECKOUT=323951f
+LLAMA_CPP_CHECKOUT=f08c4c0
+
+GGML_BASE=sources/ggml
+
+update-ggml:
+ # switch to upstream branches and tag a commit
+ git -C $(GGML_BASE) switch master
+ git -C $(GGML_BASE) pull --tags github master
+ git -C $(GGML_BASE) switch upstream/latest
+ git -C $(GGML_BASE) pull --tags github master
+
+ $(eval GGML_BUILD_NUMBER = $(shell git -C $(GGML_BASE) rev-list --count $(GGML_CHECKOUT)))
+ @echo "GGML_BUILD_NUMBER=$(GGML_BUILD_NUMBER)"
+ git -C $(GGML_BASE) tag -a -m "Pinned upstream commit" upstream/0.0.$(GGML_BUILD_NUMBER) $(GGML_CHECKOUT)
+
+ # Import patches before merging
+ git -C $(GGML_BASE) switch debian/latest
+ cd $(GGML_BASE) && gbp pq import
+
+ # Merges
+ git -C $(GGML_BASE) switch debian/latest
+ git -C $(GGML_BASE) merge --no-edit upstream/0.0.$(GGML_BUILD_NUMBER)
+
+ git -C $(GGML_BASE) switch patch-queue/debian/latest
+ git -C $(GGML_BASE) merge --no-edit debian/latest
+
+ # Rebase patches
+ cd $(GGML_BASE) && gbp pq rebase
+ cd $(GGML_BASE) && gbp pq export --drop
+
+ # Generate changelog
+ echo "ggml (0.0.$(GGML_BUILD_NUMBER)-1) unstable; urgency=medium" > $(GGML_BASE)/debian/changelog
+ echo "" >> $(GGML_BASE)/debian/changelog
+ echo " * Update upstream" >> $(GGML_BASE)/debian/changelog
+ echo "" >> $(GGML_BASE)/debian/changelog
+ echo " Closes: #1096105" >> $(GGML_BASE)/debian/changelog
+ echo "" >> $(GGML_BASE)/debian/changelog
+ echo " -- Mathieu Baudier <mbaudier@argeo.org> $(shell date --utc '+%a, %d %b %+4Y %T %z')" >> $(GGML_BASE)/debian/changelog
+
+ git commit -m "Update upstream"
+