diff --git a/contrib/src/main.mak b/contrib/src/main.mak
index 28c1701950a063875ac97917e3987e19ff2ed1de..b04f0017177647a47dff4eee8d5b614427ad2a5f 100644
--- a/contrib/src/main.mak
+++ b/contrib/src/main.mak
@@ -326,6 +326,10 @@ HOSTVARS := $(HOSTTOOLS) \
 	CXXFLAGS="$(CXXFLAGS) $(PIC)" \
 	LDFLAGS="$(LDFLAGS)"
 
+# git_download procedure
+# $1: The URL of the Git repository.
+# $2: The remote branch to clone.
+# $3: The git refspec to checkout.
 ifeq ($(DISABLE_CONTRIB_DOWNLOADS),TRUE)
 download_git = $(error Trying to clone $(1) but DISABLE_CONTRIB_DOWNLOADS is TRUE, aborting.)
 else
diff --git a/contrib/src/onnx/rules.mak b/contrib/src/onnx/rules.mak
index 2d7b57de8b444ce1d89d295328262d773e34cf1e..513c9a453bb3a82dbaf31448a465e6443088e085 100644
--- a/contrib/src/onnx/rules.mak
+++ b/contrib/src/onnx/rules.mak
@@ -3,10 +3,7 @@ ONNX_VERSION := v1.6.0
 ONNX_URL := https://github.com/microsoft/onnxruntime.git
 
 $(TARBALLS)/onnxruntime-$(ONNX_VERSION).tar.xz:
-	git clone $(ONNX_URL) ../../contrib/tarballs/onnxruntime-$(ONNX_VERSION)
-	cd ../../contrib/tarballs/onnxruntime-$(ONNX_VERSION) && git checkout $(ONNX_VERSION)
-	cd ../../contrib/tarballs/ && tar cJf onnxruntime-$(ONNX_VERSION).tar.xz onnxruntime-$(ONNX_VERSION)
-	rm -Rf ../../contrib/tarballs/onnxruntime-v1.6.0
+	$(call download_git,$(ONNX_URL),master,$(ONNX_VERSION))
 
 .sum-onnx: onnxruntime-$(ONNX_VERSION).tar.xz
 	$(warning $@ not implemented)