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