-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (62 loc) · 2.48 KB
/
Makefile
File metadata and controls
92 lines (62 loc) · 2.48 KB
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
SHELL_FILES ?= .agignore .bash_profile .bashrc .dircolors .gitconfig .inputrc .lftprc \
.bash/aliases.sh .bash/colors.sh .bash/exports.sh .bash/functions.sh .bash/prompt.sh .bash/shell.sh \
.bash/ssh-agent.sh $(wildcard .local/bin/*)
CRON_FILES ?= $(wildcard .cron/*)
XORG_FILES ?= .Xresources .xbindkeysrc .xinitrc $(wildcard .urxvt/*)
XMONAD_FILES ?= .xmonad/xmonad.hs .config/dunst/dunstrc .xmonad/conky .xmonad/icons .xmonad/scripts
TMUX_FILES ?= .tmux.conf $(wildcard .tmux/sessions/*)
GTK_FILES ?= .gtkrc-2.0
WEECHAT_FILES ?= $(wildcard .weechat/*)
LINUX_FILES ?= .linopenrc .apvlvrc .bash/linux.sh
OSX_FILES ?= .khdrc
TARGETS_CLEAN ?= XORG XMONAD TMUX SHELL OSX
TMUX_DIRS ?= .tmux/sessions .tmux/sockets
LIB_DIR ?= ~/.local/lib
BACKUP ?= $(HOME)/.dotfiles-backup/$(shell date +"%Y%m%d_%H%M")
DEST ?= $(HOME)
all:
update: fetch-github
fetch-github:
@git pull origin master
@git submodule foreach git pull origin master
install:
@echo "Use either install-linux install-mac depending on your system"
install-linux: clean linux xorg mutt tmux weechat shell gtk init
install-mac: clean tmux shell osx init
init:
@echo "Remember to source ~/.bash_profile"
# Main targets ----------------------------------------------------------------
linux: $(addprefix $(DEST)/,$(LINUX_FILES))
osx: $(addprefix $(DEST)/,$(OSX_FILES))
xorg: $(addprefix $(DEST)/,$(XORG_FILES))
cron: $(addprefix $(DEST)/,$(CRON_FILES))
gtk: $(addprefix $(DEST)/,$(GTK_FILES))
xmonad: $(addprefix $(DEST)/,$(XMONAD_FILES))
tmux: $(addprefix $(DEST)/,$(TMUX_FILES))
@mkdir -p $(addprefix $(DEST)/,$(TMUX_DIRS))
weechat: $(addprefix $(DEST)/,$(WEECHAT_FILES))
shell: $(addprefix $(DEST)/,$(SHELL_FILES))
@git submodule init
@git submodule update
# Helpers ---------------------------------------------------------------------
# Symlink a dotfile from the repo to $HOME
# This will only run if the file doesnt already exist.
$(HOME)/%:%
@echo "Symlinking $^ to $@"
@mkdir -p $(dir $@)
@ln -sf $(PWD)/$^ $@
# Backup and delete a file
$(BACKUP)/%:%
@if [[ -f $(DEST)/$^ ]]; then \
echo "Backing up $(DEST)/$^ to $@"; \
mkdir -p $(dir $@); \
cp $(DEST)/$^ $@; \
rm $(DEST)/$^ $@; \
fi
# Clean up a specific target set of files
# Usage: make CLEAN=MUTT target-clean
clean-target: $(addprefix $(BACKUP)/,$($(CLEAN)_FILES))
# Backup and delete all existing dotfiles.
clean:
@$(foreach target,$(TARGETS_CLEAN), make -s CLEAN=$(target) clean-target;)
.PHONY: xorg xmonad mutt tmux weechat shell clean-target clean install gtk