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)' | \
74 emacs-version-p
= $(shell set
-- $(EMACS_VERSION
); \
75 if
[ $$1 -gt
$1 ] ||
([ $$1 -eq
$1 ] && [ $$2 -ge
$2 ]); then \
79 ELISP
+= make-regexp ew-hols
80 ELISP
+= mdw-gnus-patch
81 ELISP
+= mdw-multiple-cursors
82 ELISP
+= git git-blame vc-git stgit quilt
84 ifeq ($(call emacs-version-p
,24,3),t
)
85 ELISP
+= bracketed-paste
89 dot-emacs_DEPS
= make-regexp
91 SCRIPTLINKS
+= emacsclient-hack movemail-hack sendmail-hack
92 SCRIPTLINKS
+= aspell-hack emerge-hack
94 %.elc
: %.el
$$(foreach e
, $$($$*_DEPS
), $$(DEP_
$$e))
95 $(call v_tag
,EMACS
)if
! $(EMACS
) >$*.build-log
2>&1 \
96 -L el
/ -L
$(EMACSLIB
) \
97 --batch
--no-site-file \
98 --eval
'(byte-compile-file "$<")'; then \
99 cat
$*.build-log
; exit
2; \
102 LOCAL_ELISP
= $(filter $(notdir $(wildcard el
/*.el
)), \
103 $(addsuffix .el
, $(ELISP
)))
104 $(foreach e
, $(LOCAL_ELISP
), \
105 $(eval DEP_
$(basename $e) = $(EMACSLIB
)/$(e
:.el
=.elc
)))
106 $(addprefix $(EMACSLIB
)/, $(LOCAL_ELISP
)): $(EMACSLIB
)/%: el
/%
107 $(call v_tag
,SYMINK
)mkdir
-p
$(EMACSLIB
) && \
109 ln
-s
$(HERE
)/$< $@.new
&& \
112 REMOTE_ELISP
= $(filter-out $(notdir $(wildcard el
/*.el
)), \
113 $(addsuffix .el
, $(ELISP
)))
114 $(foreach e
, $(REMOTE_ELISP
), \
115 $(eval DEP_
$(basename $e) = $(if
$(shell \
116 if
$(EMACS
) >/dev
/null
2>&1 --no-site-file
-q
--batch \
119 (kill-emacs (condition-case nil \
120 (progn (load-library "$e") 0) \
121 (error 1))))'; then \
123 fi
),, $(EMACSLIB
)/$(e
:.el
=.elc
))))
124 $(addprefix $(EMACSLIB
)/, $(REMOTE_ELISP
)): $(EMACSLIB
)/%:
125 $(call v_tag
,FETCH
)mkdir
-p
$(EMACSLIB
) && \
126 $(call get-url
,$@.new
,$(REPO
)/$*) && \
129 DOTLINKS
+= .emacs .emacs-calc .vm .gnus.el .ercrc.el
131 all:: $(foreach e
, $(ELISP
), $(DEP_
$e))
132 $(foreach e
, $(ELISP
), $(eval _emacs.
$e: $(EMACSLIB
)/$e.elc
))
136 ###--------------------------------------------------------------------------
137 ### Other simpler things.
140 $(call v_tag
,COPY
)cp mdw.conf
$@.new
&& mv
$@.new
$@
143 PACKAGES
+= mlib checkpath
144 mlib_CHECK
= crc-mktab
145 checkpath_CHECK
= tmpdir
146 checkpath_DEPS
= mlib
148 ## Packaging machinery.
149 SCRIPTLINKS
+= mdw-build mdw-sbuild mdw-sbuild-server
150 SCRIPTLINKS
+= update-buildable-branch
153 DOTLINKS
+= .profile .shell-rc .shell-logout
155 DOTLINKS
+= .zprofile .zshrc .zlogout .zshenv
156 DOTLINKS
+= .bash_profile .bash_completion .bash_logout
157 DOTLINKS
+= .bashrc .inputrc
158 .bash_profile_SRC
= bash-profile
159 .bash_completion_SRC
= bash-completion
160 .bash_logout_SRC
= shell-logout
161 .zlogout_SRC
= shell-logout
163 ## The Plan 9 `rc' shell. This needs special hacking, because the Linux port
164 ## and Plan 9 From User Space have incompatible syntax.
165 DOTLINKS
+= lib
/profile
166 lib
/profile_SRC
= rcrc
168 $(HOME
)/.rcrc
: dot
/rcrc
169 $(call v_tag
,SED
)sed
's/; if not/else/' $< >$@.new
&& mv
$@.new
$@
172 DOTSUBST
+= .gitconfig
173 SCRIPTLINKS
+= git-copyright-dates
174 DOTLINKS
+= .cgrc .tigrc
175 .gitconfig_SUBSTS
= \
176 $(call substvar
,releasekey
,$(call mdw-conf
,release-key
,481334C2
))
177 $(HOME
)/.gitconfig
: $(HOME
)/.mdw.conf
180 DOTLINKS
+= .pulse
/daemon.conf
181 DOTSUBST
+= .pulse
/default.pa
182 .pulse
/daemon.conf_SRC
= pulse-daemon.conf
183 .pulse
/default.pa_SRC
= pulse-default.pa.in
186 DOTLINKS
+= .vimrc .mg .zile
189 DOTLINKS
+= .mailrc .signature .muttrc
192 DOTLINKS
+= .cmucl-init.lisp .sbclrc .clisprc.lisp .eclrc
193 .cmucl-init.lisp_SRC
= lisp-init.lisp
194 .sbclrc_SRC
= lisp-init.lisp
195 .clisprc.lisp_SRC
= lisp-init.lisp
196 .eclrc_SRC
= lisp-init.lisp
197 DOTLINKS
+= .swank.lisp
200 DOTLINKS
+= .ipython
/profile_default
/ipython_config.py
201 DOTLINKS
+= .ipython
/profile_default
/startup
/50-key-bindings.py
202 .ipython
/profile_default
/ipython_config.py_SRC
= ipython-config.py
203 .ipython
/profile_default
/startup
/50-key-bindings.py_SRC
= ipython-key-bindings.py
207 DOTLINKS
+= .tclshrc .wishrc
208 .tclshrc_SRC
= tclshrc
209 .wishrc_SRC
= tclshrc
212 SCRIPTLINKS
+= mdw-editor mdw-pager
213 SCRIPTLINKS
+= mdw-conf
214 SCRIPTLINKS
+= svnwrap
215 SCRIPTLINKS
+= guest-console
216 SCRIPTLINKS
+= hyperspec
218 ## Random odds and ends.
219 DOTLINKS
+= .lesskey .infokey .sqliterc
220 DOTLINKS
+= .gdbinit .toprc .aspell.conf
221 DOTLINKS
+= .dircolors .colordiffrc .screenrc .tmux.conf
222 DOTLINKS
+= .cvsrc .indent.pro .ditz-config
224 .lftp
/rc_SRC
= lftp-rc
225 DOTSUBST
+= .mykermrc
226 SCRIPTLINKS
+= lesspipe.sh
228 SCRIPTLINKS
+= run-with-shell-env
229 SCRIPTLINKS
+= start-ssh-agent start-ssh-pageant
230 SCRIPTLINKS
+= add-ssh-keys
231 SCRIPTLINKS
+= hacks
/ssh
/ssh
232 hacks
/ssh
/ssh_SRC
= hacks
/ssh
234 DOTLINKS
+= .w3m
/config .elinks
/elinks.conf
235 .w3m
/config_SRC
= w3m-config
236 .elinks
/elinks.conf_SRC
= elinks.conf
238 DOTLINKS
+= .mc
/ini .mc
/panels.ini
240 .mc
/panels.ini_SRC
= mc-panels.ini
242 DOTLINKS
+= .parallel
/config
243 .parallel
/config_SRC
= parallel-config
245 ###--------------------------------------------------------------------------
246 ### X11 configuration.
254 DOTLINKS
+= .xinitrc .xsession .xmodmap .vncrc .vncsession
255 DOTLINKS
+= .fonts.conf
256 DOTLINKS
+= .stalonetrayrc
258 DOTLINKS
+= .putty
/sessions
/Default
%20Settings
259 .putty
/sessions
/Default
%20Settings_SRC
= putty-defaults
261 DOTLINKS
+= .config
/gnome-session
/sessions
/mdw.session
262 .config
/gnome-session
/sessions
/mdw.session_SRC
= mdw.session
264 DOTLINKS
+= .Eterm
/themes
/Eterm
/theme.cfg
265 DOTLINKS
+= .enlightenment
/keybindings.cfg
266 DOTLINKS
+= .enlightenment-vnc
/keybindings.cfg
267 DOTLINKS
+= .e16
/bindings.cfg
268 .Eterm
/themes
/Eterm
/theme.cfg_SRC
= eterm-theme.cfg
269 .enlightenment
/keybindings.cfg_SRC
= e-keybindings.cfg
270 .enlightenment-vnc
/keybindings.cfg_SRC
= evnc-keybindings.cfg
271 .e16
/bindings.cfg_SRC
= e16-bindings
273 DOTLINKS
+= .gtkrc-2.0
274 DOTLINKS
+= .config
/gtk-3.0
/gtk.css
275 DOTLINKS
+= .config
/gtk-3.0
/settings.ini
276 .config
/gtk-3.0
/gtk.css_SRC
= gtk3.css
277 .config
/gtk-3.0
/settings.ini_SRC
= gtk3-settings.ini
279 SCRIPTLINKS
+= xinitcmd lock-screen xshutdown
280 SCRIPTLINKS
+= un-backslashify-selection
281 SCRIPTLINKS
+= xpra-start-xdummy
282 SCRIPTLINKS
+= play-rawk
285 Xdefaults_DEFS
= -DEMACSWD
=$(call mdw-conf
,emacs-width
,77)
286 $(HOME
)/.Xdefaults
: $(HOME
)/.mdw.conf
288 ifeq ($(shell case
$${DISPLAY-nil
} in
(:[0-9]*) echo t
;; (*) echo nil
;; esac
),t
)
289 dotfile-hook
/.Xdefaults
= \
290 $(call v_tag
,XRDB
)xrdb
-override $<
295 ###--------------------------------------------------------------------------
296 ### Processing dotfiles.
298 dotfile-source
= $(HERE
)/dot
/$(or
$($1_SRC), $(1:.
%=%)$2)
300 ## Easiest: just make symlinks.
302 $(call symlink-ok-p
,$(HOME
)/$1,$(call dotfile-source
,$1))
303 all:: $(addprefix $(HOME
)/, $(DOTLINKS
))
304 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTLINKS
))): $(HOME
)/%: \
305 $$(if
$$(call dotlink-ok-p
,$$*),,_force
)
306 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
308 ln
-s
$(call dotfile-source
,$*) $@.new
&& \
312 ## Hack with the C preprocessor.
313 all:: $(addprefix $(HOME
)/, $(DOTCPP
))
314 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTCPP
))): $(HOME
)/%: \
315 $$(call dotfile-source
,$$*) Makefile
316 $(call v_tag
,CPP
)mkdir
-p
$(dir $@
) && \
318 cpp -P
-o
$@.new
$($*_DEFS
) $< && \
322 ## Hack by making simple substitutions.
323 substvar
= -e
$(call quote
,s
\a@
$1@
\a$2\ag
)
324 SUBSTS
+= $(call substvar
,home
,$(HOME
))
325 SUBSTS
+= $(call substvar
,profile
,$(HERE
))
326 all:: $(addprefix $(HOME
)/, $(DOTSUBST
))
327 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTSUBST
))): $(HOME
)/%: \
328 $$(call dotfile-source
,$$*,.in
) Makefile
329 $(call v_tag
,SUBST
)mkdir
-p
$(dir $@
) && \
332 $(relax)### generated by $(HERE)/Makefile; do not edit!" \
333 $(SUBSTS
) $($*_SUBSTS
) \
334 $(call dotfile-source
,$*,.in
) >$@.new
&& \
338 ###--------------------------------------------------------------------------
339 ### Processing script links.
341 script-source
= $(HERE
)/bin
/$(or
$($1_SRC), $1)
343 ifeq ($(prefix-shebang-p
),t
)
344 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
345 $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
)): $(HOME
)/bin
/%: \
346 $$(call script-source
,$$*) Makefile
347 $(call v_tag
,SHEBANG
)mkdir
-p
$(dir $@
) && \
349 sed
"1s\a\(#! *\)/\a\1$(SHEBANG_PREFIX)/\a" \
350 $(call script-source
,$*) >$@.new
&& \
351 chmod
--reference
=$(call script-source
,$*) $@.new
&& \
356 $(call symlink-ok-p
,$(HOME
)/bin
/$1,$(call script-source
,$1))
357 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
358 $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
)): $(HOME
)/bin
/%: \
359 $$(if
$$(call scriptlink-ok-p
,$$*),,_force
)
360 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
362 ln
-s
$(call script-source
,$*) $@.new
&& \
367 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
369 ###--------------------------------------------------------------------------
370 ### Building packages from source tarballs.
372 SRCDIR
= $(HOME
)/src
/profile
374 pkg-builddir
= $(SRCDIR
)/$1/build
375 pkg-stamp
= $(call pkg-builddir
,$1)/$2-stamp
377 $(foreach p
, $(PACKAGES
), $(eval DEP_
$p = $(if
$(shell \
378 if
$($p_CHECK) >/dev
/null
2>&1 --version
; then echo t
; fi
),, \
379 $(call pkg-stamp
,$p,install))))
381 $(PACKAGES
:%=$(SRCDIR
)/%.
tar.gz
): $(SRCDIR
)/%.
tar.gz
:
382 $(call v_tag
,FETCH
)mkdir
-p
$(SRCDIR
) && \
384 $(call get-url
,$@.new
,$(REPO
)/$*.
tar.gz
) && \
387 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,unpack
)): \
388 $(call pkg-stamp
,%,unpack
): $(SRCDIR
)/%.
tar.gz
389 $(call v_tag
,EXTRACT
)rm -rf
$(SRCDIR
)/$* && \
390 mkdir
$(SRCDIR
)/$*.tmp-unpack
&& \
391 cd
$(SRCDIR
)/$*.tmp-unpack
&& \
392 gzip
-cd ..
/$*.
tar.gz |
tar xf
- && \
395 rmdir
$*.tmp-unpack
&& \
397 touch
$*/build
/unpack-stamp
399 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,configure
)): \
400 $(call pkg-stamp
,%,configure
): \
401 $(call pkg-stamp
,%,unpack
) \
402 $$(foreach p
, $$($$*_DEPS
), $$(DEP_
$$p))
403 $(call v_tag
,CONFIG
)cd
$(dir $@
) && \
404 ..
/configure
--prefix=$(HOME
) \
405 PKG_CONFIG_PATH
=$(HOME
)/lib
/pkgconfig \
406 $($*_CONFIG
) >>buildlog
2>&1 && \
407 touch configure-stamp
409 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,build
)): \
410 $(call pkg-stamp
,%,build
): \
411 $(call pkg-stamp
,%,configure
)
412 $(call v_tag
,BUILD
)cd
$(dir $@
) && \
413 $(MAKE
) $($*_MAKEFLAGS
) >>buildlog
2>&1 && \
416 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,install)): \
417 $(call pkg-stamp
,%,install): \
418 $(call pkg-stamp
,%,build
)
419 $(call v_tag
,INSTALL
)cd
$(dir $@
) && \
420 $(MAKE
) $($*_MAKEFLAGS
) install >>buildlog
2>&1 && \
424 all:: $(foreach p
, $(PACKAGES
), $(DEP_
$p))
425 $(foreach p
, $(PACKAGES
), $(eval _pkg.
$p: $(call pkg-stamp
,$p,install)))
427 ###----- That's all, folks --------------------------------------------------