2012-07-19 13:37:06 +00:00
|
|
|
SHELL := /bin/bash
|
|
|
|
PKGDIR := ./packages
|
2012-07-21 21:58:46 +00:00
|
|
|
RCPDIR := ./recipes
|
2012-07-19 13:37:06 +00:00
|
|
|
HTMLDIR := ./html
|
|
|
|
WORKDIR := ./working
|
2013-09-15 00:15:43 +00:00
|
|
|
WEBROOT := $$HOME/www
|
2014-07-11 19:06:49 +00:00
|
|
|
EMACS_COMMAND ?= emacs
|
2013-11-21 09:02:54 +00:00
|
|
|
SLEEP ?= 0
|
2014-02-12 06:55:20 +00:00
|
|
|
SANDBOX := ./sandbox
|
2014-01-26 05:04:00 +00:00
|
|
|
ifdef STABLE
|
|
|
|
PKGDIR := ./packages-stable
|
|
|
|
endif
|
|
|
|
STABLE ?= nil
|
|
|
|
|
2014-07-11 19:06:49 +00:00
|
|
|
EVAL := $(EMACS_COMMAND)
|
2013-04-21 13:31:58 +00:00
|
|
|
|
|
|
|
## Check for needing to initialize CL-LIB from ELPA
|
2014-07-11 19:06:49 +00:00
|
|
|
NEED_CL-LIB := $(shell $(EMACS_COMMAND) --no-site-file --batch --eval '(prin1 (version< emacs-version "24.3"))')
|
2013-04-21 13:31:58 +00:00
|
|
|
ifeq ($(NEED_CL-LIB), t)
|
2014-07-11 19:06:49 +00:00
|
|
|
EMACS_COMMAND := $(EMACS_COMMAND) --eval "(package-initialize)"
|
2013-04-21 13:31:58 +00:00
|
|
|
endif
|
|
|
|
|
2014-07-11 19:06:49 +00:00
|
|
|
EVAL := $(EMACS_COMMAND) --no-site-file --batch -l package-build.el --eval
|
2012-07-21 21:58:46 +00:00
|
|
|
|
2013-12-01 18:57:38 +00:00
|
|
|
TIMEOUT := $(shell which timeout && echo "-k 60 600")
|
2012-07-19 13:37:06 +00:00
|
|
|
|
2013-09-15 00:15:43 +00:00
|
|
|
all: packages packages/archive-contents json index
|
2012-07-21 21:58:46 +00:00
|
|
|
|
|
|
|
## General rules
|
|
|
|
html: index
|
2013-08-24 10:06:45 +00:00
|
|
|
index: json
|
2012-07-21 21:58:46 +00:00
|
|
|
@echo " • Building html index ..."
|
2012-07-19 13:37:06 +00:00
|
|
|
$(MAKE) -C $(HTMLDIR)
|
|
|
|
|
|
|
|
|
2012-07-21 21:58:46 +00:00
|
|
|
## Cleanup rules
|
2012-07-19 13:37:06 +00:00
|
|
|
clean-working:
|
2012-07-21 21:58:46 +00:00
|
|
|
@echo " • Removing package sources ..."
|
2012-07-19 13:37:06 +00:00
|
|
|
rm -rf $(WORKDIR)/*
|
|
|
|
|
|
|
|
clean-packages:
|
2012-07-21 21:58:46 +00:00
|
|
|
@echo " • Removing packages ..."
|
2012-07-19 13:37:06 +00:00
|
|
|
rm -rfv $(PKGDIR)/*
|
|
|
|
|
2012-07-20 20:40:33 +00:00
|
|
|
clean-json:
|
2012-07-21 21:58:46 +00:00
|
|
|
@echo " • Removing json files ..."
|
2013-08-24 10:06:45 +00:00
|
|
|
-rm -vf html/archive.json html/recipes.json
|
2012-07-20 20:40:33 +00:00
|
|
|
|
2014-02-12 06:55:20 +00:00
|
|
|
clean-sandbox:
|
|
|
|
@echo " • Removing sandbox files ..."
|
|
|
|
if [ -d '$(SANDBOX)' ]; then \
|
|
|
|
rm -rfv '$(SANDBOX)/elpa'; \
|
|
|
|
rmdir '$(SANDBOX)'; \
|
|
|
|
fi
|
|
|
|
|
2013-09-15 00:15:43 +00:00
|
|
|
sync:
|
2014-01-26 05:04:00 +00:00
|
|
|
rsync -avz --delete $(PKGDIR)/ $(WEBROOT)/packages
|
|
|
|
rsync -avz --safe-links --delete $(HTMLDIR)/* $(WEBROOT)/
|
2013-09-15 00:15:43 +00:00
|
|
|
chmod -R go+rx $(WEBROOT)/packages/*
|
|
|
|
|
|
|
|
|
2014-02-12 06:55:20 +00:00
|
|
|
clean: clean-working clean-packages clean-json clean-sandbox
|
2012-07-20 20:40:33 +00:00
|
|
|
|
2013-09-15 00:15:43 +00:00
|
|
|
packages: $(RCPDIR)/*
|
|
|
|
|
2014-01-26 05:04:00 +00:00
|
|
|
packages/archive-contents: $(PKGDIR)/*.entry
|
2013-09-15 00:15:43 +00:00
|
|
|
@echo " • Updating $@ ..."
|
2014-02-12 06:55:20 +00:00
|
|
|
$(EVAL) '(package-build-dump-archive-contents)'
|
2013-09-15 00:15:43 +00:00
|
|
|
|
|
|
|
cleanup:
|
2014-01-26 05:04:00 +00:00
|
|
|
$(EVAL) '(let ((package-build-stable $(STABLE)) (package-build-archive-dir (expand-file-name "$(PKGDIR)/" pb/this-dir))) (package-build-cleanup))'
|
2012-07-20 20:40:33 +00:00
|
|
|
|
2012-07-21 21:58:46 +00:00
|
|
|
## Json rules
|
2014-01-26 05:04:00 +00:00
|
|
|
html/archive.json: $(PKGDIR)/archive-contents
|
2012-07-21 21:58:46 +00:00
|
|
|
@echo " • Building $@ ..."
|
2014-01-26 05:04:00 +00:00
|
|
|
$(EVAL) '(let ((package-build-stable $(STABLE)) (package-build-archive-dir (expand-file-name "$(PKGDIR)/" pb/this-dir))) (package-build-archive-alist-as-json "html/archive.json"))'
|
2012-07-20 20:40:33 +00:00
|
|
|
|
2013-08-24 10:06:45 +00:00
|
|
|
html/recipes.json: $(RCPDIR)/.dirstamp
|
2012-07-21 21:58:46 +00:00
|
|
|
@echo " • Building $@ ..."
|
2014-01-26 05:04:00 +00:00
|
|
|
$(EVAL) '(let ((package-build-stable $(STABLE)) (package-build-archive-dir (expand-file-name "$(PKGDIR)/" pb/this-dir))) (package-build-recipe-alist-as-json "html/recipes.json"))'
|
2012-07-20 20:40:33 +00:00
|
|
|
|
2013-08-24 10:06:45 +00:00
|
|
|
json: html/archive.json html/recipes.json
|
2012-07-19 13:37:06 +00:00
|
|
|
|
2012-07-21 21:58:46 +00:00
|
|
|
$(RCPDIR)/.dirstamp: .FORCE
|
|
|
|
@[[ ! -e $@ || "$$(find $(@D) -newer $@ -print -quit)" != "" ]] \
|
|
|
|
&& touch $@ || exit 0
|
|
|
|
|
|
|
|
|
|
|
|
## Recipe rules
|
|
|
|
$(RCPDIR)/%: .FORCE
|
|
|
|
@echo " • Building recipe $(@F) ..."
|
2013-04-21 13:31:58 +00:00
|
|
|
|
2014-01-26 05:04:00 +00:00
|
|
|
- $(TIMEOUT) $(EVAL) "(let ((package-build-stable $(STABLE)) (package-build-archive-dir (expand-file-name \"$(PKGDIR)\" pb/this-dir))) (package-build-archive '$(@F)))"
|
2012-07-21 21:58:46 +00:00
|
|
|
|
|
|
|
@echo " ✓ Wrote $$(ls -lsh $(PKGDIR)/$(@F)-*) "
|
2013-11-21 09:02:54 +00:00
|
|
|
@echo " Sleeping for $(SLEEP) ..."
|
|
|
|
sleep $(SLEEP)
|
2012-07-19 13:37:06 +00:00
|
|
|
@echo
|
2012-07-21 21:58:46 +00:00
|
|
|
|
|
|
|
|
2014-02-12 06:55:20 +00:00
|
|
|
## Sandbox
|
2014-04-20 12:36:17 +00:00
|
|
|
sandbox: packages/archive-contents
|
2014-02-12 06:55:20 +00:00
|
|
|
@echo " • Building sandbox ..."
|
|
|
|
mkdir -p $(SANDBOX)
|
2014-07-11 19:06:49 +00:00
|
|
|
$(EMACS_COMMAND) -Q \
|
2014-02-12 06:55:20 +00:00
|
|
|
--eval '(setq user-emacs-directory "$(SANDBOX)")' \
|
|
|
|
-l package \
|
2014-07-10 10:50:26 +00:00
|
|
|
--eval "(add-to-list 'package-archives '(\"gnu\" . \"http://elpa.gnu.org/packages/\") t)" \
|
2014-02-12 06:55:20 +00:00
|
|
|
--eval "(add-to-list 'package-archives '(\"melpa\" . \"http://melpa.milkbox.net/packages/\") t)" \
|
2014-04-20 06:45:32 +00:00
|
|
|
--eval "(add-to-list 'package-archives '(\"sandbox\" . \"$(shell pwd)/$(PKGDIR)/\") t)" \
|
2014-07-10 08:49:37 +00:00
|
|
|
--eval "(package-refresh-contents)"
|
2014-04-20 06:45:32 +00:00
|
|
|
--eval "(package-initialize)"
|
2014-02-12 06:55:20 +00:00
|
|
|
|
|
|
|
.PHONY: clean build index html json sandbox
|
2012-07-21 21:58:46 +00:00
|
|
|
.FORCE:
|