-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
95 lines (79 loc) · 2.44 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# TODO add diff task, to use when stow report a conflict
# ./dots.sh bspwm 2>&1 | \
# awk -F': ' "/not owned by stow/ {print \"$HOME/\"\$2\" ./bspwm/\"\$2}" | \
# xargs -n2 diff -u --color
# TODO display output only if error, like mongooseOS tool mos
# TODO {pre,post}-stow should be runned based on Makefile rules
.DEFAULT_GOAL := help
DESTDIR ?= $$HOME
ENVIRONMENT := . ./shell/.shell/environment &&
PKGS ?= $(sort $(patsubst %/, %, $(dir $(wildcard [^_@]*/.))))
REAL_DIRS := $(addprefix $(DESTDIR)/,\
.config\
.config/bat\
.config/dunst .config/tmux .config/rofi\
.local/src\
.tmux\
.git-templates\
.gnupg .ssh\
.terminfo)
comma:= ,
empty:=
space:= $(empty) $(empty)
heading:= printf "==> \033[1m%s\033[0m\n"
subheading:= printf "\033[1m%s\033[0m\n"
.PHONY: $(PKGS)
PACKAGE: ## Install PACKAGE
$(PKGS): dirs
@$(heading) "Install $@"
$(ENVIRONMENT) ./$@/pre-stow || test $$? -eq 127 && true
stow -t $(DESTDIR) $@
$(ENVIRONMENT) ./$@/post-stow || test $$? -eq 127 && true
alacritty bspwm tmux zsh: theme
# firefox rofi: theme
$(REAL_DIRS):
@mkdir -p $@
.PHONY: all
all: ## Install all packages
all: dirs $(PKGS)
# XXX: Hiding meaningless warning message from stow.
# https://github.com/aspiers/stow/issues/65
.PHONY: uninstall
uninstall: ## Uninstall PACKAGES (all or use PACKAGES=foo,bar)
@$(heading) "Uninstall files"
stow --target $(DESTDIR) --delete $(subst $(comma),$(space),$(PACKAGES)) \
2>&1 | sed '/Stow.pm line 966/d;'
.PHONY: update
update: ## Update and install
update: install
find ~/.local/src/ -path */.git -exec $(subheading) {} \; -execdir git -C ./ pull \;
.PHONY: pull
pull: ## Pull latest changes
@$(heading) "Fetch changes"
git pull
.PHONY: home
home: ## Create home directory hierarchy
@$(heading) "Create home hierarchy"
@mkdir -p $(addprefix "$$HOME"/,\
project org 42\
src vm\
misc/iso misc/vpn misc/paperasse\
misc/model misc/desktop misc/document\
sharing\
game music stream video\
picture/screenshot picture/wallpaper\
download tmp mnt)
.PHONY: bricewge
bricewge: ## Apply user specific customizations
bricewge: home
@$(heading) "Apply bricewge's customization"
git remote set-url origin "[email protected]:bricewge/dotfiles.git"
.PHONY: dirs
dirs: ## Make directories to prevent symlinking them
dirs: $(REAL_DIRS)
@$(heading) "Make directories"
.PHONY: help
help: ## Describe tasks
$(info Tasks:)
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / \
{printf "\033[1m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)