Add "open" function to fork xdg-open
[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
SK
24 push \
25 mpdconf_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
a97a6e09 46home: compiled | mpdconf_dirs
cb7fdc22 47 cp -Rp bin $(HOME)/
a97a6e09 48 $(MAKE) push
b46a64f4 49 xdg-user-dirs-update
b2efbb10 50
a97a6e09 51mpdconf_dirs:
b602a3d1 52 mkdir -p ~/arc/aud
72db580c
SK
53 mkdir -p ~/var/lib/mpd/playlists
54 mkdir -p ~/var/log/mpd
55 mkdir -p ~/var/run/mpd
9d953881 56
de7ac8e9
SK
57compiled:
58 mkdir -p bin
59 cd src && make
60 mv src/clockloop bin/
61
bf20a98b 62font_cache:
72db580c 63 fc-cache -fv
bf20a98b 64
208d5ebf
SK
65#
66# Void Linux
67#
68
69pkgs_void:
70 sudo xbps-install $(shell ./list pkgs-void.list)
71
72pkgs_void_update:
2a8bb767 73 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
7d4d7217 74 (echo '#'; ./patch-comments pkgs-void.list.comments pkgs-void.list) | sponge pkgs-void.list
208d5ebf 75
5bf7b45d
SK
76#
77# Golang
78#
f30c615c 79pkgs_golang: list pkgs-golang.list
036e0e3c 80 go get -u $(shell ./list pkgs-golang.list)
f30c615c 81
5bf7b45d
SK
82#
83# Ubuntu
84#
31b0313b
SK
85pkgs_ubuntu: list pkgs-ubuntu.list
86 sudo apt install $(shell ./list pkgs-ubuntu.list)
87
d03ce0c0
SK
88pkgs_ubuntu_debfiles: list pkgs-ubuntu-debfiles.list
89 ./install-debfiles pkgs-ubuntu-debfiles.list
90
5bf7b45d
SK
91#
92# PIP
93#
32cd449e 94pkgs_pip_install:
427362ef 95 pip install --user $(shell ./list pkgs-pip.list)
32cd449e
SK
96
97pkgs_pip_upgrade:
427362ef 98 pip install --user --upgrade $(shell ./list pkgs-pip.list)
5bf7b45d 99
dee031b5
SK
100#
101# Rust (cargo)
102#
103
104pkgs_cargo: list pkgs-cargo.list
105 cargo install $(shell ./list pkgs-cargo.list)
106
5bf7b45d
SK
107#
108# Homebrew/Mac
109#
110
70300ea4
SK
111pkgs_mac:
112 $(MAKE) pkgs_brew_install
113 $(MAKE) pkgs_brew_cask_install
114
cfe722ba
SK
115# TODO: Test pkgs_brew_tap when list contains multiple items
116pkgs_brew_tap: list pkgs-brew-tap.list
117 brew tap $(shell ./list pkgs-brew-tap.list)
118
70300ea4
SK
119pkgs_brew_install: list pkgs-brew-install.list
120 brew install $(shell ./list pkgs-brew-install.list)
121
122pkgs_brew_cask_install: list pkgs-brew-cask-install.list
123 brew cask install $(shell ./list pkgs-brew-cask-install.list)
124
5bf7b45d
SK
125#
126# Debian
127#
649af0dd
SK
128pkgs_deb_install: list pkgs-deb-install.list
129 sudo apt install $(shell ./list pkgs-deb-install.list)
600d3b0b 130
649af0dd
SK
131pkgs_deb_purge: list pkgs-deb-purge.list
132 sudo apt purge $(shell ./list pkgs-deb-purge.list)
b59a4c3b 133
5bf7b45d
SK
134#
135# Snap
136#
649af0dd
SK
137pkgs_snap_classic: list pkgs-snap-classic.list
138 @$(MAKE) $(foreach p,$(shell ./list pkgs-snap-classic.list),pkg_snap_classic_$(p))
6ce65841 139
7ae05795
SK
140pkgs_snap_strict: list pkgs-snap-strict.list
141 @$(MAKE) $(foreach p,$(shell ./list pkgs-snap-strict.list),pkg_snap_strict_$(p))
142
143# 'snap' command comes from 'snapd' deb pkg
6ce65841
SK
144pkg_snap_classic_%:
145 sudo snap install --classic $*
7ae05795
SK
146pkg_snap_strict_%:
147 sudo snap install $*
6ce65841 148
f908f2dc
SK
149deps: $(DEPS)
150
151define GEN_DEP_RULE
152$(1):
153 cd $1 && make
154endef
155
156$(foreach d,$(DEPS),$(eval $(call GEN_DEP_RULE,$(d))))
ab64e543
SK
157
158diff:
cca3111e 159 find home -type f -print0 \
0b63d662 160 | $(SED) -z 's/^home\///g' \
73c0dfd5 161 | sort -zr \
b48e809e 162 | xargs -0 -I% sh -c 'echo %; $(DIFF) --color=auto ~/% home/%'
d03ce0c0 163
8132c0e4
SK
164pull:
165 find home -type f -print0 \
0b63d662
SK
166 | $(SED) -z 's/^home\///g' \
167 | xargs -0 -I% sh -c '$(DIFF) -q ~/% home/% > /dev/null || cp ~/% home/%'
8132c0e4 168
a97a6e09 169push:
101c2c38
SK
170 # TODO Backup files before replacing.
171 # But - recursive copy is not a good strategy for this.
172 # Need to do a file by file pass, like the diff recipe.
173 #
a97a6e09
SK
174 # Limit depth because directories are copied recursively:
175 find home -maxdepth 1 -print0 \
176 | $(GREP) -zv '^home$$' \
177 | xargs -0 -I% cp -Rp % ~
178
d03ce0c0
SK
179clean:
180 rm -rf ./debfiles
181 cd src && make clean
This page took 0.156406 seconds and 4 git commands to generate.