New adhoc download directory helper
[khome.git] / Makefile
CommitLineData
80cc9199 1MAKEFLAGS := --no-builtin-rules
2a8bb767 2SHELL := /bin/bash
80cc9199 3
f908f2dc
SK
4DEPS := $(wildcard deps/*)
5
0b63d662 6ifeq ($(shell uname),Darwin)
ca0c92b8 7 GREP := ggrep
0b63d662
SK
8 SED := gsed
9 DIFF := $(shell gls -t1 /usr/local/Cellar/diffutils/*/bin/diff | head -1)
10else
ca0c92b8 11 GREP := grep
0b63d662
SK
12 SED := sed
13 DIFF := diff
14endif
15
2b497be2 16.PHONY: \
d03ce0c0
SK
17 default \
18 clean \
2b497be2
SK
19 $(DEPS) \
20 deps \
21 home \
ba898a09 22 diff \
8132c0e4 23 pull \
a97a6e09 24 push \
288fa35b 25 dirs \
208d5ebf
SK
26 pkgs_void \
27 pkgs_void_update \
2b497be2
SK
28 pkgs_brew_cask_install \
29 pkgs_brew_install \
dee031b5 30 pkgs_cargo \
2b497be2
SK
31 pkgs_deb_install \
32 pkgs_deb_purge \
33 pkgs_debian \
34 pkgs_mac \
32cd449e
SK
35 pkgs_pip_install \
36 pkgs_pip_upgrade \
2b497be2
SK
37 pkgs_snap_classic \
38 pkgs_snap_strict
80cc9199 39
75b7a956
SK
40default:
41 @echo '================================================================================'
42 @echo '| Default target disabled. Specify a concrete one.'
43 @echo '================================================================================'
44 @exit 1
45
288fa35b 46home: compiled dirs
cb7fdc22 47 cp -Rp bin $(HOME)/
a97a6e09 48 $(MAKE) push
b46a64f4 49 xdg-user-dirs-update
b2efbb10 50
288fa35b 51dirs:
96fe076e 52 mkdir -p $(shell ./list dirs)
9d953881 53
de7ac8e9
SK
54compiled:
55 mkdir -p bin
56 cd src && make
57 mv src/clockloop bin/
58
bf20a98b 59font_cache:
72db580c 60 fc-cache -fv
bf20a98b 61
208d5ebf
SK
62#
63# Void Linux
64#
65
66pkgs_void:
67 sudo xbps-install $(shell ./list pkgs-void.list)
68
dbc03ddf
SK
69# Mark $pkg as manually-installed:
70#
71# sudo xbps-pkgdb -m manual $pkg
72#
73# List manually-installed packages:
74#
75# xbps-query -m
76#
208d5ebf 77pkgs_void_update:
30a6fdab 78 xbps-query -m | awk -F - '{sub("-" $$NF "$$", ""); print}' | sort -fu | grep -vf <(./list -v sep='\n' -v end='\n' pkgs-void-src.list) > pkgs-void.list
7d4d7217 79 (echo '#'; ./patch-comments pkgs-void.list.comments pkgs-void.list) | sponge pkgs-void.list
208d5ebf 80
5bf7b45d
SK
81#
82# Golang
83#
f30c615c 84pkgs_golang: list pkgs-golang.list
192b3ef4 85 go install $(shell ./list pkgs-golang.list)
f30c615c 86
5bf7b45d
SK
87#
88# Ubuntu
89#
31b0313b
SK
90pkgs_ubuntu: list pkgs-ubuntu.list
91 sudo apt install $(shell ./list pkgs-ubuntu.list)
92
d03ce0c0
SK
93pkgs_ubuntu_debfiles: list pkgs-ubuntu-debfiles.list
94 ./install-debfiles pkgs-ubuntu-debfiles.list
95
5bf7b45d
SK
96#
97# PIP
98#
32cd449e 99pkgs_pip_install:
427362ef 100 pip install --user $(shell ./list pkgs-pip.list)
32cd449e
SK
101
102pkgs_pip_upgrade:
427362ef 103 pip install --user --upgrade $(shell ./list pkgs-pip.list)
5bf7b45d 104
dee031b5
SK
105#
106# Rust (cargo)
107#
108
109pkgs_cargo: list pkgs-cargo.list
110 cargo install $(shell ./list pkgs-cargo.list)
111
5bf7b45d
SK
112#
113# Homebrew/Mac
114#
115
70300ea4
SK
116pkgs_mac:
117 $(MAKE) pkgs_brew_install
118 $(MAKE) pkgs_brew_cask_install
119
cfe722ba
SK
120# TODO: Test pkgs_brew_tap when list contains multiple items
121pkgs_brew_tap: list pkgs-brew-tap.list
122 brew tap $(shell ./list pkgs-brew-tap.list)
123
70300ea4
SK
124pkgs_brew_install: list pkgs-brew-install.list
125 brew install $(shell ./list pkgs-brew-install.list)
126
127pkgs_brew_cask_install: list pkgs-brew-cask-install.list
128 brew cask install $(shell ./list pkgs-brew-cask-install.list)
129
5bf7b45d
SK
130#
131# Debian
132#
649af0dd
SK
133pkgs_deb_install: list pkgs-deb-install.list
134 sudo apt install $(shell ./list pkgs-deb-install.list)
600d3b0b 135
649af0dd
SK
136pkgs_deb_purge: list pkgs-deb-purge.list
137 sudo apt purge $(shell ./list pkgs-deb-purge.list)
b59a4c3b 138
5bf7b45d
SK
139#
140# Snap
141#
649af0dd
SK
142pkgs_snap_classic: list pkgs-snap-classic.list
143 @$(MAKE) $(foreach p,$(shell ./list pkgs-snap-classic.list),pkg_snap_classic_$(p))
6ce65841 144
7ae05795
SK
145pkgs_snap_strict: list pkgs-snap-strict.list
146 @$(MAKE) $(foreach p,$(shell ./list pkgs-snap-strict.list),pkg_snap_strict_$(p))
147
148# 'snap' command comes from 'snapd' deb pkg
6ce65841
SK
149pkg_snap_classic_%:
150 sudo snap install --classic $*
7ae05795
SK
151pkg_snap_strict_%:
152 sudo snap install $*
6ce65841 153
f908f2dc
SK
154deps: $(DEPS)
155
156define GEN_DEP_RULE
157$(1):
158 cd $1 && make
159endef
160
161$(foreach d,$(DEPS),$(eval $(call GEN_DEP_RULE,$(d))))
ab64e543
SK
162
163diff:
cca3111e 164 find home -type f -print0 \
0b63d662 165 | $(SED) -z 's/^home\///g' \
73c0dfd5 166 | sort -zr \
b48e809e 167 | xargs -0 -I% sh -c 'echo %; $(DIFF) --color=auto ~/% home/%'
d03ce0c0 168
a2a21403
SK
169.PHONY: diff_bins_untracked
170diff_bins_untracked:
171 ls -1 ~/bin | sort | grep -vf <(ls -1 home/bin | sort)
172
8132c0e4
SK
173pull:
174 find home -type f -print0 \
0b63d662
SK
175 | $(SED) -z 's/^home\///g' \
176 | xargs -0 -I% sh -c '$(DIFF) -q ~/% home/% > /dev/null || cp ~/% home/%'
8132c0e4 177
a97a6e09 178push:
101c2c38
SK
179 # TODO Backup files before replacing.
180 # But - recursive copy is not a good strategy for this.
181 # Need to do a file by file pass, like the diff recipe.
182 #
a97a6e09
SK
183 # Limit depth because directories are copied recursively:
184 find home -maxdepth 1 -print0 \
185 | $(GREP) -zv '^home$$' \
186 | xargs -0 -I% cp -Rp % ~
187
d03ce0c0
SK
188clean:
189 rm -rf ./debfiles
190 cd src && make clean
This page took 0.140438 seconds and 4 git commands to generate.