-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGNUmakefile
174 lines (147 loc) · 4.29 KB
/
GNUmakefile
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
.DEFAULT_GOAL := all
EDITOR ?= /usr/bin/vim
srcdir := .
prefix := $(HOME)
# Command flags
# Patterns are added to Stow's builtin ignore list
# <https://www.gnu.org/software/stow/manual/html_node/Types-And-Syntax-Of-Ignore-Lists.html>
ignore_vim := .*\.sw[a-p]
ignore_backup := .*\.bak|.*\.~[1-9]~
ignore_pcre := ^($(ignore_vim)|$(ignore_backup))$$
STOWFLAGS := --no-folding --ignore '$(ignore_pcre)'
GITFLAGS := --init --recursive
# Operating Systems
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
MACOS := 1
packages := macos
else ifeq ($(UNAME_S),Linux)
UNAME_R := $(shell uname -r)
ifneq (,$(findstring WSL2,$(UNAME_R))) # e.g. 5.10.16.3-microsoft-standard-WSL2
WSL2 := 1
packages := wsl2
else
LINUX := 1
packages := linux
endif
else ifneq (,$(findstring CYGWIN,$(UNAME_S))) # e.g. CYGWIN_NT-10.0
# Do not override the standard CYGWIN environment variable
# <https://cygwin.com/cygwin-ug-net/using-cygwinenv.html>
ifndef CYGWIN
CYGWIN := 1
unexport CYGWIN
endif
packages := cygwin linux
gitlinks := $(srcdir)/cygwin/.local/opt/cygtools/.git
cygwin: linux $(srcdir)/cygwin/.local/opt/cygtools/.git
endif
# Graphics
packages += X11
# Media
packages += ffmpeg
# WMs and DEs
packages += i3
# Terminals
packages += xterm tmux
ifdef CYGWIN
packages += mintty
endif
xterm: X11
# Shells
packages += shell bash zsh
bash: shell
zsh: shell
# Editors - Vim
packages += vim
gitlinks += $(srcdir)/vim/.vim/pack/eeowaa/.git
vim-postinstall: $(srcdir)/vim/.vim/pack/eeowaa/.git
stow -d $(srcdir)/vim/.vim -t $(prefix)/.vim/pack $(filter-out --no-folding,$(STOWFLAGS)) pack
cd $(prefix)/.vim && chmod 700 undo swap backup viminfo
# Editors - LunarVim
packages += lvim
lvim: git python node rust
# Editors - Emacs
packages += emacs
ifdef MACOS
gitlinks += $(srcdir)/emacs/.local/src/emacs/build-emacs-for-macos/.git
emacs: $(srcdir)/emacs/.local/src/emacs/build-emacs-for-macos/.git
endif
# Editors - Doom Emacs
packages += doom
doomdirs := $(addprefix $(srcdir)/doom/.local/src/doom/,hlissner/doom-emacs-private/.git tecosaur/emacs-config/.git)
gitlinks += $(doomdirs) $(srcdir)/doom/.config/doom/.git
$(doomdirs): GITFLAGS := $(filter-out --recursive,$(GITFLAGS))
doom: STOWFLAGS := $(filter-out --no-folding,$(STOWFLAGS))
doom: emacs $(doomdirs) $(srcdir)/doom/.config/doom/.git
# Pagers
packages += bat less
# Browsers
packages += lynx firefox
# Security
packages += bw openssl ssh
# Development
packages += direnv gdb git irc
# Languages
packages += dotnet go haskell lua node perl python rust
# Platforms
packages += aws az docker flatpak k8s
k8s: utils
# Databases
packages += elastic ldap mongo redis
redis: docker
# Automation
packages += ansible parallel topgrade
# Reference and Documentation
packages += info locate markdown org
gitlinks += $(srcdir)/org/org/.git
org: $(srcdir)/org/org/.git
# Miscellaneous
packages += utils work
gitlinks += $(srcdir)/utils/.local/opt/mailconvert/.git
utils: parallel $(srcdir)/utils/.local/opt/mailconvert/.git
# Local Configuration
.PHONY: dist configure
exampleconf := $(srcdir)/example-local.mk
localconf := $(srcdir)/local.mk
dist:
printf '# Override packages\npackages := \\\n' >$(exampleconf)
ls -l $(srcdir) \
| awk '/^d/ && $$NF !~ /^\./ { printf $$NF " " }' \
| fmt \
| sed -e 's/$$/ \\/' -e '$$s/ \\$$//' >>$(exampleconf)
configure:
-direnv allow .
-cp -n $(exampleconf) $(localconf)
$(EDITOR) $(localconf)
ifneq (,$(wildcard $(localconf)))
include $(localconf)
else
$(warning WARNING: File does not exist: $(localconf))
endif
# Composite
.PHONY: all submodules
all: $(packages)
submodules: $(gitlinks)
# Meta
.PHONY: list listdeps test
null :=
space := $(null) $(null)
define newline
endef
list:
@: $(info $(subst $(space),$(newline),$(sort $(packages))))
listdeps:
$(srcdir)/.bin/listdeps
test:
stow -d $(srcdir) -t $(prefix) $(STOWFLAGS) -nv $(packages)
# Recipes
preinstall_targets := $(addsuffix -preinstall,$(packages))
install_targets := $(addsuffix -install,$(packages))
postinstall_targets := $(addsuffix -postinstall,$(packages))
.PHONY: $(preinstall_targets) $(install_targets) $(postinstall_targets) $(packages)
$(install_targets): %-install: %-preinstall
stow -d $(srcdir) -t $(prefix) $(STOWFLAGS) $*
$(postinstall_targets): %-postinstall: %-install
$(packages): %: %-postinstall
$(gitlinks):
git -C $(srcdir) submodule update $(GITFLAGS) $(patsubst $(srcdir)/%,%,$(@D))