Support custom separator and ending strings
[khome.git] / Makefile
... / ...
CommitLineData
1MAKEFLAGS := --no-builtin-rules
2
3DEPS := $(wildcard deps/*)
4
5ifeq ($(shell uname),Darwin)
6 GREP := ggrep
7 SED := gsed
8 DIFF := $(shell gls -t1 /usr/local/Cellar/diffutils/*/bin/diff | head -1)
9else
10 GREP := grep
11 SED := sed
12 DIFF := diff
13endif
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
39default:
40 @echo '================================================================================'
41 @echo '| Default target disabled. Specify a concrete one.'
42 @echo '================================================================================'
43 @exit 1
44
45home: compiled | mpdconf_dirs
46 cp -Rp bin $(HOME)/
47 $(MAKE) push
48 xdg-user-dirs-update
49
50mpdconf_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
56compiled:
57 mkdir -p bin
58 cd src && make
59 mv src/clockloop bin/
60
61font_cache:
62 fc-cache -fv
63
64#
65# Void Linux
66#
67
68pkgs_void:
69 sudo xbps-install $(shell ./list pkgs-void.list)
70
71pkgs_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#
78pkgs_golang: list pkgs-golang.list
79 go get -u $(shell ./list pkgs-golang.list)
80
81#
82# Ubuntu
83#
84pkgs_ubuntu: list pkgs-ubuntu.list
85 sudo apt install $(shell ./list pkgs-ubuntu.list)
86
87pkgs_ubuntu_debfiles: list pkgs-ubuntu-debfiles.list
88 ./install-debfiles pkgs-ubuntu-debfiles.list
89
90#
91# PIP
92#
93pkgs_pip_install:
94 pip install --user $(shell ./list pkgs-pip.list)
95
96pkgs_pip_upgrade:
97 pip install --user --upgrade $(shell ./list pkgs-pip.list)
98
99#
100# Rust (cargo)
101#
102
103pkgs_cargo: list pkgs-cargo.list
104 cargo install $(shell ./list pkgs-cargo.list)
105
106#
107# Homebrew/Mac
108#
109
110pkgs_mac:
111 $(MAKE) pkgs_brew_install
112 $(MAKE) pkgs_brew_cask_install
113
114# TODO: Test pkgs_brew_tap when list contains multiple items
115pkgs_brew_tap: list pkgs-brew-tap.list
116 brew tap $(shell ./list pkgs-brew-tap.list)
117
118pkgs_brew_install: list pkgs-brew-install.list
119 brew install $(shell ./list pkgs-brew-install.list)
120
121pkgs_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#
127pkgs_deb_install: list pkgs-deb-install.list
128 sudo apt install $(shell ./list pkgs-deb-install.list)
129
130pkgs_deb_purge: list pkgs-deb-purge.list
131 sudo apt purge $(shell ./list pkgs-deb-purge.list)
132
133#
134# Snap
135#
136pkgs_snap_classic: list pkgs-snap-classic.list
137 @$(MAKE) $(foreach p,$(shell ./list pkgs-snap-classic.list),pkg_snap_classic_$(p))
138
139pkgs_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
143pkg_snap_classic_%:
144 sudo snap install --classic $*
145pkg_snap_strict_%:
146 sudo snap install $*
147
148deps: $(DEPS)
149
150define GEN_DEP_RULE
151$(1):
152 cd $1 && make
153endef
154
155$(foreach d,$(DEPS),$(eval $(call GEN_DEP_RULE,$(d))))
156
157diff:
158 find home -type f -print0 \
159 | $(SED) -z 's/^home\///g' \
160 | xargs -0 -I% sh -c 'echo %; $(DIFF) --color=auto ~/% home/%'
161
162pull:
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
167push:
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
173clean:
174 rm -rf ./debfiles
175 cd src && make clean
This page took 0.028893 seconds and 4 git commands to generate.