summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2016-11-10 01:48:47 +0100
committerJonas Bernoulli <jonas@bernoul.li>2016-11-10 01:48:47 +0100
commit7b6ac3acf02fcfe118685011d46bb8f6b5cc493c (patch)
tree220d4c1f8ea608f710e5d438ad69dbae4809ca3f /Makefile
parent650e0ad46dd4f40251e162d8537cdccddfe274eb (diff)
base the Makefile on the same template used for other packages
Beside the obvious differences (the package specific values for (`PKG', `DEPS', `DOMAIN' and `MANUAL_HTML_ARGS) this only diverges from the Makefiles of other packages that use the same template in that an additional target `authors' is available and in that `EFLAGS' is non-empty. Compared to the old Makefile the most significant breaking change is that there no longer exists a `bump-versions' target. To bump the versions one still only has to edit one file, but that's now the library, not the Makefile. Furthermore the autoloads file is now being created automatically, and the manual can be exported to more formats and the results can easily be published on the webpage.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile188
1 files changed, 119 insertions, 69 deletions
diff --git a/Makefile b/Makefile
index d26cdc0..42960f5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,59 +1,119 @@
-ELS = with-editor.el
+-include config.mk
-DEPS = dash
+PKG = with-editor
-TEXIPAGES = with-editor.texi
-INFOPAGES = with-editor.info
+ELS = $(PKG).el
+ELCS = $(ELS:.el=.elc)
+
+DEPS = dash
-ELCS = $(ELS:.el=.elc)
-DFLAGS = $(addprefix -L ../,$(DEPS))
-EFLAGS ?= $(DFLAGS)
EMACS ?= emacs
-BATCH = $(EMACS) -batch -Q -L . $(EFLAGS)
+EFLAGS ?=
+EFLAGS += --eval '(setq with-editor-emacsclient-executable nil)'
+DFLAGS ?= $(addprefix -L ../,$(DEPS))
+OFLAGS ?= -L ../dash -L ../org/lisp -L ../ox-texinfo+
-MAKEINFO ?= makeinfo
-INSTALL_INFO ?= $(shell command -v ginstall-info || printf install-info)
+INSTALL_INFO ?= $(shell command -v ginstall-info || printf install-info)
+MAKEINFO ?= makeinfo
+MANUAL_HTML_ARGS ?= --css-ref /assets/page.css
-WITH_EDITOR_VERSION = 2.5.7
-ASYNC_VERSION = 1.9
-DASH_VERSION = 2.13.0
+VERSION := $(shell test -e .git && \
+ git tag | cut -c2- | sort --version-sort | tail -1)
-.PHONY: help clean AUTHORS.md
+all: lisp info
+doc: info html html-dir pdf
help:
- $(info make all - compile elisp and manual)
- $(info make lisp - compile elisp)
- $(info make info - generate info manual)
- $(info make clean - remove generated files)
- $(info )
- $(info Release Managment)
- $(info =================)
- $(info )
- $(info make authors - generate AUTHORS.md)
- $(info make bump-versions - bump versions for release)
+ $(info make all - generate lisp and manual)
+ $(info make doc - generate most manual formats)
+ $(info make lisp - generate byte-code and autoloads)
+ $(info make texi - generate texi manual)
+ $(info make info - generate info manual)
+ $(info make html - generate html manual file)
+ $(info make html-dir - generate html manual directory)
+ $(info make pdf - generate pdf manual)
+ $(info make authors - generate AUTHORS.md)
+ $(info make preview - preview html manual)
+ $(info make publish - publish html manual)
+ $(info make clean - remove most generated files)
+ $(info make clean-texi - remove (tracked) texi manual)
+ $(info make clean-all - remove all generated files)
@printf "\n"
-all: lisp info
+lisp: $(ELCS) loaddefs
+
+loaddefs: $(PKG)-autoloads.el
-lisp: $(ELCS)
%.elc: %.el
- @printf "Compiling %s\n" $<
- @$(BATCH)\
- --eval '(setq with-editor-emacsclient-executable nil)'\
- -f batch-byte-compile $<
+ @printf "Compiling $<\n"
+ @$(EMACS) -Q --batch $(EFLAGS) -L . $(DFLAGS) -f batch-byte-compile $<
-texi: $(TEXIPAGES)
+texi: $(PKG).texi
+info: $(PKG).info dir
+html: $(PKG).html
+pdf: $(PKG).pdf
+
+%.texi: %.org
+ @printf "Generating $@\n"
+ @$(EMACS) -Q --batch $(OFLAGS) \
+ -l ox-texinfo+.el $< -f org-texinfo+export-to-texinfo
+ @printf "\n" >> $@
+ @sed -i -e '/^@title /a@subtitle for version $(VERSION)' $@
+ @rm -f $@~
-info: $(INFOPAGES) dir
%.info: %.texi
@printf "Generating $@\n"
@$(MAKEINFO) --no-split $< -o $@
-dir: $(INFOPAGES)
- @printf "Generating dir\n"
- @echo $^ | xargs -n 1 $(INSTALL_INFO) --dir=$@
+dir: $(PKG).info
+ @printf "Generating $@\n"
+ @printf "%s" $^ | xargs -n 1 $(INSTALL_INFO) --dir=$@
+
+%.html: %.texi
+ @printf "Generating $@\n"
+ @$(MAKEINFO) --html --no-split $(MANUAL_HTML_ARGS) $<
+
+html-dir: $(PKG).texi
+ @printf "Generating $(PKG)/*.html\n"
+ @$(MAKEINFO) --html $(MANUAL_HTML_ARGS) $<
+
+%.pdf: %.texi
+ @printf "Generating $@\n"
+ @texi2pdf --clean $< > /dev/null
+
+DOMAIN ?= magit.vc
+PUBLISH_BUCKET ?= s3://$(DOMAIN)
+PREVIEW_BUCKET ?= s3://preview.$(DOMAIN)
+PUBLISH_TARGET ?= $(PUBLISH_BUCKET)/manual/
+PREVIEW_TARGET ?= $(PREVIEW_BUCKET)/manual/
+
+preview: html html-dir pdf
+ @aws s3 cp $(PKG).html $(PREVIEW_TARGET)
+ @aws s3 cp $(PKG).pdf $(PREVIEW_TARGET)
+ @aws s3 sync $(PKG) $(PREVIEW_TARGET)$(PKG)/
+
+publish: html html-dir pdf
+ @aws s3 cp $(PKG).html $(PUBLISH_TARGET)
+ @aws s3 cp $(PKG).pdf $(PUBLISH_TARGET)
+ @aws s3 sync $(PKG) $(PUBLISH_TARGET)$(PKG)/
+
+CLEAN = $(ELCS) $(PKG)-autoloads.el $(PKG).info dir
+CLEAN += $(PKG) $(PKG).html $(PKG).pdf
+
+clean:
+ @printf "Cleaning...\n"
+ @rm -rf $(CLEAN)
+
+clean-texi:
+ @printf "Cleaning...\n"
+ @rm -f $(PKG).texi
+
+clean-all:
+ @printf "Cleaning...\n"
+ @rm -rf $(CLEAN) $(PKG).texi
authors: AUTHORS.md
+
AUTHORS.md:
@ printf "Authors\n=======\n\n" > $@
@ ( printf "%s\n" "- Barak A. Pearlmutter <barak+git@pearlmutter.net>" && \
@@ -62,40 +122,30 @@ AUTHORS.md:
git log --pretty=format:'- %aN <%aE>' \
) | sort -u >> $@
-clean:
- @printf "Cleaning...\n"
- @rm -f $(ELCS)
-
-define set_package_requires
-(require 'dash)
-(with-current-buffer (find-file-noselect "with-editor.el")
- (goto-char (point-min))
- (re-search-forward "^;; Package-Requires: ")
- (let ((s (read (buffer-substring (point) (line-end-position)))))
- (--when-let (assq 'async s) (setcdr it (list async-version)))
- (--when-let (assq 'dash s) (setcdr it (list dash-version)))
- (delete-region (point) (line-end-position))
- (insert (format "%S" s))
- (save-buffer)))
+define LOADDEFS_TMPL
+;;; $(PKG)-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+(add-to-list 'load-path (directory-file-name \
+(or (file-name-directory #$$) (car load-path))))
+
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; End:
+;;; $(PKG)-autoloads.el ends here
endef
-export set_package_requires
+export LOADDEFS_TMPL
#'
-define set_manual_version
-(let ((version "$(WITH_EDITOR_VERSION)"))
- (with-current-buffer (find-file-noselect "with-editor.org")
- (goto-char (point-min))
- (re-search-forward "^#\\+SUBTITLE: for version ")
- (delete-region (point) (line-end-position))
- (insert version)
- (save-buffer)))
-endef
-export set_manual_version
-
-bump-versions: bump-versions-1 texi
-bump-versions-1:
- @$(BATCH) --eval "(progn\
- (setq async-version \"$(ASYNC_VERSION)\")\
- (setq dash-version \"$(DASH_VERSION)\")\
- $$set_package_requires\
- $$set_manual_version)"
+$(PKG)-autoloads.el: $(ELS)
+ @printf "Generating $@\n"
+ @printf "%s" "$$LOADDEFS_TMPL" > $@
+ @$(EMACS) -Q --batch --eval "(progn\
+ (setq make-backup-files nil)\
+ (setq vc-handled-backends nil)\
+ (setq default-directory (file-truename default-directory))\
+ (setq generated-autoload-file (expand-file-name \"$@\"))\
+ (setq find-file-visit-truename t)\
+ (update-directory-autoloads default-directory)))"