# =============================================================================
# Makefile — Cibles de build, test et packaging pour ja4ebpf
# =============================================================================

BINARY    := ja4ebpf
IMAGE     := ja4ebpf
VERSION   ?= 0.1.0

.PHONY: generate build test docker-build help

## generate: Compile les sources eBPF C → Go via bpf2go (dans Docker)
generate:
	docker build --target go-builder \
		--build-arg SKIP_BINARY=true \
		-f Dockerfile \
		-t $(IMAGE)-generated:$(VERSION) \
		../../

## build: Construit l'image Docker de production complète
build:  ## Construit l'image Docker finale
	docker build -t $(IMAGE):$(VERSION) -f Dockerfile ../../

## test: Exécute les tests unitaires Go dans Docker
test:
	docker build -f Dockerfile.tests -t $(IMAGE)-tests:$(VERSION) ../../ && \
	docker run --rm $(IMAGE)-tests:$(VERSION)

## docker-build: Alias combiné generate + build
docker-build: build

## help: Affiche cette aide
help:
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
		awk 'BEGIN {FS = ":.*?## "}; {printf "  \033[36m%-20s\033[0m %s\n", $$1, $$2}'
