4 .SECONDEXPANSION
: #sorry
6 ###--------------------------------------------------------------------------
10 quote
= '$(subst ','\'',$1)'#'
12 ## Suss out how to print stuff.
13 print = printf
"%s" $(call quote
,$1)
15 ## Looking configuration things up.
16 mdw-conf
= $(shell bin
/mdw-conf
"$1" "$2")
18 ## Checking symlink targets.
19 symlink-ok-p
= $(shell \
20 case
$$(readlink
2>/dev
/null
$1) in
($2) echo t
;; esac
)
22 ## Silent rules machinery.
24 v_tag
= $(call v_tag_
$V,$1,$2)
25 v_tag_0
= @printf
" %-8s %s\n" "$1" $(call quote
,$@
);
32 ###--------------------------------------------------------------------------
35 ## Figure out where I am.
38 ## Decide on how to fetch things from URLs.
39 ifeq ($(shell (curl
>/dev
/null
2>&1 --version ||
[ $$?
-eq
2 ]) && echo t
),t
)
40 get-url
= curl
-fs
-o
$1 $2
42 get-url
= wget
-q
-O
$1 $2
45 ## Which Emacs should I use?
48 for i in emacs24 emacs23 emacs22 emacs21 emacs
; do \
49 if type
>/dev
/null
2>&1 $$i; then emacs
=$$i; break
; fi
; \
53 ## Whence to obtain externally hosted stuff.
54 REPO
= https
://ftp.distorted.org.uk
/u
/mdw
/profile
56 ## Additional local configuration.
59 ###--------------------------------------------------------------------------
60 ### Some utility rules.
65 ###--------------------------------------------------------------------------
70 EMACSLIB
= $(HOME
)/lib
/emacs
72 EMACS_VERSION
:= $(shell $(EMACS
) 2>&1 -Q
--batch
--eval \
73 '(message "%s %s" emacs-major-version emacs-minor-version)' | \
75 emacs-version-p
= $(shell set
-- $(EMACS_VERSION
); \
76 if
[ $$1 -gt
$1 ] ||
([ $$1 -eq
$1 ] && [ $$2 -ge
$2 ]); then \
80 ELISP
+= make-regexp ew-hols
81 ELISP
+= mdw-gnus-patch
82 ELISP
+= mdw-multiple-cursors
83 ELISP
+= git git-blame vc-git stgit quilt
85 ifeq ($(call emacs-version-p
,24,3),t
)
86 ELISP
+= bracketed-paste
90 dot-emacs_DEPS
= make-regexp
92 SCRIPTLINKS
+= emacsclient-hack movemail-hack sendmail-hack
93 SCRIPTLINKS
+= aspell-hack emerge-hack
95 %.elc
: %.el
$$(foreach e
, $$($$*_DEPS
), $$(DEP_
$$e))
96 $(call v_tag
,EMACS
)if
! $(EMACS
) >$*.build-log
2>&1 \
97 -L el
/ -L
$(EMACSLIB
) \
98 --batch
--no-site-file \
99 --eval
'(byte-compile-file "$<")'; then \
100 cat
$*.build-log
; exit
2; \
103 LOCAL_ELISP
= $(filter $(notdir $(wildcard el
/*.el
)), \
104 $(addsuffix .el
, $(ELISP
)))
105 $(foreach e
, $(LOCAL_ELISP
), \
106 $(eval DEP_
$(basename $e) = $(EMACSLIB
)/$(e
:.el
=.elc
)))
107 $(addprefix $(EMACSLIB
)/, $(LOCAL_ELISP
)): $(EMACSLIB
)/%: el
/%
108 $(call v_tag
,SYMINK
)mkdir
-p
$(EMACSLIB
) && \
110 ln
-s
$(HERE
)/$< $@.new
&& \
113 REMOTE_ELISP
= $(filter-out $(notdir $(wildcard el
/*.el
)), \
114 $(addsuffix .el
, $(ELISP
)))
115 $(foreach e
, $(REMOTE_ELISP
), \
116 $(eval DEP_
$(basename $e) = $(if
$(shell \
117 if
$(EMACS
) >/dev
/null
2>&1 --no-site-file
-q
--batch \
120 (kill-emacs (condition-case nil \
121 (progn (load-library "$e") 0) \
122 (error 1))))'; then \
124 fi
),, $(EMACSLIB
)/$(e
:.el
=.elc
))))
125 $(addprefix $(EMACSLIB
)/, $(REMOTE_ELISP
)): $(EMACSLIB
)/%:
126 $(call v_tag
,FETCH
)mkdir
-p
$(EMACSLIB
) && \
127 $(call get-url
,$@.new
,$(REPO
)/$*) && \
130 DOTLINKS
+= .emacs .emacs-calc .vm .gnus.el .ercrc.el
132 all:: $(foreach e
, $(ELISP
), $(DEP_
$e))
133 $(foreach e
, $(ELISP
), $(eval _emacs.
$e: $(EMACSLIB
)/$e.elc
))
137 ###--------------------------------------------------------------------------
138 ### Other simpler things.
141 $(call v_tag
,COPY
)cp mdw.conf
$@.new
&& mv
$@.new
$@
144 PACKAGES
+= mlib checkpath
145 mlib_CHECK
= crc-mktab
146 checkpath_CHECK
= tmpdir
147 checkpath_DEPS
= mlib
149 ## Packaging machinery.
150 SCRIPTLINKS
+= mdw-build mdw-sbuild mdw-sbuild-server
151 SCRIPTLINKS
+= update-buildable-branch
154 DOTLINKS
+= .profile .shell-rc .shell-logout
156 DOTLINKS
+= .zprofile .zshrc .zlogout .zshenv
157 DOTLINKS
+= .bash_profile .bash_completion .bash_logout
158 DOTLINKS
+= .bashrc .inputrc
159 .bash_profile_SRC
= bash-profile
160 .bash_completion_SRC
= bash-completion
161 .bash_logout_SRC
= shell-logout
162 .zlogout_SRC
= shell-logout
164 ## The Plan 9 `rc' shell. This needs special hacking, because the Linux port
165 ## and Plan 9 From User Space have incompatible syntax.
166 DOTLINKS
+= lib
/profile
167 lib
/profile_SRC
= rcrc
169 $(HOME
)/.rcrc
: dot
/rcrc
170 $(call v_tag
,SED
)sed
's/; if not/else/' $< >$@.new
&& mv
$@.new
$@
173 DOTSUBST
+= .gitconfig
174 SCRIPTLINKS
+= git-copyright-dates
175 DOTLINKS
+= .cgrc .tigrc
176 .gitconfig_SUBSTS
= \
177 $(call substvar
,releasekey
,$(call mdw-conf
,release-key
,481334C2
))
178 $(HOME
)/.gitconfig
: $(HOME
)/.mdw.conf
181 DOTLINKS
+= .pulse
/daemon.conf
182 DOTSUBST
+= .pulse
/default.pa
183 .pulse
/daemon.conf_SRC
= pulse-daemon.conf
184 .pulse
/default.pa_SRC
= pulse-default.pa.in
187 DOTLINKS
+= .vimrc .mg .zile
190 DOTLINKS
+= .mailrc .signature .muttrc
193 DOTLINKS
+= .cmucl-init.lisp .sbclrc .clisprc.lisp .eclrc
194 .cmucl-init.lisp_SRC
= lisp-init.lisp
195 .sbclrc_SRC
= lisp-init.lisp
196 .clisprc.lisp_SRC
= lisp-init.lisp
197 .eclrc_SRC
= lisp-init.lisp
198 DOTLINKS
+= .swank.lisp
201 DOTLINKS
+= .ipython
/profile_default
/ipython_config.py
202 DOTLINKS
+= .ipython
/profile_default
/startup
/50-key-bindings.py
203 .ipython
/profile_default
/ipython_config.py_SRC
= ipython-config.py
204 .ipython
/profile_default
/startup
/50-key-bindings.py_SRC
= ipython-key-bindings.py
208 DOTLINKS
+= .tclshrc .wishrc
209 .tclshrc_SRC
= tclshrc
210 .wishrc_SRC
= tclshrc
213 SCRIPTLINKS
+= mdw-editor mdw-pager
214 SCRIPTLINKS
+= mdw-conf
215 SCRIPTLINKS
+= svnwrap
216 SCRIPTLINKS
+= guest-console
217 SCRIPTLINKS
+= hyperspec
219 ## Random odds and ends.
220 DOTLINKS
+= .lesskey .infokey .sqliterc
221 DOTLINKS
+= .gdbinit .toprc .aspell.conf
222 DOTLINKS
+= .dircolors .colordiffrc .screenrc .tmux.conf
223 DOTLINKS
+= .cvsrc .indent.pro .ditz-config
225 .lftp
/rc_SRC
= lftp-rc
226 DOTSUBST
+= .mykermrc
227 SCRIPTLINKS
+= lesspipe.sh
229 SCRIPTLINKS
+= run-with-shell-env
230 SCRIPTLINKS
+= start-ssh-agent start-ssh-pageant
231 SCRIPTLINKS
+= add-ssh-keys
232 SCRIPTLINKS
+= hacks
/ssh
/ssh
233 hacks
/ssh
/ssh_SRC
= hacks
/ssh
235 DOTLINKS
+= .w3m
/config .elinks
/elinks.conf
236 .w3m
/config_SRC
= w3m-config
237 .elinks
/elinks.conf_SRC
= elinks.conf
239 DOTLINKS
+= .mc
/ini .mc
/panels.ini
241 .mc
/panels.ini_SRC
= mc-panels.ini
243 DOTLINKS
+= .parallel
/config
244 .parallel
/config_SRC
= parallel-config
246 ###--------------------------------------------------------------------------
247 ### X11 configuration.
255 DOTLINKS
+= .xinitrc .xsession .xmodmap .vncrc .vncsession
256 DOTLINKS
+= .fonts.conf
257 DOTLINKS
+= .stalonetrayrc
259 DOTLINKS
+= .putty
/sessions
/Default
%20Settings
260 .putty
/sessions
/Default
%20Settings_SRC
= putty-defaults
262 DOTLINKS
+= .config
/gnome-session
/sessions
/mdw.session
263 .config
/gnome-session
/sessions
/mdw.session_SRC
= mdw.session
265 DOTLINKS
+= .Eterm
/themes
/Eterm
/theme.cfg
266 DOTLINKS
+= .enlightenment
/keybindings.cfg
267 DOTLINKS
+= .enlightenment-vnc
/keybindings.cfg
268 DOTLINKS
+= .e16
/bindings.cfg
269 .Eterm
/themes
/Eterm
/theme.cfg_SRC
= eterm-theme.cfg
270 .enlightenment
/keybindings.cfg_SRC
= e-keybindings.cfg
271 .enlightenment-vnc
/keybindings.cfg_SRC
= evnc-keybindings.cfg
272 .e16
/bindings.cfg_SRC
= e16-bindings
274 DOTLINKS
+= .gtkrc-2.0
275 DOTLINKS
+= .config
/gtk-3.0
/gtk.css
276 DOTLINKS
+= .config
/gtk-3.0
/settings.ini
277 .config
/gtk-3.0
/gtk.css_SRC
= gtk3.css
278 .config
/gtk-3.0
/settings.ini_SRC
= gtk3-settings.ini
280 SCRIPTLINKS
+= xinitcmd lock-screen xshutdown
281 SCRIPTLINKS
+= un-backslashify-selection
282 SCRIPTLINKS
+= xpra-start-xdummy
283 SCRIPTLINKS
+= play-rawk
286 Xdefaults_DEFS
= -DEMACSWD
=$(call mdw-conf
,emacs-width
,77)
287 $(HOME
)/.Xdefaults
: $(HOME
)/.mdw.conf
289 ifeq ($(shell case
$${DISPLAY-nil
} in
(:[0-9]*) echo t
;; (*) echo nil
;; esac
),t
)
290 dotfile-hook
/.Xdefaults
= \
291 $(call v_tag
,XRDB
)xrdb
-override $<
296 ###--------------------------------------------------------------------------
297 ### Processing dotfiles.
299 dotfile-source
= $(HERE
)/dot
/$(or
$($1_SRC), $(1:.
%=%)$2)
301 ## Easiest: just make symlinks.
303 $(call symlink-ok-p
,$(HOME
)/$1,$(call dotfile-source
,$1))
304 all:: $(addprefix $(HOME
)/, $(DOTLINKS
))
305 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTLINKS
))): $(HOME
)/%: \
306 $$(if
$$(call dotlink-ok-p
,$$*),,_force
)
307 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
309 ln
-s
$(call dotfile-source
,$*) $@.new
&& \
313 ## Hack with the C preprocessor.
314 all:: $(addprefix $(HOME
)/, $(DOTCPP
))
315 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTCPP
))): $(HOME
)/%: \
316 $$(call dotfile-source
,$$*) Makefile
317 $(call v_tag
,CPP
)mkdir
-p
$(dir $@
) && \
319 cpp -P
-o
$@.new
$($*_DEFS
) $< && \
323 ## Hack by making simple substitutions.
324 substvar
= -e
$(call quote
,s
\a@
$1@
\a$2\ag
)
325 SUBSTS
+= $(call substvar
,home
,$(HOME
))
326 SUBSTS
+= $(call substvar
,profile
,$(HERE
))
327 all:: $(addprefix $(HOME
)/, $(DOTSUBST
))
328 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTSUBST
))): $(HOME
)/%: \
329 $$(call dotfile-source
,$$*,.in
) Makefile
330 $(call v_tag
,SUBST
)mkdir
-p
$(dir $@
) && \
333 $(relax)### generated by $(HERE)/Makefile; do not edit!" \
334 $(SUBSTS
) $($*_SUBSTS
) \
335 $(call dotfile-source
,$*,.in
) >$@.new
&& \
339 ###--------------------------------------------------------------------------
340 ### Processing script links.
342 script-source
= $(HERE
)/bin
/$(or
$($1_SRC), $1)
344 ifeq ($(prefix-shebang-p
),t
)
345 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
346 $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
)): $(HOME
)/bin
/%: \
347 $$(call script-source
,$$*) Makefile
348 $(call v_tag
,SHEBANG
)mkdir
-p
$(dir $@
) && \
350 sed
"1s\a\(#! *\)/\a\1$(SHEBANG_PREFIX)/\a" \
351 $(call script-source
,$*) >$@.new
&& \
352 chmod
--reference
=$(call script-source
,$*) $@.new
&& \
357 $(call symlink-ok-p
,$(HOME
)/bin
/$1,$(call script-source
,$1))
358 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
359 $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
)): $(HOME
)/bin
/%: \
360 $$(if
$$(call scriptlink-ok-p
,$$*),,_force
)
361 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
363 ln
-s
$(call script-source
,$*) $@.new
&& \
368 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
370 ###--------------------------------------------------------------------------
371 ### Building packages from source tarballs.
373 SRCDIR
= $(HOME
)/src
/profile
375 pkg-builddir
= $(SRCDIR
)/$1/build
376 pkg-stamp
= $(call pkg-builddir
,$1)/$2-stamp
378 $(foreach p
, $(PACKAGES
), $(eval DEP_
$p = $(if
$(shell \
379 if
$($p_CHECK) >/dev
/null
2>&1 --version
; then echo t
; fi
),, \
380 $(call pkg-stamp
,$p,install))))
382 $(PACKAGES
:%=$(SRCDIR
)/%.
tar.gz
): $(SRCDIR
)/%.
tar.gz
:
383 $(call v_tag
,FETCH
)mkdir
-p
$(SRCDIR
) && \
385 $(call get-url
,$@.new
,$(REPO
)/$*.
tar.gz
) && \
388 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,unpack
)): \
389 $(call pkg-stamp
,%,unpack
): $(SRCDIR
)/%.
tar.gz
390 $(call v_tag
,EXTRACT
)rm -rf
$(SRCDIR
)/$* && \
391 mkdir
$(SRCDIR
)/$*.tmp-unpack
&& \
392 cd
$(SRCDIR
)/$*.tmp-unpack
&& \
393 gzip
-cd ..
/$*.
tar.gz |
tar xf
- && \
396 rmdir
$*.tmp-unpack
&& \
398 touch
$*/build
/unpack-stamp
400 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,configure
)): \
401 $(call pkg-stamp
,%,configure
): \
402 $(call pkg-stamp
,%,unpack
) \
403 $$(foreach p
, $$($$*_DEPS
), $$(DEP_
$$p))
404 $(call v_tag
,CONFIG
)cd
$(dir $@
) && \
405 ..
/configure
--prefix=$(HOME
) \
406 PKG_CONFIG_PATH
=$(HOME
)/lib
/pkgconfig \
407 $($*_CONFIG
) >>buildlog
2>&1 && \
408 touch configure-stamp
410 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,build
)): \
411 $(call pkg-stamp
,%,build
): \
412 $(call pkg-stamp
,%,configure
)
413 $(call v_tag
,BUILD
)cd
$(dir $@
) && \
414 $(MAKE
) $($*_MAKEFLAGS
) >>buildlog
2>&1 && \
417 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,install)): \
418 $(call pkg-stamp
,%,install): \
419 $(call pkg-stamp
,%,build
)
420 $(call v_tag
,INSTALL
)cd
$(dir $@
) && \
421 $(MAKE
) $($*_MAKEFLAGS
) install >>buildlog
2>&1 && \
425 all:: $(foreach p
, $(PACKAGES
), $(DEP_
$p))
426 $(foreach p
, $(PACKAGES
), $(eval _pkg.
$p: $(call pkg-stamp
,$p,install)))
428 ###----- That's all, folks --------------------------------------------------