CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config) SSH_DIR := $(HOME)/.ssh CONFIG_ITEMS := $(wildcard config/*) CONFIG_TARGETS := $(CONFIG_ITEMS:config/%=$(CONFIG_DIR)/%) SSH_ITEMS := $(wildcard ssh/*) SSH_TARGETS := $(SSH_ITEMS:ssh/%=$(SSH_DIR)/%) LAZY_REPO := https://github.com/folke/lazy.nvim.git LAZY_DIR := $(HOME)/.local/share/nvim/lazy/lazy.nvim .PHONY: all clean link unlink install uninstall pacman all: link install clean: unlink uninstall link: $(HOME)/.profile $(CONFIG_TARGETS) $(SSH_TARGETS) $(HOME)/.ssh/sockets unlink: for link in $(CONFIG_TARGETS); do rm "$$link"; done for link in $(SSH_TARGETS); do rm "$$link"; done rmdir $(HOME)/.ssh/sockets install: $(LAZY_DIR) uninstall: rm -rf $(LAZY_DIR) pacman: sort -h pkglist.txt -o pkglist.txt pacman -T - < pkglist.txt ||\ sudo pacman --needed -S - < pkglist.txt $(CONFIG_TARGETS): $(CONFIG_DIR)/%: config/% $(SSH_TARGETS): $(SSH_DIR)/%: ssh/% $(CONFIG_TARGETS) $(SSH_TARGETS): ln -s $(PWD)/$? $@ $(HOME)/.profile: .profile ln -s $(PWD)/$? $@ $(LAZY_DIR): git clone --depth 1 $(LAZY_REPO) $@ $(CONFIG_DIR) $(SSH_DIR) $(HOME)/.ssh/sockets: mkdir -p $@