From bacfe127c4b98b9b98f8bf2317022c197e77402b Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:30:16 +1200 Subject: [PATCH] Makefile: Add wget-abc target `make wget-abc` will attempt to download abc release archive for most recent yosys tag. This should provide a solution when downloading yosys from release tarballs. May have issues if executing in a non-git repository state on a development version if an updated abc version is expected. --- Makefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Makefile b/Makefile index bd95cd132..58a07cc85 100644 --- a/Makefile +++ b/Makefile @@ -790,11 +790,29 @@ check-git-abc: echo "3. Initialize the submodule: Run 'git submodule update --init' to set up 'abc' as a submodule."; \ echo "4. Reapply your changes: Move your saved changes back to the 'abc' directory, if necessary."; \ exit 1; \ + elif git status 2>&1 | grep 'fatal: not a git repository'; then \ + echo "Did 'yosys' come from a release tarball? Try call 'make wget-abc' to download matching 'abc' tarball."; \ + exit 1; \ else \ echo "Initialize the submodule: Run 'git submodule update --init' to set up 'abc' as a submodule."; \ exit 1; \ fi +.PHONY: wget-abc +ABC_TAR := abc.tar.gz +YOSYS_TAG := $(word 1,$(subst +, ,$(YOSYS_VER))) +ABC_TAR_URL := https://github.com/YosysHQ/yosys/releases/download/yosys-$(YOSYS_TAG)/$(ABC_TAR) +wget-abc: + @if [ -z "$$(find abc -type d -prune -empty 2>&1)" ]; then \ + echo "Error: The 'abc' directory already has contents. Clear 'abc' directory before continuing."; \ + exit 1; \ + else \ + mkdir -p abc; \ + wget -nc "$(ABC_TAR_URL)"; \ + echo "Extracting '$(ABC_TAR)' contents."; \ + tar xzf $(ABC_TAR) -C abc --strip-components=1; \ + fi + abc/abc$(EXE) abc/libabc.a: check-git-abc $(P) $(Q) mkdir -p abc && $(MAKE) -C $(PROGRAM_PREFIX)abc -f "$(realpath $(YOSYS_SRC)/abc/Makefile)" ABCSRC="$(realpath $(YOSYS_SRC)/abc/)" $(S) $(ABCMKARGS) $(if $(filter %.a,$@),PROG="abc",PROG="abc$(EXE)") MSG_PREFIX="$(eval P_OFFSET = 5)$(call P_SHOW)$(eval P_OFFSET = 10) ABC: " $(if $(filter %.a,$@),libabc.a)