SKILL_DIR ?= $(HOME)/.config/crush/skills SKILLS := $(patsubst skills/%/,%,$(wildcard skills/*/)) UNINSTALL_TARGETS := $(addprefix uninstall-,$(SKILLS)) .PHONY: list all uninstall $(SKILLS) $(UNINSTALL_TARGETS) list: @echo "Available skills:" @printf " %s\n" $(SKILLS) @echo "" @echo "Install with: make [SKILL_DIR=path]" @echo "Default target: $(SKILL_DIR)" all: $(SKILLS) $(SKILLS): @mkdir -p "$(SKILL_DIR)" @ln -sfn "$(CURDIR)/skills/$@" "$(SKILL_DIR)/$@" @echo "Installed $@ → $(SKILL_DIR)/$@" $(UNINSTALL_TARGETS): $(eval SKILL := $(patsubst uninstall-%,%,$@)) @if [ -e "$(SKILL_DIR)/$(SKILL)" ]; then \ rm -f "$(SKILL_DIR)/$(SKILL)"; \ echo "Uninstalled $(SKILL) from $(SKILL_DIR)"; \ else \ echo "Warning: $(SKILL) not found in $(SKILL_DIR)" >&2; \ fi uninstall: @for skill in $(SKILLS); do \ if [ -e "$(SKILL_DIR)/$$skill" ]; then \ rm -f "$(SKILL_DIR)/$$skill"; \ echo "Uninstalled $$skill from $(SKILL_DIR)"; \ fi; \ done