Makefile: Fix a stupid typo.
[profile] / Makefile
CommitLineData
67b1a15a
MW
1## -*-makefile-*-
2
3all::
4.SECONDEXPANSION: #sorry
5
6###--------------------------------------------------------------------------
7### Utilities.
8
9##
10quote = '$(subst ','\'',$1)'#'
11
12## Suss out how to print stuff.
13print = printf "%s" $(call quote,$1)
14
15## Looking configuration things up.
16mdw-conf = $(shell bin/mdw-conf "$1" "$2")
17
18## Checking symlink targets.
19symlink-ok-p = $(shell \
20 case $$(readlink 2>/dev/null $1) in ($2) echo t ;; esac)
21
22## Silent rules machinery.
23V = 0
24v_tag = $(call v_tag_$V,$1,$2)
25v_tag_0 = @printf " %-8s %s\n" "$1" $(call quote,$@);
26V_AT = $(V_AT_$V)
27V_AT_0 = @
28
29## Hack.
30relax =
31
32###--------------------------------------------------------------------------
33### Configuration.
34
35## Figure out where I am.
36HERE = $(shell pwd)
37
38## Decide on how to fetch things from URLs.
39ifeq ($(shell (curl >/dev/null 2>&1 --version || [ $$? -eq 2 ]) && echo t),t)
40 get-url = curl -fs -o $1 $2
41else
42 get-url = wget -q -O $1 $2
43endif
44
45## Which Emacs should I use?
46EMACS := $(shell \
47 emacs=nil; \
48 for i in emacs24 emacs23 emacs22 emacs21 emacs; do \
49 if type >/dev/null 2>&1 $$i; then echo $$i; break; fi; \
50 done)
51
52## Whence to obtain externally hosted stuff.
53REPO = https://ftp.distorted.org.uk/u/mdw/profile
54
55## Additional local configuration.
56-include local.mk
57
58###--------------------------------------------------------------------------
59### Some utility rules.
60
61_force:
62.PHONY: _force
63
64###--------------------------------------------------------------------------
65### Emacs.
66
67EMACSLIB = $(HOME)/lib/emacs
68
6369ae29
MW
69ELISP += make-regexp ew-hols
70ELISP += mdw-gnus-patch
71ELISP += mdw-multiple-cursors
72ELISP += git git-blame vc-git stgit quilt
73ELISP += bracketed-paste
67b1a15a 74
3e441da6
MW
75ELISP += dot-emacs
76dot-emacs_DEPS = make-regexp
77
67b1a15a
MW
78SCRIPTLINKS += emacsclient-hack movemail-hack sendmail-hack
79SCRIPTLINKS += aspell-hack emerge-hack
80
3e441da6 81%.elc: %.el $$(foreach e, $$($$*_DEPS), $$(DEP_$$e))
67b1a15a
MW
82 $(call v_tag,EMACS)$(EMACS) -L el/ -L $(EMACSLIB) \
83 --batch --no-site-file \
84 --eval '(byte-compile-file "$<")'
85
6369ae29
MW
86LOCAL_ELISP = $(filter $(notdir $(wildcard el/*.el)), \
87 $(addsuffix .el, $(ELISP)))
88$(foreach e, $(LOCAL_ELISP), \
89 $(eval DEP_$(basename $e) = $(EMACSLIB)/$(e:.el=.elc)))
67b1a15a
MW
90$(addprefix $(EMACSLIB)/, $(LOCAL_ELISP)): $(EMACSLIB)/%: el/%
91 $(call v_tag,SYMINK)mkdir -p $(EMACSLIB) && \
92 rm -f $@.new && \
93 ln -s $(HERE)/$< $@.new && \
94 mv $@.new $@
95
96REMOTE_ELISP = $(filter-out $(notdir $(wildcard el/*.el)), \
6369ae29 97 $(addsuffix .el, $(ELISP)))
67b1a15a 98$(foreach e, $(REMOTE_ELISP), \
6369ae29 99 $(eval DEP_$(basename $e) = $(if $(shell \
67b1a15a
MW
100 if $(EMACS) >/dev/null 2>&1 --no-site-file -q --batch \
101 --eval ' \
102 (progn \
103 (kill-emacs (condition-case nil \
104 (progn (load-library "$e") 0) \
105 (error 1))))'; then \
106 echo t; \
107 fi),, $(EMACSLIB)/$(e:.el=.elc))))
108$(addprefix $(EMACSLIB)/, $(REMOTE_ELISP)): $(EMACSLIB)/%:
109 $(call v_tag,FETCH)mkdir -p $(EMACSLIB) && \
110 $(call get-url,$@.new,$(REPO)/$*) && \
111 mv $@.new $@
112
113DOTLINKS += .emacs .emacs-calc .vm .gnus.el .ercrc.el
114
115all:: $(foreach e, $(ELISP), $(DEP_$e))
6369ae29 116$(foreach e, $(ELISP), $(eval _emacs.$e: $(EMACSLIB)/$e.elc))
67b1a15a
MW
117
118###--------------------------------------------------------------------------
119### Other simpler things.
120
121$(HOME)/.mdw.conf:
122 $(call v_tag,COPY)cp mdw.conf $@.new && mv $@.new $@
123
124## Utility packages.
125PACKAGES += mlib checkpath
126mlib_CHECK = crc-mktab
127checkpath_CHECK = tmpdir
128checkpath_DEPS = mlib
129
130## Packaging machinery.
131SCRIPTLINKS += mdw-build mdw-sbuild mdw-sbuild-server
132SCRIPTLINKS += update-buildable-branch
133
134## Shells.
135DOTLINKS += .profile .shell-rc .shell-logout
136DOTLINKS += .shrc .rcrc
137DOTLINKS += .zprofile .zshrc .zshenv
138DOTLINKS += .bash_profile .bash_completion .bashrc .inputrc
139.bash_profile_SRC = bash-profile
140.bash_completion_SRC = bash-completion
141
142## Git.
143DOTSUBST += .gitconfig
144DOTLINKS += .cgrc .tigrc
145.gitconfig_SUBSTS = \
146 $(call substvar,releasekey,$(call mdw-conf,release-key,481334C2))
147$(HOME)/.gitconfig: $(HOME)/.mdw.conf
148
149## PulseAudio.
150DOTLINKS += .pulse/daemon.conf
151DOTSUBST += .pulse/default.pa
152.pulse/daemon.conf_SRC = pulse-daemon.conf
153.pulse/default.pa_SRC = pulse-default.pa.in
154
155## Other editors.
156DOTLINKS += .vimrc .mg .zile
157
158## Mail.
159DOTLINKS += .mailrc .signature .muttrc
160
161## Lisp.
162DOTLINKS += .cmucl-init.lisp .sbclrc .clisprc.lisp .eclrc
163.cmucl-init.lisp_SRC = lisp-init.lisp
164.sbclrc_SRC = lisp-init.lisp
165.clisprc.lisp_SRC = lisp-init.lisp
166.eclrc_SRC = lisp-init.lisp
167DOTLINKS += .swank.lisp
168
169## IPython.
170DOTLINKS += .ipython/profile_default/ipython_config.py
171DOTLINKS += .ipython/profile_default/startup/50-key-bindings.py
172.ipython/profile_default/ipython_config.py_SRC = ipython-config.py
173.ipython/profile_default/startup/50-key-bindings.py_SRC = ipython-key-bindings.py
174
175## Other languages.
176DOTLINKS += .guile
177DOTLINKS += .tclshrc .wishrc
178.tclshrc_SRC = tclshrc
179.wishrc_SRC = tclshrc
180
181## Random scripts.
182SCRIPTLINKS += mdw-editor mdw-pager
183SCRIPTLINKS += mdw-conf
184SCRIPTLINKS += svnwrap
185SCRIPTLINKS += guest-console
186SCRIPTLINKS += hyperspec
187
188## Random odds and ends.
189DOTLINKS += .lesskey .infokey .sqliterc
190DOTLINKS += .gdbinit .toprc .aspell.conf
191DOTLINKS += .dircolors .colordiffrc .screenrc .tmux.conf
192DOTLINKS += .cvsrc .indent.pro .ditz-config
193DOTSUBST += .mykermrc
194SCRIPTLINKS += lesspipe.sh
195
196SCRIPTLINKS += run-with-shell-env
197SCRIPTLINKS += start-ssh-agent start-ssh-pageant
198SCRIPTLINKS += add-ssh-keys
199SCRIPTLINKS += hacks/ssh/ssh
200hacks/ssh/ssh_SRC = hacks/ssh
201
202DOTLINKS += .w3m/config .elinks/elinks.conf
203.w3m/config_SRC = w3m-config
204.elinks/elinks.conf_SRC = elinks.conf
205
206DOTLINKS += .mc/ini .mc/panels.ini
207.mc/ini_SRC = mc-ini
208.mc/panels.ini_SRC = mc-panels.ini
209
210DOTLINKS += .parallel/config
211.parallel/config_SRC = parallel-config
212
213###--------------------------------------------------------------------------
214### X11 configuration.
215
216ifeq ($X,t)
217
218PACKAGES += xtoys
219xtoys_CHECK = xatom
220xtoys_DEPS = mlib
221
222DOTLINKS += .xinitrc .xsession .xmodmap .vncrc .vncsession
223DOTLINKS += .fonts.conf
224DOTLINKS += .stalonetrayrc
225
226DOTLINKS += .putty/sessions/Default%20Settings
227.putty/sessions/Default%20Settings_SRC = putty-defaults
228
229DOTLINKS += .config/gnome-session/sessions/mdw.session
230.config/gnome-session/sessions/mdw.session_SRC = mdw.session
231
232DOTLINKS += .Eterm/themes/Eterm/theme.cfg
233DOTLINKS += .enlightenment/keybindings.cfg
234DOTLINKS += .enlightenment-vnc/keybindings.cfg
235DOTLINKS += .e16/bindings.cfg
236.Eterm/themes/Eterm/theme.cfg_SRC = eterm-theme.cfg
237.enlightenment/keybindings.cfg_SRC = e-keybindings.cfg
238.enlightenment-vnc/keybindings.cfg_SRC = evnc-keybindings.cfg
239.e16/bindings.cfg_SRC = e16-bindings
240
241DOTLINKS += .gtkrc-2.0
242DOTLINKS += .config/gtk-3.0/gtk.css
243DOTLINKS += .config/gtk-3.0/settings.ini
244.config/gtk-3.0/gtk.css_SRC = gtk3.css
245.config/gtk-3.0/settings.ini_SRC = gtk3-settings.ini
246
247SCRIPTLINKS += xinitcmd lock-screen xshutdown
248SCRIPTLINKS += un-backslashify-selection
249SCRIPTLINKS += xpra-start-xdummy
250
251DOTCPP += .Xdefaults
252Xdefaults_DEFS = -DEMACSWD=$(call mdw-conf,emacs-width,77)
253$(HOME)/.Xdefaults: $(HOME)/.mdw.conf
254
255endif
256
257###--------------------------------------------------------------------------
258### Processing dotfiles.
259
260dotfile-source = $(HERE)/dot/$(or $($1_SRC), $(1:.%=%)$2)
261
4937ba2d 262## Easiest: just make symlinks.
67b1a15a
MW
263dotlink-ok-p = \
264 $(call symlink-ok-p,$(HOME)/$1,$(call dotfile-source,$1))
265all:: $(addprefix $(HOME)/, $(DOTLINKS))
266$(addprefix $(HOME)/, $(subst %,\%,$(DOTLINKS))): $(HOME)/%: \
267 $$(if $$(call dotlink-ok-p,$$*),,_force)
268 $(call v_tag,SYMLINK)mkdir -p $(dir $@) && \
269 rm -f $@.new && \
270 ln -s $(call dotfile-source,$*) $@.new && \
271 mv $@.new $@
272
273## Hack with the C preprocessor.
274all:: $(addprefix $(HOME)/, $(DOTCPP))
275$(addprefix $(HOME)/, $(subst %,\%,$(DOTCPP))): $(HOME)/%: \
276 $$(call dotfile-source,$$*) Makefile
277 $(call v_tag,CPP)mkdir -p $(dir $@) && \
278 rm -f $@.new && \
279 cpp -P -o$@.new $($*_DEFS) $< && \
280 mv $@.new $@
281
282## Hack by making simple substitutions.
283substvar = -e $(call quote,s\a@$1@\a$2\ag)
284SUBSTS += $(call substvar,home,$(HOME))
285SUBSTS += $(call substvar,profile,$(HERE))
286all:: $(addprefix $(HOME)/, $(DOTSUBST))
287$(addprefix $(HOME)/, $(subst %,\%,$(DOTSUBST))): $(HOME)/%: \
288 $$(call dotsubst-source,$$*,.in) Makefile
289 $(call v_tag,SUBST)mkdir -p $(dir $@) && \
290 rm -f $@.new && \
291 sed -e "1i\
292$(relax)### generated by $(HERE)/Makefile; do not edit!" \
293 $(SUBSTS) $($*_SUBSTS) \
294 $(call dotfile-source,$*,.in) >$@.new && \
295 mv $@.new $@
296
297###--------------------------------------------------------------------------
298### Processing script links.
299
300script-source = $(HERE)/bin/$(or $($1_SRC), $1)
301scriptlink-ok-p = \
302 $(call symlink-ok-p,$(HOME)/bin/$1,$(call script-source,$1))
303all:: $(addprefix $(HOME)/bin/, $(SCRIPTLINKS))
304$(addprefix $(HOME)/bin/, $(SCRIPTLINKS)): $(HOME)/bin/%: \
305 $$(if $$(call scriptlink-ok-p,$$*),,_force)
306 $(call v_tag,SYMLINK)mkdir -p $(dir $@) && \
307 rm -f $@.new && \
308 ln -s $(call script-source,$*) $@.new && \
309 mv $@.new $@
310
311all:: $(addprefix $(HOME)/bin/, $(SCRIPTLINKS))
312
313###--------------------------------------------------------------------------
314### Building packages from source tarballs.
315
316SRCDIR = $(HOME)/src/profile
317
318pkg-builddir = $(SRCDIR)/$1/build
319pkg-stamp = $(call pkg-builddir,$1)/$2-stamp
320
321$(foreach p, $(PACKAGES), $(eval DEP_$p = $(if $(shell \
322 if $($p_CHECK) >/dev/null 2>&1 --version; then echo t; fi),, \
323 $(call pkg-stamp,$p,install))))
324
325$(PACKAGES:%=$(SRCDIR)/%.tar.gz): $(SRCDIR)/%.tar.gz:
326 $(call v_tag,FETCH)mkdir -p $(SRCDIR) && \
327 rm -f $@.new && \
328 $(call get-url,$@.new,$(REPO)/$*.tar.gz) && \
329 mv $@.new $@
330
331$(foreach p, $(PACKAGES), $(call pkg-stamp,$p,unpack)): \
332 $(call pkg-stamp,%,unpack): $(SRCDIR)/%.tar.gz
333 $(call v_tag,EXTRACT)rm -rf $(SRCDIR)/$* && \
334 mkdir $(SRCDIR)/$*.tmp-unpack && \
335 cd $(SRCDIR)/$*.tmp-unpack && \
336 gzip -cd ../$*.tar.gz | tar xf - && \
337 mv * ../$* && \
338 cd .. && \
339 rmdir $*.tmp-unpack && \
340 mkdir $*/build && \
341 touch $*/build/unpack-stamp
342
343$(foreach p, $(PACKAGES), $(call pkg-stamp,$p,configure)): \
344 $(call pkg-stamp,%,configure): \
345 $(call pkg-stamp,%,unpack) \
346 $$(foreach p, $$($$*_DEPS), $$(DEP_$$p))
347 $(call v_tag,CONFIG)cd $(dir $@) && \
348 ../configure --prefix=$(HOME) \
349 PKG_CONFIG_PATH=$(HOME)/lib/pkgconfig \
350 $($*_CONFIG) >>buildlog 2>&1 && \
351 touch configure-stamp
352
353$(foreach p, $(PACKAGES), $(call pkg-stamp,$p,build)): \
354 $(call pkg-stamp,%,build): \
355 $(call pkg-stamp,%,configure)
356 $(call v_tag,BUILD)cd $(dir $@) && \
357 $(MAKE) $($*_MAKEFLAGS) >>buildlog 2>&1 && \
358 touch build-stamp
359
360$(foreach p, $(PACKAGES), $(call pkg-stamp,$p,install)): \
361 $(call pkg-stamp,%,install): \
362 $(call pkg-stamp,%,build)
363 $(call v_tag,INSTALL)cd $(dir $@) && \
364 $(MAKE) $($*_MAKEFLAGS) install >>buildlog 2>&1 && \
365 touch install-stamp
366
367all:: $(foreach p, $(PACKAGES), $(DEP_$p))
368$(foreach p, $(PACKAGES), $(eval _pkg.$p: $(call pkg-stamp,$p,install)))
369
370###----- That's all, folks --------------------------------------------------