Add more dirs to base dir recipe
[khome.git] / Makefile
1 MAKEFLAGS := --no-builtin-rules
2 SHELL := /bin/bash
3
4 DEPS := $(wildcard deps/*)
5
6 ifeq ($(shell uname),Darwin)
7 GREP := ggrep
8 SED := gsed
9 DIFF := $(shell gls -t1 /usr/local/Cellar/diffutils/*/bin/diff | head -1)
10 else
11 GREP := grep
12 SED := sed
13 DIFF := diff
14 endif
15
16 .PHONY: \
17 default \
18 clean \
19 $(DEPS) \
20 deps \
21 home \
22 diff \
23 pull \
24 push \
25 dirs \
26 pkgs_void \
27 pkgs_void_update \
28 pkgs_brew_cask_install \
29 pkgs_brew_install \
30 pkgs_cargo \
31 pkgs_deb_install \
32 pkgs_deb_purge \
33 pkgs_debian \
34 pkgs_mac \
35 pkgs_pip_install \
36 pkgs_pip_upgrade \
37 pkgs_snap_classic \
38 pkgs_snap_strict
39
40 default:
41 @echo '================================================================================'
42 @echo '| Default target disabled. Specify a concrete one.'
43 @echo '================================================================================'
44 @exit 1
45
46 home: compiled dirs
47 cp -Rp bin $(HOME)/
48 $(MAKE) push
49 xdg-user-dirs-update
50
51 dirs:
52 mkdir -p ~/arc/aud
53 mkdir -p ~/arc/backup
54 mkdir -p ~/arc/doc
55 mkdir -p ~/arc/img
56 mkdir -p ~/arc/log
57 mkdir -p ~/arc/misc
58 mkdir -p ~/arc/sw/bin
59 mkdir -p ~/arc/sw/src/misc
60 mkdir -p ~/arc/sw/src/pkgs
61 mkdir -p ~/arc/sw/src/repos
62 mkdir -p ~/arc/sw/src/tarballs
63 mkdir -p ~/arc/vid
64 mkdir -p ~/arc/work
65 mkdir -p ~/bin
66 mkdir -p ~/dl
67 mkdir -p ~/doc
68 mkdir -p ~/ex
69 mkdir -p ~/fork
70 mkdir -p ~/lib
71 mkdir -p ~/org
72 mkdir -p ~/proj/priv
73 mkdir -p ~/proj/pub
74 mkdir -p ~/snips
75 mkdir -p ~/tmp
76 mkdir -p ~/var/lib/mpd/playlists
77 mkdir -p ~/var/log/mpd
78 mkdir -p ~/var/run/mpd
79 mkdir -p ~/work
80 mkdir -p ~/x
81
82 compiled:
83 mkdir -p bin
84 cd src && make
85 mv src/clockloop bin/
86
87 font_cache:
88 fc-cache -fv
89
90 #
91 # Void Linux
92 #
93
94 pkgs_void:
95 sudo xbps-install $(shell ./list pkgs-void.list)
96
97 pkgs_void_update:
98 xbps-query -m | awk -F - '{sub("-" $$NF "$$", ""); print}' | sort -u | grep -vf <(./list -v sep='\n' -v end='\n' pkgs-void-src.list) > pkgs-void.list
99 (echo '#'; ./patch-comments pkgs-void.list.comments pkgs-void.list) | sponge pkgs-void.list
100
101 #
102 # Golang
103 #
104 pkgs_golang: list pkgs-golang.list
105 go get -u $(shell ./list pkgs-golang.list)
106
107 #
108 # Ubuntu
109 #
110 pkgs_ubuntu: list pkgs-ubuntu.list
111 sudo apt install $(shell ./list pkgs-ubuntu.list)
112
113 pkgs_ubuntu_debfiles: list pkgs-ubuntu-debfiles.list
114 ./install-debfiles pkgs-ubuntu-debfiles.list
115
116 #
117 # PIP
118 #
119 pkgs_pip_install:
120 pip install --user $(shell ./list pkgs-pip.list)
121
122 pkgs_pip_upgrade:
123 pip install --user --upgrade $(shell ./list pkgs-pip.list)
124
125 #
126 # Rust (cargo)
127 #
128
129 pkgs_cargo: list pkgs-cargo.list
130 cargo install $(shell ./list pkgs-cargo.list)
131
132 #
133 # Homebrew/Mac
134 #
135
136 pkgs_mac:
137 $(MAKE) pkgs_brew_install
138 $(MAKE) pkgs_brew_cask_install
139
140 # TODO: Test pkgs_brew_tap when list contains multiple items
141 pkgs_brew_tap: list pkgs-brew-tap.list
142 brew tap $(shell ./list pkgs-brew-tap.list)
143
144 pkgs_brew_install: list pkgs-brew-install.list
145 brew install $(shell ./list pkgs-brew-install.list)
146
147 pkgs_brew_cask_install: list pkgs-brew-cask-install.list
148 brew cask install $(shell ./list pkgs-brew-cask-install.list)
149
150 #
151 # Debian
152 #
153 pkgs_deb_install: list pkgs-deb-install.list
154 sudo apt install $(shell ./list pkgs-deb-install.list)
155
156 pkgs_deb_purge: list pkgs-deb-purge.list
157 sudo apt purge $(shell ./list pkgs-deb-purge.list)
158
159 #
160 # Snap
161 #
162 pkgs_snap_classic: list pkgs-snap-classic.list
163 @$(MAKE) $(foreach p,$(shell ./list pkgs-snap-classic.list),pkg_snap_classic_$(p))
164
165 pkgs_snap_strict: list pkgs-snap-strict.list
166 @$(MAKE) $(foreach p,$(shell ./list pkgs-snap-strict.list),pkg_snap_strict_$(p))
167
168 # 'snap' command comes from 'snapd' deb pkg
169 pkg_snap_classic_%:
170 sudo snap install --classic $*
171 pkg_snap_strict_%:
172 sudo snap install $*
173
174 deps: $(DEPS)
175
176 define GEN_DEP_RULE
177 $(1):
178 cd $1 && make
179 endef
180
181 $(foreach d,$(DEPS),$(eval $(call GEN_DEP_RULE,$(d))))
182
183 diff:
184 find home -type f -print0 \
185 | $(SED) -z 's/^home\///g' \
186 | sort -zr \
187 | xargs -0 -I% sh -c 'echo %; $(DIFF) --color=auto ~/% home/%'
188
189 pull:
190 find home -type f -print0 \
191 | $(SED) -z 's/^home\///g' \
192 | xargs -0 -I% sh -c '$(DIFF) -q ~/% home/% > /dev/null || cp ~/% home/%'
193
194 push:
195 # TODO Backup files before replacing.
196 # But - recursive copy is not a good strategy for this.
197 # Need to do a file by file pass, like the diff recipe.
198 #
199 # Limit depth because directories are copied recursively:
200 find home -maxdepth 1 -print0 \
201 | $(GREP) -zv '^home$$' \
202 | xargs -0 -I% cp -Rp % ~
203
204 clean:
205 rm -rf ./debfiles
206 cd src && make clean
This page took 0.082752 seconds and 5 git commands to generate.