72 lines
1.5 KiB
Makefile
Executable File
72 lines
1.5 KiB
Makefile
Executable File
# GWEncoder Makefile
|
|
|
|
# Variables
|
|
BINARY_NAME = gwencoder
|
|
BUILD_DIR = build
|
|
CMD_DIR = cmd/gwencoder
|
|
PKG_DIR = pkg
|
|
|
|
# Go parameters
|
|
GOCMD = go
|
|
GOBUILD = $(GOCMD) build
|
|
GOCLEAN = $(GOCMD) clean
|
|
GOTEST = $(GOCMD) test
|
|
GOGET = $(GOCMD) get
|
|
GOMOD = $(GOCMD) mod
|
|
|
|
# Build flags
|
|
LDFLAGS = -ldflags "-s -w"
|
|
BUILD_FLAGS = -v
|
|
|
|
.PHONY: all build clean test run help install deps tidy
|
|
|
|
all: clean deps build
|
|
|
|
## build: Build the gwencoder binary
|
|
build:
|
|
@echo "Building $(BINARY_NAME)..."
|
|
@mkdir -p $(BUILD_DIR)
|
|
$(GOBUILD) $(BUILD_FLAGS) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) ./$(CMD_DIR)
|
|
@echo "✅ Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
|
|
|
|
## clean: Clean build artifacts
|
|
clean:
|
|
@echo "Cleaning build artifacts..."
|
|
$(GOCLEAN)
|
|
@rm -rf $(BUILD_DIR)
|
|
@echo "✅ Clean complete"
|
|
|
|
## test: Run tests
|
|
test:
|
|
@echo "Running tests..."
|
|
$(GOTEST) -v ./...
|
|
|
|
## run: Build and run the application
|
|
run: build
|
|
@echo "Running $(BINARY_NAME)..."
|
|
./$(BUILD_DIR)/$(BINARY_NAME) --help
|
|
|
|
## install: Install the binary to GOPATH/bin
|
|
install:
|
|
@echo "Installing $(BINARY_NAME)..."
|
|
$(GOBUILD) $(LDFLAGS) -o $(GOPATH)/bin/$(BINARY_NAME) ./$(CMD_DIR)
|
|
@echo "✅ Installed to $(GOPATH)/bin/$(BINARY_NAME)"
|
|
|
|
## deps: Download dependencies
|
|
deps:
|
|
@echo "Downloading dependencies..."
|
|
$(GOGET) -v ./...
|
|
|
|
## tidy: Tidy go.mod
|
|
tidy:
|
|
@echo "Tidying go.mod..."
|
|
$(GOMOD) tidy
|
|
|
|
## help: Show this help message
|
|
help:
|
|
@echo "GWEncoder Build System"
|
|
@echo ""
|
|
@echo "Available targets:"
|
|
@grep -E '^## ' Makefile | sed 's/## / /'
|
|
|