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