diff --git a/Makefile b/Makefile index 868f343..221d83a 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ # Destination folder for the downloaded libraries LIBS_DIR := $(abspath ./libs) -UNAME_S := $(shell uname -s) # Flags for CGO to find the headers and the shared library +UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) CGO_CFLAGS := -I$(LIBS_DIR) CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,@executable_path/libs @@ -21,14 +21,17 @@ endif OS ?= "linux" ARCH ?= "amd64" VERSION ?= "v0.0.17" -LATEST_URL := "https://github.com/codex-storage/codex-go-bindings/releases/latest/download/codex-${OS}-${ARCH}.zip" -VERSIONED_URL := "https://github.com/codex-storage/codex-go-bindings/releases/download/$(VERSION)/codex-${OS}-${ARCH}.zip" +DOWNLOAD_URL ?= "https://github.com/codex-storage/codex-go-bindings/releases/latest/download/codex-${OS}-${ARCH}.zip" + +ifneq ($(VERSION),) + DOWNLOAD_URL := "https://github.com/codex-storage/codex-go-bindings/releases/download/$(VERSION)/codex-${OS}-${ARCH}.zip" +endif all: run fetch: - @echo "Fetching libcodex from GitHub Actions: ${LATEST_URL}" - curl -fSL --create-dirs -o $(LIBS_DIR)/codex-${OS}-${ARCH}.zip ${LATEST_URL} + @echo "Fetching libcodex from GitHub Actions from: ${DOWNLOAD_URL}" + curl -fSL --create-dirs -o $(LIBS_DIR)/codex-${OS}-${ARCH}.zip ${DOWNLOAD_URL} unzip -o -qq $(LIBS_DIR)/codex-${OS}-${ARCH}.zip -d $(LIBS_DIR) rm -f $(LIBS_DIR)/*.zip # Update the path to the shared library on macOS