forked from melpa/melpa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
137 lines (105 loc) · 3.88 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
TOP := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
-include ./config.mk
SHELL := bash
EMACS_COMMAND ?= emacs
PKGDIR := packages
RCPDIR := recipes
HTMLDIR := html
WORKDIR := working
SLEEP ?= 0
SANDBOX := sandbox
STABLE ?= nil
ifneq ($(STABLE), nil)
PKGDIR := packages-stable
HTMLDIR := html-stable
endif
LISP_CONFIG ?= '(progn\
(setq package-build-working-dir "$(TOP)/$(WORKDIR)/")\
(setq package-build-archive-dir "$(TOP)/$(PKGDIR)/")\
(setq package-build-recipes-dir "$(TOP)/$(RCPDIR)/")\
(setq package-build-stable $(STABLE))\
(setq package-build-write-melpa-badge-images t)\
(setq package-build-timeout-secs (when (string= "linux" (symbol-name system-type)) 600)))'
LOAD_PATH ?= $(TOP)/package-build
EVAL := $(EMACS_COMMAND) --no-site-file --batch \
$(addprefix -L ,$(LOAD_PATH)) \
--eval $(LISP_CONFIG) \
--load package-build.el \
--eval
TIMEOUT := $(shell which timeout && echo "-k 60 600")
all: packages packages/archive-contents json index
## General rules
html: index
index: json
@echo " • Building html index ..."
$(MAKE) -C $(HTMLDIR)
## Cleanup rules
clean-working:
@echo " • Removing package sources ..."
@git clean -dffX $(WORKDIR)/.
clean-packages:
@echo " • Removing packages ..."
@git clean -dffX $(PKGDIR)/.
clean-json:
@echo " • Removing json files ..."
@-rm -vf $(HTMLDIR)/archive.json $(HTMLDIR)/recipes.json
clean-sandbox:
@echo " • Removing sandbox files ..."
@if [ -d '$(SANDBOX)' ]; then \
rm -rfv '$(SANDBOX)/elpa'; \
rmdir '$(SANDBOX)'; \
fi
pull-package-build:
git subtree pull --squash -P package-build package-build master
add-package-build-remote:
git remote add package-build [email protected]:melpa/package-build.git
clean: clean-working clean-packages clean-json clean-sandbox
packages: $(RCPDIR)/*
packages/archive-contents: .FORCE
@echo " • Updating $@ ..."
@$(EVAL) '(package-build-dump-archive-contents)'
cleanup:
@$(EVAL) '(package-build-cleanup)'
## Json rules
html/archive.json: $(PKGDIR)/archive-contents
@echo " • Building $@ ..."
@$(EVAL) '(package-build-archive-alist-as-json "html/archive.json")'
html/recipes.json: $(RCPDIR)/.dirstamp
@echo " • Building $@ ..."
@$(EVAL) '(package-build-recipe-alist-as-json "html/recipes.json")'
html-stable/archive.json: $(PKGDIR)/archive-contents
@echo " • Building $@ ..."
@$(EVAL) '(package-build-archive-alist-as-json "html-stable/archive.json")'
html-stable/recipes.json: $(RCPDIR)/.dirstamp
@echo " • Building $@ ..."
@$(EVAL) '(package-build-recipe-alist-as-json "html-stable/recipes.json")'
json: $(HTMLDIR)/archive.json $(HTMLDIR)/recipes.json
$(RCPDIR)/.dirstamp: .FORCE
@[[ ! -e $@ || "$$(find $(@D) -newer $@ -print -quit)" != "" ]] \
&& touch $@ || exit 0
## Recipe rules
$(RCPDIR)/%: .FORCE
@echo " • Building package $(@F) ..."
@exec 2>&1; exec &> >(tee $(PKGDIR)/$(@F).log); \
$(TIMEOUT) $(EVAL) "(package-build-archive \"$(@F)\")" \
&& echo " ✓ Success:" \
&& ls -lsh $(PKGDIR)/$(@F)-*
@test $(SLEEP) -gt 0 && echo " Sleeping $(SLEEP) seconds ..." && sleep $(SLEEP) || true
@echo
## Sandbox
sandbox: packages/archive-contents
@echo " • Building sandbox ..."
@mkdir -p $(SANDBOX)
@$(EMACS_COMMAND) -Q \
--eval '(setq user-emacs-directory (file-truename "$(SANDBOX)"))' \
-l package \
--eval "(add-to-list 'package-archives '(\"gnu\" . \"https://elpa.gnu.org/packages/\") t)" \
--eval "(add-to-list 'package-archives '(\"melpa\" . \"https://melpa.org/packages/\") t)" \
--eval "(add-to-list 'package-archives '(\"sandbox\" . \"$(TOP)/$(PKGDIR)/\") t)" \
--eval "(package-refresh-contents)" \
--eval "(package-initialize)" \
--eval '(setq sandbox-install-package "$(INSTALL)")' \
--eval "(unless (string= \"\" sandbox-install-package) (package-install (intern sandbox-install-package)))" \
--eval "(when (get-buffer \"*Compile-Log*\") (display-buffer \"*Compile-Log*\"))"
.PHONY: clean build index html json sandbox
.FORCE: