-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (58 loc) · 1.63 KB
/
Makefile
File metadata and controls
73 lines (58 loc) · 1.63 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Makefile for container - Docker clone project
# Binary name
BINARY_NAME=container
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
# Source directory
SRC_DIR=./cmd/container
# Build the binary
build:
$(GOBUILD) -o $(BINARY_NAME) $(SRC_DIR)
# Build for Linux (useful if developing on different OS)
build-linux:
GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_NAME) $(SRC_DIR)
# Clean build artifacts
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
# Run tests
test:
$(GOTEST) -v ./...
# Download dependencies
deps:
$(GOMOD) download
$(GOMOD) tidy
# Install the binary to $GOPATH/bin
install: build
cp $(BINARY_NAME) $(GOPATH)/bin/
# Run the binary (example usage)
run: build
./$(BINARY_NAME)
# Development build with debug info
debug:
$(GOBUILD) -gcflags="-N -l" -o $(BINARY_NAME) $(SRC_DIR)
# Build with all optimizations disabled for debugging
dev:
$(GOBUILD) -race -o $(BINARY_NAME) $(SRC_DIR)
# Show help
help:
@echo "Available targets:"
@echo " build - Build the container binary"
@echo " build-linux - Build for Linux (cross-compile)"
@echo " clean - Remove build artifacts"
@echo " test - Run tests"
@echo " deps - Download and tidy dependencies"
@echo " install - Install binary to GOPATH/bin"
@echo " run - Build and run the binary"
@echo " debug - Build with debug symbols"
@echo " dev - Build with race detection"
@echo " help - Show this help message"
# Default target
.DEFAULT_GOAL := build
# Declare phony targets
.PHONY: build build-linux clean test deps install run debug dev help