11# Makefile for kubeprobes
22
3+ # Default target
4+ .PHONY : all
5+ all : build
6+
7+ # Variables
38BINARY_NAME =kubeprobes
49BUILD_DIR =./bin
510CMD_DIR =./cmd/kubeprobes
11+ INSTALL_DIR? =/usr/local/bin
12+ ARGS? =
613
7- # Build for current platform
14+ # Build the binary for current platform
815.PHONY : build
916build :
1017 @echo " Building $( BINARY_NAME) ..."
1118 @mkdir -p $(BUILD_DIR )
1219 @go build -o $(BUILD_DIR ) /$(BINARY_NAME ) $(CMD_DIR )
1320
14- # Build for multiple platforms
21+ # Build for multiple platforms
1522.PHONY : build-all
1623build-all :
1724 @echo " Building for multiple platforms..."
@@ -21,18 +28,30 @@ build-all:
2128 @GOOS=darwin GOARCH=arm64 go build -o $(BUILD_DIR ) /$(BINARY_NAME ) -darwin-arm64 $(CMD_DIR )
2229 @GOOS=windows GOARCH=amd64 go build -o $(BUILD_DIR ) /$(BINARY_NAME ) -windows-amd64.exe $(CMD_DIR )
2330
24- # Run tests
25- .PHONY : test
26- test :
27- @echo " Running tests..."
28- @go test -v ./...
31+ # Install the binary to system
32+ .PHONY : install
33+ install : build
34+ @echo " Installing $( BINARY_NAME) to $( INSTALL_DIR) ..."
35+ @sudo cp $(BUILD_DIR ) /$(BINARY_NAME ) $(INSTALL_DIR ) /$(BINARY_NAME )
36+
37+ # Run the application with optional arguments
38+ # Usage: make run ARGS="scan --help"
39+ .PHONY : run
40+ run :
41+ @go run $(CMD_DIR ) $(ARGS )
2942
3043# Clean build artifacts
3144.PHONY : clean
3245clean :
3346 @echo " Cleaning..."
3447 @rm -rf $(BUILD_DIR )
3548
49+ # Run tests
50+ .PHONY : test
51+ test :
52+ @echo " Running tests..."
53+ @go test -v ./...
54+
3655# Format code
3756.PHONY : fmt
3857fmt :
4362.PHONY : lint
4463lint :
4564 @echo " Linting code..."
46- @golangci-lint run
65+ @go vet ./...
4766
48- # Install dependencies
67+ # Download dependencies
4968.PHONY : deps
5069deps :
5170 @echo " Installing dependencies..."
5271 @go mod download
5372 @go mod tidy
5473
55- # Install binary to system
56- .PHONY : install
57- install : build
58- @echo " Installing $( BINARY_NAME) to /usr/local/bin..."
59- @sudo cp $(BUILD_DIR ) /$(BINARY_NAME ) /usr/local/bin/
60-
61- # Run the application
62- .PHONY : run
63- run :
64- @go run $(CMD_DIR ) $(ARGS )
65-
66- # Show help
74+ # Help target
6775.PHONY : help
6876help :
6977 @echo " Available targets:"
78+ @echo " all - Default target, builds the binary"
7079 @echo " build - Build the binary for current platform"
7180 @echo " build-all - Build binaries for multiple platforms"
72- @echo " test - Run tests"
81+ @echo " install - Install binary to $( INSTALL_DIR) (configurable with INSTALL_DIR)"
82+ @echo " run - Run the application (use ARGS to pass parameters)"
7383 @echo " clean - Clean build artifacts"
84+ @echo " test - Run tests"
7485 @echo " fmt - Format code"
7586 @echo " lint - Lint code"
76- @echo " deps - Install dependencies"
77- @echo " install - Install binary to system"
78- @echo " run - Run the application (use ARGS=... for arguments)"
79- @echo " help - Show this help message"
87+ @echo " deps - Download and tidy dependencies"
88+ @echo " help - Show this help"
89+ @echo " "
90+ @echo " Examples:"
91+ @echo " make run ARGS=\" scan --help\" "
92+ @echo " make install INSTALL_DIR=/opt/bin"
0 commit comments