Makefile: Add a facility for general symlinks.
[profile] / Makefile
index 3665493..4742ad6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -324,6 +324,22 @@ endif
 endif
 
 ###--------------------------------------------------------------------------
+### General symlinking.
+
+misclink-source                 = $(HERE)/$(or $($1_SRC), $1)
+
+all:: $(addprefix $(HOME)/, $(MISCLINKS))
+misclink-ok-p           = \
+       $(call symlink-ok-p,$(HOME)/$1,$(call misclink-source,$1))
+$(addprefix $(HOME)/, $(subst %,\%,$(MISCLINKS))): $(HOME)/%: \
+               $$(if $$(call misclink-ok-p,$$*),,_force)
+       $(call v_tag,SYMLINK)mkdir -p $(dir $@) && \
+               rm -f $@.new && \
+               ln -s $(call misclink-source,$*) $@.new && \
+               mv $@.new $@
+       $(symlink-hook/$*)
+
+###--------------------------------------------------------------------------
 ### Processing dotfiles.
 
 dotfile-source          = $(HERE)/dot/$(or $($1_SRC), $(1:.%=%)$2)