1 # Makefile for GNU Emacs Lisp Package Archive.
5 ARCHIVE_TMP=archive-tmp
8 .PHONY: archive-tmp changelogs process-archive archive-full org-fetch clean all do-it
12 CR_EXCEPTIONS=copyright_exceptions
13 .PHONY: check_copyrights
15 @echo "Compute exceptions >$(CR_EXCEPTIONS)~"
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 | \
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" \
28 done) | sort >$(CR_EXCEPTIONS)~
29 diff -u "$(CR_EXCEPTIONS)" "$(CR_EXCEPTIONS)~"
31 ## Deploy the package archive to archive/, with packages in
34 $(MAKE) $(MFLAGS) process-archive
38 mkdir -p $(ARCHIVE_TMP)
39 cp -a packages/. $(ARCHIVE_TMP)/packages
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 \
48 @cd $(ARCHIVE_TMP)/packages; \
50 if [ -f "$${pt}/.elpaignore" ]; then \
51 ignore="$${pt}/.elpaignore"; \
55 if [ -d $$pt ]; then \
56 echo "Creating tarball $${pt}.tar" && \
57 tar -cf $${pt}.tar $$pt --exclude-vcs -X "$$ignore"; \
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
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/
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; \
87 rm -rf archive $(ARCHIVE_TMP) $(SITE_DIR)
89 ########## Rules for in-place installation ####################################
90 pkgs := $(foreach pkg, $(wildcard packages/*), \
91 $(if $(shell [ -d "$(pkg)" ] && echo true), $(pkg)))
94 $(shell echo "$(1)" "$(2)" "$(2)" | tr ' ' '\n' | sort | uniq -u)
98 $(filter-out %-autoloads.el %-pkg.el, $(1))
102 $(1): $$(call FILTER-nonsrc, $$(wildcard $$(dir $(1))/*.el))
105 # Compute the set of autolods files and their dependencies.
106 autoloads := $(foreach pkg, $(pkgs), $(pkg)/$(notdir $(pkg))-autoloads.el)
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.
117 packages/aggressive-indent/aggressive-indent-autoloads.el: \
118 packages/names/names-autoloads.el
120 $(foreach al, $(autoloads), $(eval $(call RULE-srcdeps, $(al))))
122 @echo 'Generating autoloads for $@'
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))\" \
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)
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)))
143 # '(dolist (al (quote ($(patsubst %, "%", $(autoloads))))) (load (expand-file-name al) nil t))'
145 @echo 'Byte compiling $<'
147 --eval "(setq package-directory-list nil package-user-dir \"$(abspath packages)\")" \
148 -f package-initialize \
149 -L $(dir $@) -f batch-byte-compile $<
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 $@
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))))
164 @echo 'Generating description file $@'
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 "$@")'
172 all-in-place: $(extra_elcs) $(autoloads) $(pkg_descs)
173 # Do them in a sub-make, so that autoloads are done first.
177 ############### Rules to prepare the externals ################################
181 $(EMACS) -l admin/archive-contents.el \
182 -f archive-add/remove/update-externals