9 .SECONDEXPANSION
: #sorry
11 ###--------------------------------------------------------------------------
15 quote
= '$(subst ','\'',$1)'#'
17 ## Suss out how to print stuff.
18 print = printf
"%s" $(call quote
,$1)
20 ## Looking configuration things up.
21 mdw-conf
= $(shell bin
/mdw-conf
"$1" "$2")
23 ## Checking symlink targets.
24 symlink-ok-p
= $(shell \
25 case
$$(readlink
2>/dev
/null
$1) in
($2) echo t
;; esac
)
27 ## Silent rules machinery.
31 v_print
= $(call v_print_
$V,$1,$2)
33 printf
" %-8s %s\n" "$1" $(call quote
,$(patsubst $(HOME
)/%,~
/%,$2));
34 v_tag
= $(V_AT
)$(call v_print_
$V,$1,$@
)
39 ###--------------------------------------------------------------------------
42 ## Figure out where I am.
45 ## Decide on how to fetch things from URLs.
46 ifeq ($(shell (curl
>/dev
/null
2>&1 --version ||
[ $$?
-eq
2 ]) && echo t
),t
)
47 get-url
= curl
-fs
-o
$1 $2
49 get-url
= wget
-q
-O
$1 $2
52 ## Which Emacs should I use?
55 for i in emacs24 emacs23 emacs22 emacs21 emacs
; do \
56 if type
>/dev
/null
2>&1 $$i; then emacs
=$$i; break
; fi
; \
60 ## Whence to obtain externally hosted stuff.
61 REPO
= https
://ftp.distorted.org.uk
/u
/mdw
/profile
63 ## Additional local configuration.
66 ###--------------------------------------------------------------------------
67 ### Some utility rules.
72 ###--------------------------------------------------------------------------
77 EMACSLIB
= $(HOME
)/lib
/emacs
79 EMACS_VERSION
:= $(shell $(EMACS
) 2>&1 -Q
--batch
--eval \
80 '(message "%s %s" emacs-major-version emacs-minor-version)' | \
82 emacs-version-p
= $(shell set
-- $(EMACS_VERSION
); \
83 if
[ $$1 -gt
$1 ] ||
([ $$1 -eq
$1 ] && [ $$2 -ge
$2 ]); then \
87 ELISP
+= make-regexp ew-hols
88 ELISP
+= mdw-gnus-patch
89 ELISP
+= mdw-multiple-cursors
90 ELISP
+= git git-blame vc-git stgit quilt
92 ifeq ($(call emacs-version-p
,24,3),t
)
93 ELISP
+= bracketed-paste
97 dot-emacs_DEPS
= make-regexp
99 SCRIPTLINKS
+= emacsclient-hack movemail-hack sendmail-hack
100 SCRIPTLINKS
+= aspell-hack emerge-hack wakey.sh
102 %.elc
: %.el
$$(foreach e
, $$($$*_DEPS
), $$(DEP_
$$e))
103 $(call v_tag
,EMACS
)if
! $(EMACS
) >$*.build-log
2>&1 \
104 -L el
/ -L
$(EMACSLIB
) \
105 --batch
--no-site-file \
106 --eval
'(byte-compile-file "$<")'; then \
107 cat
$*.build-log
; exit
2; \
110 LOCAL_ELISP
= $(filter $(notdir $(wildcard el
/*.el
)), \
111 $(addsuffix .el
, $(ELISP
)))
112 $(foreach e
, $(LOCAL_ELISP
), \
113 $(eval DEP_
$(basename $e) = $(EMACSLIB
)/$(e
:.el
=.elc
)))
114 $(addprefix $(EMACSLIB
)/, $(LOCAL_ELISP
)): $(EMACSLIB
)/%: el
/%
115 $(call v_tag
,SYMINK
)mkdir
-p
$(EMACSLIB
) && \
117 ln
-s
$(HERE
)/$< $@.new
&& \
120 REMOTE_ELISP
= $(filter-out $(notdir $(wildcard el
/*.el
)), \
121 $(addsuffix .el
, $(ELISP
)))
122 $(foreach e
, $(REMOTE_ELISP
), \
123 $(eval DEP_
$(basename $e) = $(if
$(shell \
124 if
$(EMACS
) >/dev
/null
2>&1 --no-site-file
-q
--batch \
127 (kill-emacs (condition-case nil \
128 (progn (load-library "$e") 0) \
129 (error 1))))'; then \
131 fi
),, $(EMACSLIB
)/$(e
:.el
=.elc
))))
132 $(addprefix $(EMACSLIB
)/, $(REMOTE_ELISP
)): $(EMACSLIB
)/%:
133 $(call v_tag
,FETCH
)mkdir
-p
$(EMACSLIB
) && \
134 $(call get-url
,$@.new
,$(REPO
)/$*) && \
137 DOTLINKS
+= .emacs .emacs-calc .vm .gnus.el .ercrc.el
139 all: $(foreach e
, $(ELISP
), $(DEP_
$e))
140 $(foreach e
, $(ELISP
), $(eval _emacs.
$e: $(EMACSLIB
)/$e.elc
))
144 ###--------------------------------------------------------------------------
145 ### Other simpler things.
148 $(call v_tag
,COPY
)cp mdw.conf
$@.new
&& mv
$@.new
$@
151 PACKAGES
+= mlib checkpath
152 mlib_CHECK
= crc-mktab
153 checkpath_CHECK
= tmpdir
154 checkpath_DEPS
= mlib
156 ## Packaging machinery.
157 SCRIPTLINKS
+= mdw-build mdw-sbuild mdw-sbuild-server
158 SCRIPTLINKS
+= update-buildable-branch
159 DOTLINKS
+= .config
/mdw-build.conf
160 .config
/mdw-build.conf_SRC
= mdw-build.conf
163 DOTLINKS
+= .profile .shell-rc .shell-logout
165 DOTLINKS
+= .zprofile .zshrc .zlogout .zshenv
166 DOTLINKS
+= .bash_profile .bash_completion .bash_logout
167 DOTLINKS
+= .bashrc .inputrc
168 .bash_profile_SRC
= bash-profile
169 .bash_completion_SRC
= bash-completion
170 .bash_logout_SRC
= shell-logout
171 .zlogout_SRC
= shell-logout
173 all: zap-stale-zcompdump
175 $(V_AT
)if
[ $(HOME
)/.zcompdump
-ot dot
/zshrc
]; then \
176 $(call v_print
,ZAP
,$(HOME
)/.zcompdump
)rm -f
$(HOME
)/.zcompdump
; \
178 .PHONY
: zap-stale-zcompdump
180 ## The Plan 9 `rc' shell. This needs special hacking, because the Linux port
181 ## and Plan 9 From User Space have incompatible syntax.
182 DOTLINKS
+= lib
/profile
183 lib
/profile_SRC
= rcrc
185 $(HOME
)/.rcrc
: dot
/rcrc
186 $(call v_tag
,SED
)sed
's/; if not/else/' $< >$@.new
&& mv
$@.new
$@
189 DOTSUBST
+= .gitconfig
190 SCRIPTLINKS
+= git-copyright-dates
191 DOTLINKS
+= .cgrc .tigrc
192 .gitconfig_SUBSTS
= \
193 $(call substvar
,releasekey
,$(call mdw-conf
,releasekey
,481334C2
)) \
194 $(call substvar
,email
,$(call mdw-conf
,email
,mdw@distorted.org.uk
))
195 $(HOME
)/.gitconfig
: $(HOME
)/.mdw.conf
198 DOTLINKS
+= .pulse
/daemon.conf
199 DOTSUBST
+= .pulse
/default.pa
200 .pulse
/daemon.conf_SRC
= pulse-daemon.conf
201 .pulse
/default.pa_SRC
= pulse-default.pa.in
204 DOTLINKS
+= .vimrc .mg .zile
207 DOTLINKS
+= .mailrc .signature .muttrc
210 DOTLINKS
+= .cmucl-init.lisp .sbclrc .clisprc.lisp
211 DOTLINKS
+= .eclrc .ccl-init.lisp .abclrc
212 .cmucl-init.lisp_SRC
= lisp-init.lisp
213 .sbclrc_SRC
= lisp-init.lisp
214 .clisprc.lisp_SRC
= lisp-init.lisp
215 .eclrc_SRC
= lisp-init.lisp
216 .ccl-init.lisp_SRC
= lisp-init.lisp
217 .abclrc_SRC
= lisp-init.lisp
218 DOTLINKS
+= .swank.lisp
221 DOTLINKS
+= .ipython
/profile_default
/ipython_config.py
222 DOTLINKS
+= .ipython
/profile_default
/startup
/50-key-bindings.py
223 .ipython
/profile_default
/ipython_config.py_SRC
= ipython-config.py
224 .ipython
/profile_default
/startup
/50-key-bindings.py_SRC
= ipython-key-bindings.py
228 DOTLINKS
+= .tclshrc .wishrc
229 .tclshrc_SRC
= tclshrc
230 .wishrc_SRC
= tclshrc
232 ## The `nocss' machinery.
234 all: $(HOME
)/lib
/hacks
/nocss
/libdvdcss.so
.2
235 $(HOME
)/lib
/hacks
/nocss
/libdvdcss.so
.2:
236 $(V_AT
)mkdir
-p
$(dir $@
)
237 $(call v_tag
,TOUCH
)touch
$@
240 SCRIPTLINKS
+= mdw-editor mdw-pager
241 SCRIPTLINKS
+= mdw-conf
242 SCRIPTLINKS
+= svnwrap
243 SCRIPTLINKS
+= guest-console
244 SCRIPTLINKS
+= hyperspec
246 SCRIPTLINKS
+= datasyms
247 SCRIPTLINKS
+= fixsub
248 SCRIPTLINKS
+= check-debsyms
249 SCRIPTLINKS
+= check-blkdev-size
250 SCRIPTLINKS
+= xremote
251 SCRIPTLINKS
+= remote-disorder
252 SCRIPTLINKS
+= remote-slideshow
254 ## Random odds and ends.
255 DOTLINKS
+= .infokey .sqliterc
256 DOTLINKS
+= .gdbinit .toprc .aspell.conf
257 DOTLINKS
+= .dircolors .colordiffrc .screenrc .tmux.conf
258 DOTLINKS
+= .cvsrc .indent.pro .ditz-config
260 .lftp
/rc_SRC
= lftp-rc
261 DOTLINKS
+= .a2ps
/a2psrc
262 .a2ps
/a2psrc_SRC
= a2psrc
263 DOTSUBST
+= .mykermrc
264 SCRIPTLINKS
+= lesspipe.sh
266 SCRIPTLINKS
+= run-with-shell-env
267 SCRIPTLINKS
+= start-ssh-agent start-ssh-pageant
268 SCRIPTLINKS
+= add-ssh-keys
269 SCRIPTLINKS
+= hacks
/ssh
/ssh
270 hacks
/ssh
/ssh_SRC
= hacks
/ssh
272 DOTLINKS
+= .w3m
/config .elinks
/elinks.conf
273 .w3m
/config_SRC
= w3m-config
274 .elinks
/elinks.conf_SRC
= elinks.conf
276 DOTLINKS
+= .mc
/ini .mc
/panels.ini
278 .mc
/panels.ini_SRC
= mc-panels.ini
280 DOTLINKS
+= .parallel
/config .parallel
/sshloginfile
281 .parallel
/config_SRC
= parallel-config
282 .parallel
/sshloginfile_SRC
= parallel-hosts
285 $(HOME
)/.less
: dot
/lesskey
286 $(V_AT
)rm -f
$(HOME
)/.lesskey
287 $(call v_tag
,LESSKEY
)lesskey
-o
$@
$<
289 ###--------------------------------------------------------------------------
290 ### X11 configuration.
298 DOTLINKS
+= .xinitrc .xsession .xmodmap .vncrc .vncsession
299 DOTLINKS
+= .config
/fontconfig
/fonts.conf
300 .config
/fontconfig
/fonts.conf_SRC
= fonts.conf
301 DOTLINKS
+= .stalonetrayrc
303 DOTLINKS
+= .config
/gnome-session
/sessions
/mdw.session
304 .config
/gnome-session
/sessions
/mdw.session_SRC
= mdw.session
306 DOTLINKS
+= .Eterm
/themes
/Eterm
/theme.cfg
307 DOTLINKS
+= .enlightenment
/keybindings.cfg
308 DOTLINKS
+= .enlightenment-vnc
/keybindings.cfg
309 DOTLINKS
+= .e16
/bindings.cfg
310 .Eterm
/themes
/Eterm
/theme.cfg_SRC
= eterm-theme.cfg
311 .enlightenment
/keybindings.cfg_SRC
= e-keybindings.cfg
312 .enlightenment-vnc
/keybindings.cfg_SRC
= evnc-keybindings.cfg
313 .e16
/bindings.cfg_SRC
= e16-bindings
315 DOTLINKS
+= .gtkrc-2.0
316 DOTLINKS
+= .config
/gtk-3.0
/gtk.css
317 DOTLINKS
+= .config
/gtk-3.0
/settings.ini
318 .config
/gtk-3.0
/gtk.css_SRC
= gtk3.css
319 .config
/gtk-3.0
/settings.ini_SRC
= gtk3-settings.ini
321 DOTLINKS
+= .config
/user-dirs.dirs .config
/user-dirs.locale
322 .config
/user-dirs.dirs_SRC
= user-dirs.dirs
323 .config
/user-dirs.locale_SRC
= user-dirs.locale
325 SCRIPTLINKS
+= xinitcmd lock-screen xshutdown
326 SCRIPTLINKS
+= un-backslashify-selection
327 SCRIPTLINKS
+= xpra-start-xdummy
328 SCRIPTLINKS
+= play-rawk
329 SCRIPTLINKS
+= x2x-privsep
330 SCRIPTLINKS
+= xduplic-terminal
333 Xdefaults_DEFS
= -DEMACSWD
=$(call mdw-conf
,emacs-width
,77)
334 $(HOME
)/.Xdefaults
: $(HOME
)/.mdw.conf dot
/Xdefaults.pterm
336 ifeq ($(shell case
$${DISPLAY-nil
} in
(:[0-9]*) echo t
;; (*) echo nil
;; esac
),t
)
337 dotfile-hook
/.Xdefaults
= \
338 $(call v_tag
,XRDB
)xrdb
-load
$<
343 ###--------------------------------------------------------------------------
349 $(call v_tag
,MKDIR
)mkdir
$@
352 $(call v_tag
,MKDIR
)mkdir
$@
356 all: out
/firefox
/smartup-gestures.config
357 out
/firefox
/smartup-gestures.config
: firefox
/smartup-gestures.json | out
/firefox
/
359 jq
-c .
$< | bincode base64
>$@.new
&& mv
$@.new
$@
361 all: out
/firefox
/stylus.json
362 out
/firefox
/stylus.json
: firefox
/stylus
/ firefox
/stylus
/*.css | out
/firefox
/
363 $(call v_tag
,IMPLODE
)\
364 firefox
/implode-stylus firefox
/stylus
/ >$@.new
&& \
368 ###--------------------------------------------------------------------------
369 ### General symlinking.
371 misclink-source
= $(HERE
)/$(or
$($1_SRC), $1)
373 all: $(addprefix $(HOME
)/, $(MISCLINKS
))
375 $(call symlink-ok-p
,$(HOME
)/$1,$(call misclink-source
,$1))
376 $(addprefix $(HOME
)/, $(subst %,\
%,$(MISCLINKS
))): $(HOME
)/%: \
377 $$(if
$$(call misclink-ok-p
,$$*),,_force
)
378 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
380 ln
-s
$(call misclink-source
,$*) $@.new
&& \
384 ###--------------------------------------------------------------------------
385 ### Processing dotfiles.
387 dotfile-source
= $(HERE
)/dot
/$(or
$($1_SRC), $(1:.
%=%)$2)
389 ## Easiest: just make symlinks.
391 $(call symlink-ok-p
,$(HOME
)/$1,$(call dotfile-source
,$1))
392 all: $(addprefix $(HOME
)/, $(DOTLINKS
))
393 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTLINKS
))): $(HOME
)/%: \
394 $$(if
$$(call dotlink-ok-p
,$$*),,_force
)
395 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
397 ln
-s
$(call dotfile-source
,$*) $@.new
&& \
401 ## Hack with the C preprocessor.
402 all: $(addprefix $(HOME
)/, $(DOTCPP
))
403 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTCPP
))): $(HOME
)/%: \
404 $$(call dotfile-source
,$$*) Makefile
405 $(call v_tag
,CPP
)mkdir
-p
$(dir $@
) && \
407 cpp -P
-o
$@.new
$($*_DEFS
) $< && \
411 ## Hack by making simple substitutions.
412 substvar
= -e
$(call quote
,s
\a@
$1@
\a$2\ag
)
413 SUBSTS
+= $(call substvar
,home
,$(HOME
))
414 SUBSTS
+= $(call substvar
,profile
,$(HERE
))
415 all: $(addprefix $(HOME
)/, $(DOTSUBST
))
416 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTSUBST
))): $(HOME
)/%: \
417 $$(call dotfile-source
,$$*,.in
) Makefile
418 $(call v_tag
,SUBST
)mkdir
-p
$(dir $@
) && \
421 $(relax)### generated by $(HERE)/Makefile; do not edit!" \
422 $(SUBSTS
) $($*_SUBSTS
) \
423 $(call dotfile-source
,$*,.in
) >$@.new
&& \
427 ###--------------------------------------------------------------------------
428 ### Processing script links.
430 script-source
= $(HERE
)/bin
/$(or
$($1_SRC), $1)
432 ifeq ($(prefix-shebang-p
),t
)
433 all: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
434 $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
)): $(HOME
)/bin
/%: \
435 $$(call script-source
,$$*) Makefile
436 $(call v_tag
,SHEBANG
)mkdir
-p
$(dir $@
) && \
438 sed
"1s\a\(#! *\)/\a\1$(SHEBANG_PREFIX)/\a" \
439 $(call script-source
,$*) >$@.new
&& \
440 chmod
--reference
=$(call script-source
,$*) $@.new
&& \
445 $(call symlink-ok-p
,$(HOME
)/bin
/$1,$(call script-source
,$1))
446 all: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
447 $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
)): $(HOME
)/bin
/%: \
448 $$(if
$$(call scriptlink-ok-p
,$$*),,_force
)
449 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
451 ln
-s
$(call script-source
,$*) $@.new
&& \
456 all: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
458 ###--------------------------------------------------------------------------
459 ### Building packages from source tarballs.
461 SRCDIR
= $(HOME
)/src
/profile
463 pkg-builddir
= $(SRCDIR
)/$1/build
464 pkg-stamp
= $(call pkg-builddir
,$1)/$2-stamp
466 $(foreach p
, $(PACKAGES
), $(eval DEP_
$p = $(if
$(shell \
467 if
$($p_CHECK) >/dev
/null
2>&1 --version
; then echo t
; fi
),, \
468 $(call pkg-stamp
,$p,install))))
470 $(PACKAGES
:%=$(SRCDIR
)/%.
tar.gz
): $(SRCDIR
)/%.
tar.gz
:
471 $(call v_tag
,FETCH
)mkdir
-p
$(SRCDIR
) && \
473 $(call get-url
,$@.new
,$(REPO
)/$*.
tar.gz
) && \
476 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,unpack
)): \
477 $(call pkg-stamp
,%,unpack
): $(SRCDIR
)/%.
tar.gz
478 $(call v_tag
,EXTRACT
)rm -rf
$(SRCDIR
)/$* && \
479 mkdir
$(SRCDIR
)/$*.tmp-unpack
&& \
480 cd
$(SRCDIR
)/$*.tmp-unpack
&& \
481 gzip
-cd ..
/$*.
tar.gz |
tar xf
- && \
484 rmdir
$*.tmp-unpack
&& \
486 touch
$*/build
/unpack-stamp
488 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,configure
)): \
489 $(call pkg-stamp
,%,configure
): \
490 $(call pkg-stamp
,%,unpack
) \
491 $$(foreach p
, $$($$*_DEPS
), $$(DEP_
$$p))
492 $(call v_tag
,CONFIG
)cd
$(dir $@
) && \
493 ..
/configure
--prefix=$(HOME
) \
494 PKG_CONFIG_PATH
=$(HOME
)/lib
/pkgconfig \
495 $($*_CONFIG
) >>buildlog
2>&1 && \
496 touch configure-stamp
498 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,build
)): \
499 $(call pkg-stamp
,%,build
): \
500 $(call pkg-stamp
,%,configure
)
501 $(call v_tag
,BUILD
)cd
$(dir $@
) && \
502 $(MAKE
) $($*_MAKEFLAGS
) >>buildlog
2>&1 && \
505 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,install)): \
506 $(call pkg-stamp
,%,install): \
507 $(call pkg-stamp
,%,build
)
508 $(call v_tag
,INSTALL
)cd
$(dir $@
) && \
509 $(MAKE
) $($*_MAKEFLAGS
) install >>buildlog
2>&1 && \
513 all: $(foreach p
, $(PACKAGES
), $(DEP_
$p))
514 $(foreach p
, $(PACKAGES
), $(eval _pkg.
$p: $(call pkg-stamp
,$p,install)))
516 ###----- That's all, folks --------------------------------------------------