summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 0af6c0e1631f605319a30f844dd5e6a4dedd3a6e (plain) (blame)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
INTO := $(HOME)

INSTALL := \
    .agignore \
    .bash_logout \
    .bash_profile \
    .bashrc \
    .config/alacritty/alacritty.yml \
    .config/touchegg/touchegg.conf \
    .crawlrc \
    .gdbinit \
    .gitconfig \
    .gitignore \
    .i3status.conf \
    .inputrc \
    .ledgerrc \
    .less \
    .mailcap \
    .mpdconf \
    .msmtprc \
    .muttrc \
    .nethackrc \
    .notmuch-config \
    .offlineimaprc \
    .perlcriticrc \
    .procmailrc \
    .profile \
    .proverc \
    .replyrc \
    .screenrc \
    .tigrc \
    .tmux.conf \
    .vimrc \
    .wunderground \
    .xbindkeysrc \
    .Xdefaults \
    .xinitrc \
    .xprofile \
    .Xmodmap \
    .zlogout \
    .zshcomplete \
    .zshinput \
    .zshrc \
    .abook \
    .bin \
    .config/karabiner \
    .dzil \
    .fortune \
    .gnupg \
    .hammerspoon \
    .i3 \
    .mpdscribble \
    .ncmpcpp \
    .offlineimap \
    .procmail \
    .services \
    .sh \
    .ssh \
    .terminfo \
    .tex \
    .vim \
    .weechat \
    .zsh

EMPTYDIRS := \
    $(patsubst services/available/%,.log/%,$(wildcard services/available/*)) \
    Maildir \
    .cache/mutt/headers \
    .cache/mutt/bodies \
    .cache/mpd \
    .cache/vim/hist \
    .cache/vim/undo \
    .config/mpd/playlists \
    .config/alacritty \
    .config/touchegg

INSTALLED := \
    $(patsubst %,$(INTO)/%,$(EMPTYDIRS) $(INSTALL)) \
    /var/spool/cron/$(USER) \
    $(INTO)/Maildir/.notmuch

BUILD := \
    $(patsubst services/available/%,services/enabled/%,$(wildcard services/available/*)) \
    $(addsuffix .dat,$(filter-out %.dat,$(wildcard fortune/*))) \
    $(addsuffix tags,$(wildcard vim/pack/*/start/*/doc/)) \
    vim/spell/en.utf-8.add.spl \
    less \
    wunderground \
    mpdscribble/mpdscribble.conf \
    bin/local/timettyrec

ECHO      = @echo
LN        = @ln -sf
MKDIR     = @mkdir -p
RM        = @rm -f

# named targets

all : submodules build

submodules :
	@git submodule update --init --recursive

build : $(BUILD)

install : all $(INSTALLED)
	@chmod 600 msmtprc
	@chmod 700 gnupg
	$(ECHO) Installed into $(INTO)

clean :
	$(ECHO) Cleaning from $(INTO)
	@crontab -r
	$(RM) $(BUILD) $(INSTALLED)

update :
	@git submodule foreach '(if [ $$path == "vim/pack/filetype/start/perl" ]; then git checkout dev; else git checkout master; fi) && git pull'

versions :
	@git submodule foreach -q 'printf "%-53s" " $$path" && GIT_PAGER=cat git show -s --format=format:%cI%n $$sha1'

updates :
	@git submodule foreach -q 'if [ $$path == "vim/pack/filetype/start/perl" ]; then if [ $$(git rev-parse dev) != $$sha1 ]; then git lg dev...$$sha1; fi; else if [ $$(git rev-parse master) != $$sha1 ]; then git lg master...$$sha1; fi; fi'

.PHONY: all submodules build install clean update versions updates

# installation targets

$(patsubst %,$(INTO)/%,$(EMPTYDIRS)) :
	$(MKDIR) $@

$(patsubst %,$(INTO)/%,$(INSTALL)) : $(INTO)/.% : %
	@[ ! -e $@ ] || [ -h $@ ] || mv -f $@ $@.bak
	$(LN) $(PWD)/$< $@

/var/spool/cron/$(USER) : crontab
	@crontab $<

$(INTO)/Maildir/.notmuch: notmuch
	$(MKDIR) $(INTO)/Maildir
	@[ ! -e $@ ] || [ -h $@ ] || mv -f $@ $@.bak
	$(LN) $(PWD)/$< $@

# build targets

services/enabled/% : services/available/%
	$(MKDIR) services/enabled
	$(LN) ../available/$(notdir $<) $@

fortune/%.dat : fortune/%
	$(ECHO) "Compiling $@"
	@strfile -s $(basename $@)

%/doc/tags: %/doc
	@vim -u NONE -c':helptags $< | :q'

%.spl : %
	@vim -u NONE -c':mkspell! $< | :q'

less : lesskey
	lesskey -o $@ $<

wunderground :
	[ -e ~/.password-store ] && pass show websites/wunderground.com/wunderground@tozt.net > $@ || touch $@

mpdscribble/mpdscribble.conf : mpdscribble/mpdscribble.conf.tmpl
	perl -E'while (<STDIN>) { if (/^password =/) { say "password = $$ARGV[0]" } else { print } }' "$$(pass show websites/last.fm/doyster)" < $< > $@