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 echo
$$i; break
; fi
; \
52 ## Whence to obtain externally hosted stuff.
53 REPO
= https
://ftp.distorted.org.uk
/u
/mdw
/profile
55 ## Additional local configuration.
58 ###--------------------------------------------------------------------------
59 ### Some utility rules.
64 ###--------------------------------------------------------------------------
69 EMACSLIB
= $(HOME
)/lib
/emacs
71 EMACS_VERSION
:= $(shell $(EMACS
) 2>&1 -Q
--batch
--eval \
72 '(message "%s %s" emacs-major-version emacs-minor-version)')
73 emacs-version-p
= $(shell set
-- $(EMACS_VERSION
); \
74 if
[ $$1 -gt
$1 ] ||
([ $$1 -eq
$1 ] && [ $$2 -ge
$2 ]); then \
78 ELISP
+= make-regexp ew-hols
79 ELISP
+= mdw-gnus-patch
80 ELISP
+= mdw-multiple-cursors
81 ELISP
+= git git-blame vc-git stgit quilt
83 ifeq ($(call emacs-version-p
,24,3),t
)
84 ELISP
+= bracketed-paste
88 dot-emacs_DEPS
= make-regexp
90 SCRIPTLINKS
+= emacsclient-hack movemail-hack sendmail-hack
91 SCRIPTLINKS
+= aspell-hack emerge-hack
93 %.elc
: %.el
$$(foreach e
, $$($$*_DEPS
), $$(DEP_
$$e))
94 $(call v_tag
,EMACS
)if
! $(EMACS
) >$*.build-log
2>&1 \
95 -L el
/ -L
$(EMACSLIB
) \
96 --batch
--no-site-file \
97 --eval
'(byte-compile-file "$<")'; then \
98 cat
$*.build-log
; exit
2; \
101 LOCAL_ELISP
= $(filter $(notdir $(wildcard el
/*.el
)), \
102 $(addsuffix .el
, $(ELISP
)))
103 $(foreach e
, $(LOCAL_ELISP
), \
104 $(eval DEP_
$(basename $e) = $(EMACSLIB
)/$(e
:.el
=.elc
)))
105 $(addprefix $(EMACSLIB
)/, $(LOCAL_ELISP
)): $(EMACSLIB
)/%: el
/%
106 $(call v_tag
,SYMINK
)mkdir
-p
$(EMACSLIB
) && \
108 ln
-s
$(HERE
)/$< $@.new
&& \
111 REMOTE_ELISP
= $(filter-out $(notdir $(wildcard el
/*.el
)), \
112 $(addsuffix .el
, $(ELISP
)))
113 $(foreach e
, $(REMOTE_ELISP
), \
114 $(eval DEP_
$(basename $e) = $(if
$(shell \
115 if
$(EMACS
) >/dev
/null
2>&1 --no-site-file
-q
--batch \
118 (kill-emacs (condition-case nil \
119 (progn (load-library "$e") 0) \
120 (error 1))))'; then \
122 fi
),, $(EMACSLIB
)/$(e
:.el
=.elc
))))
123 $(addprefix $(EMACSLIB
)/, $(REMOTE_ELISP
)): $(EMACSLIB
)/%:
124 $(call v_tag
,FETCH
)mkdir
-p
$(EMACSLIB
) && \
125 $(call get-url
,$@.new
,$(REPO
)/$*) && \
128 DOTLINKS
+= .emacs .emacs-calc .vm .gnus.el .ercrc.el
130 all:: $(foreach e
, $(ELISP
), $(DEP_
$e))
131 $(foreach e
, $(ELISP
), $(eval _emacs.
$e: $(EMACSLIB
)/$e.elc
))
135 ###--------------------------------------------------------------------------
136 ### Other simpler things.
139 $(call v_tag
,COPY
)cp mdw.conf
$@.new
&& mv
$@.new
$@
142 PACKAGES
+= mlib checkpath
143 mlib_CHECK
= crc-mktab
144 checkpath_CHECK
= tmpdir
145 checkpath_DEPS
= mlib
147 ## Packaging machinery.
148 SCRIPTLINKS
+= mdw-build mdw-sbuild mdw-sbuild-server
149 SCRIPTLINKS
+= update-buildable-branch
152 DOTLINKS
+= .profile .shell-rc .shell-logout
153 DOTLINKS
+= .shrc .rcrc
154 DOTLINKS
+= .zprofile .zshrc .zlogout .zshenv
155 DOTLINKS
+= .bash_profile .bash_completion .bash_logout
156 DOTLINKS
+= .bashrc .inputrc
157 .bash_profile_SRC
= bash-profile
158 .bash_completion_SRC
= bash-completion
159 .bash_logout_SRC
= shell-logout
160 .zlogout_SRC
= shell-logout
163 DOTSUBST
+= .gitconfig
164 SCRIPTLINKS
+= git-copyright-dates
165 DOTLINKS
+= .cgrc .tigrc
166 .gitconfig_SUBSTS
= \
167 $(call substvar
,releasekey
,$(call mdw-conf
,release-key
,481334C2
))
168 $(HOME
)/.gitconfig
: $(HOME
)/.mdw.conf
171 DOTLINKS
+= .pulse
/daemon.conf
172 DOTSUBST
+= .pulse
/default.pa
173 .pulse
/daemon.conf_SRC
= pulse-daemon.conf
174 .pulse
/default.pa_SRC
= pulse-default.pa.in
177 DOTLINKS
+= .vimrc .mg .zile
180 DOTLINKS
+= .mailrc .signature .muttrc
183 DOTLINKS
+= .cmucl-init.lisp .sbclrc .clisprc.lisp .eclrc
184 .cmucl-init.lisp_SRC
= lisp-init.lisp
185 .sbclrc_SRC
= lisp-init.lisp
186 .clisprc.lisp_SRC
= lisp-init.lisp
187 .eclrc_SRC
= lisp-init.lisp
188 DOTLINKS
+= .swank.lisp
191 DOTLINKS
+= .ipython
/profile_default
/ipython_config.py
192 DOTLINKS
+= .ipython
/profile_default
/startup
/50-key-bindings.py
193 .ipython
/profile_default
/ipython_config.py_SRC
= ipython-config.py
194 .ipython
/profile_default
/startup
/50-key-bindings.py_SRC
= ipython-key-bindings.py
198 DOTLINKS
+= .tclshrc .wishrc
199 .tclshrc_SRC
= tclshrc
200 .wishrc_SRC
= tclshrc
203 SCRIPTLINKS
+= mdw-editor mdw-pager
204 SCRIPTLINKS
+= mdw-conf
205 SCRIPTLINKS
+= svnwrap
206 SCRIPTLINKS
+= guest-console
207 SCRIPTLINKS
+= hyperspec
209 ## Random odds and ends.
210 DOTLINKS
+= .lesskey .infokey .sqliterc
211 DOTLINKS
+= .gdbinit .toprc .aspell.conf
212 DOTLINKS
+= .dircolors .colordiffrc .screenrc .tmux.conf
213 DOTLINKS
+= .cvsrc .indent.pro .ditz-config
214 DOTSUBST
+= .mykermrc
215 SCRIPTLINKS
+= lesspipe.sh
217 SCRIPTLINKS
+= run-with-shell-env
218 SCRIPTLINKS
+= start-ssh-agent start-ssh-pageant
219 SCRIPTLINKS
+= add-ssh-keys
220 SCRIPTLINKS
+= hacks
/ssh
/ssh
221 hacks
/ssh
/ssh_SRC
= hacks
/ssh
223 DOTLINKS
+= .w3m
/config .elinks
/elinks.conf
224 .w3m
/config_SRC
= w3m-config
225 .elinks
/elinks.conf_SRC
= elinks.conf
227 DOTLINKS
+= .mc
/ini .mc
/panels.ini
229 .mc
/panels.ini_SRC
= mc-panels.ini
231 DOTLINKS
+= .parallel
/config
232 .parallel
/config_SRC
= parallel-config
234 ###--------------------------------------------------------------------------
235 ### X11 configuration.
243 DOTLINKS
+= .xinitrc .xsession .xmodmap .vncrc .vncsession
244 DOTLINKS
+= .fonts.conf
245 DOTLINKS
+= .stalonetrayrc
247 DOTLINKS
+= .putty
/sessions
/Default
%20Settings
248 .putty
/sessions
/Default
%20Settings_SRC
= putty-defaults
250 DOTLINKS
+= .config
/gnome-session
/sessions
/mdw.session
251 .config
/gnome-session
/sessions
/mdw.session_SRC
= mdw.session
253 DOTLINKS
+= .Eterm
/themes
/Eterm
/theme.cfg
254 DOTLINKS
+= .enlightenment
/keybindings.cfg
255 DOTLINKS
+= .enlightenment-vnc
/keybindings.cfg
256 DOTLINKS
+= .e16
/bindings.cfg
257 .Eterm
/themes
/Eterm
/theme.cfg_SRC
= eterm-theme.cfg
258 .enlightenment
/keybindings.cfg_SRC
= e-keybindings.cfg
259 .enlightenment-vnc
/keybindings.cfg_SRC
= evnc-keybindings.cfg
260 .e16
/bindings.cfg_SRC
= e16-bindings
262 DOTLINKS
+= .gtkrc-2.0
263 DOTLINKS
+= .config
/gtk-3.0
/gtk.css
264 DOTLINKS
+= .config
/gtk-3.0
/settings.ini
265 .config
/gtk-3.0
/gtk.css_SRC
= gtk3.css
266 .config
/gtk-3.0
/settings.ini_SRC
= gtk3-settings.ini
268 SCRIPTLINKS
+= xinitcmd lock-screen xshutdown
269 SCRIPTLINKS
+= un-backslashify-selection
270 SCRIPTLINKS
+= xpra-start-xdummy
273 Xdefaults_DEFS
= -DEMACSWD
=$(call mdw-conf
,emacs-width
,77)
274 $(HOME
)/.Xdefaults
: $(HOME
)/.mdw.conf
278 ###--------------------------------------------------------------------------
279 ### Processing dotfiles.
281 dotfile-source
= $(HERE
)/dot
/$(or
$($1_SRC), $(1:.
%=%)$2)
283 ## Easiest: just make symlinks.
285 $(call symlink-ok-p
,$(HOME
)/$1,$(call dotfile-source
,$1))
286 all:: $(addprefix $(HOME
)/, $(DOTLINKS
))
287 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTLINKS
))): $(HOME
)/%: \
288 $$(if
$$(call dotlink-ok-p
,$$*),,_force
)
289 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
291 ln
-s
$(call dotfile-source
,$*) $@.new
&& \
294 ## Hack with the C preprocessor.
295 all:: $(addprefix $(HOME
)/, $(DOTCPP
))
296 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTCPP
))): $(HOME
)/%: \
297 $$(call dotfile-source
,$$*) Makefile
298 $(call v_tag
,CPP
)mkdir
-p
$(dir $@
) && \
300 cpp -P
-o
$@.new
$($*_DEFS
) $< && \
303 ## Hack by making simple substitutions.
304 substvar
= -e
$(call quote
,s
\a@
$1@
\a$2\ag
)
305 SUBSTS
+= $(call substvar
,home
,$(HOME
))
306 SUBSTS
+= $(call substvar
,profile
,$(HERE
))
307 all:: $(addprefix $(HOME
)/, $(DOTSUBST
))
308 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTSUBST
))): $(HOME
)/%: \
309 $$(call dotsubst-source
,$$*,.in
) Makefile
310 $(call v_tag
,SUBST
)mkdir
-p
$(dir $@
) && \
313 $(relax)### generated by $(HERE)/Makefile; do not edit!" \
314 $(SUBSTS
) $($*_SUBSTS
) \
315 $(call dotfile-source
,$*,.in
) >$@.new
&& \
318 ###--------------------------------------------------------------------------
319 ### Processing script links.
321 script-source
= $(HERE
)/bin
/$(or
$($1_SRC), $1)
323 $(call symlink-ok-p
,$(HOME
)/bin
/$1,$(call script-source
,$1))
324 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
325 $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
)): $(HOME
)/bin
/%: \
326 $$(if
$$(call scriptlink-ok-p
,$$*),,_force
)
327 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
329 ln
-s
$(call script-source
,$*) $@.new
&& \
332 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
334 ###--------------------------------------------------------------------------
335 ### Building packages from source tarballs.
337 SRCDIR
= $(HOME
)/src
/profile
339 pkg-builddir
= $(SRCDIR
)/$1/build
340 pkg-stamp
= $(call pkg-builddir
,$1)/$2-stamp
342 $(foreach p
, $(PACKAGES
), $(eval DEP_
$p = $(if
$(shell \
343 if
$($p_CHECK) >/dev
/null
2>&1 --version
; then echo t
; fi
),, \
344 $(call pkg-stamp
,$p,install))))
346 $(PACKAGES
:%=$(SRCDIR
)/%.
tar.gz
): $(SRCDIR
)/%.
tar.gz
:
347 $(call v_tag
,FETCH
)mkdir
-p
$(SRCDIR
) && \
349 $(call get-url
,$@.new
,$(REPO
)/$*.
tar.gz
) && \
352 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,unpack
)): \
353 $(call pkg-stamp
,%,unpack
): $(SRCDIR
)/%.
tar.gz
354 $(call v_tag
,EXTRACT
)rm -rf
$(SRCDIR
)/$* && \
355 mkdir
$(SRCDIR
)/$*.tmp-unpack
&& \
356 cd
$(SRCDIR
)/$*.tmp-unpack
&& \
357 gzip
-cd ..
/$*.
tar.gz |
tar xf
- && \
360 rmdir
$*.tmp-unpack
&& \
362 touch
$*/build
/unpack-stamp
364 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,configure
)): \
365 $(call pkg-stamp
,%,configure
): \
366 $(call pkg-stamp
,%,unpack
) \
367 $$(foreach p
, $$($$*_DEPS
), $$(DEP_
$$p))
368 $(call v_tag
,CONFIG
)cd
$(dir $@
) && \
369 ..
/configure
--prefix=$(HOME
) \
370 PKG_CONFIG_PATH
=$(HOME
)/lib
/pkgconfig \
371 $($*_CONFIG
) >>buildlog
2>&1 && \
372 touch configure-stamp
374 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,build
)): \
375 $(call pkg-stamp
,%,build
): \
376 $(call pkg-stamp
,%,configure
)
377 $(call v_tag
,BUILD
)cd
$(dir $@
) && \
378 $(MAKE
) $($*_MAKEFLAGS
) >>buildlog
2>&1 && \
381 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,install)): \
382 $(call pkg-stamp
,%,install): \
383 $(call pkg-stamp
,%,build
)
384 $(call v_tag
,INSTALL
)cd
$(dir $@
) && \
385 $(MAKE
) $($*_MAKEFLAGS
) install >>buildlog
2>&1 && \
388 all:: $(foreach p
, $(PACKAGES
), $(DEP_
$p))
389 $(foreach p
, $(PACKAGES
), $(eval _pkg.
$p: $(call pkg-stamp
,$p,install)))
391 ###----- That's all, folks --------------------------------------------------