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