dotfiles/Makefile

50 lines
1003 B
Makefile
Raw Normal View History

2022-01-31 16:41:17 +00:00
# Set default target for make > 3.80
.DEFAULT_GOAL := default
# Default make to the dev target
.PHONY: default
default: all
# Variables
STOW := $(shell command -v stow 2> /dev/null)
STOW_FLAGS=-v -t $(HOME)
STOW_PACKAGE_DIR=user-config
STOW_PACKAGES=$(shell ls $(STOW_PACKAGE_DIR))
# Add additional flags if requested
ifeq ($(DRY),true)
STOW_FLAGS+=-n
endif
ifeq ($(RESTOW),true)
STOW_FLAGS+=-R
endif
ifeq ($(DELETE),true)
STOW_FLAGS+=-D
endif
.PHONY: check-env
check-env:
ifndef STOW
$(error GNU stow must be installed)
endif
@[ -d ~/.config ] || mkdir ~/.config
@[ -d ~/.bin ] || mkdir ~/.bin
@[ -d ~/.local/share ] || mkdir -p ~/.local/share
.PHONY: list-packages
list-packages:
@ls $(STOW_PACKAGE_DIR)
.PHONY: $(STOW_PACKAGES)
$(STOW_PACKAGES): check-env
@cd $(STOW_PACKAGE_DIR) && $(STOW) $(STOW_FLAGS) $@
.PHONY: all
all: check-env
@cd $(STOW_PACKAGE_DIR) && $(STOW) $(STOW_FLAGS) $(STOW_PACKAGES)
.PHONY: init
init:
guix pull -C channels.scm
guix package -m user-manifest.scm