]> code.delx.au - gnu-emacs-elpa/blob - GNUmakefile
Merge commit '00920450d83ffe7a02bbe98997e266726819efc2'
[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 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'.
114 # The right solution is to check the Package-Requires and create the autoloads
115 # files in topological order, but for now we can just do it the ad-hoc way and
116 # add hand-made dependencies between autoloads files, and explicitly
117 # load the names-autoloads file when building autoloads files. An example entry
118 # is commented below, this is what should be done if a package depends on Names.
119
120 # packages/aggressive-indent/aggressive-indent-autoloads.el: \
121 # packages/names/names-autoloads.el
122
123 $(foreach al, $(autoloads), $(eval $(call RULE-srcdeps, $(al))))
124 %-autoloads.el:
125 @echo 'Generating autoloads for $@'
126 @cd $(dir $@); \
127 $(EMACS) -l $(CURDIR)/admin/archive-contents.el \
128 --eval "(archive--refresh-pkg-file)" \
129 --eval "(require 'package)" \
130 --eval "(load (expand-file-name \"../names/names-autoloads.el\") t t)" \
131 --eval "(package-generate-autoloads \"$$(basename $$(pwd))\" \
132 \"$$(pwd)\")"
133
134 # Put into elcs the set of elc files we need to keep up-to-date.
135 # I.e. one for each .el file except for the -pkg.el, the -autoloads.el, and
136 # the .el files that are marked "no-byte-compile".
137 els := $(call FILTER-nonsrc, $(wildcard packages/*/*.el))
138 naive_elcs := $(patsubst %.el, %.elc, $(els))
139 current_elcs := $(wildcard packages/*/*.elc)
140
141 extra_els := $(call SET-diff, $(els), $(patsubst %.elc, %.el, $(current_elcs)))
142 nbc_els := $(foreach el, $(extra_els), \
143 $(if $(shell grep '^;.*no-byte-compile: t' "$(el)"), $(el)))
144 elcs := $(call SET-diff, $(naive_elcs), $(patsubst %.el, %.elc, $(nbc_els)))
145
146 # '(dolist (al (quote ($(patsubst %, "%", $(autoloads))))) (load (expand-file-name al) nil t))'
147 %.elc: %.el
148 @echo 'Byte compiling $<'
149 @$(EMACS) \
150 --eval "(setq package-directory-list nil package-user-dir \"$(abspath packages)\")" \
151 -f package-initialize \
152 -L $(dir $@) -f batch-byte-compile $<
153
154 .PHONY: elcs
155 elcs: $(elcs)
156
157 # Remove .elc files that don't have a corresponding .el file any more.
158 extra_elcs := $(call SET-diff, $(current_elcs), $(naive_elcs))
159 .PHONY: $(extra_elcs)
160 $(extra_elcs):; rm $@
161
162 # # Put into single_pkgs the set of -pkg.el files we need to keep up-to-date.
163 # # I.e. all the -pkg.el files for the single-file packages.
164 pkg_descs:=$(foreach pkg, $(pkgs), $(pkg)/$(notdir $(pkg))-pkg.el)
165 #$(foreach al, $(single_pkgs), $(eval $(call RULE-srcdeps, $(al))))
166 %-pkg.el: %.el
167 @echo 'Generating description file $@'
168 @$(EMACS) \
169 --eval '(require (quote package))' \
170 --eval '(setq b (find-file-noselect "$<"))' \
171 --eval '(setq d (with-current-buffer b (package-buffer-info)))' \
172 --eval '(package-generate-description-file d "$@")'
173
174 .PHONY: all-in-place
175 all-in-place: $(extra_elcs) $(autoloads) $(pkg_descs)
176 # Do them in a sub-make, so that autoloads are done first.
177 $(MAKE) elcs
178
179
180 ############### Rules to prepare the externals ################################
181
182 .PHONY:
183 externals:
184 $(EMACS) -l admin/archive-contents.el \
185 -f archive-add/remove/update-externals