chiark / gitweb /
bin/mdw-build, bin/mdw-sbuild, bin/mdw-sbuild-server: Additional packages.
[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))
83198952
MW
82 $(call v_tag,EMACS)if ! $(EMACS) >$*.build-log 2>&1 \
83 -L el/ -L $(EMACSLIB) \
67b1a15a 84 --batch --no-site-file \
83198952
MW
85 --eval '(byte-compile-file "$<")'; then \
86 cat $*.build-log; exit 2; \
87 fi
67b1a15a 88
6369ae29
MW
89LOCAL_ELISP = $(filter $(notdir $(wildcard el/*.el)), \
90 $(addsuffix .el, $(ELISP)))
91$(foreach e, $(LOCAL_ELISP), \
92 $(eval DEP_$(basename $e) = $(EMACSLIB)/$(e:.el=.elc)))
67b1a15a
MW
93$(addprefix $(EMACSLIB)/, $(LOCAL_ELISP)): $(EMACSLIB)/%: el/%
94 $(call v_tag,SYMINK)mkdir -p $(EMACSLIB) && \
95 rm -f $@.new && \
96 ln -s $(HERE)/$< $@.new && \
97 mv $@.new $@
98
99REMOTE_ELISP = $(filter-out $(notdir $(wildcard el/*.el)), \
6369ae29 100 $(addsuffix .el, $(ELISP)))
67b1a15a 101$(foreach e, $(REMOTE_ELISP), \
6369ae29 102 $(eval DEP_$(basename $e) = $(if $(shell \
67b1a15a
MW
103 if $(EMACS) >/dev/null 2>&1 --no-site-file -q --batch \
104 --eval ' \
105 (progn \
106 (kill-emacs (condition-case nil \
107 (progn (load-library "$e") 0) \
108 (error 1))))'; then \
109 echo t; \
110 fi),, $(EMACSLIB)/$(e:.el=.elc))))
111$(addprefix $(EMACSLIB)/, $(REMOTE_ELISP)): $(EMACSLIB)/%:
112 $(call v_tag,FETCH)mkdir -p $(EMACSLIB) && \
113 $(call get-url,$@.new,$(REPO)/$*) && \
114 mv $@.new $@
115
116DOTLINKS += .emacs .emacs-calc .vm .gnus.el .ercrc.el
117
118all:: $(foreach e, $(ELISP), $(DEP_$e))
6369ae29 119$(foreach e, $(ELISP), $(eval _emacs.$e: $(EMACSLIB)/$e.elc))
67b1a15a
MW
120
121###--------------------------------------------------------------------------
122### Other simpler things.
123
124$(HOME)/.mdw.conf:
125 $(call v_tag,COPY)cp mdw.conf $@.new && mv $@.new $@
126
127## Utility packages.
128PACKAGES += mlib checkpath
129mlib_CHECK = crc-mktab
130checkpath_CHECK = tmpdir
131checkpath_DEPS = mlib
132
133## Packaging machinery.
134SCRIPTLINKS += mdw-build mdw-sbuild mdw-sbuild-server
135SCRIPTLINKS += update-buildable-branch
136
137## Shells.
138DOTLINKS += .profile .shell-rc .shell-logout
139DOTLINKS += .shrc .rcrc
140DOTLINKS += .zprofile .zshrc .zshenv
141DOTLINKS += .bash_profile .bash_completion .bashrc .inputrc
142.bash_profile_SRC = bash-profile
143.bash_completion_SRC = bash-completion
144
145## Git.
146DOTSUBST += .gitconfig
147DOTLINKS += .cgrc .tigrc
148.gitconfig_SUBSTS = \
149 $(call substvar,releasekey,$(call mdw-conf,release-key,481334C2))
150$(HOME)/.gitconfig: $(HOME)/.mdw.conf
151
152## PulseAudio.
153DOTLINKS += .pulse/daemon.conf
154DOTSUBST += .pulse/default.pa
155.pulse/daemon.conf_SRC = pulse-daemon.conf
156.pulse/default.pa_SRC = pulse-default.pa.in
157
158## Other editors.
159DOTLINKS += .vimrc .mg .zile
160
161## Mail.
162DOTLINKS += .mailrc .signature .muttrc
163
164## Lisp.
165DOTLINKS += .cmucl-init.lisp .sbclrc .clisprc.lisp .eclrc
166.cmucl-init.lisp_SRC = lisp-init.lisp
167.sbclrc_SRC = lisp-init.lisp
168.clisprc.lisp_SRC = lisp-init.lisp
169.eclrc_SRC = lisp-init.lisp
170DOTLINKS += .swank.lisp
171
172## IPython.
173DOTLINKS += .ipython/profile_default/ipython_config.py
174DOTLINKS += .ipython/profile_default/startup/50-key-bindings.py
175.ipython/profile_default/ipython_config.py_SRC = ipython-config.py
176.ipython/profile_default/startup/50-key-bindings.py_SRC = ipython-key-bindings.py
177
178## Other languages.
179DOTLINKS += .guile
180DOTLINKS += .tclshrc .wishrc
181.tclshrc_SRC = tclshrc
182.wishrc_SRC = tclshrc
183
184## Random scripts.
185SCRIPTLINKS += mdw-editor mdw-pager
186SCRIPTLINKS += mdw-conf
187SCRIPTLINKS += svnwrap
188SCRIPTLINKS += guest-console
189SCRIPTLINKS += hyperspec
190
191## Random odds and ends.
192DOTLINKS += .lesskey .infokey .sqliterc
193DOTLINKS += .gdbinit .toprc .aspell.conf
194DOTLINKS += .dircolors .colordiffrc .screenrc .tmux.conf
195DOTLINKS += .cvsrc .indent.pro .ditz-config
196DOTSUBST += .mykermrc
197SCRIPTLINKS += lesspipe.sh
198
199SCRIPTLINKS += run-with-shell-env
200SCRIPTLINKS += start-ssh-agent start-ssh-pageant
201SCRIPTLINKS += add-ssh-keys
202SCRIPTLINKS += hacks/ssh/ssh
203hacks/ssh/ssh_SRC = hacks/ssh
204
205DOTLINKS += .w3m/config .elinks/elinks.conf
206.w3m/config_SRC = w3m-config
207.elinks/elinks.conf_SRC = elinks.conf
208
209DOTLINKS += .mc/ini .mc/panels.ini
210.mc/ini_SRC = mc-ini
211.mc/panels.ini_SRC = mc-panels.ini
212
213DOTLINKS += .parallel/config
214.parallel/config_SRC = parallel-config
215
216###--------------------------------------------------------------------------
217### X11 configuration.
218
219ifeq ($X,t)
220
221PACKAGES += xtoys
222xtoys_CHECK = xatom
223xtoys_DEPS = mlib
224
225DOTLINKS += .xinitrc .xsession .xmodmap .vncrc .vncsession
226DOTLINKS += .fonts.conf
227DOTLINKS += .stalonetrayrc
228
229DOTLINKS += .putty/sessions/Default%20Settings
230.putty/sessions/Default%20Settings_SRC = putty-defaults
231
232DOTLINKS += .config/gnome-session/sessions/mdw.session
233.config/gnome-session/sessions/mdw.session_SRC = mdw.session
234
235DOTLINKS += .Eterm/themes/Eterm/theme.cfg
236DOTLINKS += .enlightenment/keybindings.cfg
237DOTLINKS += .enlightenment-vnc/keybindings.cfg
238DOTLINKS += .e16/bindings.cfg
239.Eterm/themes/Eterm/theme.cfg_SRC = eterm-theme.cfg
240.enlightenment/keybindings.cfg_SRC = e-keybindings.cfg
241.enlightenment-vnc/keybindings.cfg_SRC = evnc-keybindings.cfg
242.e16/bindings.cfg_SRC = e16-bindings
243
244DOTLINKS += .gtkrc-2.0
245DOTLINKS += .config/gtk-3.0/gtk.css
246DOTLINKS += .config/gtk-3.0/settings.ini
247.config/gtk-3.0/gtk.css_SRC = gtk3.css
248.config/gtk-3.0/settings.ini_SRC = gtk3-settings.ini
249
250SCRIPTLINKS += xinitcmd lock-screen xshutdown
251SCRIPTLINKS += un-backslashify-selection
252SCRIPTLINKS += xpra-start-xdummy
253
254DOTCPP += .Xdefaults
255Xdefaults_DEFS = -DEMACSWD=$(call mdw-conf,emacs-width,77)
256$(HOME)/.Xdefaults: $(HOME)/.mdw.conf
257
258endif
259
260###--------------------------------------------------------------------------
261### Processing dotfiles.
262
263dotfile-source = $(HERE)/dot/$(or $($1_SRC), $(1:.%=%)$2)
264
4937ba2d 265## Easiest: just make symlinks.
67b1a15a
MW
266dotlink-ok-p = \
267 $(call symlink-ok-p,$(HOME)/$1,$(call dotfile-source,$1))
268all:: $(addprefix $(HOME)/, $(DOTLINKS))
269$(addprefix $(HOME)/, $(subst %,\%,$(DOTLINKS))): $(HOME)/%: \
270 $$(if $$(call dotlink-ok-p,$$*),,_force)
271 $(call v_tag,SYMLINK)mkdir -p $(dir $@) && \
272 rm -f $@.new && \
273 ln -s $(call dotfile-source,$*) $@.new && \
274 mv $@.new $@
275
276## Hack with the C preprocessor.
277all:: $(addprefix $(HOME)/, $(DOTCPP))
278$(addprefix $(HOME)/, $(subst %,\%,$(DOTCPP))): $(HOME)/%: \
279 $$(call dotfile-source,$$*) Makefile
280 $(call v_tag,CPP)mkdir -p $(dir $@) && \
281 rm -f $@.new && \
282 cpp -P -o$@.new $($*_DEFS) $< && \
283 mv $@.new $@
284
285## Hack by making simple substitutions.
286substvar = -e $(call quote,s\a@$1@\a$2\ag)
287SUBSTS += $(call substvar,home,$(HOME))
288SUBSTS += $(call substvar,profile,$(HERE))
289all:: $(addprefix $(HOME)/, $(DOTSUBST))
290$(addprefix $(HOME)/, $(subst %,\%,$(DOTSUBST))): $(HOME)/%: \
291 $$(call dotsubst-source,$$*,.in) Makefile
292 $(call v_tag,SUBST)mkdir -p $(dir $@) && \
293 rm -f $@.new && \
294 sed -e "1i\
295$(relax)### generated by $(HERE)/Makefile; do not edit!" \
296 $(SUBSTS) $($*_SUBSTS) \
297 $(call dotfile-source,$*,.in) >$@.new && \
298 mv $@.new $@
299
300###--------------------------------------------------------------------------
301### Processing script links.
302
303script-source = $(HERE)/bin/$(or $($1_SRC), $1)
304scriptlink-ok-p = \
305 $(call symlink-ok-p,$(HOME)/bin/$1,$(call script-source,$1))
306all:: $(addprefix $(HOME)/bin/, $(SCRIPTLINKS))
307$(addprefix $(HOME)/bin/, $(SCRIPTLINKS)): $(HOME)/bin/%: \
308 $$(if $$(call scriptlink-ok-p,$$*),,_force)
309 $(call v_tag,SYMLINK)mkdir -p $(dir $@) && \
310 rm -f $@.new && \
311 ln -s $(call script-source,$*) $@.new && \
312 mv $@.new $@
313
314all:: $(addprefix $(HOME)/bin/, $(SCRIPTLINKS))
315
316###--------------------------------------------------------------------------
317### Building packages from source tarballs.
318
319SRCDIR = $(HOME)/src/profile
320
321pkg-builddir = $(SRCDIR)/$1/build
322pkg-stamp = $(call pkg-builddir,$1)/$2-stamp
323
324$(foreach p, $(PACKAGES), $(eval DEP_$p = $(if $(shell \
325 if $($p_CHECK) >/dev/null 2>&1 --version; then echo t; fi),, \
326 $(call pkg-stamp,$p,install))))
327
328$(PACKAGES:%=$(SRCDIR)/%.tar.gz): $(SRCDIR)/%.tar.gz:
329 $(call v_tag,FETCH)mkdir -p $(SRCDIR) && \
330 rm -f $@.new && \
331 $(call get-url,$@.new,$(REPO)/$*.tar.gz) && \
332 mv $@.new $@
333
334$(foreach p, $(PACKAGES), $(call pkg-stamp,$p,unpack)): \
335 $(call pkg-stamp,%,unpack): $(SRCDIR)/%.tar.gz
336 $(call v_tag,EXTRACT)rm -rf $(SRCDIR)/$* && \
337 mkdir $(SRCDIR)/$*.tmp-unpack && \
338 cd $(SRCDIR)/$*.tmp-unpack && \
339 gzip -cd ../$*.tar.gz | tar xf - && \
340 mv * ../$* && \
341 cd .. && \
342 rmdir $*.tmp-unpack && \
343 mkdir $*/build && \
344 touch $*/build/unpack-stamp
345
346$(foreach p, $(PACKAGES), $(call pkg-stamp,$p,configure)): \
347 $(call pkg-stamp,%,configure): \
348 $(call pkg-stamp,%,unpack) \
349 $$(foreach p, $$($$*_DEPS), $$(DEP_$$p))
350 $(call v_tag,CONFIG)cd $(dir $@) && \
351 ../configure --prefix=$(HOME) \
352 PKG_CONFIG_PATH=$(HOME)/lib/pkgconfig \
353 $($*_CONFIG) >>buildlog 2>&1 && \
354 touch configure-stamp
355
356$(foreach p, $(PACKAGES), $(call pkg-stamp,$p,build)): \
357 $(call pkg-stamp,%,build): \
358 $(call pkg-stamp,%,configure)
359 $(call v_tag,BUILD)cd $(dir $@) && \
360 $(MAKE) $($*_MAKEFLAGS) >>buildlog 2>&1 && \
361 touch build-stamp
362
363$(foreach p, $(PACKAGES), $(call pkg-stamp,$p,install)): \
364 $(call pkg-stamp,%,install): \
365 $(call pkg-stamp,%,build)
366 $(call v_tag,INSTALL)cd $(dir $@) && \
367 $(MAKE) $($*_MAKEFLAGS) install >>buildlog 2>&1 && \
368 touch install-stamp
369
370all:: $(foreach p, $(PACKAGES), $(DEP_$p))
371$(foreach p, $(PACKAGES), $(eval _pkg.$p: $(call pkg-stamp,$p,install)))
372
373###----- That's all, folks --------------------------------------------------