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