# Alle Targets sind Kommando-Targets (keine Dateien) und werden immer ausgeführt.
.PHONY: basic term utils hypr kreation buntes-monster

# basic wird immer zuerst eingerichtet: es legt die Basis-Systemumgebung an
# (multilib, yay, Display-Manager, Audio-Stack, Docker), von der alle anderen
# Zweige abhaengen. Die uebrigen Ziele haengen nur von basic ab und sind
# untereinander unabhaengig.
basic:
	bash setup/basic/setup.sh
	stow basic

term: basic
	bash setup/term/setup.sh
	stow term

utils: basic
	bash setup/utils/setup.sh
	bash setup/nextcloud.sh

hypr: basic
	bash setup/hypr/setup.sh
	stow hypr

kreation: basic
	bash setup/kreation/setup.sh
	stow kreation

buntes-monster: hypr kreation
	bash setup/buntes-monster-links.sh

# ---------------------------------------------------------------------------
# Testing (see README.md "Testing" and test/ for details)
# ---------------------------------------------------------------------------
.PHONY: test test-lint test-smoke test-stow test-shellcheck test-lint-docker

# Full test suite: offline lint first, then the Docker smoke (which by
# default runs the real install + verification; see test-smoke below).
test: test-lint test-smoke

# Fast, offline integrity checks. No Docker required.
#   shellcheck is used if installed, otherwise only syntax checks run.
test-lint:
	bash test/lint.sh

# Check stow package resolution without creating symlinks.
test-stow:
	bash test/probe_stow.sh

# Run shellcheck over all tracked repo scripts (needs shellcheck installed).
test-shellcheck:
	shellcheck -S warning $$(git ls-files '*.sh' | grep -v '/tpm/')

# Test shellcheck: build the /dev stage with shellcheck and run lint.sh.
#   docker build context is the repo root; .dockerignore excludes heavy dirs.
test-lint-docker:
	docker build --target dev -t dotfiles-lint -f test/Dockerfile .
	docker run --rm dotfiles-lint

# Docker smoke test: builds the Arch container and runs the dry probes.
#   By default (REAL_SMOKE=1) it also installs the real term pacman + npm
#   packages inside the container (AUR stays opt-in) and verifies them, so a
#   plain `make test` actually exercises the install path. Set REAL_SMOKE=0
#   (or RUN_SMOKE=0) for the fast dry-probe run. RUN_FULL=1 additionally
#   attempts AUR + hypr/kreation/buntes-monster. SKIP_NET=1 skips anything
#   that contacts the network.
# Example:  make test-smoke            # real term pacman+npm install + verify
#           make test-smoke REAL_SMOKE=0   # dry probes only
#           make test-smoke RUN_FULL=1 # full AUR + hypr/kreation
REAL_SMOKE ?= 1
test-smoke:
	docker build --target test -t dotfiles-test -f test/Dockerfile .
	docker run --rm \
		-e RUN_SMOKE="$${RUN_SMOKE:-$(REAL_SMOKE)}" \
		-e RUN_FULL="$${RUN_FULL:-0}" \
		-e SKIP_NET=$${SKIP_NET:-0} \
		-v "$$PWD":/dotfiles \
		dotfiles-test
