# 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: fast offline lint first, then the optional Docker smoke.
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.
#   RUN_SMOKE=1  also installs the real pacman packages inside the container.
#   RUN_SMOKE=1 RUN_FULL=1  additionally attempts AUR/npm + hypr/kreation.
#   SKIP_NET=1   skips anything that contacts the network.
# Example:  make test-smoke RUN_SMOKE=1
test-smoke:
	docker build --target test -t dotfiles-test -f test/Dockerfile .
	docker run --rm \
		-e RUN_SMOKE="$${RUN_SMOKE:-0}" \
		-e RUN_FULL="$${RUN_FULL:-0}" \
		-e SKIP_NET=$${SKIP_NET:-0} \
		-v "$$PWD":/dotfiles \
		dotfiles-test
