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 ###--------------------------------------------------------------------------
67 EMACSLIB
= $(HOME
)/lib
/emacs
69 ELISP
+= make-regexp ew-hols
70 ELISP
+= mdw-gnus-patch
71 ELISP
+= mdw-multiple-cursors
72 ELISP
+= git git-blame vc-git stgit quilt
73 ELISP
+= bracketed-paste
76 dot-emacs_DEPS
= make-regexp
78 SCRIPTLINKS
+= emacsclient-hack movemail-hack sendmail-hack
79 SCRIPTLINKS
+= aspell-hack emerge-hack
81 %.elc
: %.el
$$(foreach e
, $$($$*_DEPS
), $$(DEP_
$$e))
82 $(call v_tag
,EMACS
)$(EMACS
) -L el
/ -L
$(EMACSLIB
) \
83 --batch
--no-site-file \
84 --eval
'(byte-compile-file "$<")'
86 LOCAL_ELISP
= $(filter $(notdir $(wildcard el
/*.el
)), \
87 $(addsuffix .el
, $(ELISP
)))
88 $(foreach e
, $(LOCAL_ELISP
), \
89 $(eval DEP_
$(basename $e) = $(EMACSLIB
)/$(e
:.el
=.elc
)))
90 $(addprefix $(EMACSLIB
)/, $(LOCAL_ELISP
)): $(EMACSLIB
)/%: el
/%
91 $(call v_tag
,SYMINK
)mkdir
-p
$(EMACSLIB
) && \
93 ln
-s
$(HERE
)/$< $@.new
&& \
96 REMOTE_ELISP
= $(filter-out $(notdir $(wildcard el
/*.el
)), \
97 $(addsuffix .el
, $(ELISP
)))
98 $(foreach e
, $(REMOTE_ELISP
), \
99 $(eval DEP_
$(basename $e) = $(if
$(shell \
100 if
$(EMACS
) >/dev
/null
2>&1 --no-site-file
-q
--batch \
103 (kill-emacs (condition-case nil \
104 (progn (load-library "$e") 0) \
105 (error 1))))'; then \
107 fi
),, $(EMACSLIB
)/$(e
:.el
=.elc
))))
108 $(addprefix $(EMACSLIB
)/, $(REMOTE_ELISP
)): $(EMACSLIB
)/%:
109 $(call v_tag
,FETCH
)mkdir
-p
$(EMACSLIB
) && \
110 $(call get-url
,$@.new
,$(REPO
)/$*) && \
113 DOTLINKS
+= .emacs .emacs-calc .vm .gnus.el .ercrc.el
115 all:: $(foreach e
, $(ELISP
), $(DEP_
$e))
116 $(foreach e
, $(ELISP
), $(eval _emacs.
$e: $(EMACSLIB
)/$e.elc
))
118 ###--------------------------------------------------------------------------
119 ### Other simpler things.
122 $(call v_tag
,COPY
)cp mdw.conf
$@.new
&& mv
$@.new
$@
125 PACKAGES
+= mlib checkpath
126 mlib_CHECK
= crc-mktab
127 checkpath_CHECK
= tmpdir
128 checkpath_DEPS
= mlib
130 ## Packaging machinery.
131 SCRIPTLINKS
+= mdw-build mdw-sbuild mdw-sbuild-server
132 SCRIPTLINKS
+= update-buildable-branch
135 DOTLINKS
+= .profile .shell-rc .shell-logout
136 DOTLINKS
+= .shrc .rcrc
137 DOTLINKS
+= .zprofile .zshrc .zshenv
138 DOTLINKS
+= .bash_profile .bash_completion .bashrc .inputrc
139 .bash_profile_SRC
= bash-profile
140 .bash_completion_SRC
= bash-completion
143 DOTSUBST
+= .gitconfig
144 DOTLINKS
+= .cgrc .tigrc
145 .gitconfig_SUBSTS
= \
146 $(call substvar
,releasekey
,$(call mdw-conf
,release-key
,481334C2
))
147 $(HOME
)/.gitconfig
: $(HOME
)/.mdw.conf
150 DOTLINKS
+= .pulse
/daemon.conf
151 DOTSUBST
+= .pulse
/default.pa
152 .pulse
/daemon.conf_SRC
= pulse-daemon.conf
153 .pulse
/default.pa_SRC
= pulse-default.pa.in
156 DOTLINKS
+= .vimrc .mg .zile
159 DOTLINKS
+= .mailrc .signature .muttrc
162 DOTLINKS
+= .cmucl-init.lisp .sbclrc .clisprc.lisp .eclrc
163 .cmucl-init.lisp_SRC
= lisp-init.lisp
164 .sbclrc_SRC
= lisp-init.lisp
165 .clisprc.lisp_SRC
= lisp-init.lisp
166 .eclrc_SRC
= lisp-init.lisp
167 DOTLINKS
+= .swank.lisp
170 DOTLINKS
+= .ipython
/profile_default
/ipython_config.py
171 DOTLINKS
+= .ipython
/profile_default
/startup
/50-key-bindings.py
172 .ipython
/profile_default
/ipython_config.py_SRC
= ipython-config.py
173 .ipython
/profile_default
/startup
/50-key-bindings.py_SRC
= ipython-key-bindings.py
177 DOTLINKS
+= .tclshrc .wishrc
178 .tclshrc_SRC
= tclshrc
179 .wishrc_SRC
= tclshrc
182 SCRIPTLINKS
+= mdw-editor mdw-pager
183 SCRIPTLINKS
+= mdw-conf
184 SCRIPTLINKS
+= svnwrap
185 SCRIPTLINKS
+= guest-console
186 SCRIPTLINKS
+= hyperspec
188 ## Random odds and ends.
189 DOTLINKS
+= .lesskey .infokey .sqliterc
190 DOTLINKS
+= .gdbinit .toprc .aspell.conf
191 DOTLINKS
+= .dircolors .colordiffrc .screenrc .tmux.conf
192 DOTLINKS
+= .cvsrc .indent.pro .ditz-config
193 DOTSUBST
+= .mykermrc
194 SCRIPTLINKS
+= lesspipe.sh
196 SCRIPTLINKS
+= run-with-shell-env
197 SCRIPTLINKS
+= start-ssh-agent start-ssh-pageant
198 SCRIPTLINKS
+= add-ssh-keys
199 SCRIPTLINKS
+= hacks
/ssh
/ssh
200 hacks
/ssh
/ssh_SRC
= hacks
/ssh
202 DOTLINKS
+= .w3m
/config .elinks
/elinks.conf
203 .w3m
/config_SRC
= w3m-config
204 .elinks
/elinks.conf_SRC
= elinks.conf
206 DOTLINKS
+= .mc
/ini .mc
/panels.ini
208 .mc
/panels.ini_SRC
= mc-panels.ini
210 DOTLINKS
+= .parallel
/config
211 .parallel
/config_SRC
= parallel-config
213 ###--------------------------------------------------------------------------
214 ### X11 configuration.
222 DOTLINKS
+= .xinitrc .xsession .xmodmap .vncrc .vncsession
223 DOTLINKS
+= .fonts.conf
224 DOTLINKS
+= .stalonetrayrc
226 DOTLINKS
+= .putty
/sessions
/Default
%20Settings
227 .putty
/sessions
/Default
%20Settings_SRC
= putty-defaults
229 DOTLINKS
+= .config
/gnome-session
/sessions
/mdw.session
230 .config
/gnome-session
/sessions
/mdw.session_SRC
= mdw.session
232 DOTLINKS
+= .Eterm
/themes
/Eterm
/theme.cfg
233 DOTLINKS
+= .enlightenment
/keybindings.cfg
234 DOTLINKS
+= .enlightenment-vnc
/keybindings.cfg
235 DOTLINKS
+= .e16
/bindings.cfg
236 .Eterm
/themes
/Eterm
/theme.cfg_SRC
= eterm-theme.cfg
237 .enlightenment
/keybindings.cfg_SRC
= e-keybindings.cfg
238 .enlightenment-vnc
/keybindings.cfg_SRC
= evnc-keybindings.cfg
239 .e16
/bindings.cfg_SRC
= e16-bindings
241 DOTLINKS
+= .gtkrc-2.0
242 DOTLINKS
+= .config
/gtk-3.0
/gtk.css
243 DOTLINKS
+= .config
/gtk-3.0
/settings.ini
244 .config
/gtk-3.0
/gtk.css_SRC
= gtk3.css
245 .config
/gtk-3.0
/settings.ini_SRC
= gtk3-settings.ini
247 SCRIPTLINKS
+= xinitcmd lock-screen xshutdown
248 SCRIPTLINKS
+= un-backslashify-selection
249 SCRIPTLINKS
+= xpra-start-xdummy
252 Xdefaults_DEFS
= -DEMACSWD
=$(call mdw-conf
,emacs-width
,77)
253 $(HOME
)/.Xdefaults
: $(HOME
)/.mdw.conf
257 ###--------------------------------------------------------------------------
258 ### Processing dotfiles.
260 dotfile-source
= $(HERE
)/dot
/$(or
$($1_SRC), $(1:.
%=%)$2)
262 ## Easist: just make symlinks.
264 $(call symlink-ok-p
,$(HOME
)/$1,$(call dotfile-source
,$1))
265 all:: $(addprefix $(HOME
)/, $(DOTLINKS
))
266 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTLINKS
))): $(HOME
)/%: \
267 $$(if
$$(call dotlink-ok-p
,$$*),,_force
)
268 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
270 ln
-s
$(call dotfile-source
,$*) $@.new
&& \
273 ## Hack with the C preprocessor.
274 all:: $(addprefix $(HOME
)/, $(DOTCPP
))
275 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTCPP
))): $(HOME
)/%: \
276 $$(call dotfile-source
,$$*) Makefile
277 $(call v_tag
,CPP
)mkdir
-p
$(dir $@
) && \
279 cpp -P
-o
$@.new
$($*_DEFS
) $< && \
282 ## Hack by making simple substitutions.
283 substvar
= -e
$(call quote
,s
\a@
$1@
\a$2\ag
)
284 SUBSTS
+= $(call substvar
,home
,$(HOME
))
285 SUBSTS
+= $(call substvar
,profile
,$(HERE
))
286 all:: $(addprefix $(HOME
)/, $(DOTSUBST
))
287 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTSUBST
))): $(HOME
)/%: \
288 $$(call dotsubst-source
,$$*,.in
) Makefile
289 $(call v_tag
,SUBST
)mkdir
-p
$(dir $@
) && \
292 $(relax)### generated by $(HERE)/Makefile; do not edit!" \
293 $(SUBSTS
) $($*_SUBSTS
) \
294 $(call dotfile-source
,$*,.in
) >$@.new
&& \
297 ###--------------------------------------------------------------------------
298 ### Processing script links.
300 script-source
= $(HERE
)/bin
/$(or
$($1_SRC), $1)
302 $(call symlink-ok-p
,$(HOME
)/bin
/$1,$(call script-source
,$1))
303 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
304 $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
)): $(HOME
)/bin
/%: \
305 $$(if
$$(call scriptlink-ok-p
,$$*),,_force
)
306 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
308 ln
-s
$(call script-source
,$*) $@.new
&& \
311 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
313 ###--------------------------------------------------------------------------
314 ### Building packages from source tarballs.
316 SRCDIR
= $(HOME
)/src
/profile
318 pkg-builddir
= $(SRCDIR
)/$1/build
319 pkg-stamp
= $(call pkg-builddir
,$1)/$2-stamp
321 $(foreach p
, $(PACKAGES
), $(eval DEP_
$p = $(if
$(shell \
322 if
$($p_CHECK) >/dev
/null
2>&1 --version
; then echo t
; fi
),, \
323 $(call pkg-stamp
,$p,install))))
325 $(PACKAGES
:%=$(SRCDIR
)/%.
tar.gz
): $(SRCDIR
)/%.
tar.gz
:
326 $(call v_tag
,FETCH
)mkdir
-p
$(SRCDIR
) && \
328 $(call get-url
,$@.new
,$(REPO
)/$*.
tar.gz
) && \
331 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,unpack
)): \
332 $(call pkg-stamp
,%,unpack
): $(SRCDIR
)/%.
tar.gz
333 $(call v_tag
,EXTRACT
)rm -rf
$(SRCDIR
)/$* && \
334 mkdir
$(SRCDIR
)/$*.tmp-unpack
&& \
335 cd
$(SRCDIR
)/$*.tmp-unpack
&& \
336 gzip
-cd ..
/$*.
tar.gz |
tar xf
- && \
339 rmdir
$*.tmp-unpack
&& \
341 touch
$*/build
/unpack-stamp
343 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,configure
)): \
344 $(call pkg-stamp
,%,configure
): \
345 $(call pkg-stamp
,%,unpack
) \
346 $$(foreach p
, $$($$*_DEPS
), $$(DEP_
$$p))
347 $(call v_tag
,CONFIG
)cd
$(dir $@
) && \
348 ..
/configure
--prefix=$(HOME
) \
349 PKG_CONFIG_PATH
=$(HOME
)/lib
/pkgconfig \
350 $($*_CONFIG
) >>buildlog
2>&1 && \
351 touch configure-stamp
353 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,build
)): \
354 $(call pkg-stamp
,%,build
): \
355 $(call pkg-stamp
,%,configure
)
356 $(call v_tag
,BUILD
)cd
$(dir $@
) && \
357 $(MAKE
) $($*_MAKEFLAGS
) >>buildlog
2>&1 && \
360 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,install)): \
361 $(call pkg-stamp
,%,install): \
362 $(call pkg-stamp
,%,build
)
363 $(call v_tag
,INSTALL
)cd
$(dir $@
) && \
364 $(MAKE
) $($*_MAKEFLAGS
) install >>buildlog
2>&1 && \
367 all:: $(foreach p
, $(PACKAGES
), $(DEP_
$p))
368 $(foreach p
, $(PACKAGES
), $(eval _pkg.
$p: $(call pkg-stamp
,$p,install)))
370 ###----- That's all, folks --------------------------------------------------