-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
42 lines (36 loc) · 1.26 KB
/
Makefile
File metadata and controls
42 lines (36 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
.PHONY: build install clean
# Binary name
BINARY=slark
# Go module path
MODULE=$(shell grep module go.mod | awk '{print $$2}')
# Main entry point
MAIN_FILE=cmd/slark/main.go
# Version from git tag or default
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
# Build directory
BUILD_DIR=build
build:
@echo "Building $(BINARY)..."
@mkdir -p $(BUILD_DIR)
go build -ldflags "-X $(MODULE)/internal/version.Version=$(VERSION)" -o $(BUILD_DIR)/$(BINARY) $(MAIN_FILE)
@echo "Build complete: $(BUILD_DIR)/$(BINARY)"
install: build
@echo "Installing $(BINARY)..."
@cp $(BUILD_DIR)/$(BINARY) ${GOPATH}/bin/$(BINARY)
@echo "$(BINARY) installed successfully to ${GOPATH}/bin/$(BINARY)"
clean:
@echo "Cleaning..."
@rm -rf $(BUILD_DIR)
@echo "Clean complete"
# For users using go install directly
go-install:
@echo "Running go install..."
go install -ldflags "-X $(MODULE)/internal/version.Version=$(VERSION)" ./cmd/slark
# Help output
help:
@echo "Available commands:"
@echo " make build - Build the binary to ./build directory"
@echo " make install - Install the binary to GOPATH/bin"
@echo " make clean - Remove build artifacts"
@echo " make go-install - Use go install to install directly"
@echo " make help - Show this help"