Add targets in Makefile to build compile lisp file and autoloads
authorÉtienne Deparis <etienne@depar.is>
Wed, 30 Jun 2021 07:20:30 +0000 (09:20 +0200)
committerÉtienne Deparis <etienne@depar.is>
Wed, 30 Jun 2021 07:20:30 +0000 (09:20 +0200)
.gitignore [new file with mode: 0644]
Makefile
config.mk

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..c039f9a
--- /dev/null
@@ -0,0 +1,2 @@
+elpher-loaddefs.el
+elpher.elc
\ No newline at end of file
index ac9c1c5..441528a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,24 @@
 include config.mk
 
-.PHONY: all help info package clean
+.PHONY: all autoloads clean compile help info package
 
 .SUFFIXES: .texi .info
 
 all: clean package
 
+autoloads: $(PKG)-loaddefs.el
+
+compile: clean $(PKG).elc
+
 help:
-       $(info make info     - generate the info manual)
-       $(info make package  - generate a tar file containing the package)
-       $(info make clean    - remove generated files)
+       $(info make help      - show brief help)
+       $(info make           - generate a tar file containing the package)
+       $(info make all       - ditto)
+       $(info make package   - ditto)
+       $(info make info      - generate the info manual)
+       $(info make compile   - byte-compile the package lisp files)
+       $(info make autoloads - create $(PKG)-loaddefs.el to load Elpher in-place)
+       $(info make clean     - remove generated files)
        @exit
 
 .texi.info:
@@ -29,4 +38,21 @@ $(PKG)-$(VERSION).tar: $(PKG).info dir *.el COPYING
 package: $(PKG)-$(VERSION).tar
 
 clean:
+       rm -f $(PKG).elc $(PKG)-loaddefs.el
        rm -f $(PKG).info dir $(PKG)-$(VERSION).tar
+
+define LOADDEFS_TPL
+(add-to-list 'load-path (directory-file-name\n\
+........................(or (file-name-directory #$$) (car load-path))))
+endef
+#' (ends emacs font-face garbage due to previous single quote)
+
+$(PKG)-loaddefs.el:
+       $(EMACS) -L $(PWD) \
+               --eval "(setq-default backup-inhibited t)" \
+               --eval "(setq generated-autoload-file \"$(PWD)/$@\")" \
+               --eval "(update-directory-autoloads \"$(PWD)\")"
+       sed -i "s/^;;; Code:$$/;;; Code:\n\n$(subst ., ,$(LOADDEFS_TPL))/" $@
+
+$(PKG).elc:
+       $(EMACS) -f batch-byte-compile $(@:.elc=.el)
index 443dca8..0c257d5 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -3,4 +3,5 @@ VERSION = 2.11.0
 
 INSTALLINFO = install-info
 MAKEINFO    = makeinfo
+EMACS       = emacs -Q --batch -nw
 TAR         = tar