]> code.delx.au - gnu-emacs-elpa/blob - GNUmakefile
7f2061d12f3323302c16d1314ccfa7a31f4a7804
[gnu-emacs-elpa] / GNUmakefile
1 # Makefile for GNU Emacs Lisp Package Archive.
2
3 EMACS=emacs
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 ## Set up the source files for direct usage, by pointing
13 ## `package-directory-list' to the site/ directory.
14 site: packages
15 mkdir -p $(SITE_DIR)
16 $(EMACS) -batch -l $(CURDIR)/admin/archive-contents.el \
17 --eval "(batch-make-site-dir \"packages\" \"$(SITE_DIR)\")"
18
19 site/%: do-it
20 $(EMACS) -batch -l $(CURDIR)/admin/archive-contents.el \
21 --eval "(progn (setq debug-on-error t) (batch-make-site-package \"$@\"))"
22
23 ## Deploy the package archive to archive/, with packages in
24 ## archive/packages/:
25 archive: archive-tmp
26 $(MAKE) $(MFLAGS) process-archive
27
28 archive-tmp: packages changelogs
29 -rm -r $(ARCHIVE_TMP)
30 mkdir -p $(ARCHIVE_TMP)
31 cp -a packages/. $(ARCHIVE_TMP)/packages
32
33 # Refresh the ChangeLog files. This needs to be done in
34 # the source tree, because it needs the Bzr data!
35 changelogs:
36 cd packages; \
37 $(EMACS) -batch -l $(CURDIR)/admin/archive-contents.el \
38 -f batch-prepare-packages
39
40 process-archive:
41 # FIXME, we could probably speed this up significantly with
42 # rules like "%.tar: ../%/ChangeLog" so we only rebuild the packages
43 # that have indeed changed.
44 cd $(ARCHIVE_TMP)/packages; $(EMACS) -batch -l $(CURDIR)/admin/archive-contents.el -f batch-make-archive
45 @cd $(ARCHIVE_TMP)/packages; \
46 for pt in *; do \
47 if [ -d $$pt ]; then \
48 echo "Creating tarball $${pt}.tar" && \
49 tar -cf $${pt}.tar $$pt --remove-files; \
50 fi; \
51 done
52 mkdir -p archive/packages
53 mv archive/packages archive/packages-old
54 mv $(ARCHIVE_TMP)/packages archive/packages
55 chmod -R a+rX archive/packages
56 rm -rf archive/packages-old
57 rm -rf $(ARCHIVE_TMP)
58
59 ## Deploy the package archive to archive/ including the Org daily:
60 archive-full: archive-tmp org-fetch
61 $(MAKE) $(MFLAGS) process-archive
62 #mkdir -p archive/admin
63 #cp admin/* archive/admin/
64
65 org-fetch: archive-tmp
66 cd $(ARCHIVE_TMP)/packages; \
67 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"}'`; \
68 wget -q http://orgmode.org/elpa/$${pkgname}.tar -O $${pkgname}.tar; \
69 if [ -f $${pkgname}.tar ]; then \
70 tar xf $${pkgname}.tar; \
71 rm -f $${pkgname}.tar; \
72 mv $${pkgname} org; \
73 fi
74
75 clean:
76 rm -rf archive $(ARCHIVE_TMP) $(SITE_DIR)
77
78 ########## Rules for in-place installation ##########
79 pkgs := $(foreach pkg, $(wildcard packages/*), \
80 $(if $(shell [ -d "$(pkg)" ] && echo true), $(pkg)))
81
82 define SET-diff
83 $(shell echo "$(1)" "$(2)" "$(2)" | tr ' ' '\n' | sort | uniq -u)
84 endef
85
86 define FILTER-nonsrc
87 $(filter-out %-autoloads.el %-pkg.el, $(1))
88 endef
89
90 define RULE-srcdeps
91 $(1): $$(call FILTER-nonsrc, $$(wildcard $$(dir $(1))/*.el))
92 endef
93
94 # Compute the set of autolods files and their dependencies.
95 autoloads := $(foreach pkg, $(pkgs), $(pkg)/$(notdir $(pkg))-autoloads.el)
96
97 $(foreach al, $(autoloads), $(eval $(call RULE-srcdeps, $(al))))
98 %-autoloads.el:
99 @echo 'EMACS -f package-generate-autoloads $@'
100 @cd $(dir $@); \
101 $(EMACS) --batch \
102 -l $(CURDIR)/admin/archive-contents.el \
103 --eval "(archive--refresh-pkg-file)" \
104 --eval "(require 'package)" \
105 --eval "(package-generate-autoloads '$$(basename $$(pwd)) \
106 \"$$(pwd)\")"
107
108 # Put into elcs the set of elc files we need to keep up-to-date.
109 # I.e. one for each .el file except for the -pkg.el, the -autoloads.el, and
110 # the .el files that are marked "no-byte-compile".
111 els := $(call FILTER-nonsrc, $(wildcard packages/*/*.el))
112 naive_elcs := $(patsubst %.el, %.elc, $(els))
113 current_elcs := $(wildcard packages/*/*.elc)
114
115 extra_els := $(call SET-diff, $(els), $(patsubst %.elc, %.el, $(current_elcs)))
116 nbc_els := $(foreach el, $(extra_els), \
117 $(if $(shell grep '^;.*no-byte-compile: t' "$(el)"), $(el)))
118 elcs := $(call SET-diff, $(naive_elcs), $(patsubst %.el, %.elc, $(nbc_els)))
119
120 # '(dolist (al (quote ($(patsubst %, "%", $(autoloads))))) (load (expand-file-name al) nil t))'
121 %.elc: %.el
122 @echo 'EMACS -f batch-byte-compile $<'
123 @$(EMACS) --batch \
124 --eval "(setq package-directory-list '(\"$(abspath packages)\"))" \
125 --eval '(package-initialize)' \
126 -L $(dir $@) -f batch-byte-compile $<
127
128 .PHONY: elcs
129 elcs: $(elcs)
130
131 # Remove .elc files that don't have a corresponding .el file any more.
132 extra_elcs := $(call SET-diff, $(current_elcs), $(naive_elcs))
133 .PHONY: $(extra_elcs)
134 $(extra_elcs):; rm $@
135
136 # # Put into single_pkgs the set of -pkg.el files we need to keep up-to-date.
137 # # I.e. all the -pkg.el files for the single-file packages.
138 # single_pkgs:=$(foreach pkg, $(pkgs), \
139 # $(word $(words $(call FILTER-nonsrc, \
140 # $(wildcard $(pkg)/*.el))), \
141 # $(pkg)/$(notdir $(pkg))-pkg.el))
142 # #$(foreach al, $(single_pkgs), $(eval $(call RULE-srcdeps, $(al))))
143 # %-pkg.el: %.el
144 # @echo 'EMACS -f package-generate-description-file $@'
145 # @$(EMACS) --batch \
146 # --eval '(require (quote package))' \
147 # --eval '(setq b (find-file-noselect "$<"))' \
148 # --eval '(setq d (with-current-buffer b (package-buffer-info)))' \
149 # --eval '(package-generate-description-file d "$(dir $@)")'
150
151 .PHONY: all-in-place
152 all-in-place: $(extra_elcs) $(autoloads) # $(single_pkgs)
153 # Do them in a sub-make, so that autoloads are done first.
154 $(MAKE) elcs