From 02ef2f78fb9ba35a2823e95cfd99ceb99642ebcd Mon Sep 17 00:00:00 2001 From: Ar1ste1a <107807560+Ar1ste1a@users.noreply.github.com> Date: Thu, 15 May 2025 17:24:45 -0400 Subject: [PATCH] Added Makefile --- Makefile | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..194bcdd --- /dev/null +++ b/Makefile @@ -0,0 +1,53 @@ +# Makefile for Dehasher + +# Go command +GO=go + +# Binary name +BINARY_NAME=dehasher + +# Build directory +BUILD_DIR=build/bin + +# Platforms to build for +PLATFORMS=linux darwin windows + +# Architecture to build for +ARCHS=amd64 arm64 + +# Version info from git tag or default +VERSION=$(shell git describe --tags 2>/dev/null || echo "v1.0.1") + +.PHONY: all clean build build-all + +# Default target +all: clean build-all + +# Clean build artifacts +clean: + rm -rf $(BUILD_DIR) + mkdir -p $(BUILD_DIR) + +# Build for current platform +build: + $(GO) build -o $(BUILD_DIR)/$(BINARY_NAME) -ldflags "-X main.version=$(VERSION)" dehasher.go + +# Build for all platforms +build-all: clean + @for platform in $(PLATFORMS); do \ + for arch in $(ARCHS); do \ + echo "Building for $$platform/$$arch..."; \ + GOOS=$$platform GOARCH=$$arch $(GO) build -o $(BUILD_DIR)/$(BINARY_NAME)-$$platform-$$arch -ldflags "-X main.version=$(VERSION)" dehasher.go; \ + if [ "$$platform" = "windows" ]; then \ + mv $(BUILD_DIR)/$(BINARY_NAME)-$$platform-$$arch $(BUILD_DIR)/$(BINARY_NAME)-$$platform-$$arch.exe; \ + fi; \ + done; \ + done + +# Install locally +install: build + cp $(BUILD_DIR)/$(BINARY_NAME) /usr/local/bin/ + +# Run tests +test: + $(GO) test ./... \ No newline at end of file