]> code.delx.au - gnu-emacs-elpa/blob - GNUmakefile
Merge commit 'aaeb619f1ff57e666925bcef22bb3195c22d589e'
[gnu-emacs-elpa] / GNUmakefile
1 # Makefile for GNU Emacs Lisp Package Archive.
2 #
3
4 EMACS=emacs --batch
5
6 ARCHIVE_TMP=archive-tmp
7 SITE_DIR=site
8
9 .PHONY: archive-tmp changelogs process-archive archive-full org-fetch clean all do-it
10
11 all: all-in-place
12
13 CR_EXCEPTIONS=copyright_exceptions
14 .PHONY: check_copyrights
15 check_copyrights:
16 @echo "Compute exceptions >$(CR_EXCEPTIONS)~"
17 @export LC_ALL=C; \
18 (cd packages && \
19 find . -name '.git' -prune -o \
20 -name 'test' -prune -o \
21 -name '*.el' -print0 | \
22 xargs -0 grep -L 'Free Software Foundation, Inc' | \
23 grep -v '\(\.dir-locals\|.-\(pkg\|autoloads\)\)\.el$$'; \
24 find . -name '.git' -prune -o -name '*.el' -type f -print | \
25 while read f; do \
26 fquoted="$$(echo $$f|tr '|' '_')"; \
27 sed -n -e '/[Cc]opyright.*, *[1-9][-0-9]*,\?$$/N' \
28 -e '/Free Software Foundation/d' \
29 -e "s|^\\(.*[Cc]opyright\\)|$$fquoted:\\1|p" \
30 "$$f"; \
31 done) | sort >$(CR_EXCEPTIONS)~
32 diff -u "$(CR_EXCEPTIONS)" "$(CR_EXCEPTIONS)~"
33
34 ## Deploy the package archive to archive/, with packages in
35 ## archive/packages/:
36 archive: archive-tmp
37 $(MAKE) $(MFLAGS) process-archive
38
39 archive-tmp: packages
40 -rm -r $(ARCHIVE_TMP)
41 mkdir -p $(ARCHIVE_TMP)
42 cp -a packages/. $(ARCHIVE_TMP)/packages
43
44 # Use && after the cd commands, not ;, to ensure the build fails
45 # immediately if the directory $(ARCHIVE_TMP)/packages does not exist.
46 # For process-archive this is crucial; otherwise batch-make-archive in
47 # archive-contents.el will interpret directories in the current
48 # directory as unreleased packages, and recursively delete them,
49 # including .git. Prior to using &&, running "make process-archive"
50 # could silently delete all local git history!
51 process-archive:
52 # FIXME, we could probably speed this up significantly with
53 # rules like "%.tar: ../%/ChangeLog" so we only rebuild the packages
54 # that have indeed changed.
55 cd $(ARCHIVE_TMP)/packages && \
56 $(EMACS) -l $(CURDIR)/admin/archive-contents.el \
57 -f batch-make-archive
58 @cd $(ARCHIVE_TMP)/packages && \
59 for pt in *; do \
60 if [ -f "$${pt}/.elpaignore" ]; then \
61 ignore="$${pt}/.elpaignore"; \
62 else \
63 ignore="/dev/null"; \
64 fi; \
65 if [ -d $$pt ]; then \
66 echo "Creating tarball $${pt}.tar" && \
67 tar -chf $${pt}.tar $$pt --exclude-vcs -X "$$ignore"; \
68 rm -rf $${pt}; \
69 fi; \
70 done
71 mkdir -p archive/packages
72 mv archive/packages archive/packages-old
73 mv $(ARCHIVE_TMP)/packages archive/packages
74 chmod -R a+rX archive/packages
75 rm -rf archive/packages-old
76 rm -rf $(ARCHIVE_TMP)
77
78 ## Deploy the package archive to archive/ including the Org daily:
79 archive-full: archive-tmp org-fetch
80 $(MAKE) $(MFLAGS) process-archive
81 #mkdir -p archive/admin
82 #cp admin/* archive/admin/
83
84 # FIXME: Turn it into an `external', which will require adding the notion of
85 # "snapshot" packages.
86 org-fetch: archive-tmp
87 cd $(ARCHIVE_TMP)/packages && \
88 pkgname=`curl -s http://orgmode.org/elpa/|perl -ne 'push @f, $$1 if m/(org-\d{8})\.tar/; END { @f = sort @f; print "$$f[-1]\n"}'`; \
89 wget -q http://orgmode.org/elpa/$${pkgname}.tar -O $${pkgname}.tar; \
90 if [ -f $${pkgname}.tar ]; then \
91 tar xf $${pkgname}.tar; \
92 rm -f $${pkgname}.tar; \
93 mv $${pkgname} org; \
94 fi
95
96 clean:
97 rm -rf archive $(ARCHIVE_TMP) $(SITE_DIR)
98
99 ########## Rules for in-place installation ####################################
100 pkgs := $(foreach pkg, $(wildcard packages/*), \
101 $(if $(shell [ -d "$(pkg)" ] && echo true), $(pkg)))
102
103 define SET-diff
104 $(shell echo "$(1)" "$(2)" "$(2)" | tr ' ' '\n' | sort | uniq -u)
105 endef
106
107 define FILTER-nonsrc
108 $(filter-out %-autoloads.el %-pkg.el, $(1))
109 endef
110
111 define RULE-srcdeps
112 $(1): $$(call FILTER-nonsrc, $$(wildcard $$(dir $(1))/*.el))
113 endef
114
115 # Compute the set of autolods files and their dependencies.
116 autoloads := $(foreach pkg, $(pkgs), $(pkg)/$(notdir $(pkg))-autoloads.el)
117
118 # FIXME: In 99% of the cases, autoloads can be generated in any order.
119 # But the `names' package is an exception because it sets up an advice that
120 # changes the way autload.el operates, and that advice is needed when creating
121 # the autoloads file of packages that use `names'.
122 # The right solution is to check the Package-Requires and create the autoloads
123 # files in topological order, but for now we can just do it the ad-hoc way and
124 # add hand-made dependencies between autoloads files, and explicitly
125 # load the names-autoloads file when building autoloads files. An example entry
126 # is commented below, this is what should be done if a package depends on Names.
127
128 # packages/aggressive-indent/aggressive-indent-autoloads.el: \
129 # packages/names/names-autoloads.el
130
131 $(foreach al, $(autoloads), $(eval $(call RULE-srcdeps, $(al))))
132 %-autoloads.el:
133 @echo 'Generating autoloads for $@'
134 @cd $(dir $@) && \
135 $(EMACS) -l $(CURDIR)/admin/archive-contents.el \
136 --eval "(archive--refresh-pkg-file)" \
137 --eval "(require 'package)" \
138 --eval "(load (expand-file-name \"../names/names-autoloads.el\") t t)" \
139 --eval "(package-generate-autoloads \"$$(basename $$(pwd))\" \
140 \"$$(pwd)\")"
141
142 # Put into elcs the set of elc files we need to keep up-to-date.
143 # I.e. one for each .el file except for the -pkg.el, the -autoloads.el, and
144 # the .el files that are marked "no-byte-compile".
145 els := $(call FILTER-nonsrc, $(wildcard packages/*/*.el))
146 naive_elcs := $(patsubst %.el, %.elc, $(els))
147 current_elcs := $(wildcard packages/*/*.elc)
148
149 extra_els := $(call SET-diff, $(els), $(patsubst %.elc, %.el, $(current_elcs)))
150 nbc_els := $(foreach el, $(extra_els), \
151 $(if $(shell grep '^;.*no-byte-compile: t' "$(el)"), $(el)))
152 elcs := $(call SET-diff, $(naive_elcs), $(patsubst %.el, %.elc, $(nbc_els)))
153
154 # '(dolist (al (quote ($(patsubst %, "%", $(autoloads))))) (load (expand-file-name al) nil t))'
155 %.elc: %.el
156 @echo 'Byte compiling $<'
157 @$(EMACS) \
158 --eval "(setq package-directory-list nil package-user-dir \"$(abspath packages)\")" \
159 -f package-initialize \
160 -L $(dir $@) -f batch-byte-compile $<
161
162 .PHONY: elcs
163 elcs: $(elcs)
164
165 # Remove .elc files that don't have a corresponding .el file any more.
166 extra_elcs := $(call SET-diff, $(current_elcs), $(naive_elcs))
167 .PHONY: $(extra_elcs)
168 $(extra_elcs):; rm $@
169
170 # # Put into single_pkgs the set of -pkg.el files we need to keep up-to-date.
171 # # I.e. all the -pkg.el files for the single-file packages.
172 pkg_descs:=$(foreach pkg, $(pkgs), $(pkg)/$(notdir $(pkg))-pkg.el)
173 #$(foreach al, $(single_pkgs), $(eval $(call RULE-srcdeps, $(al))))
174 %-pkg.el: %.el
175 @echo 'Generating description file $@'
176 @$(EMACS) \
177 --eval '(require (quote package))' \
178 --eval '(setq b (find-file-noselect "$<"))' \
179 --eval '(setq d (with-current-buffer b (package-buffer-info)))' \
180 --eval '(package-generate-description-file d "$@")'
181
182 .PHONY: all-in-place
183 all-in-place: $(extra_elcs) $(autoloads) $(pkg_descs)
184 # Do them in a sub-make, so that autoloads are done first.
185 $(MAKE) elcs
186
187
188 ############### Rules to prepare the externals ################################
189
190 .PHONY:
191 externals:
192 $(EMACS) -l admin/archive-contents.el \
193 -f archive-add/remove/update-externals
194
195
196
197
198 ################### Testing ###############
199
200 PACKAGE_DIRS = $(shell find packages -maxdepth 1 -type d)
201 PACKAGES=$(subst /,,$(subst packages,,$(PACKAGE_DIRS)))
202
203 TOP =$(shell pwd)
204
205 define test_template
206 $(1)-test:
207 cd packages/$(1);\
208 $(EMACS) -l $(TOP)/admin/ert-support.el \
209 --eval "(ert-support-test-package \"$(TOP)\" '$(1))" \
210
211 $(1)-test-log:
212 $(MAKE) $(1)-test > packages/$(1)/$(1).log 2>&1 || { stat=ERROR; }
213 endef
214
215 $(foreach package,$(PACKAGES),$(eval $(call test_template,$(package))))
216
217 PACKAGES_TESTS=$(addsuffix -test-log,$(PACKAGES))
218 PACKAGES_LOG=$(foreach package,$(PACKAGES),packages/$(package)/$(package).log)
219
220 check: $(PACKAGES_TESTS)
221 $(EMACS) -l ert -f ert-summarize-tests-batch-and-exit $(PACKAGES_LOG)