From 797a63581bac53f8eb9cba268a975807ec6b841e Mon Sep 17 00:00:00 2001 From: "Pedro A. Aranda" Date: Thu, 14 Mar 2024 08:17:11 +0100 Subject: [PATCH] Make cleaneln work, execute cleanly when native comp not available. --- lisp/Makefile: clean .eln files from the directory where the user's natively compiled files are stored. Detect when native compilation is not available and exit gracefully in that case * Makefile: Add help for =make native= * lisp/Makefile: Implement =make cleaneln= * mk/targets.mk: Add =cleaneln= target Makefile | 1 + etc/ORG-NEWS | 7 +++++++ lisp/Makefile | 20 +++++++++++++++++++- mk/targets.mk | 5 ++++- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f476a3ea7..b3a167ecb 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,7 @@ help helpall:: $(info make all - ditto) $(info make compile - build Org ELisp files) $(info make single - build Org ELisp files, single Emacs per source) + $(info make native - build Org natively compiled Elisp files) $(info make autoloads - create org-loaddefs.el to load Org in-place) $(info make test - build Org ELisp files and run test suite) $(info make vanilla - run Emacs with this Org-mode and no personal config) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index ca73f06e7..cb8ed9b71 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -1281,6 +1281,13 @@ optional argument =NEW-HEADING-CONTAINER= specifies where in the buffer it will be added. If not specified, new headings are created at level 1 at the end of the accessible part of the buffer, as before. +*** ~make cleaneln~ will remove the .eln files from the user emacs configuration + +Natively compiled Emacs lisp files generated with ~make native~ are +now correctly located and deleted with ~make cleaneln~. + +*** Add text for =make native= to ~make help~ + ** Miscellaneous *** =org-crypt.el= now applies initial visibility settings to decrypted entries diff --git a/lisp/Makefile b/lisp/Makefile index c570d9cfa..ff49dccff 100644 --- a/lisp/Makefile +++ b/lisp/Makefile @@ -11,12 +11,15 @@ LISPF := $(filter-out $(LISPA),$(sort $(wildcard *.el))) LISPC := $(filter-out $(LISPB) $(LISPN:%el=%elc),$(LISPF:%el=%elc)) LISPN := $(filter-out $(LISPB) $(LISPN:%el=%eln),$(LISPF:%el=%eln)) _ORGCM_ := dirall single native source slint1 slint2 +# This is where Emacs stores the .eln files +ELNDIR := $(shell $(EMACS) --batch --eval '(when (native-comp-available-p) (princ (car native-comp-eln-load-path)))') + -include local.mk .PHONY: all compile compile-dirty \ $(_ORGCM_) $(_ORGCM_:%=compile-%) \ autoloads \ - install clean cleanauto cleanall cleanelc clean-install + install clean cleanauto cleanall cleanelc cleaneln clean-install # do not clean here, done in toplevel make all compile compile-dirty:: | autoloads @@ -52,9 +55,15 @@ slint1: @$(info Compiling single $(abspath $<)...) -@$(ELC) $< +ifeq (,$(ELNDIR)) +%.eln: %.el + @$(info Native compilation not enabled!) + @false +else %.eln: %.el @$(info Native compiling single $(abspath $<)...) -@$(ELN) $< +endif autoloads: cleanauto $(LISPI) $(LISPV) @@ -79,6 +88,15 @@ cleanauto clean cleanall:: clean cleanall cleanelc:: $(RM) *.elc +ifeq (,$(ELNDIR)) +cleaneln: + @$(info Native compilation not enabled. Nothing to do.) +else +cleaneln: + @$(foreach elnf,$(patsubst %.eln, %-*.eln, $(LISPN)), \ + $(FIND) $(ELNDIR) -name $(elnf) -exec $(RM) -v {} \; ;) +endif + clean-install: if [ -d $(DESTDIR)$(lispdir) ] ; then \ $(RM) $(DESTDIR)$(lispdir)/org*.el* $(DESTDIR)$(lispdir)/ob*.el* $(DESTDIR)$(lispdir)/ol*.el* $(DESTDIR)$(lispdir)/ox*.el* ; \ diff --git a/mk/targets.mk b/mk/targets.mk index de849c4fb..4ab5fa13c 100644 --- a/mk/targets.mk +++ b/mk/targets.mk @@ -31,7 +31,7 @@ endif info html pdf card refcard doc docs \ autoloads cleanall clean $(CLEANDIRS:%=clean%) \ clean-install cleanelc cleandirs \ - cleanlisp cleandoc cleandocs cleantest \ + cleanlisp cleandoc cleandocs cleantest cleaneln \ compile compile-dirty uncompiled \ config config-test config-exe config-all config-eol config-version \ vanilla repro @@ -143,6 +143,9 @@ cleanall: cleandirs cleantest $(CLEANDIRS:%=clean%): -$(FIND) $(@:clean%=%) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} + +cleaneln: + $(MAKE) -C lisp $@ + cleanelc: $(MAKE) -C lisp $@ -- 2.34.1