WHICH_EMACS:=$(shell which emacs >/dev/null 2>&1 || echo "fail")
ELC_FILES=
+EL_FILES=
+ORG_EL_FILES=
ifeq ($(strip $(WHICH_EMACS)),)
-ELC_FILES=$(patsubst %.el,%.elc,$(wildcard *.el)) $(patsubsts %.org,%.elc,$(wildcard *.el))
+ORG_EL_FILES=$(patsubst %.org,%.el,$(wildcard *.org))
+EL_FILES=$(sort $(wildcard *.el) $(ORG_EL_FILES))
+ELC_FILES=$(patsubst %.el,%.elc,$(EL_FILES))
endif
+LIB_PATH=-L . -L .. -L ../helm
+
all: $(ELC_FILES)
EMACS=emacs
-%.elc: %.el
- $(EMACS) -q -no-site-file -L . -L .. --no-site-file -batch -f batch-byte-compile $<;
+$(ELC_FILES): %.elc: %.el
+ $(EMACS) -batch -q -no-site-file $(LIB_PATH) --no-site-file --eval '(byte-recompile-directory "." 0)'
-%.el: %.org
+$(ORG_EL_FILES): %.el: %.org
$(EMACS) -batch -q -no-site-file --visit $< --funcall org-babel-tangle