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