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