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 \
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 | \
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" \
30 done) | sort >$(CR_EXCEPTIONS)~
31 diff -u "$(CR_EXCEPTIONS)" "$(CR_EXCEPTIONS)~"
33 ## Deploy the package archive to archive/, with packages in
36 $(MAKE) $(MFLAGS) process-archive
40 mkdir -p $(ARCHIVE_TMP)
41 cp -a packages/. $(ARCHIVE_TMP)/packages
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 \
50 @cd $(ARCHIVE_TMP)/packages; \
52 if [ -f "$${pt}/.elpaignore" ]; then \
53 ignore="$${pt}/.elpaignore"; \
57 if [ -d $$pt ]; then \
58 echo "Creating tarball $${pt}.tar" && \
59 tar -cf $${pt}.tar $$pt --exclude-vcs -X "$$ignore"; \
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
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/
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; \
89 rm -rf archive $(ARCHIVE_TMP) $(SITE_DIR)
91 ########## Rules for in-place installation ####################################
92 pkgs := $(foreach pkg, $(wildcard packages/*), \
93 $(if $(shell [ -d "$(pkg)" ] && echo true), $(pkg)))
96 $(shell echo "$(1)" "$(2)" "$(2)" | tr ' ' '\n' | sort | uniq -u)
100 $(filter-out %-autoloads.el %-pkg.el, $(1))
104 $(1): $$(call FILTER-nonsrc, $$(wildcard $$(dir $(1))/*.el))
107 # Compute the set of autolods files and their dependencies.
108 autoloads := $(foreach pkg, $(pkgs), $(pkg)/$(notdir $(pkg))-autoloads.el)
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.
120 # packages/aggressive-indent/aggressive-indent-autoloads.el: \
121 # packages/names/names-autoloads.el
123 $(foreach al, $(autoloads), $(eval $(call RULE-srcdeps, $(al))))
125 @echo 'Generating autoloads for $@'
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))\" \
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)
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)))
146 # '(dolist (al (quote ($(patsubst %, "%", $(autoloads))))) (load (expand-file-name al) nil t))'
148 @echo 'Byte compiling $<'
150 --eval "(setq package-directory-list nil package-user-dir \"$(abspath packages)\")" \
151 -f package-initialize \
152 -L $(dir $@) -f batch-byte-compile $<
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 $@
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))))
167 @echo 'Generating description file $@'
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 "$@")'
175 all-in-place: $(extra_elcs) $(autoloads) $(pkg_descs)
176 # Do them in a sub-make, so that autoloads are done first.
180 ############### Rules to prepare the externals ################################
184 $(EMACS) -l admin/archive-contents.el \
185 -f archive-add/remove/update-externals