aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2020-01-24 16:41:38 -0800
committerPaul Eggert2020-01-24 16:46:42 -0800
commitf42d57c7dbd571b449270c8899a67e537561c2b2 (patch)
tree3750aa093fb8ac135c20a247e8d82c49b55bd8a4
parent0c6c8aa002d321db61afdd14c70744f7bc27f268 (diff)
downloademacs-f42d57c7dbd571b449270c8899a67e537561c2b2.tar.gz
emacs-f42d57c7dbd571b449270c8899a67e537561c2b2.zip
Install C source code for C-h f etc.
Without this change, on typical GNU/Linux distributions like Debian, the first button of ‘C-h f car RET’ does not work because the source code for ‘car’ is not installed (Bug#37527). Fix this by installing the (compressed) C source code alongside the (compressed) Lisp source code that is already installed. This adds about 3 MB (about 2%) to the size of the installed files on my platform. * Makefile.in (emacs_srcdir): New macro. (epaths-force): Substitute PATH_EMACS_SOURCE. (install-c-src): New rule, that installs a copy of the C source code if emacs_srcdir says to. (install-arch-indep): Depend on it. * configure.ac (emacs_srcdir): New var. Add support for --disable-install-srcdir. * lisp/emacs-lisp/find-func.el (find-function-C-source-directory): Look in emacs-source-directory first. (find-function-C-source): Also look for gzipped source files. * lisp/startup.el (normal-top-level): Also recode emacs-source-directory. * src/epaths.in (PATH_EMACS_SOURCE): New macro. * src/lread.c: Include dosname.h, for IS_ABSOLUTE_FILE_NAME. (syms_of_lread): New var emacs-source-directory.
-rw-r--r--INSTALL65
-rw-r--r--Makefile.in31
-rw-r--r--configure.ac14
-rw-r--r--etc/NEWS9
-rw-r--r--lisp/emacs-lisp/find-func.el11
-rw-r--r--lisp/startup.el3
-rw-r--r--src/epaths.in4
-rw-r--r--src/lread.c10
8 files changed, 108 insertions, 39 deletions
diff --git a/INSTALL b/INSTALL
index 2d257f9ce68..cb12e4a17aa 100644
--- a/INSTALL
+++ b/INSTALL
@@ -214,41 +214,42 @@ like 'apt-get build-dep emacs' (on older systems, replace 'emacs' with
214eg 'emacs25'). On Red Hat-based systems, the corresponding command is 214eg 'emacs25'). On Red Hat-based systems, the corresponding command is
215'dnf builddep emacs' (on older systems, use 'yum-builddep' instead). 215'dnf builddep emacs' (on older systems, use 'yum-builddep' instead).
216 216
217
218DEBUGGING AN INSTALLED EMACS
219
220* Installed Emacs source code
221
222Emacs installs a compressed copy of much of its source code, to make
223it easy for users to read the source code of Emacs via commands like
224M-x describe-function (C-h f) to display the definition of a function.
225This compressed copy ordinarily includes both the Elisp source code
226that Emacs is mostly written in, as well as the C source code for the
227core Emacs executable.
228
217* GNU/Linux source and debug packages 229* GNU/Linux source and debug packages
218 230
219Many GNU/Linux systems provide separate packages containing the 231Many GNU/Linux systems provide separate packages containing the
220sources and debug symbols of Emacs. They are useful if you want to 232sources and debug symbols of Emacs. They can help you debug the
221check the source code of Emacs primitive functions or debug Emacs on 233installed Emacs on the C level. The procedures for installing these
222the C level. 234packages depend on the GNU/Linux system that you use.
223 235
224The names of the packages that you need vary according to the 236Emacs debugging symbols are distributed by a debug package if one
225GNU/Linux distribution that you use. On Debian-based systems, you can 237exists for your system. On Debian-based systems, you can
226install a source package of Emacs with a command like 'apt-get source 238install a debug package of Emacs with a command like 'apt-get install
227emacs' (on older systems, replace 'emacs' with eg 'emacs25'). The 239emacs-dbg' (on older systems, replace 'emacs' with e.g. 'emacs25').
228target directory for unpacking the source tree is the current 240On Red Hat-based systems, the corresponding command is 'dnf
229directory. On Red Hat-based systems, the corresponding command is 241debuginfo-install emacs'; this may require adding the *-debuginfo
230'dnf install emacs-debugsource', with target directory /usr/src/debug 242repositories first, via 'dnf config-manager --set-enabled
231(this requires to add the *-debuginfo repositories first, via 'dnf 243fedora-debuginfo updates-debuginfo'.
232config-manager --set-enabled fedora-debuginfo updates-debuginfo'). 244
233 245Some systems also have an Emacs source package that is also helpful
234Once you have installed the source package, for example at 246when debugging the installed Emacs. To unpack an Emacs source package
235/path/to/emacs-26.1, add the following line to your startup file: 247into the current directory on Debian-based systems, you can use a
236 248command like 'apt-get source emacs' (on older systems, replace 'emacs'
237 (setq find-function-C-source-directory 249with e.g. 'emacs25'); you may first need to add the appropriate
238 "/path/to/emacs-26.1/src") 250'source' URIs to your sources.list. On Red Hat-based systems,
239 251installing the debugging symbols automatically installs the
240The installation directory of the Emacs source package will contain 252corresponding source package in the appropriate location.
241the exact package name and version number Emacs is installed on your
242system. If a new Emacs package is installed, the source package must
243be reinstalled as well, and the setting in your startup file must be
244updated.
245
246Emacs debugging symbols are distributed by a debug package. It does
247not exist for every released Emacs package, this depends on the
248distribution. On Debian-based systems, you can install a debug
249package of Emacs with a command like 'apt-get install emacs-dbg' (on
250older systems, replace 'emacs' with eg 'emacs25'). On Red Hat-based
251systems, the corresponding command is 'dnf debuginfo-install emacs'.
252 253
253 254
254DETAILED BUILDING AND INSTALLATION: 255DETAILED BUILDING AND INSTALLATION:
diff --git a/Makefile.in b/Makefile.in
index 2c82c49fba5..adefa98fd02 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -266,6 +266,9 @@ etcdir=@etcdir@
266# once. 266# once.
267archlibdir=@archlibdir@ 267archlibdir=@archlibdir@
268 268
269# Where to install Emacs C source code, or empty if it is not installed.
270emacs_srcdir=@emacs_srcdir@
271
269# Where to put the etc/DOC file. 272# Where to put the etc/DOC file.
270etcdocdir=@etcdocdir@ 273etcdocdir=@etcdocdir@
271 274
@@ -374,6 +377,7 @@ epaths-force:
374 -e 's;\(#.*PATH_BITMAPS\).*$$;\1 "${bitmapdir}";' \ 377 -e 's;\(#.*PATH_BITMAPS\).*$$;\1 "${bitmapdir}";' \
375 -e 's;\(#.*PATH_X_DEFAULTS\).*$$;\1 "${x_default_search_path}";' \ 378 -e 's;\(#.*PATH_X_DEFAULTS\).*$$;\1 "${x_default_search_path}";' \
376 -e 's;\(#.*PATH_GAME\).*$$;\1 $(PATH_GAME);' \ 379 -e 's;\(#.*PATH_GAME\).*$$;\1 $(PATH_GAME);' \
380 -e 's;\(#.*PATH_EMACS_SOURCE\).*$$;\1 "${emacs_srcdir}";' \
377 -e 's;\(#.*PATH_DOC\).*$$;\1 "${etcdocdir}";') && \ 381 -e 's;\(#.*PATH_DOC\).*$$;\1 "${etcdocdir}";') && \
378 ${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h 382 ${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h
379 383
@@ -461,7 +465,7 @@ $(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/m4/*.m4
461# ==================== Installation ==================== 465# ==================== Installation ====================
462 466
463.PHONY: install install-arch-dep install-arch-indep install-etcdoc install-info 467.PHONY: install install-arch-dep install-arch-indep install-etcdoc install-info
464.PHONY: install-man install-etc install-strip install-$(NTDIR) 468.PHONY: install-man install-c-src install-etc install-strip install-$(NTDIR)
465.PHONY: uninstall uninstall-$(NTDIR) 469.PHONY: uninstall uninstall-$(NTDIR)
466 470
467## If we let lib-src do its own installation, that means we 471## If we let lib-src do its own installation, that means we
@@ -568,7 +572,8 @@ set_installuser=for installuser in $${LOGNAME} $${USERNAME} $${USER} \
568## work correctly, and therefore no idea when tar can be replaced. 572## work correctly, and therefore no idea when tar can be replaced.
569## See also these comments from 2004 about cp -r working fine: 573## See also these comments from 2004 about cp -r working fine:
570## https://lists.gnu.org/r/autoconf-patches/2004-11/msg00005.html 574## https://lists.gnu.org/r/autoconf-patches/2004-11/msg00005.html
571install-arch-indep: lisp install-info install-man ${INSTALL_ARCH_INDEP_EXTRA} 575install-arch-indep: lisp install-info install-man install-c-src \
576 $(INSTALL_ARCH_INDEP_EXTRA)
572 umask 022 && $(MKDIR_P) "$(DESTDIR)$(includedir)" 577 umask 022 && $(MKDIR_P) "$(DESTDIR)$(includedir)"
573 $(INSTALL_DATA) src/emacs-module.h "$(DESTDIR)$(includedir)/emacs-module.h" 578 $(INSTALL_DATA) src/emacs-module.h "$(DESTDIR)$(includedir)/emacs-module.h"
574 -set ${COPYDESTS} ; \ 579 -set ${COPYDESTS} ; \
@@ -700,6 +705,28 @@ install-man:
700 ${GZIP_PROG} -9n "$(DESTDIR)${man1dir}/$${dest}" || true; \ 705 ${GZIP_PROG} -9n "$(DESTDIR)${man1dir}/$${dest}" || true; \
701 done 706 done
702 707
708install-c-src:
709ifneq (,$(emacs_srcdir))
710 -unset CDPATH; \
711 umask 022; $(MKDIR_P) "$(DESTDIR)$(emacs_srcdir)/src" && \
712 exp_sourcesrcdir=`cd "$(DESTDIR)$(emacs_srcdir)/src" && /bin/pwd` && \
713 [ "`cd $(srcdir)/src && /bin/pwd`" = "$$exp_sourcesrcdir" ] || { \
714 $(set_installuser); \
715 printf 'Copying compressed C sources to %s ...\n' \
716 "$(DESTDIR)$(emacs_srcdir)/src"; \
717 for file in `cd $(srcdir) && echo src/*.[cm]`; do \
718 installed_file="$(DESTDIR)$(emacs_srcdir)/$$file" && \
719 $(INSTALL_DATA) "$$file" "$$installed_file" && \
720 [ -z "$(GZIP_PROG)" ] || { \
721 rm -f "$$installed_file.gz" && \
722 $(GZIP_PROG) -9n "$$installed_file" && \
723 installed_file=$$installed_file.gz; \
724 } || exit; \
725 chown $$installuser "$$installed_file" || true; \
726 done; \
727 }
728endif
729
703## Install those items from etc/ that need to end up elsewhere. 730## Install those items from etc/ that need to end up elsewhere.
704 731
705## If you prefer, choose "emacs22" at installation time. 732## If you prefer, choose "emacs22" at installation time.
diff --git a/configure.ac b/configure.ac
index 27e44dacfb2..4de83c6b261 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,6 +194,7 @@ locallisppath='${datadir}/emacs/${version}/site-lisp:'\
194lisppath='${locallisppath}:${standardlisppath}' 194lisppath='${locallisppath}:${standardlisppath}'
195etcdir='${datadir}/emacs/${version}/etc' 195etcdir='${datadir}/emacs/${version}/etc'
196archlibdir='${libexecdir}/emacs/${version}/${configuration}' 196archlibdir='${libexecdir}/emacs/${version}/${configuration}'
197emacs_srcdir='${datadir}/emacs/${version}'
197etcdocdir='${datadir}/emacs/${version}/etc' 198etcdocdir='${datadir}/emacs/${version}/etc'
198gamedir='${localstatedir}/games/emacs' 199gamedir='${localstatedir}/games/emacs'
199 200
@@ -540,6 +541,15 @@ elif test "${enableval}" != "yes"; then
540 locallisppath=${enableval} locallisppathset=yes 541 locallisppath=${enableval} locallisppathset=yes
541fi) 542fi)
542 543
544AC_ARG_ENABLE([install-srcdir],
545 [AS_HELP_STRING([--disable-install-srcdir],
546 [do not install low-level Emacs source code useful for debugging.])],
547 [case $enableval in
548 yes) ;;
549 no) emacs_srcdir=;;
550 *) AC_MSG_ERROR([invalid install-srcdir]);;
551 esac])
552
543AC_ARG_ENABLE(checking, 553AC_ARG_ENABLE(checking,
544[AS_HELP_STRING([--enable-checking@<:@=LIST@:>@], 554[AS_HELP_STRING([--enable-checking@<:@=LIST@:>@],
545 [enable expensive checks. With LIST, 555 [enable expensive checks. With LIST,
@@ -2048,6 +2058,9 @@ if test "${HAVE_NS}" = yes; then
2048 dnl This one isn't really used, only archlibdir is. 2058 dnl This one isn't really used, only archlibdir is.
2049 libexecdir="\${ns_appbindir}/libexec" 2059 libexecdir="\${ns_appbindir}/libexec"
2050 archlibdir="\${ns_appbindir}/libexec" 2060 archlibdir="\${ns_appbindir}/libexec"
2061 case $emacs_srcdir in
2062 ?*) emacs_srcdir="\${ns_appresdir}";;
2063 esac
2051 etcdocdir="\${ns_appresdir}/etc" 2064 etcdocdir="\${ns_appresdir}/etc"
2052 etcdir="\${ns_appresdir}/etc" 2065 etcdir="\${ns_appresdir}/etc"
2053 dnl FIXME maybe set datarootdir instead. 2066 dnl FIXME maybe set datarootdir instead.
@@ -5230,6 +5243,7 @@ AC_SUBST(lisppath)
5230AC_SUBST(x_default_search_path) 5243AC_SUBST(x_default_search_path)
5231AC_SUBST(etcdir) 5244AC_SUBST(etcdir)
5232AC_SUBST(archlibdir) 5245AC_SUBST(archlibdir)
5246AC_SUBST([emacs_srcdir])
5233AC_SUBST(etcdocdir) 5247AC_SUBST(etcdocdir)
5234AC_SUBST(bitmapdir) 5248AC_SUBST(bitmapdir)
5235AC_SUBST(gamedir) 5249AC_SUBST(gamedir)
diff --git a/etc/NEWS b/etc/NEWS
index 5395f2ccfb2..c3a71ade8ac 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -58,6 +58,12 @@ shaping, so 'configure' now recommends that combination.
58** The ftx font backend driver has been removed. 58** The ftx font backend driver has been removed.
59It was declared obsolete in Emacs 27.1. 59It was declared obsolete in Emacs 27.1.
60 60
61---
62** Emacs now installs a copy of its C source code, used for debugging help.
63For example, pressing the first button in the *Help* buffer generated
64by 'C-h f car RET' now takes you to a copy of the C-language
65implementation of the function 'car'.
66
61 67
62* Startup Changes in Emacs 28.1 68* Startup Changes in Emacs 28.1
63 69
@@ -142,6 +148,9 @@ called when the function object is garbage-collected. Use
142** 'parse-time-string' can now parse ISO 8601 format strings, 148** 'parse-time-string' can now parse ISO 8601 format strings,
143such as "2020-01-15T16:12:21-08:00". 149such as "2020-01-15T16:12:21-08:00".
144 150
151** The new variable 'emacs-source-directory' gives the Emacs source
152code location.
153
145 154
146* Changes in Emacs 28.1 on Non-Free Operating Systems 155* Changes in Emacs 28.1 on Non-Free Operating Systems
147 156
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index 167ead3ce02..be53324f141 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -219,8 +219,10 @@ LIBRARY should be a string (the name of the library)."
219 (locate-file basename (list dir) (find-library-suffixes))))))) 219 (locate-file basename (list dir) (find-library-suffixes)))))))
220 220
221(defvar find-function-C-source-directory 221(defvar find-function-C-source-directory
222 (let ((dir (expand-file-name "src" source-directory))) 222 (let ((dir (expand-file-name "src" emacs-source-directory)))
223 (if (file-accessible-directory-p dir) dir)) 223 (if (file-accessible-directory-p dir) dir
224 (setq dir (expand-file-name "src" source-directory))
225 (if (file-accessible-directory-p dir) dir)))
224 "Directory where the C source files of Emacs can be found. 226 "Directory where the C source files of Emacs can be found.
225If nil, do not try to find the source code of functions and variables 227If nil, do not try to find the source code of functions and variables
226defined in C.") 228defined in C.")
@@ -245,7 +247,10 @@ TYPE should be nil to find a function, or `defvar' to find a variable."
245 (let ((dir (or find-function-C-source-directory 247 (let ((dir (or find-function-C-source-directory
246 (read-directory-name "Emacs C source dir: " nil nil t)))) 248 (read-directory-name "Emacs C source dir: " nil nil t))))
247 (setq file (expand-file-name file dir)) 249 (setq file (expand-file-name file dir))
248 (if (file-readable-p file) 250 (if (or (file-readable-p file)
251 (let ((file-gz (concat file ".gz")))
252 (and (file-readable-p file-gz)
253 (setq file file-gz))))
249 (if (null find-function-C-source-directory) 254 (if (null find-function-C-source-directory)
250 (setq find-function-C-source-directory dir)) 255 (setq find-function-C-source-directory dir))
251 (error "The C source file %s is not available" 256 (error "The C source file %s is not available"
diff --git a/lisp/startup.el b/lisp/startup.el
index 1f545c66922..676fb35e000 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -623,7 +623,8 @@ It is the default value of the variable `top-level'."
623 (set pathsym (mapcar (lambda (dir) 623 (set pathsym (mapcar (lambda (dir)
624 (decode-coding-string dir coding t)) 624 (decode-coding-string dir coding t))
625 path))))) 625 path)))))
626 (dolist (filesym '(data-directory doc-directory exec-directory 626 (dolist (filesym '(data-directory doc-directory emacs-source-directory
627 exec-directory
627 installation-directory 628 installation-directory
628 invocation-directory invocation-name 629 invocation-directory invocation-name
629 source-directory 630 source-directory
diff --git a/src/epaths.in b/src/epaths.in
index 3cadd160ecf..554fdd7228a 100644
--- a/src/epaths.in
+++ b/src/epaths.in
@@ -73,5 +73,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
73/* Where Emacs should store game score files. */ 73/* Where Emacs should store game score files. */
74#define PATH_GAME "/usr/local/var/games/emacs" 74#define PATH_GAME "/usr/local/var/games/emacs"
75 75
76/* Where Emacs should look for its own installed source code,
77 or the empty string if the source code is not installed. */
78#define PATH_EMACS_SOURCE "/usr/local/share/emacs"
79
76/* Where Emacs should look for the application default file. */ 80/* Where Emacs should look for the application default file. */
77#define PATH_X_DEFAULTS "/usr/lib/X11/%L/%T/%N%C%S:/usr/lib/X11/%l/%T/%N%C%S:/usr/lib/X11/%T/%N%C%S:/usr/lib/X11/%L/%T/%N%S:/usr/lib/X11/%l/%T/%N%S:/usr/lib/X11/%T/%N%S" 81#define PATH_X_DEFAULTS "/usr/lib/X11/%L/%T/%N%C%S:/usr/lib/X11/%l/%T/%N%C%S:/usr/lib/X11/%T/%N%C%S:/usr/lib/X11/%L/%T/%N%S:/usr/lib/X11/%l/%T/%N%S:/usr/lib/X11/%T/%N%S"
diff --git a/src/lread.c b/src/lread.c
index 69dd73912bc..274491f0229 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -44,6 +44,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
44#include "blockinput.h" 44#include "blockinput.h"
45#include "pdumper.h" 45#include "pdumper.h"
46#include <c-ctype.h> 46#include <c-ctype.h>
47#include <dosname.h>
47#include <vla.h> 48#include <vla.h>
48 49
49#ifdef MSDOS 50#ifdef MSDOS
@@ -4992,11 +4993,18 @@ and is not meant for users to change. */);
4992 4993
4993 DEFVAR_LISP ("source-directory", Vsource_directory, 4994 DEFVAR_LISP ("source-directory", Vsource_directory,
4994 doc: /* Directory in which Emacs sources were found when Emacs was built. 4995 doc: /* Directory in which Emacs sources were found when Emacs was built.
4995You cannot count on them to still be there! */); 4996You cannot count on them to still be there! Also see
4997`emacs-source-directory'. */);
4996 Vsource_directory 4998 Vsource_directory
4997 = Fexpand_file_name (build_string ("../"), 4999 = Fexpand_file_name (build_string ("../"),
4998 Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH, 0))); 5000 Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH, 0)));
4999 5001
5002 DEFVAR_LISP ("emacs-source-directory", Vemacs_source_directory,
5003 doc: /* Directory where Emacs sources can be found. */);
5004 Vemacs_source_directory = (IS_ABSOLUTE_FILE_NAME (PATH_EMACS_SOURCE)
5005 ? build_string (PATH_EMACS_SOURCE)
5006 : Vsource_directory);
5007
5000 DEFVAR_LISP ("preloaded-file-list", Vpreloaded_file_list, 5008 DEFVAR_LISP ("preloaded-file-list", Vpreloaded_file_list,
5001 doc: /* List of files that were preloaded (when dumping Emacs). */); 5009 doc: /* List of files that were preloaded (when dumping Emacs). */);
5002 Vpreloaded_file_list = Qnil; 5010 Vpreloaded_file_list = Qnil;