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