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
70 ELISP
+= make-regexp.el ew-hols.el
71 ELISP
+= mdw-gnus-patch.el
72 ELISP
+= mdw-multiple-cursors.el
73 ELISP
+= git.el git-blame.el vc-git.el stgit.el quilt.el
74 ELISP
+= bracketed-paste.el
76 SCRIPTLINKS
+= emacsclient-hack movemail-hack sendmail-hack
77 SCRIPTLINKS
+= aspell-hack emerge-hack
80 $(call v_tag
,EMACS
)$(EMACS
) -L el
/ -L
$(EMACSLIB
) \
81 --batch
--no-site-file \
82 --eval
'(byte-compile-file "$<")'
84 LOCAL_ELISP
= $(filter $(notdir $(wildcard el
/*.el
)), $(ELISP
))
85 $(foreach e
, $(LOCAL_ELISP
), $(eval DEP_
$e = $(EMACSLIB
)/$(e
:.el
=.elc
)))
86 $(addprefix $(EMACSLIB
)/, $(LOCAL_ELISP
)): $(EMACSLIB
)/%: el
/%
87 $(call v_tag
,SYMINK
)mkdir
-p
$(EMACSLIB
) && \
89 ln
-s
$(HERE
)/$< $@.new
&& \
92 REMOTE_ELISP
= $(filter-out $(notdir $(wildcard el
/*.el
)), \
94 $(foreach e
, $(REMOTE_ELISP
), \
95 $(eval DEP_
$e = $(if
$(shell \
96 if
$(EMACS
) >/dev
/null
2>&1 --no-site-file
-q
--batch \
99 (kill-emacs (condition-case nil \
100 (progn (load-library "$e") 0) \
101 (error 1))))'; then \
103 fi
),, $(EMACSLIB
)/$(e
:.el
=.elc
))))
104 $(addprefix $(EMACSLIB
)/, $(REMOTE_ELISP
)): $(EMACSLIB
)/%:
105 $(call v_tag
,FETCH
)mkdir
-p
$(EMACSLIB
) && \
106 $(call get-url
,$@.new
,$(REPO
)/$*) && \
109 DOTLINKS
+= .emacs .emacs-calc .vm .gnus.el .ercrc.el
111 all:: $(foreach e
, $(ELISP
), $(DEP_
$e))
112 $(foreach e
, $(ELISP
), $(eval _emacs.
$(e
:.el
=): $(EMACSLIB
)/$(e
:.el
=.elc
)))
114 ###--------------------------------------------------------------------------
115 ### Other simpler things.
118 $(call v_tag
,COPY
)cp mdw.conf
$@.new
&& mv
$@.new
$@
121 PACKAGES
+= mlib checkpath
122 mlib_CHECK
= crc-mktab
123 checkpath_CHECK
= tmpdir
124 checkpath_DEPS
= mlib
126 ## Packaging machinery.
127 SCRIPTLINKS
+= mdw-build mdw-sbuild mdw-sbuild-server
128 SCRIPTLINKS
+= update-buildable-branch
131 DOTLINKS
+= .profile .shell-rc .shell-logout
132 DOTLINKS
+= .shrc .rcrc
133 DOTLINKS
+= .zprofile .zshrc .zshenv
134 DOTLINKS
+= .bash_profile .bash_completion .bashrc .inputrc
135 .bash_profile_SRC
= bash-profile
136 .bash_completion_SRC
= bash-completion
139 DOTSUBST
+= .gitconfig
140 DOTLINKS
+= .cgrc .tigrc
141 .gitconfig_SUBSTS
= \
142 $(call substvar
,releasekey
,$(call mdw-conf
,release-key
,481334C2
))
143 $(HOME
)/.gitconfig
: $(HOME
)/.mdw.conf
146 DOTLINKS
+= .pulse
/daemon.conf
147 DOTSUBST
+= .pulse
/default.pa
148 .pulse
/daemon.conf_SRC
= pulse-daemon.conf
149 .pulse
/default.pa_SRC
= pulse-default.pa.in
152 DOTLINKS
+= .vimrc .mg .zile
155 DOTLINKS
+= .mailrc .signature .muttrc
158 DOTLINKS
+= .cmucl-init.lisp .sbclrc .clisprc.lisp .eclrc
159 .cmucl-init.lisp_SRC
= lisp-init.lisp
160 .sbclrc_SRC
= lisp-init.lisp
161 .clisprc.lisp_SRC
= lisp-init.lisp
162 .eclrc_SRC
= lisp-init.lisp
163 DOTLINKS
+= .swank.lisp
166 DOTLINKS
+= .ipython
/profile_default
/ipython_config.py
167 DOTLINKS
+= .ipython
/profile_default
/startup
/50-key-bindings.py
168 .ipython
/profile_default
/ipython_config.py_SRC
= ipython-config.py
169 .ipython
/profile_default
/startup
/50-key-bindings.py_SRC
= ipython-key-bindings.py
173 DOTLINKS
+= .tclshrc .wishrc
174 .tclshrc_SRC
= tclshrc
175 .wishrc_SRC
= tclshrc
178 SCRIPTLINKS
+= mdw-editor mdw-pager
179 SCRIPTLINKS
+= mdw-conf
180 SCRIPTLINKS
+= svnwrap
181 SCRIPTLINKS
+= guest-console
182 SCRIPTLINKS
+= hyperspec
184 ## Random odds and ends.
185 DOTLINKS
+= .lesskey .infokey .sqliterc
186 DOTLINKS
+= .gdbinit .toprc .aspell.conf
187 DOTLINKS
+= .dircolors .colordiffrc .screenrc .tmux.conf
188 DOTLINKS
+= .cvsrc .indent.pro .ditz-config
189 DOTSUBST
+= .mykermrc
190 SCRIPTLINKS
+= lesspipe.sh
192 SCRIPTLINKS
+= run-with-shell-env
193 SCRIPTLINKS
+= start-ssh-agent start-ssh-pageant
194 SCRIPTLINKS
+= add-ssh-keys
195 SCRIPTLINKS
+= hacks
/ssh
/ssh
196 hacks
/ssh
/ssh_SRC
= hacks
/ssh
198 DOTLINKS
+= .w3m
/config .elinks
/elinks.conf
199 .w3m
/config_SRC
= w3m-config
200 .elinks
/elinks.conf_SRC
= elinks.conf
202 DOTLINKS
+= .mc
/ini .mc
/panels.ini
204 .mc
/panels.ini_SRC
= mc-panels.ini
206 DOTLINKS
+= .parallel
/config
207 .parallel
/config_SRC
= parallel-config
209 ###--------------------------------------------------------------------------
210 ### X11 configuration.
218 DOTLINKS
+= .xinitrc .xsession .xmodmap .vncrc .vncsession
219 DOTLINKS
+= .fonts.conf
220 DOTLINKS
+= .stalonetrayrc
222 DOTLINKS
+= .putty
/sessions
/Default
%20Settings
223 .putty
/sessions
/Default
%20Settings_SRC
= putty-defaults
225 DOTLINKS
+= .config
/gnome-session
/sessions
/mdw.session
226 .config
/gnome-session
/sessions
/mdw.session_SRC
= mdw.session
228 DOTLINKS
+= .Eterm
/themes
/Eterm
/theme.cfg
229 DOTLINKS
+= .enlightenment
/keybindings.cfg
230 DOTLINKS
+= .enlightenment-vnc
/keybindings.cfg
231 DOTLINKS
+= .e16
/bindings.cfg
232 .Eterm
/themes
/Eterm
/theme.cfg_SRC
= eterm-theme.cfg
233 .enlightenment
/keybindings.cfg_SRC
= e-keybindings.cfg
234 .enlightenment-vnc
/keybindings.cfg_SRC
= evnc-keybindings.cfg
235 .e16
/bindings.cfg_SRC
= e16-bindings
237 DOTLINKS
+= .gtkrc-2.0
238 DOTLINKS
+= .config
/gtk-3.0
/gtk.css
239 DOTLINKS
+= .config
/gtk-3.0
/settings.ini
240 .config
/gtk-3.0
/gtk.css_SRC
= gtk3.css
241 .config
/gtk-3.0
/settings.ini_SRC
= gtk3-settings.ini
243 SCRIPTLINKS
+= xinitcmd lock-screen xshutdown
244 SCRIPTLINKS
+= un-backslashify-selection
245 SCRIPTLINKS
+= xpra-start-xdummy
248 Xdefaults_DEFS
= -DEMACSWD
=$(call mdw-conf
,emacs-width
,77)
249 $(HOME
)/.Xdefaults
: $(HOME
)/.mdw.conf
253 ###--------------------------------------------------------------------------
254 ### Processing dotfiles.
256 dotfile-source
= $(HERE
)/dot
/$(or
$($1_SRC), $(1:.
%=%)$2)
258 ## Easist: just make symlinks.
260 $(call symlink-ok-p
,$(HOME
)/$1,$(call dotfile-source
,$1))
261 all:: $(addprefix $(HOME
)/, $(DOTLINKS
))
262 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTLINKS
))): $(HOME
)/%: \
263 $$(if
$$(call dotlink-ok-p
,$$*),,_force
)
264 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
266 ln
-s
$(call dotfile-source
,$*) $@.new
&& \
269 ## Hack with the C preprocessor.
270 all:: $(addprefix $(HOME
)/, $(DOTCPP
))
271 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTCPP
))): $(HOME
)/%: \
272 $$(call dotfile-source
,$$*) Makefile
273 $(call v_tag
,CPP
)mkdir
-p
$(dir $@
) && \
275 cpp -P
-o
$@.new
$($*_DEFS
) $< && \
278 ## Hack by making simple substitutions.
279 substvar
= -e
$(call quote
,s
\a@
$1@
\a$2\ag
)
280 SUBSTS
+= $(call substvar
,home
,$(HOME
))
281 SUBSTS
+= $(call substvar
,profile
,$(HERE
))
282 all:: $(addprefix $(HOME
)/, $(DOTSUBST
))
283 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTSUBST
))): $(HOME
)/%: \
284 $$(call dotsubst-source
,$$*,.in
) Makefile
285 $(call v_tag
,SUBST
)mkdir
-p
$(dir $@
) && \
288 $(relax)### generated by $(HERE)/Makefile; do not edit!" \
289 $(SUBSTS
) $($*_SUBSTS
) \
290 $(call dotfile-source
,$*,.in
) >$@.new
&& \
293 ###--------------------------------------------------------------------------
294 ### Processing script links.
296 script-source
= $(HERE
)/bin
/$(or
$($1_SRC), $1)
298 $(call symlink-ok-p
,$(HOME
)/bin
/$1,$(call script-source
,$1))
299 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
300 $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
)): $(HOME
)/bin
/%: \
301 $$(if
$$(call scriptlink-ok-p
,$$*),,_force
)
302 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
304 ln
-s
$(call script-source
,$*) $@.new
&& \
307 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
309 ###--------------------------------------------------------------------------
310 ### Building packages from source tarballs.
312 SRCDIR
= $(HOME
)/src
/profile
314 pkg-builddir
= $(SRCDIR
)/$1/build
315 pkg-stamp
= $(call pkg-builddir
,$1)/$2-stamp
317 $(foreach p
, $(PACKAGES
), $(eval DEP_
$p = $(if
$(shell \
318 if
$($p_CHECK) >/dev
/null
2>&1 --version
; then echo t
; fi
),, \
319 $(call pkg-stamp
,$p,install))))
321 $(PACKAGES
:%=$(SRCDIR
)/%.
tar.gz
): $(SRCDIR
)/%.
tar.gz
:
322 $(call v_tag
,FETCH
)mkdir
-p
$(SRCDIR
) && \
324 $(call get-url
,$@.new
,$(REPO
)/$*.
tar.gz
) && \
327 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,unpack
)): \
328 $(call pkg-stamp
,%,unpack
): $(SRCDIR
)/%.
tar.gz
329 $(call v_tag
,EXTRACT
)rm -rf
$(SRCDIR
)/$* && \
330 mkdir
$(SRCDIR
)/$*.tmp-unpack
&& \
331 cd
$(SRCDIR
)/$*.tmp-unpack
&& \
332 gzip
-cd ..
/$*.
tar.gz |
tar xf
- && \
335 rmdir
$*.tmp-unpack
&& \
337 touch
$*/build
/unpack-stamp
339 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,configure
)): \
340 $(call pkg-stamp
,%,configure
): \
341 $(call pkg-stamp
,%,unpack
) \
342 $$(foreach p
, $$($$*_DEPS
), $$(DEP_
$$p))
343 $(call v_tag
,CONFIG
)cd
$(dir $@
) && \
344 ..
/configure
--prefix=$(HOME
) \
345 PKG_CONFIG_PATH
=$(HOME
)/lib
/pkgconfig \
346 $($*_CONFIG
) >>buildlog
2>&1 && \
347 touch configure-stamp
349 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,build
)): \
350 $(call pkg-stamp
,%,build
): \
351 $(call pkg-stamp
,%,configure
)
352 $(call v_tag
,BUILD
)cd
$(dir $@
) && \
353 $(MAKE
) $($*_MAKEFLAGS
) >>buildlog
2>&1 && \
356 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,install)): \
357 $(call pkg-stamp
,%,install): \
358 $(call pkg-stamp
,%,build
)
359 $(call v_tag
,INSTALL
)cd
$(dir $@
) && \
360 $(MAKE
) $($*_MAKEFLAGS
) install >>buildlog
2>&1 && \
363 all:: $(foreach p
, $(PACKAGES
), $(DEP_
$p))
364 $(foreach p
, $(PACKAGES
), $(eval _pkg.
$p: $(call pkg-stamp
,$p,install)))
366 ###----- That's all, folks --------------------------------------------------