]> code.delx.au - gnu-emacs-elpa/blob - GNUmakefile
1067e4c6f0d43c8ec481ea952a9f2a50c7c2fab2
[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 @(cd packages; \
17 export LANG=C; \
18 find . -name '*.el' -print0 | \
19 xargs -0 grep -L 'Free Software Foundation, Inc' | \
20 grep -v '\(\.dir-locals\|.-\(pkg\|autoloads\)\)\.el$$'; \
21 find . -name '*.el' -print | \
22 while read f; do \
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" \
27 "$$f"; \
28 done) | sort >$(CR_EXCEPTIONS)~
29 diff -u "$(CR_EXCEPTIONS)" "$(CR_EXCEPTIONS)~"
30
31 ## Deploy the package archive to archive/, with packages in
32 ## archive/packages/:
33 archive: archive-tmp
34 $(MAKE) $(MFLAGS) process-archive
35
36 archive-tmp: packages
37 -rm -r $(ARCHIVE_TMP)
38 mkdir -p $(ARCHIVE_TMP)
39 cp -a packages/. $(ARCHIVE_TMP)/packages
40
41 process-archive:
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 \
47 -f batch-make-archive
48 @cd $(ARCHIVE_TMP)/packages; \
49 for pt in *; do \
50 if [ -d $$pt ]; then \
51 echo "Creating tarball $${pt}.tar" && \
52 tar -cf $${pt}.tar $$pt --remove-files; \
53 fi; \
54 done
55 mkdir -p archive/packages
56 mv archive/packages archive/packages-old
57 mv $(ARCHIVE_TMP)/packages archive/packages
58 chmod -R a+rX archive/packages
59 rm -rf archive/packages-old
60 rm -rf $(ARCHIVE_TMP)
61
62 ## Deploy the package archive to archive/ including the Org daily:
63 archive-full: archive-tmp org-fetch
64 $(MAKE) $(MFLAGS) process-archive
65 #mkdir -p archive/admin
66 #cp admin/* archive/admin/
67
68 # FIXME: Turn it into an `external', which will require adding the notion of
69 # "snapshot" packages.
70 org-fetch: archive-tmp
71 cd $(ARCHIVE_TMP)/packages; \
72 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"}'`; \
73 wget -q http://orgmode.org/elpa/$${pkgname}.tar -O $${pkgname}.tar; \
74 if [ -f $${pkgname}.tar ]; then \
75 tar xf $${pkgname}.tar; \
76 rm -f $${pkgname}.tar; \
77 mv $${pkgname} org; \
78 fi
79
80 clean:
81 rm -rf archive $(ARCHIVE_TMP) $(SITE_DIR)
82
83 ########## Rules for in-place installation ####################################
84 pkgs := $(foreach pkg, $(wildcard packages/*), \
85 $(if $(shell [ -d "$(pkg)" ] && echo true), $(pkg)))
86
87 define SET-diff
88 $(shell echo "$(1)" "$(2)" "$(2)" | tr ' ' '\n' | sort | uniq -u)
89 endef
90
91 define FILTER-nonsrc
92 $(filter-out %-autoloads.el %-pkg.el, $(1))
93 endef
94
95 define RULE-srcdeps
96 $(1): $$(call FILTER-nonsrc, $$(wildcard $$(dir $(1))/*.el))
97 endef
98
99 # Compute the set of autolods files and their dependencies.
100 autoloads := $(foreach pkg, $(pkgs), $(pkg)/$(notdir $(pkg))-autoloads.el)
101
102 $(foreach al, $(autoloads), $(eval $(call RULE-srcdeps, $(al))))
103 %-autoloads.el:
104 @echo 'EMACS -f package-generate-autoloads $@'
105 @cd $(dir $@); \
106 $(EMACS) -l $(CURDIR)/admin/archive-contents.el \
107 --eval "(archive--refresh-pkg-file)" \
108 --eval "(require 'package)" \
109 --eval "(package-generate-autoloads '$$(basename $$(pwd)) \
110 \"$$(pwd)\")"
111
112 # Put into elcs the set of elc files we need to keep up-to-date.
113 # I.e. one for each .el file except for the -pkg.el, the -autoloads.el, and
114 # the .el files that are marked "no-byte-compile".
115 els := $(call FILTER-nonsrc, $(wildcard packages/*/*.el))
116 naive_elcs := $(patsubst %.el, %.elc, $(els))
117 current_elcs := $(wildcard packages/*/*.elc)
118
119 extra_els := $(call SET-diff, $(els), $(patsubst %.elc, %.el, $(current_elcs)))
120 nbc_els := $(foreach el, $(extra_els), \
121 $(if $(shell grep '^;.*no-byte-compile: t' "$(el)"), $(el)))
122 elcs := $(call SET-diff, $(naive_elcs), $(patsubst %.el, %.elc, $(nbc_els)))
123
124 # '(dolist (al (quote ($(patsubst %, "%", $(autoloads))))) (load (expand-file-name al) nil t))'
125 %.elc: %.el
126 @echo 'EMACS -f batch-byte-compile $<'
127 @$(EMACS) \
128 --eval "(setq package-directory-list '(\"$(abspath packages)\"))" \
129 --eval '(package-initialize)' \
130 -L $(dir $@) -f batch-byte-compile $<
131
132 .PHONY: elcs
133 elcs: $(elcs)
134
135 # Remove .elc files that don't have a corresponding .el file any more.
136 extra_elcs := $(call SET-diff, $(current_elcs), $(naive_elcs))
137 .PHONY: $(extra_elcs)
138 $(extra_elcs):; rm $@
139
140 # # Put into single_pkgs the set of -pkg.el files we need to keep up-to-date.
141 # # I.e. all the -pkg.el files for the single-file packages.
142 # single_pkgs:=$(foreach pkg, $(pkgs), \
143 # $(word $(words $(call FILTER-nonsrc, \
144 # $(wildcard $(pkg)/*.el))), \
145 # $(pkg)/$(notdir $(pkg))-pkg.el))
146 # #$(foreach al, $(single_pkgs), $(eval $(call RULE-srcdeps, $(al))))
147 # %-pkg.el: %.el
148 # @echo 'EMACS -f package-generate-description-file $@'
149 # @$(EMACS) \
150 # --eval '(require (quote package))' \
151 # --eval '(setq b (find-file-noselect "$<"))' \
152 # --eval '(setq d (with-current-buffer b (package-buffer-info)))' \
153 # --eval '(package-generate-description-file d "$(dir $@)")'
154
155 .PHONY: all-in-place
156 all-in-place: $(extra_elcs) $(autoloads) # $(single_pkgs)
157 # Do them in a sub-make, so that autoloads are done first.
158 $(MAKE) elcs
159
160
161 ############### Rules to prepare the externals ################################
162
163 .PHONY:
164 externals:
165 $(EMACS) -l admin/archive-contents.el \
166 -f archive-add/remove/update-externals