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