function.
@end defun
-@defun batch-native-compile
+@defun batch-native-compile &optional for-tarball
This function runs native-compilation on files specified on the Emacs
command line in batch mode. It must be used only in a batch execution
of Emacs, as it kills Emacs upon completion of the compilation. If
one or more of the files fail to compile, the Emacs process will
attempt to compile all the other files, and will terminate with a
-non-zero status code.
+non-zero status code. The optional argument @var{for-tarball}, if
+non-@code{nil}, tells the function to place the resulting @file{.eln}
+files in the last directory mentioned in
+@code{native-comp-eln-load-path} (@pxref{Library Search}); this is
+meant to be used as part of building an Emacs source tarball for the
+first time, when the natively-compiled files, which are absent from
+the source tarball, should be generated in the build tree instead of
+the user's cache directory.
@end defun
Native compilation can be run entirely asynchronously, in a subprocess
-f batch-byte-compile $(THEFILE)
endif
+ifeq ($(HAVE_NATIVE_COMP),yes)
+.PHONY: $(THEFILE)n
+$(THEFILE)n:
+ $(AM_V_ELN)$(emacs) $(BYTE_COMPILE_FLAGS) \
+ -l comp -f byte-compile-refresh-preloaded \
+ --eval '(batch-native-compile t)' $(THEFILE)
+endif
+
# Files MUST be compiled one by one. If we compile several files in a
# row (i.e., in the same instance of Emacs) we can't make sure that
# the compilation environment is clean. We also set the load-path of
(comp--native-compile function-or-file nil output))
;;;###autoload
-(defun batch-native-compile ()
+(defun batch-native-compile (&optional for-tarball)
"Perform batch native compilation of remaining command-line arguments.
Native compilation equivalent of `batch-byte-compile'.
Use this from the command line, with ‘-batch’; it won’t work
-in an interactive Emacs session."
+in an interactive Emacs session.
+Optional argument FOR-TARBALL non-nil means the file being compiled
+as part of building the source tarball, in which case the .eln file
+will be placed under the native-lisp/ directory (actually, in the
+last directory in `native-comp-eln-load-path')."
(comp-ensure-native-compiler)
- (cl-loop for file in command-line-args-left
- if (or (null byte+native-compile)
- (cl-notany (lambda (re) (string-match re file))
- native-comp-bootstrap-deny-list))
- do (comp--native-compile file)
- else
- do (byte-compile-file file)))
+ (let ((native-compile-target-directory
+ (if for-tarball
+ (car (last native-comp-eln-load-path)))))
+ (cl-loop for file in command-line-args-left
+ if (or (null byte+native-compile)
+ (cl-notany (lambda (re) (string-match re file))
+ native-comp-bootstrap-deny-list))
+ do (comp--native-compile file)
+ else
+ do (byte-compile-file file))))
;;;###autoload
(defun batch-byte+native-compile ()
ALLOBJS = $(FIRSTFILE_OBJ) $(VMLIMIT_OBJ) $(obj) $(otherobj)
# Must be first, before dep inclusion!
+ifeq ($(HAVE_NATIVE_COMP),yes)
+ifeq ($(NATIVE_DISABLED),)
+all: emacs$(EXEEXT) $(pdmp) $(OTHER_FILES) ../native-lisp
+else
+all: emacs$(EXEEXT) $(pdmp) $(OTHER_FILES)
+endif
+else
all: emacs$(EXEEXT) $(pdmp) $(OTHER_FILES)
+endif
.PHONY: all
dmpstruct_headers=$(srcdir)/lisp.h $(srcdir)/buffer.h \
@$(MAKE) $(AM_V_NO_PD) -C ../lisp EMACS="$(bootstrap_exe)"\
THEFILE=$< $<c
+ifeq ($(HAVE_NATIVE_COMP),yes)
+ifeq ($(NATIVE_DISABLED),)
+## The following rules are used only when building a source tarball
+## for the first time, when the native-lisp/ directory doesn't yet
+## exist and needs to be created and populated with the preloaded
+## *.eln files.
+
+## List of *.eln files we need to produce in addition to the preloaded
+## ones in $(lisp).
+elnlisp := \
+ emacs-lisp/autoload.eln \
+ emacs-lisp/byte-opt.eln \
+ emacs-lisp/bytecomp.eln \
+ emacs-lisp/cconv.eln \
+ international/charscript.eln \
+ emacs-lisp/comp.eln \
+ emacs-lisp/comp-cstr.eln \
+ international/emoji-zwj.eln
+elnlisp := $(addprefix ${lispsource}/,${elnlisp}) $(lisp:.elc=.eln)
+
+%.eln: %.el | emacs$(EXEEXT) $(pdmp)
+ @$(MAKE) $(AM_V_NO_PD) -C ../lisp EMACS="../src/emacs$(EXEEXT)"\
+ THEFILE=$< $<n
+
+../native-lisp: | $(pdmp)
+ mkdir $@ && $(MAKE) $(AM_V_NO_PD) $(elnlisp)
+ LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=pdump \
+ --bin-dest $(BIN_DESTDIR) --eln-dest $(ELN_DESTDIR)
+ cp -f $@ $(bootstrap_pdmp)
+endif
+endif
+
## VCSWITNESS points to the file that holds info about the current checkout.
## We use it as a heuristic to decide when to rebuild loaddefs.el.
## If empty it is ignored; the parent makefile can set it to some other value.
AM_V_CC =
AM_V_CCLD =
AM_V_ELC =
+AM_V_ELN =
AM_V_GEN =
AM_V_GLOBALS =
AM_V_NO_PD =
ifeq ($(HAVE_NATIVE_COMP),yes)
ifeq ($(NATIVE_DISABLED),1)
AM_V_ELC = @echo " ELC " $@;
+AM_V_ELN =
else
AM_V_ELC = @echo " ELC+ELN " $@;
+AM_V_ELN = @echo " ELN " $@;
endif
else
AM_V_ELC = @echo " ELC " $@;
+AM_V_ELN =
endif
AM_V_GEN = @echo " GEN " $@;
AM_V_GLOBALS = @echo " GEN " globals.h;