34 lines
1020 B
Makefile
Raw Normal View History

2025-10-14 14:16:15 +02:00
# Destination folder for the downloaded libraries
LIBS_DIR := $(abspath ./libs)
# Flags for CGO to find the headers and the shared library
CGO_CFLAGS := -I$(LIBS_DIR)
2025-10-15 08:10:37 +02:00
CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,$(LIBS_DIR)
2025-10-14 14:16:15 +02:00
# Configuration for fetching the right binary
OS ?= "linux"
ARCH ?= "amd64"
VERSION ?= "v0.0.15"
2025-10-14 14:16:15 +02:00
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"
# Just for the example
BIN=example
all: run
fetch:
2025-10-14 14:22:03 +02:00
@echo "Fetching libcodex from GitHub Actions: ${LATEST_URL}"
@curl -fSL --create-dirs -o $(LIBS_DIR)/codex-${OS}-${ARCH}.zip ${LATEST_URL}
2025-10-15 06:57:04 +02:00
@unzip -o -qq $(LIBS_DIR)/codex-${OS}-${ARCH}.zip -d $(LIBS_DIR)
2025-10-14 14:16:15 +02:00
@rm -f $(LIBS_DIR)/*.zip
build:
2025-10-15 08:10:37 +02:00
CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o $(BIN) main.go
2025-10-14 14:16:15 +02:00
run:
./example
clean:
rm -f $(BIN)
rm -Rf $(LIBS_DIR)/*