star-build

Automation tool for project installation
git clone git://git.meso-star.fr/star-build.git
Log | Files | Refs | README | LICENSE

commit b4fd240175fc0db1966cc47b39905e96fba3bef5
parent 70c9d2f46a965335a19931dbbc9fa9debf04e3fa
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue,  7 May 2024 18:34:35 +0200

Add a cache directory

Temporary resources are no longer created at the root of the star-build
directory. They are now created in a cache directory that can be
controlled by the CACHE macro. This avoids polluting the root directory
with temporary directories and files. It's also easier to remove all
temporary files by simply deleting the cache directory. In this way,
the distclean target would become obsolete and would have to be deleted
in the near future.

This commit also removes Makefile targets on build scripts. These are
artifacts of a time when the makefile was generated conditionally. This
is no longer the case since commit 35c9bb7.

Finally, this commit corrects a problem when installing a Star-Package
in parallel. Commands could be executed out of sequence.

Diffstat:
MMakefile | 6+++++-
Mconfig.mk | 7++++++-
Msrc/build.sh | 12------------
Msrc/clipper2.mk.in | 2+-
Msrc/git.mk.in | 21+++++++++++----------
Msrc/libcyaml.mk.in | 2+-
Msrc/noweb.mk.in | 12+++---------
Msrc/noweb_2.13rc3.sh | 4----
Msrc/profile.mk.in | 6++++--
Msrc/random123.mk.in | 4++--
Msrc/scdoc.mk.in | 4++--
Msrc/sleef.mk.in | 2+-
Msrc/spkg.mk.in | 31++++++++++++++++++-------------
13 files changed, 54 insertions(+), 59 deletions(-)

diff --git a/Makefile b/Makefile @@ -42,7 +42,11 @@ uninstall: makefile # Generate the Makefile of the build makefile: @echo "Setup $(MK)" - @PATH="src:$${PATH}" USE_SIMD=$(USE_SIMD) $(SHELL) $(BUILD) > $(MK) + @{ \ + printf 'CACHE = %s\n' "$(CACHE)"; \ + PATH="src:$${PATH}" USE_SIMD=$(USE_SIMD) \ + $(SHELL) "$(BUILD)"; \ + } > "$(MK)" prefix: @# store in .prefix the absolute prefix path diff --git a/config.mk b/config.mk @@ -21,7 +21,8 @@ REPO = https://gitlab.com/meso-star REPO_BIN = https://www.meso-star.com/packages/v0.4/ REPO_VAPLV = https://gitlab.com/vaplv -# Project to build. To see the available projects, list the shell scripts in +# Project to build. To see the available projects, list the shell +# scripts in # the src directory: # find src/ -name "*.sh" ! -name "build.sh" | sort BUILD = src/star-engine_0.15.sh @@ -34,3 +35,7 @@ BUILD_TYPE = RELEASE # Are SIMD instruction sets enabled? USE_SIMD = 0 + +# Cache directory, i.e. temporary directory into which temporary +# resources are downloaded and sources compiled before installation. +CACHE = ./cache diff --git a/src/build.sh b/src/build.sh @@ -36,10 +36,6 @@ git_repo() -e "s#@OPT@#${opt}#g" \ "src/git.mk.in" - # Add the template file as a prerequisite for the script invoked - # i.e. the build file - printf "%s: src/git.mk.in\n" "$0" - # Reset variables name="" url="" @@ -63,10 +59,6 @@ bin_spkg() -e "s#@PATH@#${path}#g" \ "src/spkg.mk.in" - # Add the template file as a prerequisite for the script invoked - # i.e. the build file - printf "%s: src/spkg.mk.in\n" "$0" - # Reset variables name="" url="" @@ -76,8 +68,4 @@ bin_spkg() profile() { sed -e "s#@NAME@#$1#g" "src/profile.mk.in" - - # Add the template file as a prerequisite for the script invoked - # i.e. the build file - printf "%s: src/profile.mk.in\n" "$0" } diff --git a/src/clipper2.mk.in b/src/clipper2.mk.in @@ -18,7 +18,7 @@ CLIPPER2_TAG=@TAG@ CLIPPER2_URL=https://github.com/AngusJohnson/Clipper2 # Helper macros -CLIPPER2_DIR=clipper2_$(CLIPPER2_TAG) +CLIPPER2_DIR=$(CACHE)/clipper2/$(CLIPPER2_TAG) CLIPPER2_CMAKE_OPTIONS =\ -DCMAKE_BUILD_TYPE=Release\ -DCMAKE_INSTALL_LIBDIR="lib"\ diff --git a/src/git.mk.in b/src/git.mk.in @@ -1,36 +1,37 @@ @NAME@: build_@NAME@ prefix @prefix=$$(cat .prefix) &&\ - cd -- "@NAME@_@TAG@" &&\ + cd -- "$(CACHE)/@NAME@/@TAG@" &&\ $(MAKE) PREFIX="$${prefix}" @OPT@ install # Delete the dependency file to force their regeneration. This is necessary # because the .prefix file may have been updated and therefore the dependency # files may be outdated. build_@NAME@: @DEP@ fetch_@NAME@ prefix - @cd -- "@NAME@_@TAG@" &&\ + @cd -- "$(CACHE)/@NAME@/@TAG@" &&\ rm -f $$(find src -name "*.d") &&\ $(MAKE) @OPT@ -@NAME@_@TAG@: - @git clone @URL@ $@ +$(CACHE)/@NAME@/@TAG@: + git clone @URL@ "$@" -fetch_@NAME@: @NAME@_@TAG@ - @cd -- "@NAME@_@TAG@" &&\ +fetch_@NAME@: $(CACHE)/@NAME@/@TAG@ + @cd -- "$(CACHE)/@NAME@/@TAG@" &&\ git fetch origin &&\ git checkout -B star-build &&\ git reset --hard @TAG@ clean_@NAME@: - @if [ -d @NAME@_@TAG@ ]; then\ - cd -- "@NAME@_@TAG@" && $(MAKE) clean;\ + @if [ -d "$(CACHE)/@NAME@/@TAG@" ]; then\ + cd -- "$(CACHE)/@NAME@/@TAG@" && $(MAKE) clean;\ fi uninstall_@NAME@: fetch_@NAME@ prefix @prefix=$$(cat .prefix) &&\ - cd -- "@NAME@_@TAG@" && $(MAKE) PREFIX="$${prefix}" uninstall + cd -- "$(CACHE)/@NAME@/@TAG@" && \ + $(MAKE) PREFIX="$${prefix}" uninstall distclean_@NAME@: - rm -rf @NAME@_@TAG@ + rm -rf "$(CACHE)/@NAME@/@TAG@" clean_all: clean_@NAME@ distclean_all: distclean_@NAME@ diff --git a/src/libcyaml.mk.in b/src/libcyaml.mk.in @@ -18,7 +18,7 @@ LIBCYAML_TAG=@TAG@ LIBCYAML_URL=https://github.com/tlsa/libcyaml # Helper macros -LIBCYAML_DIR=libcyaml_$(LIBCYAML_TAG) +LIBCYAML_DIR=$(CACHE)/libcyaml/$(LIBCYAML_TAG) libcyaml: build_libcyaml @prefix="$$(cat .prefix)" && \ diff --git a/src/noweb.mk.in b/src/noweb.mk.in @@ -18,7 +18,7 @@ NOWEB_TAG=@TAG@ NOWEB_URL=https://github.com/nrnrnr/noweb # Helper macros -NOWEB_DIR=noweb_$(NOWEB_TAG) +NOWEB_DIR=$(CACHE)/noweb/$(NOWEB_TAG) NOWEB_MAKE=$(MAKE)\ BIN="$${prefix}/bin"\ LIB="$${prefix}/lib"\ @@ -31,7 +31,7 @@ noweb: build_noweb cd -- "$(NOWEB_DIR)/src" &&\ $(NOWEB_MAKE) install -build_noweb: fetch_noweb prefix +build_noweb: $(NOWEB_DIR) prefix @prefix=$$(cat .prefix) &&\ cd -- "$(NOWEB_DIR)/src" &&\ ./awkname awk &&\ @@ -39,13 +39,7 @@ build_noweb: fetch_noweb prefix $(NOWEB_MAKE) all $(NOWEB_DIR): - @git clone $(NOWEB_URL) "$@" - -fetch_noweb: $(NOWEB_DIR) - @cd -- "$(NOWEB_DIR)" &&\ - git fetch origin &&\ - git checkout -B star-build &&\ - git reset --hard $(NOWEB_TAG) + @git clone --branch "$(NOWEB_TAG)" --depth 1 "$(NOWEB_URL)" "$@" clean_noweb: if [ -d "$(NOWEB_DIR)/src" ]; then\ diff --git a/src/noweb_2.13rc3.sh b/src/noweb_2.13rc3.sh @@ -23,7 +23,3 @@ export NOWEB_SH=1 tag=v2_13rc3 sed "s/@TAG@/${tag}/" "src/noweb.mk.in" - -# Add the template file as a prerequisite for the script invoked -# i.e. the build file -printf "%s: src/noweb.mk.in\n" "$0" diff --git a/src/profile.mk.in b/src/profile.mk.in @@ -1,9 +1,11 @@ -@NAME@: src/build.profile.in prefix +@NAME@: $(CACHE)/@NAME@ + +$(CACHE)/@NAME@: src/build.profile.in prefix sed "s#@PREFIX@#$$(cat .prefix)#g" src/build.profile.in > $@ install_@NAME@: @NAME@ mkdir -p "$$(cat .prefix)/etc" - cp @NAME@ "$$(cat .prefix)/etc" + cp $(CACHE)/@NAME@ "$$(cat .prefix)/etc" uninstall_@NAME@: prefix rm -f "$$(cat .prefix)/etc/@NAME@" diff --git a/src/random123.mk.in b/src/random123.mk.in @@ -19,7 +19,7 @@ RANDOM123_TAG=@TAG@ RANDOM123_URL=https://github.com/DEShawResearch/random123 # Helper macros -RANDOM123_DIR=random123_$(RANDOM123_TAG) +RANDOM123_DIR=$(CACHE)/random123/$(RANDOM123_TAG) random123: $(RANDOM123_DIR) $(RANDOM123_DIR)/random123.pc.in prefix="$$(cat .prefix)" && \ @@ -77,7 +77,7 @@ uninstall_random123: rm -f "$${prefix}/share/doc/Random123/LICENSE" distclean_random123: - rm -rf random123_$(RANDOM123_TAG) + rm -rf "$(RANDOM123_DIR)" distclean_all: distclean_random123 install_all: random123 diff --git a/src/scdoc.mk.in b/src/scdoc.mk.in @@ -18,7 +18,7 @@ SCDOC_TAG = @TAG@ SCDOC_URL = https://git.sr.ht/~sircmpwn/scdoc # Helper macros -SCDOC_DIR = scdoc/$(SCDOC_TAG) +SCDOC_DIR = $(CACHE)/scdoc/$(SCDOC_TAG) scdoc: build_scdoc @prefix=$$(cat .prefix) && \ @@ -46,7 +46,7 @@ uninstall_scdoc: fetch_scdoc prefix cd -- "$(SCDOC_DIR)" && $(MAKE) PREFIX="$${prefix}" uninstall distclean_scdoc: - rm -rf scdoc + rm -rf "$(SCDOC_DIR)" clean_all: clean_scdoc distclean_all: distclean_scdoc diff --git a/src/sleef.mk.in b/src/sleef.mk.in @@ -18,7 +18,7 @@ SLEEF_TAG = @TAG@ SLEEF_URL = https://github.com/shibatch/sleef # Helper macros -SLEEF_DIR = sleef_$(SLEEF_TAG) +SLEEF_DIR = $(CACHE)/sleef/$(SLEEF_TAG) SLEEF_CMAKE_OPTIONS =\ -G "Unix Makefiles"\ -DBUILD_TESTS=OFF\ diff --git a/src/spkg.mk.in b/src/spkg.mk.in @@ -1,20 +1,25 @@ -@NAME@: @ARCH@.tgz @ARCH@.sha512sum prefix - @if ! sha512sum -c @ARCH@.sha512sum; then \ - rm -f @ARCH@.tgz; \ - rm -f @ARCH@.sha512sum; \ - >&2 printf "ERROR: %s was corrupted and therefore deleted.\n" @ARCH@.tgz; \ +@NAME@: $(CACHE)/@ARCH@.tgz $(CACHE)/@ARCH@.sha512sum prefix + @prefix="$$(cat .prefix)"; \ + cd -- "$(CACHE)"; \ + if ! sha512sum -c "@ARCH@.sha512sum"; then \ + rm -f "@ARCH@.tgz"; \ + rm -f "@ARCH@.sha512sum"; \ + >&2 printf "ERROR: %s was corrupted and therefore deleted.\n" "$(CACHE)/@ARCH@.tgz"; \ >&2 printf "Try rerunning make\n"; \ exit 1; \ - fi - @if ! cmp @ARCH@.sha512sum "$$(cat .prefix)/share/spkg/@ARCH@.sha512sum" \ + fi; \ + if ! cmp "@ARCH@.sha512sum" "$${prefix}/share/spkg/@ARCH@.sha512sum" \ > /dev/null 2>&1; then \ - tar -xvf @ARCH@.tgz -C $$(cat .prefix); \ - $(SHELL) "$$(cat .prefix)/share/spkg/@NAME@.sh" install "$$(cat .prefix)"; \ - cp @ARCH@.sha512sum "$$(cat .prefix)/share/spkg/"; \ + tar -xvf "@ARCH@.tgz" -C "$${prefix}"; \ + $(SHELL) "$${prefix}/share/spkg/@NAME@.sh" install "$${prefix}"; \ + cp "@ARCH@.sha512sum" "$${prefix}/share/spkg/"; \ fi -@ARCH@.sha512sum @ARCH@.tgz: - curl --fail --retry 3 -O "@PATH@/$@" +$(CACHE)/@ARCH@.tgz: + curl --fail --retry 3 -o $@ "@PATH@/@ARCH@.tgz" + +$(CACHE)/@ARCH@.sha512sum: + curl --fail --retry 3 -o $@ "@PATH@/@ARCH@.sha512sum" uninstall_@NAME@: prefix if [ -f "$$(cat .prefix)/share/spkg/@NAME@.sh" ]; then \ @@ -23,7 +28,7 @@ uninstall_@NAME@: prefix rm -f "$$(cat .prefix)/share/spkg/@ARCH@.sha512sum" distclean_@NAME@: - rm -rf @ARCH@.tgz @ARCH@.sha512sum + rm -rf "$(CACHE)/@ARCH@.tgz" "$(CACHE)/@ARCH@.sha512sum" distclean_all: distclean_@NAME@ install_all: @NAME@