# 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), von der alle anderen
# Zweige abhaengen. Die uebrigen Ziele haengen nur von basic ab und sind
# untereinander unabhaengig.
basic:
	bash basic/setup.sh

term: basic
	bash term/setup.sh
	stow term

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

hypr: basic
	bash _install_skripte/install_hypr_pcks.sh
	stow hypr
	bash hypr/.config/hypr/scripts/ensure-env.sh
	bash hypr/.config/hypr/scripts/portal-host-override.sh
	bash hypr/.config/hypr/scripts/fix_dolphin_file_associations.sh

kreation: basic
	bash _install_skripte/install_kreation_pcks.sh
	stow kreation

buntes-monster: hypr kreation
	_install_skripte/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 pacman packages inside
#   the container 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/npm + hypr/kreation. SKIP_NET=1
#   skips anything that contacts the network.
# Example:  make test-smoke            # real term package install + verify
#           make test-smoke REAL_SMOKE=0   # dry probes only
#           make test-smoke RUN_FULL=1 # full AUR/npm + 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
