-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
152 lines (141 loc) · 3.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
SHELL:=/bin/bash -o pipefail
MAKEFLAGS+=--always-make # This makes all targets "phony"
.DEFAULT_GOAL:=$(shell echo $${HOSTNAME,,})
APT:=$(shell command -v apt 2>/dev/null)
PRINT=$(info $(shell printf '\e[32m%-*s\e[m\n' $$(tput cols) $@ | perl -pe 's/(?<= ) /─/g'))
ifneq "$(shell command -v pacman 2>/dev/null)" ""
PACMAN:=sudo pacman -S --noconfirm --needed
endif
# Mod lists. Running `make` will install the mod list corresponding to the
# machine's hostname, thanks to the "default goal" above.
tamriel: \
archive-tools \
bash \
bat \
cron \
dig \
docker \
exiftool \
fclones \
fd \
ffmpeg \
fzf \
gallery-dl \
gif-tools \
git \
gpg \
htop \
hyperfine \
ifconfig \
imagemagick \
json-tools \
man \
misc-utils \
mkvtoolnix \
nano \
node \
pv \
python \
rsync \
shellcheck \
sqlite \
starship \
sudo \
sweetroll \
tree \
wget \
whois \
wsl \
xdelta3 \
yt-dlp \
oblivion: tamriel
sovngarde: \
bash \
bat \
docker \
fclones \
fd \
fzf \
git \
mkvtoolnix \
nano \
starship \
sweetroll \
unraid \
server: \
bash \
docker \
git \
htop \
nano \
pv \
starship \
tree \
# Create targets for each mod. Double colon targets are separate targets with
# the same name that run in series; this lets mods define additional install
# steps or depend upon other mods via their included Makefile.
$(notdir $(wildcard mods/*)):: stow
$(PRINT)
stow $@
include mods/*/Makefile
# Install stow
stow:
$(PRINT)
ifdef APT
sudo apt-get update -qq
sudo apt-get install -qy stow
else ifdef PACMAN
# Perform a system upgrade before beginning to make sure there are no outdated
# package dependencies (Arch is designed to update everything in unison, so
# pacman -S pkg won't simply update pkg's dependencies)
# https://wiki.archlinux.org/title/System_maintenance#Partial_upgrades_are_unsupported
$(PACMAN) -yu stow
else
# https://gist.github.com/maxkagamine/7e3741b883a272230eb451bdd84a8e23
# MAKEFLAGS need to be reset to prevent weird behavior in stow's Makefile
wget http://ftp.gnu.org/gnu/stow/stow-latest.tar.gz -O - | tar -xzC /tmp
cd /tmp/stow* && ./configure && MFLAGS= MAKEFLAGS= make install
rm -rf /tmp/stow*
endif
# Shellcheck (see .vscode/tasks.json)
test:
@find mods -type f -exec awk '/^#.*sh/{printf "%s\0",FILENAME}{nextfile}' {} + | \
xargs -r0 shellcheck -xf gcc
watch:
ifeq "$(shell command -v inotifywait 2>/dev/null)" ""
$(info Installing inotifywait...)
ifdef APT
@sudo apt-get install -y inotify-tools >/dev/null
else ifdef PACMAN
@$(PACMAN) inotify-tools
else
$(error inotifywait install requires apt or pacman)
endif
endif
@while $(MAKE) test; inotifywait -qre close_write mods; do :; done
# Unnecessary visualization
# https://github.com/lindenb/makefile2graph
graph:
ifeq "$(shell command -v make2graph 2>/dev/null)" ""
rm -rf /tmp/make2graph
git clone https://github.com/lindenb/makefile2graph.git /tmp/make2graph
make -C /tmp/make2graph
sudo make -C /tmp/make2graph install
rm -rf /tmp/make2graph
endif
ifeq "$(shell command -v dot 2>/dev/null)" ""
ifdef APT
sudo apt-get install -y graphviz
else ifdef PACMAN
$(PACMAN) graphviz
else
$(error graphviz install requires apt or pacman)
endif
endif
make -Bnd tamriel sovngarde | \
grep -Pv '(stow|Makefile)' | \
make2graph | \
sed 's/, color="red"//g' | \
dot -Gmargin=0.3 -Gbgcolor=transparent -Tpng -o /dev/stdout | \
magick /dev/stdin -channel RGB -negate -background '#0d1117' -alpha remove \
.github/images/graph.png