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
75 SCRIPTLINKS
+= emacsclient-hack movemail-hack sendmail-hack
76 SCRIPTLINKS
+= aspell-hack emerge-hack
79 $(call v_tag
,EMACS
)$(EMACS
) -L el
/ -L
$(EMACSLIB
) \
80 --batch
--no-site-file \
81 --eval
'(byte-compile-file "$<")'
83 LOCAL_ELISP
= $(filter $(notdir $(wildcard el
/*.el
)), \
84 $(addsuffix .el
, $(ELISP
)))
85 $(foreach e
, $(LOCAL_ELISP
), \
86 $(eval DEP_
$(basename $e) = $(EMACSLIB
)/$(e
:.el
=.elc
)))
87 $(addprefix $(EMACSLIB
)/, $(LOCAL_ELISP
)): $(EMACSLIB
)/%: el
/%
88 $(call v_tag
,SYMINK
)mkdir
-p
$(EMACSLIB
) && \
90 ln
-s
$(HERE
)/$< $@.new
&& \
93 REMOTE_ELISP
= $(filter-out $(notdir $(wildcard el
/*.el
)), \
94 $(addsuffix .el
, $(ELISP
)))
95 $(foreach e
, $(REMOTE_ELISP
), \
96 $(eval DEP_
$(basename $e) = $(if
$(shell \
97 if
$(EMACS
) >/dev
/null
2>&1 --no-site-file
-q
--batch \
100 (kill-emacs (condition-case nil \
101 (progn (load-library "$e") 0) \
102 (error 1))))'; then \
104 fi
),, $(EMACSLIB
)/$(e
:.el
=.elc
))))
105 $(addprefix $(EMACSLIB
)/, $(REMOTE_ELISP
)): $(EMACSLIB
)/%:
106 $(call v_tag
,FETCH
)mkdir
-p
$(EMACSLIB
) && \
107 $(call get-url
,$@.new
,$(REPO
)/$*) && \
110 DOTLINKS
+= .emacs .emacs-calc .vm .gnus.el .ercrc.el
112 all:: $(foreach e
, $(ELISP
), $(DEP_
$e))
113 $(foreach e
, $(ELISP
), $(eval _emacs.
$e: $(EMACSLIB
)/$e.elc
))
115 ###--------------------------------------------------------------------------
116 ### Other simpler things.
119 $(call v_tag
,COPY
)cp mdw.conf
$@.new
&& mv
$@.new
$@
122 PACKAGES
+= mlib checkpath
123 mlib_CHECK
= crc-mktab
124 checkpath_CHECK
= tmpdir
125 checkpath_DEPS
= mlib
127 ## Packaging machinery.
128 SCRIPTLINKS
+= mdw-build mdw-sbuild mdw-sbuild-server
129 SCRIPTLINKS
+= update-buildable-branch
132 DOTLINKS
+= .profile .shell-rc .shell-logout
133 DOTLINKS
+= .shrc .rcrc
134 DOTLINKS
+= .zprofile .zshrc .zshenv
135 DOTLINKS
+= .bash_profile .bash_completion .bashrc .inputrc
136 .bash_profile_SRC
= bash-profile
137 .bash_completion_SRC
= bash-completion
140 DOTSUBST
+= .gitconfig
141 DOTLINKS
+= .cgrc .tigrc
142 .gitconfig_SUBSTS
= \
143 $(call substvar
,releasekey
,$(call mdw-conf
,release-key
,481334C2
))
144 $(HOME
)/.gitconfig
: $(HOME
)/.mdw.conf
147 DOTLINKS
+= .pulse
/daemon.conf
148 DOTSUBST
+= .pulse
/default.pa
149 .pulse
/daemon.conf_SRC
= pulse-daemon.conf
150 .pulse
/default.pa_SRC
= pulse-default.pa.in
153 DOTLINKS
+= .vimrc .mg .zile
156 DOTLINKS
+= .mailrc .signature .muttrc
159 DOTLINKS
+= .cmucl-init.lisp .sbclrc .clisprc.lisp .eclrc
160 .cmucl-init.lisp_SRC
= lisp-init.lisp
161 .sbclrc_SRC
= lisp-init.lisp
162 .clisprc.lisp_SRC
= lisp-init.lisp
163 .eclrc_SRC
= lisp-init.lisp
164 DOTLINKS
+= .swank.lisp
167 DOTLINKS
+= .ipython
/profile_default
/ipython_config.py
168 DOTLINKS
+= .ipython
/profile_default
/startup
/50-key-bindings.py
169 .ipython
/profile_default
/ipython_config.py_SRC
= ipython-config.py
170 .ipython
/profile_default
/startup
/50-key-bindings.py_SRC
= ipython-key-bindings.py
174 DOTLINKS
+= .tclshrc .wishrc
175 .tclshrc_SRC
= tclshrc
176 .wishrc_SRC
= tclshrc
179 SCRIPTLINKS
+= mdw-editor mdw-pager
180 SCRIPTLINKS
+= mdw-conf
181 SCRIPTLINKS
+= svnwrap
182 SCRIPTLINKS
+= guest-console
183 SCRIPTLINKS
+= hyperspec
185 ## Random odds and ends.
186 DOTLINKS
+= .lesskey .infokey .sqliterc
187 DOTLINKS
+= .gdbinit .toprc .aspell.conf
188 DOTLINKS
+= .dircolors .colordiffrc .screenrc .tmux.conf
189 DOTLINKS
+= .cvsrc .indent.pro .ditz-config
190 DOTSUBST
+= .mykermrc
191 SCRIPTLINKS
+= lesspipe.sh
193 SCRIPTLINKS
+= run-with-shell-env
194 SCRIPTLINKS
+= start-ssh-agent start-ssh-pageant
195 SCRIPTLINKS
+= add-ssh-keys
196 SCRIPTLINKS
+= hacks
/ssh
/ssh
197 hacks
/ssh
/ssh_SRC
= hacks
/ssh
199 DOTLINKS
+= .w3m
/config .elinks
/elinks.conf
200 .w3m
/config_SRC
= w3m-config
201 .elinks
/elinks.conf_SRC
= elinks.conf
203 DOTLINKS
+= .mc
/ini .mc
/panels.ini
205 .mc
/panels.ini_SRC
= mc-panels.ini
207 DOTLINKS
+= .parallel
/config
208 .parallel
/config_SRC
= parallel-config
210 ###--------------------------------------------------------------------------
211 ### X11 configuration.
219 DOTLINKS
+= .xinitrc .xsession .xmodmap .vncrc .vncsession
220 DOTLINKS
+= .fonts.conf
221 DOTLINKS
+= .stalonetrayrc
223 DOTLINKS
+= .putty
/sessions
/Default
%20Settings
224 .putty
/sessions
/Default
%20Settings_SRC
= putty-defaults
226 DOTLINKS
+= .config
/gnome-session
/sessions
/mdw.session
227 .config
/gnome-session
/sessions
/mdw.session_SRC
= mdw.session
229 DOTLINKS
+= .Eterm
/themes
/Eterm
/theme.cfg
230 DOTLINKS
+= .enlightenment
/keybindings.cfg
231 DOTLINKS
+= .enlightenment-vnc
/keybindings.cfg
232 DOTLINKS
+= .e16
/bindings.cfg
233 .Eterm
/themes
/Eterm
/theme.cfg_SRC
= eterm-theme.cfg
234 .enlightenment
/keybindings.cfg_SRC
= e-keybindings.cfg
235 .enlightenment-vnc
/keybindings.cfg_SRC
= evnc-keybindings.cfg
236 .e16
/bindings.cfg_SRC
= e16-bindings
238 DOTLINKS
+= .gtkrc-2.0
239 DOTLINKS
+= .config
/gtk-3.0
/gtk.css
240 DOTLINKS
+= .config
/gtk-3.0
/settings.ini
241 .config
/gtk-3.0
/gtk.css_SRC
= gtk3.css
242 .config
/gtk-3.0
/settings.ini_SRC
= gtk3-settings.ini
244 SCRIPTLINKS
+= xinitcmd lock-screen xshutdown
245 SCRIPTLINKS
+= un-backslashify-selection
246 SCRIPTLINKS
+= xpra-start-xdummy
249 Xdefaults_DEFS
= -DEMACSWD
=$(call mdw-conf
,emacs-width
,77)
250 $(HOME
)/.Xdefaults
: $(HOME
)/.mdw.conf
254 ###--------------------------------------------------------------------------
255 ### Processing dotfiles.
257 dotfile-source
= $(HERE
)/dot
/$(or
$($1_SRC), $(1:.
%=%)$2)
259 ## Easist: just make symlinks.
261 $(call symlink-ok-p
,$(HOME
)/$1,$(call dotfile-source
,$1))
262 all:: $(addprefix $(HOME
)/, $(DOTLINKS
))
263 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTLINKS
))): $(HOME
)/%: \
264 $$(if
$$(call dotlink-ok-p
,$$*),,_force
)
265 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
267 ln
-s
$(call dotfile-source
,$*) $@.new
&& \
270 ## Hack with the C preprocessor.
271 all:: $(addprefix $(HOME
)/, $(DOTCPP
))
272 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTCPP
))): $(HOME
)/%: \
273 $$(call dotfile-source
,$$*) Makefile
274 $(call v_tag
,CPP
)mkdir
-p
$(dir $@
) && \
276 cpp -P
-o
$@.new
$($*_DEFS
) $< && \
279 ## Hack by making simple substitutions.
280 substvar
= -e
$(call quote
,s
\a@
$1@
\a$2\ag
)
281 SUBSTS
+= $(call substvar
,home
,$(HOME
))
282 SUBSTS
+= $(call substvar
,profile
,$(HERE
))
283 all:: $(addprefix $(HOME
)/, $(DOTSUBST
))
284 $(addprefix $(HOME
)/, $(subst %,\
%,$(DOTSUBST
))): $(HOME
)/%: \
285 $$(call dotsubst-source
,$$*,.in
) Makefile
286 $(call v_tag
,SUBST
)mkdir
-p
$(dir $@
) && \
289 $(relax)### generated by $(HERE)/Makefile; do not edit!" \
290 $(SUBSTS
) $($*_SUBSTS
) \
291 $(call dotfile-source
,$*,.in
) >$@.new
&& \
294 ###--------------------------------------------------------------------------
295 ### Processing script links.
297 script-source
= $(HERE
)/bin
/$(or
$($1_SRC), $1)
299 $(call symlink-ok-p
,$(HOME
)/bin
/$1,$(call script-source
,$1))
300 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
301 $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
)): $(HOME
)/bin
/%: \
302 $$(if
$$(call scriptlink-ok-p
,$$*),,_force
)
303 $(call v_tag
,SYMLINK
)mkdir
-p
$(dir $@
) && \
305 ln
-s
$(call script-source
,$*) $@.new
&& \
308 all:: $(addprefix $(HOME
)/bin
/, $(SCRIPTLINKS
))
310 ###--------------------------------------------------------------------------
311 ### Building packages from source tarballs.
313 SRCDIR
= $(HOME
)/src
/profile
315 pkg-builddir
= $(SRCDIR
)/$1/build
316 pkg-stamp
= $(call pkg-builddir
,$1)/$2-stamp
318 $(foreach p
, $(PACKAGES
), $(eval DEP_
$p = $(if
$(shell \
319 if
$($p_CHECK) >/dev
/null
2>&1 --version
; then echo t
; fi
),, \
320 $(call pkg-stamp
,$p,install))))
322 $(PACKAGES
:%=$(SRCDIR
)/%.
tar.gz
): $(SRCDIR
)/%.
tar.gz
:
323 $(call v_tag
,FETCH
)mkdir
-p
$(SRCDIR
) && \
325 $(call get-url
,$@.new
,$(REPO
)/$*.
tar.gz
) && \
328 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,unpack
)): \
329 $(call pkg-stamp
,%,unpack
): $(SRCDIR
)/%.
tar.gz
330 $(call v_tag
,EXTRACT
)rm -rf
$(SRCDIR
)/$* && \
331 mkdir
$(SRCDIR
)/$*.tmp-unpack
&& \
332 cd
$(SRCDIR
)/$*.tmp-unpack
&& \
333 gzip
-cd ..
/$*.
tar.gz |
tar xf
- && \
336 rmdir
$*.tmp-unpack
&& \
338 touch
$*/build
/unpack-stamp
340 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,configure
)): \
341 $(call pkg-stamp
,%,configure
): \
342 $(call pkg-stamp
,%,unpack
) \
343 $$(foreach p
, $$($$*_DEPS
), $$(DEP_
$$p))
344 $(call v_tag
,CONFIG
)cd
$(dir $@
) && \
345 ..
/configure
--prefix=$(HOME
) \
346 PKG_CONFIG_PATH
=$(HOME
)/lib
/pkgconfig \
347 $($*_CONFIG
) >>buildlog
2>&1 && \
348 touch configure-stamp
350 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,build
)): \
351 $(call pkg-stamp
,%,build
): \
352 $(call pkg-stamp
,%,configure
)
353 $(call v_tag
,BUILD
)cd
$(dir $@
) && \
354 $(MAKE
) $($*_MAKEFLAGS
) >>buildlog
2>&1 && \
357 $(foreach p
, $(PACKAGES
), $(call pkg-stamp
,$p,install)): \
358 $(call pkg-stamp
,%,install): \
359 $(call pkg-stamp
,%,build
)
360 $(call v_tag
,INSTALL
)cd
$(dir $@
) && \
361 $(MAKE
) $($*_MAKEFLAGS
) install >>buildlog
2>&1 && \
364 all:: $(foreach p
, $(PACKAGES
), $(DEP_
$p))
365 $(foreach p
, $(PACKAGES
), $(eval _pkg.
$p: $(call pkg-stamp
,$p,install)))
367 ###----- That's all, folks --------------------------------------------------