# inBOXER Makefile

.PHONY: build run test clean

# Build the application
build:
	@echo "Building inBOXER..."
	go build -o bin/inboxer ./src/cmd
	@echo "Binary created at bin/inboxer"

# Run the application
run: build
	@echo "Starting inBOXER..."
	./bin/inboxer

# Run tests
test:
	@echo "Running tests..."
	go test ./...

# Clean build artifacts
clean:
	@echo "Cleaning..."
	rm -f bin/inboxer
	rm -f bin/*.log
	@echo "Clean complete"

# Install dependencies
deps:
	@echo "Installing dependencies..."
	go mod download

# Format code
fmt:
	@echo "Formatting code..."
	go fmt ./...

# Lint code (if golangci-lint is installed)
lint:
	@if command -v golangci-lint >/dev/null 2>&1; then \
		echo "Linting code..."; \
		golangci-lint run ./...; \
	else \
		echo "golangci-lint not installed, skipping lint"; \
	fi

# Build for production (stripped binary)
prod: build
	@echo "Stripping binary..."
	strip bin/inboxer
	@echo "Production binary ready"

# Run with development environment
dev:
	APP_ENV=development ./bin/inboxer

# Help
help:
	@echo "Available targets:"
	@echo "  build    - Build the application"
	@echo "  run      - Build and run the application"
	@echo "  test     - Run tests"
	@echo "  clean    - Clean build artifacts"
	@echo "  deps     - Install dependencies"
	@echo "  fmt      - Format code"
	@echo "  lint     - Lint code (requires golangci-lint)"
	@echo "  prod     - Build stripped binary for production"
	@echo "  dev      - Run in development mode"
	@echo "  help     - Show this help"