.PHONY: bootstrap setup assets test lint fmt fmt-check check build run dev deps docker clean hooks css version

# Default target
.DEFAULT_GOAL := check

# Version stamped into the binary. Derived from git by script/version;
# override it (`make build VERSION=v1.2.3`) where git metadata is
# unavailable, which is how the Dockerfile passes its build arg in.
VERSION ?= $(shell script/version)

# Extra linker flags for the build target. The static relink in the
# Dockerfile adds -extldflags here rather than passing its own -ldflags,
# so composing flags cannot drop the version stamp.
GO_LDFLAGS ?=

bootstrap:
	@script/bootstrap

setup:
	@script/setup

assets:
	@script/fetch-assets

test:
	@script/test

lint:
	@script/lint

fmt:
	@script/fmt

fmt-check:
	@script/fmt-check

check:
	@script/check

build:
	go build -ldflags '$(strip -X main.version=$(VERSION) $(GO_LDFLAGS))' -o bin/webhooker ./cmd/webhooker

run: build
	./bin/webhooker

dev:
	go run ./cmd/webhooker

deps:
	go mod download
	go mod tidy

version:
	@echo $(VERSION)

docker:
	@script/docker

clean:
	rm -rf bin/

hooks:
	@script/install-precommit

css:
	tailwindcss -i static/css/input.css -o static/css/tailwind.css --minify
