Fix diff and pull targets on Mac
[khome.git] / Makefile
1 MAKEFLAGS := --no-builtin-rules
2
3 DEPS := $(wildcard deps/*)
4
5 ifeq ($(shell uname),Darwin)
6 SED := gsed
7 DIFF := $(shell gls -t1 /usr/local/Cellar/diffutils/*/bin/diff | head -1)
8 else
9 SED := sed
10 DIFF := diff
11 endif
12
13 .PHONY: \
14 default \
15 clean \
16 $(DEPS) \
17 deps \
18 home \
19 diff \
20 pull \
21 mpdconf \
22 pkgs_brew_cask_install \
23 pkgs_brew_install \
24 pkgs_deb_install \
25 pkgs_deb_purge \
26 pkgs_debian \
27 pkgs_mac \
28 pkgs_pip \
29 pkgs_snap_classic \
30 pkgs_snap_strict
31
32 default:
33 @echo '================================================================================'
34 @echo '| Default target disabled. Specify a concrete one.'
35 @echo '================================================================================'
36 @exit 1
37
38 home: mpdconf compiled
39 @cp -Rp bin $(HOME)/
40 @cp -Rp home/bin $(HOME)/
41 @cp -Rp home/lib $(HOME)/
42 @cp home/.compton.conf $(HOME)/
43 @cp -Rp home/.config/ $(HOME)/
44 @cp -Rp home/.newsboat/ $(HOME)/
45 @cp home/.profile $(HOME)/
46 @cp home/.fonts.conf $(HOME)/
47 @cp home/.Rprofile $(HOME)/
48 @cp home/.tmux.conf $(HOME)/
49 @cp home/.xbindkeysrc $(HOME)/
50
51 mpdconf:
52 @mkdir -p ~/Archives/Audio
53 @mkdir -p ~/var/lib/mpd/playlists
54 @mkdir -p ~/var/log/mpd
55 @mkdir -p ~/var/run/mpd
56 @cp home/.mpdconf $(HOME)/
57
58 compiled:
59 mkdir -p bin
60 cd src && make
61 mv src/clockloop bin/
62
63 font_cache:
64 @fc-cache -fv
65
66 #
67 # Golang
68 #
69 pkgs_golang: list pkgs-golang.list
70 go get $(shell ./list pkgs-golang.list)
71
72 #
73 # Ubuntu
74 #
75 pkgs_ubuntu: list pkgs-ubuntu.list
76 sudo apt install $(shell ./list pkgs-ubuntu.list)
77
78 pkgs_ubuntu_debfiles: list pkgs-ubuntu-debfiles.list
79 ./install-debfiles pkgs-ubuntu-debfiles.list
80
81 #
82 # PIP
83 #
84 pkgs_pip:
85 sudo pip3 install $(shell ./list pkgs-pip.list)
86
87 #
88 # Homebrew/Mac
89 #
90
91 pkgs_mac:
92 $(MAKE) pkgs_brew_install
93 $(MAKE) pkgs_brew_cask_install
94
95 # TODO: Test pkgs_brew_tap when list contains multiple items
96 pkgs_brew_tap: list pkgs-brew-tap.list
97 brew tap $(shell ./list pkgs-brew-tap.list)
98
99 pkgs_brew_install: list pkgs-brew-install.list
100 brew install $(shell ./list pkgs-brew-install.list)
101
102 pkgs_brew_cask_install: list pkgs-brew-cask-install.list
103 brew cask install $(shell ./list pkgs-brew-cask-install.list)
104
105 #
106 # Debian
107 #
108 pkgs_deb_install: list pkgs-deb-install.list
109 sudo apt install $(shell ./list pkgs-deb-install.list)
110
111 pkgs_deb_purge: list pkgs-deb-purge.list
112 sudo apt purge $(shell ./list pkgs-deb-purge.list)
113
114 #
115 # Snap
116 #
117 pkgs_snap_classic: list pkgs-snap-classic.list
118 @$(MAKE) $(foreach p,$(shell ./list pkgs-snap-classic.list),pkg_snap_classic_$(p))
119
120 pkgs_snap_strict: list pkgs-snap-strict.list
121 @$(MAKE) $(foreach p,$(shell ./list pkgs-snap-strict.list),pkg_snap_strict_$(p))
122
123 # 'snap' command comes from 'snapd' deb pkg
124 pkg_snap_classic_%:
125 sudo snap install --classic $*
126 pkg_snap_strict_%:
127 sudo snap install $*
128
129 deps: $(DEPS)
130
131 define GEN_DEP_RULE
132 $(1):
133 cd $1 && make
134 endef
135
136 $(foreach d,$(DEPS),$(eval $(call GEN_DEP_RULE,$(d))))
137
138 diff:
139 find home -type f -print0 \
140 | $(SED) -z 's/^home\///g' \
141 | xargs -0 -I% sh -c 'echo %; $(DIFF) --color=always ~/% home/%'
142
143 pull:
144 find home -type f -print0 \
145 | $(SED) -z 's/^home\///g' \
146 | xargs -0 -I% sh -c '$(DIFF) -q ~/% home/% > /dev/null || cp ~/% home/%'
147
148 clean:
149 rm -rf ./debfiles
150 cd src && make clean
This page took 0.06287 seconds and 4 git commands to generate.