melpa/Makefile
Donald Curtis a5859f2e7a add rules to evaluate packages if older emacs
cl-lib from ELPA is needed with versions of emacs < 24.3. this modification to the Makefile will test if a call to `package-initialize` may be needed.
2013-04-21 08:31:58 -05:00

78 lines
1.7 KiB
Makefile

SHELL := /bin/bash
PKGDIR := ./packages
RCPDIR := ./recipes
HTMLDIR := ./html
WORKDIR := ./working
EMACS := emacs
EVAL := $(EMACS)
## Check for needing to initialize CL-LIB from ELPA
NEED_CL-LIB := $(shell $(EMACS) --no-site-file --batch --eval '(prin1 (version< emacs-version "24.3"))')
ifeq ($(NEED_CL-LIB), t)
EVAL := $(EVAL) --eval "(package-initialize)"
endif
EVAL := $(EVAL) --no-site-file --batch -l package-build.el --eval
all: build json index
## General rules
build:
@echo " • Building $$(ls -1 $(RCPDIR) | wc -l) recipes ..."
$(EVAL) "(package-build-all)"
html: index
index: archive.json recipes.json
@echo " • Building html index ..."
$(MAKE) -C $(HTMLDIR)
## Cleanup rules
clean-working:
@echo " • Removing package sources ..."
rm -rf $(WORKDIR)/*
clean-packages:
@echo " • Removing packages ..."
rm -rfv $(PKGDIR)/*
clean-json:
@echo " • Removing json files ..."
-rm -vf archive.json recipes.json
clean: clean-working clean-packages clean-json
## Json rules
archive.json: packages/archive-contents
@echo " • Building $@ ..."
$(EVAL) '(package-build-archive-alist-as-json "archive.json")'
recipes.json: $(RCPDIR)/.dirstamp
@echo " • Building $@ ..."
$(EVAL) '(package-build-recipe-alist-as-json "recipes.json")'
json: archive.json recipes.json
$(RCPDIR)/.dirstamp: .FORCE
@[[ ! -e $@ || "$$(find $(@D) -newer $@ -print -quit)" != "" ]] \
&& touch $@ || exit 0
## Recipe rules
$(RCPDIR)/%: .FORCE
@echo " • Building recipe $(@F) ..."
@echo "---$(TEST)"
-rm -vf $(PKGDIR)/$(@F)-*
$(EVAL) "(package-build-archive '$(@F))"
@echo " ✓ Wrote $$(ls -lsh $(PKGDIR)/$(@F)-*) "
@echo
.PHONY: clean build index html json
.FORCE: