diff --git a/build.sh b/build.sh index 1f3855d..d650d52 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,8 @@ #! /usr/bin/env bash +# Avoid rebuilds of the same version +[[ ! -d build ]] && exit 0 + source util.sh cd build diff --git a/configure.sh b/configure.sh index 027b21d..1aeaceb 100755 --- a/configure.sh +++ b/configure.sh @@ -3,9 +3,22 @@ source util.sh VERSION=$1 +PREFIX="$2" URL="https://ftp.gnu.org/gnu/gcc/gcc-$VERSION/gcc-$VERSION.tar.xz" ARCHIVE=$(basename "$URL") +# Avoid rebuilds of the same version + +existing_gcc="$PREFIX/bin/sh-elf-gcc" + +if [[ -f "$existing_gcc" ]]; then + existing_version=$(sh-elf-gcc --version | head -n 1 | grep -Eo '[0-9.]+$') + if [[ $existing_version == $VERSION ]]; then + echo "$TAG Version $VERSION already installed, skipping rebuild" + exit 0 + fi +fi + # Download archive if [[ -f "$ARCHIVE" ]]; then diff --git a/giteapc.make b/giteapc.make index e156289..d293f94 100644 --- a/giteapc.make +++ b/giteapc.make @@ -9,7 +9,7 @@ include giteapc-config-$(GITEAPC_CONFIG).make endif configure: - @ ./configure.sh $(VERSION) + @ ./configure.sh $(VERSION) "$(PREFIX)" build: @ ./build.sh diff --git a/install.sh b/install.sh index 5b89e3d..4600bb9 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,8 @@ #! /usr/bin/env bash +# Avoid rebuilds of the same version +[[ ! -d build ]] && exit 0 + source util.sh PREFIX="$1"