legacy-dotfiles/dotfiles.mk

109 lines
3.2 KiB
Makefile
Raw Normal View History

2012-12-04 22:05:24 +01:00
LOAD_PATH=. /usr/share/emacs/site-lisp $(HOME)/.emacs.d/site-lisp
EMACS=emacs $(addprefix -L ,$(LOAD_PATH))
MODE=644
2012-12-04 22:05:24 +01:00
FG_BLU=\033[0;34m
2012-12-04 22:05:24 +01:00
FG_YEL=\033[0;33m
FG_GRE=\033[0;32m
FG_RED=\033[0;31m
CLR_RE=\033[0;00m
compile = $(EMACS) -Q -batch -eval "(byte-compile-file \"$(1)\")"
define newer =
$(shell if [ "$(1)" -nt "$(DESTDIR)/$(1)" ]; then echo "newer"; fi)
endef
define older =
$(shell if [ "$(1)" -ot "$(DESTDIR)/$(1)" ]; then echo "older"; fi)
endef
2012-12-04 22:05:24 +01:00
check-objects=$(addprefix check-,$(objects))
2012-12-04 22:05:24 +01:00
install-objects=$(addprefix install-,$(objects))
reverse-objects=$(addprefix reverse-,$(objects))
2012-12-04 22:05:24 +01:00
uninstall-objects=$(addprefix uninstall-,$(objects))
check-modules=$(addprefix check-,$(modules))
2012-12-04 22:05:24 +01:00
install-modules=$(addprefix install-,$(modules))
reverse-modules=$(addprefix reverse-,$(modules))
2012-12-04 22:05:24 +01:00
uninstall-modules=$(addprefix uninstall-,$(modules))
2012-12-05 00:13:28 +01:00
.PHONY: all install uninstall check uninstall $(modules) \
$(install-objects) $(uninstall-objects) $(check-objects) \
$(install-modules) $(uninstall-modules) $(check-modules) \
$(reverse) $(reverse-objects) $(reverse-modules)
2012-12-04 22:05:24 +01:00
all: $(modules) $(objects)
ifeq ($(MAKEROOT),y)
2012-12-04 22:05:24 +01:00
check: $(check-modules) $(check-objects)
install: uninstall $(install-modules) $(install-objects) Makefile.old
reverse: $(reverse-modules) $(reverse-objects)
ifeq ($(firstword $(MAKEFILE_LIST)),Makefile.old)
2012-12-04 22:05:24 +01:00
uninstall: $(uninstall-modules) $(uninstall-objects)
@rmdir --ignore-fail-on-non-empty $(DESTDIR) 2> /dev/null || true
else
uninstall: export NEWLIST = $(objects)
uninstall:
@$(MAKE) -s -f Makefile.old uninstall
Makefile.old: $(firstword $(MAKEFILE_LIST))
@cp "$^" "$@"
ifdef SUBDIR
DESTDIR:=$(DESTDIR)/$(SUBDIR)
endif
endif
else
check:
@$(MAKE) -s -C ../ check
install:
@$(MAKE) -s -C ../ install
reverse:
@$(MAKE) -s -C ../ reverse
uninstall:
@$(MAKE) -s -C ../ uninstall
endif
2012-12-04 22:05:24 +01:00
$(modules): %:
$(MAKE) -C $*
2012-12-04 22:05:24 +01:00
$(install-objects): install-%: %
@$(if $(call newer,$*), \
2013-02-15 01:10:51 +01:00
echo -e "$(FG_GRE)+ $(FG_YEL)$(MKDPREFIX)$* $(CLR_RE)to $(DESTDIR) as $(MODE)"; \
install -pDm $(MODE) "$*" "$(DESTDIR)/$*", \
$(if $(call older,$*) ,\
echo -e "$(FG_RED)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"))
2012-12-04 22:05:24 +01:00
$(install-modules): install-%:
@$(MAKE) -s -C $* install MKDPREFIX=$(MKDPREFIX)$*/
2012-12-04 22:05:24 +01:00
$(reverse-objects): reverse-%:
@$(if $(call older,$*), \
2013-02-15 01:10:51 +01:00
echo -e "$(FG_GRE)+ $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"; \
cp -a "$(DESTDIR)/$*" "$*", \
2013-02-15 01:10:51 +01:00
echo -e "$(FG_RED)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)")
$(reverse-modules): reverse-%:
@$(MAKE) -s -C $* reverse MKDPREFIX=$(MKDPREFIX)$*/
2012-12-04 22:05:24 +01:00
$(uninstall-objects): uninstall-%:
@$(if $(findstring $*,$(NEWLIST)),, \
@$(if $(call older,$*), \
echo -e "$(FG_RED)+ $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \
echo -e "$(FG_GRE)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"; \
unlink "$(DESTDIR)/$*" || true))
2012-12-04 22:05:24 +01:00
$(uninstall-modules): uninstall-%:
@$(MAKE) -C $* uninstall MKDPREFIX=$(MKDPREFIX)$*/
2012-12-04 22:05:24 +01:00
$(check-objects): check-%:
@$(if $(call newer,$*), \
2013-02-15 01:10:51 +01:00
echo -e "$(FG_GRE)+ $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \
$(if $(call older,$*), \
2013-02-15 01:10:51 +01:00
echo -e "$(FG_RED)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \
echo -e "$(FG_BLU)= $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"))
2012-12-04 22:05:24 +01:00
$(check-modules): check-%:
@$(MAKE) -s -C $* check MKDPREFIX=$(MKDPREFIX)$*/
2012-12-05 00:13:28 +01:00
$(filter %.elc,$(objects)): %.elc: %.el
$(call compile,$^)