Stefan Monnier <monn...@iro.umontreal.ca> writes:

>> AFAIU, using `update-file-autoloads' again means keeping track of all
>> AUCTeX files in the new GNUmakefile, or is there a better solution?
>
> You should be able to use `update-directory-autoloads`.
> It's a bit more cumbersome to use than `loaddefs-generate` but other
> than that it should be OK.

I think `make-directory-autoloads' would be even easier, but it was
introduced with 28.1, and we currently support 27.1, sigh!  I think I
can solve it with the patch below.

@Uwe: Can you please apply this to a clean main branch and run make?
This change contains what Stefan sent, but I don't think it can take
care of your Mercurial setup, try it in a real Git repo.  It should at
least cater for your Emacs version.  Thanks.

Best, Arash

diff --git a/GNUmakefile b/GNUmakefile
index b5cec482..49b677cf 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -17,7 +17,8 @@
 #   latex: prtightpage.def
 #   latex: prtracingall.def
 
-EMACS=emacs --batch -q -no-site-file -no-init-file -l lpath.el
+EMACSBIN=emacs
+EMACS=$(EMACSBIN) --batch -q -no-site-file -no-init-file -l lpath.el
 MAKEINFO=makeinfo
 INSTALL_INFO=install-info
 PERL=perl
@@ -39,12 +40,41 @@ ALL_GENERATED_FILES=$(MAIN_GENERATED_FILES)	\
 		$(INFO_FILES)
 
 # Generate & compile everything including the manuals below doc/.
-all: $(ALL_GENERATED_FILES) compile autoloads
+all: $(ALL_GENERATED_FILES) compile auctex-autoloads.el
 
 compile: $(patsubst %.el,%.elc,$(wildcard *.el style/*.el))
 
-autoloads:
-	$(EMACS) -f loaddefs-generate-batch loaddefs.el .
+AUCSRC = tex.el tex-style.el plain-tex.el latex.el tex-info.el \
+        texmathp.el multi-prompt.el tex-mik.el font-latex.el tex-font.el \
+        context.el context-en.el context-nl.el tex-fold.el tex-jp.el \
+        toolbar-x.el tex-bar.el bib-cite.el tex-ispell.el latex-flymake.el \
+        preview.el
+
+AUTOLOAD=--eval '\
+(let* ((autoload-file (expand-file-name "$@")) \
+       (autoload-file-dir (file-name-directory autoload-file))) \
+  (if (fboundp `loaddefs-generate) \
+      (loaddefs-generate autoload-file-dir autoload-file \
+                         (list "tex-wizard.el") \
+                         "(add-to-list `load-path\n\
+                                       (directory-file-name\n\
+                                         (file-name-directory load-file-name)))")\
+    (mapc (lambda (file) \
+            (update-file-autoloads file nil autoload-file)) \
+          command-line-args-left)) \
+  (save-buffers-kill-emacs t))' $(AUCSRC)
+
+auctex-autoloads.el:
+	-rm -f $@
+	$(EMACS) $(AUTOLOAD) $(AUCSRC)
+
+# auctex-autoloads.el:
+# 	$(EMACS) --eval \
+#           "(loaddefs-generate \".\" \"auctex-autoloads.el\" nil \"\
+# (add-to-list 'load-path\n\
+#              (directory-file-name\n\
+#               (file-name-directory load-file-name)))\
+# \")"
 
 %.elc: %.el
 	$(EMACS) -f batch-byte-compile $<
@@ -63,7 +93,7 @@ elpa: $(MAIN_GENERATED_FILES)
 clean:
 	rm -f $(ALL_GENERATED_FILES) \
 		$(wildcard *.elc style/*.elc) \
-		loaddefs.el
+		auctex-autoloads.el
 
 # Copied&adapted from doc/Makefile.in.
 MAKEINFO_PLAIN=$(MAKEINFO) -D rawfile --no-headers
@@ -74,18 +104,16 @@ README: doc/intro.texi doc/preview-readme.texi doc/macros.texi
 # Commands copied&adapted from autogen.sh and doc/Makefile.in.
 IGNORED:=$(shell rm -f ChangeLog && ./build-aux/gitlog-to-auctexlog && cat ChangeLog.1 >> ChangeLog)
 # Committer date of HEAD.
-AUCTEXDATE:=$(shell git log -n1 --pretty=tformat:"%ci" \
-	| sed -nre 's/ /_/p' | sed -nre 's/ .*//p')
+AUCTEXDATE:=$(shell (git log -n1 --pretty=tformat:"%ci" 2>/dev/null \
+                     || date +"%Y-%m-%d %T") 		       	    \
+                    | sed -re 's/ /_/' -e 's/ .*//')
 # Extract the version number from the diff line "+;; Version: 14.0.4" of
 # the commit HEAD which is only filled when we did a release in the last
 # commit.
-THISVERSION:=$(shell git show HEAD -- auctex.el \
+THISVERSION:=$(shell git show HEAD -- auctex.el 2>/dev/null \
 	| sed -nre 's/[+];; Version: ([0-9]+.[0-9]+.[0-9]+)/\1/p')
-# Extract the last version number from the previous change to auctex.el,
-# i.e., only look at commits starting at HEAD~1.
-LASTVERSION:=$(shell git log HEAD~1 -p --first-parent -- auctex.el \
-	| grep "+;; Version: " \
-	| sed -nre 's/[+];; Version: ([0-9]+.[0-9]+.[0-9]+)/\1/p;q')
+# Extract the last released version number from `auctex.el`.
+LASTVERSION:=$(shell sed -nre '/Version:/{s/;; Version: ([0-9]+.[0-9]+.[0-9]+)/\1/p;q}' auctex.el)
 AUCTEXVERSION:=$(if $(THISVERSION),$(THISVERSION),$(LASTVERSION).$(AUCTEXDATE))
 
 tex-site.el: tex-site.el.in

Reply via email to