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))
|
2012-12-05 09:21:35 +01:00
|
|
|
MODE=644
|
2012-12-04 22:05:24 +01:00
|
|
|
|
2013-04-14 23:58:59 +02:00
|
|
|
ifeq ($(shell if [ "`tput colors`" -gt 0 ]; then echo -n "y"; fi),y)
|
2012-12-14 00:25:34 +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
|
2013-04-14 23:58:59 +02:00
|
|
|
else
|
|
|
|
FG_BLU=
|
|
|
|
FG_YEL=
|
|
|
|
FG_GRE=
|
|
|
|
FG_RED=
|
|
|
|
CLR_RE=
|
|
|
|
endif
|
2012-12-04 22:05:24 +01:00
|
|
|
|
|
|
|
compile = $(EMACS) -Q -batch -eval "(byte-compile-file \"$(1)\")"
|
|
|
|
define newer =
|
|
|
|
$(shell if [ "$(1)" -nt "$(DESTDIR)/$(1)" ]; then echo "newer"; fi)
|
|
|
|
endef
|
2012-12-14 00:25:34 +01:00
|
|
|
define older =
|
|
|
|
$(shell if [ "$(1)" -ot "$(DESTDIR)/$(1)" ]; then echo "older"; fi)
|
|
|
|
endef
|
2012-12-04 22:05:24 +01:00
|
|
|
|
2013-02-15 00:47:01 +01:00
|
|
|
check-objects=$(addprefix check-,$(objects))
|
2012-12-04 22:05:24 +01:00
|
|
|
install-objects=$(addprefix install-,$(objects))
|
2013-02-15 00:47:01 +01:00
|
|
|
reverse-objects=$(addprefix reverse-,$(objects))
|
2013-04-14 01:05:42 +02:00
|
|
|
cleanup-objects=$(addprefix cleanup-,$(objects))
|
2013-04-14 23:58:45 +02:00
|
|
|
uninstall-objects=$(addprefix uninstall-,$(objects))
|
2012-12-04 22:05:24 +01:00
|
|
|
|
2013-02-15 00:47:01 +01:00
|
|
|
check-modules=$(addprefix check-,$(modules))
|
2012-12-04 22:05:24 +01:00
|
|
|
install-modules=$(addprefix install-,$(modules))
|
2013-02-15 00:47:01 +01:00
|
|
|
reverse-modules=$(addprefix reverse-,$(modules))
|
2013-04-14 01:05:42 +02:00
|
|
|
cleanup-modules=$(addprefix cleanup-,$(modules))
|
2013-04-14 23:58:45 +02:00
|
|
|
uninstall-modules=$(addprefix uninstall-,$(modules))
|
2012-12-04 22:05:24 +01:00
|
|
|
|
2013-04-14 01:05:42 +02:00
|
|
|
.PHONY: all install cleanup check cleanup $(modules) \
|
|
|
|
$(install-objects) $(cleanup-objects) $(check-objects) \
|
|
|
|
$(install-modules) $(cleanup-modules) $(check-modules) \
|
2013-04-14 23:58:45 +02:00
|
|
|
$(reverse) $(reverse-objects) $(reverse-modules) \
|
|
|
|
$(uninstall-objects) $(uninstall-modules)
|
2012-12-04 22:05:24 +01:00
|
|
|
all: $(modules) $(objects)
|
2013-02-15 00:11:23 +01:00
|
|
|
|
|
|
|
ifeq ($(MAKEROOT),y)
|
2012-12-04 22:05:24 +01:00
|
|
|
check: $(check-modules) $(check-objects)
|
2013-04-14 01:05:42 +02:00
|
|
|
install: cleanup $(install-modules) $(install-objects) Makefile.old
|
2013-02-15 00:47:01 +01:00
|
|
|
reverse: $(reverse-modules) $(reverse-objects)
|
2013-04-14 23:58:45 +02:00
|
|
|
uninstall: $(uninstall-modules) $(uninstall-objects)
|
|
|
|
@rmdir --ignore-fail-on-non-empty $(DESTDIR) 2> /dev/null || true
|
2013-04-14 01:03:11 +02:00
|
|
|
ifeq ($(firstword $(MAKEFILE_LIST)),Makefile.old)
|
2013-04-14 01:05:42 +02:00
|
|
|
cleanup: $(cleanup-modules) $(cleanup-objects)
|
2013-04-14 01:03:11 +02:00
|
|
|
@rmdir --ignore-fail-on-non-empty $(DESTDIR) 2> /dev/null || true
|
|
|
|
else
|
2013-04-14 23:58:45 +02:00
|
|
|
cleanup: export NEWOBJS = $(objects)
|
|
|
|
cleanup: export NEWMODS = $(modules)
|
2013-04-14 01:05:42 +02:00
|
|
|
cleanup:
|
|
|
|
@$(MAKE) -s -f Makefile.old cleanup
|
2013-04-14 01:03:11 +02:00
|
|
|
|
|
|
|
Makefile.old: $(firstword $(MAKEFILE_LIST))
|
|
|
|
@cp "$^" "$@"
|
|
|
|
|
|
|
|
ifdef SUBDIR
|
|
|
|
DESTDIR:=$(DESTDIR)/$(SUBDIR)
|
|
|
|
endif
|
|
|
|
endif
|
2013-02-15 00:11:23 +01:00
|
|
|
else
|
|
|
|
check:
|
2013-02-15 00:31:34 +01:00
|
|
|
@$(MAKE) -s -C ../ check
|
2013-02-15 00:11:23 +01:00
|
|
|
install:
|
2013-02-15 00:31:34 +01:00
|
|
|
@$(MAKE) -s -C ../ install
|
2013-02-15 00:47:01 +01:00
|
|
|
reverse:
|
|
|
|
@$(MAKE) -s -C ../ reverse
|
2013-04-14 01:05:42 +02:00
|
|
|
cleanup:
|
|
|
|
@$(MAKE) -s -C ../ cleanup
|
2013-04-14 23:58:45 +02:00
|
|
|
uninstall:
|
|
|
|
@$(MAKE) -s -C ../ uninstall
|
2013-02-15 00:11:23 +01:00
|
|
|
endif
|
2012-12-04 22:05:24 +01:00
|
|
|
|
|
|
|
$(modules): %:
|
2013-02-15 01:05:06 +01:00
|
|
|
$(MAKE) -C $*
|
2012-12-04 22:05:24 +01:00
|
|
|
|
|
|
|
$(install-objects): install-%: %
|
2013-02-15 00:31:34 +01:00
|
|
|
@$(if $(call newer,$*), \
|
2013-02-15 01:10:51 +01:00
|
|
|
echo -e "$(FG_GRE)+ $(FG_YEL)$(MKDPREFIX)$* $(CLR_RE)to $(DESTDIR) as $(MODE)"; \
|
2013-02-15 00:31:34 +01:00
|
|
|
install -pDm $(MODE) "$*" "$(DESTDIR)/$*", \
|
2013-03-31 01:52:19 +01:00
|
|
|
$(if $(call older,$*) ,\
|
|
|
|
echo -e "$(FG_RED)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"))
|
2012-12-04 22:05:24 +01:00
|
|
|
|
|
|
|
$(install-modules): install-%:
|
2013-02-15 01:05:06 +01:00
|
|
|
@$(MAKE) -s -C $* install MKDPREFIX=$(MKDPREFIX)$*/
|
2012-12-04 22:05:24 +01:00
|
|
|
|
2013-02-15 00:47:01 +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)"; \
|
2013-02-15 00:47:01 +01:00
|
|
|
cp -a "$(DESTDIR)/$*" "$*", \
|
2013-02-15 01:10:51 +01:00
|
|
|
echo -e "$(FG_RED)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)")
|
2013-02-15 00:47:01 +01:00
|
|
|
|
|
|
|
$(reverse-modules): reverse-%:
|
2013-02-15 01:05:06 +01:00
|
|
|
@$(MAKE) -s -C $* reverse MKDPREFIX=$(MKDPREFIX)$*/
|
2013-02-15 00:47:01 +01:00
|
|
|
|
2013-04-14 01:05:42 +02:00
|
|
|
$(cleanup-objects): cleanup-%:
|
2013-04-14 23:58:45 +02:00
|
|
|
@$(if $(findstring $*,$(NEWOBJS)),, \
|
2013-04-14 01:03:11 +02:00
|
|
|
@$(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
|
|
|
|
2013-04-14 01:05:42 +02:00
|
|
|
$(cleanup-modules): cleanup-%:
|
2013-04-14 23:58:45 +02:00
|
|
|
@$(if $(findstring $*,$(NEWMODS)), \
|
|
|
|
@$(MAKE) -C $* cleanup MKDPREFIX=$(MKDPREFIX)$*/, \
|
|
|
|
@$(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)", \
|
2012-12-14 00:25:34 +01:00
|
|
|
$(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-%:
|
2013-02-15 01:05:06 +01:00
|
|
|
@$(MAKE) -s -C $* check MKDPREFIX=$(MKDPREFIX)$*/
|
2012-12-05 00:13:28 +01:00
|
|
|
|
2013-04-14 23:58:45 +02:00
|
|
|
$(uninstall-objects): uninstall-%:
|
|
|
|
@$(if $(call older,$*), \
|
|
|
|
echo -e "$(FG_RED)+ $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \
|
|
|
|
echo -e "$(FG_GRE)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"; \
|
|
|
|
unlink "$(DESTDIR)/$*" || true)
|
|
|
|
|
|
|
|
$(uninstall-modules): uninstall-%:
|
|
|
|
@$(MAKE) -s -C $* uninstall MKDPREFIX=$(MKDPREFIX)$*/
|
|
|
|
|
2012-12-05 00:13:28 +01:00
|
|
|
$(filter %.elc,$(objects)): %.elc: %.el
|
|
|
|
$(call compile,$^)
|