export GO111MODULE=on

.PHONY: build test clean deps

# Build the main application
build:
	go build -o go-rofs-err-watcher ./cmd/go-rofs-err-watcher
	go test -c -o ./test-client ./pkg/client

# Run tests (requires root privileges for netlink operations)
test:
	go test -v ./pkg/client

# Run tests with root privileges
test-root:
	sudo go test -v ./pkg/client

# Clean build artifacts
clean:
	rm -f go-rofs-err-watcher
	rm -f test-client

# Download dependencies and update go.sum
deps:
	go mod tidy
	go mod download

# Install the application
install: build
	sudo cp go-rofs-err-watcher /usr/local/bin/

# Run the monitor
monitor: build
	sudo ./go-rofs-err-watcher monitor

# Show help
help:
	@echo "Available targets:"
	@echo "  build      - Build the go-rofs-err-watcher binary"
	@echo "  build-test - Build the test-client binary"
	@echo "  test       - Run tests (requires root for netlink operations)"
	@echo "  test-root  - Run tests with sudo"
	@echo "  clean      - Clean build artifacts"
	@echo "  deps       - Download dependencies and update go.sum"
	@echo "  install    - Install the binary to /usr/local/bin"
	@echo "  monitor    - Run the monitor (requires root)"
	@echo "  help       - Show this help message"
