commit 70cb88141afa420a4460eca93b150416eeb1b382
parent c6cf1d210db6476a86122c0340e988da50a5e387
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 18 Jul 2024 17:46:08 +0200
Merge branch 'feature_offline_build'
Diffstat:
7 files changed, 85 insertions(+), 14 deletions(-)
diff --git a/Makefile b/Makefile
@@ -26,24 +26,27 @@ install: makefile prefix
PATH="$${prefix}/bin:$${PATH}" \
PKG_CONFIG_PATH="$${prefix}/lib/pkgconfig:$${PKG_CONFIG_PATH}" \
TEXINPUTS="$${prefix}/share/tex:$${TEXINPUTS}" \
- $(MAKE) -f $(MK) -f Makefile install_all
+ $(MAKE) -f Makefile -f $(MK) install_all
clean: makefile
- @$(MAKE) -f $(MK) -f Makefile clean_all
+ @$(MAKE) -f Makefile -f $(MK) clean_all
rm -rf .prefix $(MK)
distclean: makefile
- @$(MAKE) -f $(MK) -f Makefile distclean_all
+ @$(MAKE) -f Makefile -f $(MK) distclean_all
rm -rf .prefix src/*.sh.mk
uninstall: makefile
- @$(MAKE) -f $(MK) -f Makefile uninstall_all
+ @$(MAKE) -f Makefile -f $(MK) uninstall_all
+
+mirror: makefile
+ mkdir -p "$(MIRROR)"
+ @$(MAKE) -f Makefile -f $(MK) mirror_all
# Generate the Makefile of the build
makefile: cache
@echo "Setup $(MK)"
@{ \
- printf 'CACHE = %s\n' "$(CACHE)"; \
PATH="src:$${PATH}" USE_SIMD=$(USE_SIMD) \
$(SHELL) "$(BUILD)"; \
} > "$(MK)"
diff --git a/config.mk b/config.mk
@@ -39,7 +39,35 @@ CACHE = ./cache
# download archives of precompiled binaries.
CURL_OPT = --fail --retry 3
-# List of repositories
-REPO = https://gitlab.com/meso-star
-REPO_BIN = https://www.meso-star.com/packages/v0.4/
-REPO_VAPLV = https://gitlab.com/vaplv
+# Define the state of the network, either ONLINE or OFFLINE.
+# If the network is OFFLINE, the sources and precompiled binaries are
+# retrieved from the local MIRROR directory, which must therefore
+# contain the expected data. To do this, simply run the 'mirror' target
+# to download the source repositories and binary packages locally:
+#
+# make NETWORK=ONLINE mirror
+#
+NETWORK = ONLINE
+
+# Directory in which to download the data required for offline
+# build of the project (see the NETWORK macro)
+MIRROR = ./mirror
+
+# Option passed to git when cloning a repository to make it a local
+# mirror
+MIRROR_GIT_OPT = --depth 1
+
+# URLs for online repositories
+REPO_ONLINE = https://gitlab.com/meso-star
+REPO_BIN_ONLINE = https://www.meso-star.com/packages/v0.4/
+REPO_VAPLV_ONLINE = https://gitlab.com/vaplv
+
+# URLs for offline repositories
+REPO_OFFLINE = $(MIRROR)
+REPO_BIN_OFFLINE = "file://$$(pwd)/$(MIRROR)"
+REPO_VAPLV_OFFLINE = $(MIRROR)
+
+# List of repositories to use depending on the state of the network
+REPO = $(REPO_$(NETWORK))
+REPO_BIN = $(REPO_BIN_$(NETWORK))
+REPO_VAPLV = $(REPO_VAPLV_$(NETWORK))
diff --git a/src/clipper2.mk.in b/src/clipper2.mk.in
@@ -15,7 +15,9 @@
# Configuration macros
CLIPPER2_TAG=@TAG@
-CLIPPER2_URL=https://github.com/AngusJohnson/Clipper2
+CLIPPER2_URL_ONLINE = https://github.com/AngusJohnson/Clipper2
+CLIPPER2_URL_OFFLINE = $(MIRROR)/Clipper2
+CLIPPER2_URL = $(CLIPPER2_URL_$(NETWORK))
# Helper macros
CLIPPER2_DIR=$(CACHE)/clipper2/$(CLIPPER2_TAG)
@@ -71,7 +73,15 @@ uninstall_clipper2:
distclean_clipper2:
rm -rf "$(CLIPPER2_DIR)"
+mirror_clipper2:
+ repo="$$(echo "$(CLIPPER2_URL)" | sed 's/[\/]\{0,\}$$//g')" && \
+ repo="$(MIRROR)/$${repo##*/}" && \
+ rm -rf "$${repo}" && \
+ git clone --bare --branch "$(CLIPPER2_TAG)" $(MIRROR_GIT_OPT) \
+ $(CLIPPER2_URL) "$${repo}"
+
clean_all: clean_clipper2
distclean_all: distclean_clipper2
install_all: clipper2
uninstall_all: uninstall_clipper2
+mirror_all: mirror_clipper2
diff --git a/src/git.mk.in b/src/git.mk.in
@@ -33,7 +33,14 @@ uninstall_@NAME@: fetch_@NAME@ prefix
distclean_@NAME@:
rm -rf "$(CACHE)/@NAME@/@TAG@"
+mirror_@NAME@:
+ repo="$$(echo "@URL@" | sed 's/[\/]\{0,\}$$//g')" && \
+ repo="$(MIRROR)/$${repo##*/}" && \
+ rm -rf "$${repo}" && \
+ git clone --bare --branch @TAG@ $(MIRROR_GIT_OPT) @URL@ "$${repo}"
+
clean_all: clean_@NAME@
distclean_all: distclean_@NAME@
install_all: @NAME@
uninstall_all: uninstall_@NAME@
+mirror_all: mirror_@NAME@
diff --git a/src/libcyaml.mk.in b/src/libcyaml.mk.in
@@ -15,7 +15,9 @@
# Configuration macros
LIBCYAML_TAG=@TAG@
-LIBCYAML_URL=https://github.com/tlsa/libcyaml
+LIBCYAML_URL_ONLINE = https://github.com/tlsa/libcyaml
+LIBCYAML_URL_OFFLINE = $(MIRROR)/libcyaml
+LIBCYAML_URL = $(LIBCYAML_URL_$(NETWORK))
# Helper macros
LIBCYAML_DIR=$(CACHE)/libcyaml/$(LIBCYAML_TAG)
@@ -47,7 +49,15 @@ uninstall_libcyaml:
distclean_libcyaml:
rm -rf "$(LIBCYAML_DIR)"
+mirror_libcyaml:
+ repo="$$(echo "$(LIBCYAML_URL)" | sed 's/[\/]\{0,\}$$//g')" && \
+ repo="$(MIRROR)/$${repo##*/}" && \
+ rm -rf "$${repo}" && \
+ git clone --bare --branch "$(LIBCYAML_TAG)" $(MIRROR_GIT_OPT) \
+ $(LIBCYAML_URL) "$${repo}"
+
clean_all: clean_libcyaml
distclean_all: distclean_libcyaml
install_all: libcyaml
uninstall_all: uninstall_libcyaml
+mirror_all: mirror_libcyaml
diff --git a/src/random123.mk.in b/src/random123.mk.in
@@ -16,7 +16,9 @@
# Configuration macros
RANDOM123_VERSION=@VERSION@
RANDOM123_TAG=@TAG@
-RANDOM123_URL=https://github.com/DEShawResearch/random123
+RANDOM123_URL_ONLINE=https://github.com/DEShawResearch/random123
+RANDOM123_URL_OFFLINE=$(MIRROR)/random123
+RANDOM123_URL = $(RANDOM123_URL_$(NETWORK))
# Helper macros
RANDOM123_DIR=$(CACHE)/random123/$(RANDOM123_TAG)
@@ -79,6 +81,14 @@ uninstall_random123: prefix
distclean_random123:
rm -rf "$(RANDOM123_DIR)"
+mirror_random123:
+ repo="$$(echo "$(RANDOM123_URL)" | sed 's/[\/]\{0,\}$$//g')" && \
+ repo="$(MIRROR)/$${repo##*/}" && \
+ rm -rf "$${repo}" && \
+ git clone --bare --branch "$(RANDOM123_TAG)" $(MIRROR_GIT_OPT) \
+ $(RANDOM123_URL) "$${repo}"
+
distclean_all: distclean_random123
install_all: random123
uninstall_all: uninstall_random123
+mirror_all: mirror_random123
diff --git a/src/spkg.mk.in b/src/spkg.mk.in
@@ -15,10 +15,10 @@
cp "@ARCH@.sha512sum" "$${prefix}/share/spkg/"; \
fi
-$(CACHE)/@ARCH@.tgz:
+$(CACHE)/@ARCH@.tgz $(MIRROR)/@ARCH@.tgz:
curl $(CURL_OPT) -o $@ "@PATH@/@ARCH@.tgz"
-$(CACHE)/@ARCH@.sha512sum:
+$(CACHE)/@ARCH@.sha512sum $(MIRROR)/@ARCH@.sha512sum:
curl $(CURL_OPT) -o $@ "@PATH@/@ARCH@.sha512sum"
uninstall_@NAME@: prefix
@@ -30,6 +30,9 @@ uninstall_@NAME@: prefix
distclean_@NAME@:
rm -rf "$(CACHE)/@ARCH@.tgz" "$(CACHE)/@ARCH@.sha512sum"
+mirror_@NAME@: $(MIRROR)/@ARCH@.tgz $(MIRROR)/@ARCH@.sha512sum
+
distclean_all: distclean_@NAME@
install_all: @NAME@
uninstall_all: uninstall_@NAME@
+mirror_all: mirror_@NAME@