diff options
| author | Alan Third | 2021-06-16 21:28:10 +0100 |
|---|---|---|
| committer | Alan Third | 2021-06-26 10:34:59 +0100 |
| commit | 5dd2d50f3d5e65b85c87da86e2e8a6d087fe5767 (patch) | |
| tree | f8add442c328e37e5b8519415ed60d0c54523e65 | |
| parent | 4d63a033a726a8da33bda8d18a503e88bfb794fb (diff) | |
| download | emacs-5dd2d50f3d5e65b85c87da86e2e8a6d087fe5767.tar.gz emacs-5dd2d50f3d5e65b85c87da86e2e8a6d087fe5767.zip | |
Fix NS native compilation builds
* Makefile.in (ns_applibexecdir):
(ns_applibdir):
(ns_appdir): New variables.
(.PHONY): Include new rule.
(epaths-force-ns-self-contained): Remove the app bundle directory from
all paths.
* configure.ac (NS_SELF_CONTAINED): Set the default site-lisp
directory instead of hard-coding it in the ObjC code, and use the new
epaths generating make rule.
* src/callproc.c (init_callproc_1):
(init_callproc): Remove all the NS specific code as the special cases
are now handled by decode_env_path.
* src/emacs.c (load_pdump):
(decode_env_path): Use ns_relocate to find the correct directory after
relocation.
* src/lread.c (load_path_default): Remove all the NS specific code as
the special cases are now handled by decode_env_path.
* src/nsterm.h: Update function definitions.
* src/nsterm.m (ns_etc_directory):
(ns_exec_path):
(ns_load_path): Remove functions that are no longer needed.
(ns_relocate): New function to calculate paths within the NS app
bundle.
* nextstep/Makefile.in (ns_applibexecdir): New variable, and update
anything relying on the libexec location.
| -rw-r--r-- | Makefile.in | 18 | ||||
| -rw-r--r-- | configure.ac | 19 | ||||
| -rw-r--r-- | nextstep/Makefile.in | 12 | ||||
| -rw-r--r-- | src/Makefile.in | 2 | ||||
| -rw-r--r-- | src/callproc.c | 36 | ||||
| -rw-r--r-- | src/emacs.c | 16 | ||||
| -rw-r--r-- | src/lread.c | 7 | ||||
| -rw-r--r-- | src/nsterm.h | 4 | ||||
| -rw-r--r-- | src/nsterm.m | 125 |
9 files changed, 80 insertions, 159 deletions
diff --git a/Makefile.in b/Makefile.in index b7502880230..420cb544a4d 100644 --- a/Makefile.in +++ b/Makefile.in | |||
| @@ -106,8 +106,11 @@ USE_STARTUP_NOTIFICATION = @USE_STARTUP_NOTIFICATION@ | |||
| 106 | 106 | ||
| 107 | # Location to install Emacs.app under GNUstep / macOS. | 107 | # Location to install Emacs.app under GNUstep / macOS. |
| 108 | # Later values may use these. | 108 | # Later values may use these. |
| 109 | ns_appdir=@ns_appdir@ | ||
| 109 | ns_appbindir=@ns_appbindir@ | 110 | ns_appbindir=@ns_appbindir@ |
| 111 | ns_applibexecdir=@ns_applibexecdir@ | ||
| 110 | ns_appresdir=@ns_appresdir@ | 112 | ns_appresdir=@ns_appresdir@ |
| 113 | ns_applibdir=@ns_applibdir@ | ||
| 111 | # Either yes or no depending on whether this is a relocatable Emacs.app. | 114 | # Either yes or no depending on whether this is a relocatable Emacs.app. |
| 112 | ns_self_contained=@ns_self_contained@ | 115 | ns_self_contained=@ns_self_contained@ |
| 113 | 116 | ||
| @@ -330,12 +333,12 @@ BIN_DESTDIR='$(DESTDIR)${bindir}/' | |||
| 330 | ELN_DESTDIR = $(DESTDIR)${libdir}/emacs/${version}/ | 333 | ELN_DESTDIR = $(DESTDIR)${libdir}/emacs/${version}/ |
| 331 | else | 334 | else |
| 332 | BIN_DESTDIR='${ns_appbindir}/' | 335 | BIN_DESTDIR='${ns_appbindir}/' |
| 333 | ELN_DESTDIR = ${ns_appresdir}/ | 336 | ELN_DESTDIR = ${ns_applibdir}/emacs/${version}/ |
| 334 | endif | 337 | endif |
| 335 | 338 | ||
| 336 | all: ${SUBDIR} info | 339 | all: ${SUBDIR} info |
| 337 | 340 | ||
| 338 | .PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 etc-emacsver | 341 | .PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 epaths-force-ns-self-contained etc-emacsver |
| 339 | 342 | ||
| 340 | # If configure were to just generate emacsver.tex from emacsver.tex.in | 343 | # If configure were to just generate emacsver.tex from emacsver.tex.in |
| 341 | # in the normal way, the timestamp of emacsver.tex would always be | 344 | # in the normal way, the timestamp of emacsver.tex would always be |
| @@ -404,6 +407,17 @@ epaths-force-w32: | |||
| 404 | -e "/^.*#/s|@SRC@|$${w32srcdir}|g") && \ | 407 | -e "/^.*#/s|@SRC@|$${w32srcdir}|g") && \ |
| 405 | ${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h | 408 | ${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h |
| 406 | 409 | ||
| 410 | # A NextStep style app bundle is relocatable, so instead of | ||
| 411 | # hard-coding paths try to generate them at run-time. | ||
| 412 | # | ||
| 413 | # The paths are mostly the same, and the bundle paths are different | ||
| 414 | # between macOS and GNUstep, so just replace any references to the app | ||
| 415 | # bundle root itself with the relative path. | ||
| 416 | epaths-force-ns-self-contained: epaths-force | ||
| 417 | @(sed < ${srcdir}/src/epaths.h > epaths.h.$$$$ \ | ||
| 418 | -e 's;${ns_appdir}/;;') && \ | ||
| 419 | ${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h | ||
| 420 | |||
| 407 | lib-src src: $(NTDIR) lib | 421 | lib-src src: $(NTDIR) lib |
| 408 | 422 | ||
| 409 | src: lib-src | 423 | src: lib-src |
diff --git a/configure.ac b/configure.ac index 830f33844b6..92527056b95 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -1891,10 +1891,11 @@ if test "${with_ns}" != no; then | |||
| 1891 | # so avoid NS_IMPL_COCOA if macuvs.h is absent. | 1891 | # so avoid NS_IMPL_COCOA if macuvs.h is absent. |
| 1892 | # Even a headless Emacs can build macuvs.h, so this should let you bootstrap. | 1892 | # Even a headless Emacs can build macuvs.h, so this should let you bootstrap. |
| 1893 | if test "${opsys}" = darwin && test -f "$srcdir/src/macuvs.h"; then | 1893 | if test "${opsys}" = darwin && test -f "$srcdir/src/macuvs.h"; then |
| 1894 | lispdirrel=Contents/Resources/lisp | ||
| 1895 | NS_IMPL_COCOA=yes | 1894 | NS_IMPL_COCOA=yes |
| 1896 | ns_appdir=`pwd`/nextstep/Emacs.app | 1895 | ns_appdir=`pwd`/nextstep/Emacs.app |
| 1897 | ns_appbindir=${ns_appdir}/Contents/MacOS | 1896 | ns_appbindir=${ns_appdir}/Contents/MacOS |
| 1897 | ns_applibexecdir=${ns_appdir}/Contents/MacOS/libexec | ||
| 1898 | ns_applibdir=${ns_appdir}/Contents/MacOS/lib | ||
| 1898 | ns_appresdir=${ns_appdir}/Contents/Resources | 1899 | ns_appresdir=${ns_appdir}/Contents/Resources |
| 1899 | ns_appsrc=Cocoa/Emacs.base | 1900 | ns_appsrc=Cocoa/Emacs.base |
| 1900 | ns_fontfile=macfont.o | 1901 | ns_fontfile=macfont.o |
| @@ -1952,6 +1953,8 @@ fail; | |||
| 1952 | if test $NS_IMPL_GNUSTEP = yes; then | 1953 | if test $NS_IMPL_GNUSTEP = yes; then |
| 1953 | ns_appdir=`pwd`/nextstep/Emacs.app | 1954 | ns_appdir=`pwd`/nextstep/Emacs.app |
| 1954 | ns_appbindir=${ns_appdir} | 1955 | ns_appbindir=${ns_appdir} |
| 1956 | ns_applibexecdir=${ns_appdir}/libexec | ||
| 1957 | ns_applibdir=${ns_appdir}/lib | ||
| 1955 | ns_appresdir=${ns_appdir}/Resources | 1958 | ns_appresdir=${ns_appdir}/Resources |
| 1956 | ns_appsrc=GNUstep/Emacs.base | 1959 | ns_appsrc=GNUstep/Emacs.base |
| 1957 | ns_fontfile=nsfont.o | 1960 | ns_fontfile=nsfont.o |
| @@ -2008,12 +2011,13 @@ if test "${HAVE_NS}" = yes; then | |||
| 2008 | window_system=nextstep | 2011 | window_system=nextstep |
| 2009 | # set up packaging dirs | 2012 | # set up packaging dirs |
| 2010 | if test "${EN_NS_SELF_CONTAINED}" = yes; then | 2013 | if test "${EN_NS_SELF_CONTAINED}" = yes; then |
| 2014 | AC_DEFINE(NS_SELF_CONTAINED, 1, [Build an NS bundled app]) | ||
| 2011 | ns_self_contained=yes | 2015 | ns_self_contained=yes |
| 2012 | prefix=${ns_appresdir} | 2016 | prefix=${ns_appresdir} |
| 2013 | exec_prefix=${ns_appbindir} | 2017 | exec_prefix=${ns_appbindir} |
| 2014 | dnl This one isn't really used, only archlibdir is. | 2018 | dnl This one isn't really used, only archlibdir is. |
| 2015 | libexecdir="\${ns_appbindir}/libexec" | 2019 | libexecdir="\${ns_applibexecdir}" |
| 2016 | archlibdir="\${ns_appbindir}/libexec" | 2020 | archlibdir="\${ns_applibexecdir}" |
| 2017 | etcdocdir="\${ns_appresdir}/etc" | 2021 | etcdocdir="\${ns_appresdir}/etc" |
| 2018 | etcdir="\${ns_appresdir}/etc" | 2022 | etcdir="\${ns_appresdir}/etc" |
| 2019 | dnl FIXME maybe set datarootdir instead. | 2023 | dnl FIXME maybe set datarootdir instead. |
| @@ -2021,7 +2025,7 @@ if test "${HAVE_NS}" = yes; then | |||
| 2021 | infodir="\${ns_appresdir}/info" | 2025 | infodir="\${ns_appresdir}/info" |
| 2022 | mandir="\${ns_appresdir}/man" | 2026 | mandir="\${ns_appresdir}/man" |
| 2023 | lispdir="\${ns_appresdir}/lisp" | 2027 | lispdir="\${ns_appresdir}/lisp" |
| 2024 | test "$locallisppathset" = no && locallisppath="" | 2028 | test "$locallisppathset" = no && locallisppath="\${ns_appresdir}/site-lisp" |
| 2025 | INSTALL_ARCH_INDEP_EXTRA= | 2029 | INSTALL_ARCH_INDEP_EXTRA= |
| 2026 | fi | 2030 | fi |
| 2027 | 2031 | ||
| @@ -5414,6 +5418,8 @@ AC_SUBST(CFLAGS) | |||
| 5414 | AC_SUBST(X_TOOLKIT_TYPE) | 5418 | AC_SUBST(X_TOOLKIT_TYPE) |
| 5415 | AC_SUBST(ns_appdir) | 5419 | AC_SUBST(ns_appdir) |
| 5416 | AC_SUBST(ns_appbindir) | 5420 | AC_SUBST(ns_appbindir) |
| 5421 | AC_SUBST(ns_applibexecdir) | ||
| 5422 | AC_SUBST(ns_applibdir) | ||
| 5417 | AC_SUBST(ns_appresdir) | 5423 | AC_SUBST(ns_appresdir) |
| 5418 | AC_SUBST(ns_appsrc) | 5424 | AC_SUBST(ns_appsrc) |
| 5419 | AC_SUBST(GNU_OBJC_CFLAGS) | 5425 | AC_SUBST(GNU_OBJC_CFLAGS) |
| @@ -6014,10 +6020,13 @@ dnl the use of force in the 'epaths-force' rule in Makefile.in. | |||
| 6014 | AC_CONFIG_COMMANDS([src/epaths.h], [ | 6020 | AC_CONFIG_COMMANDS([src/epaths.h], [ |
| 6015 | if test "${opsys}" = "mingw32"; then | 6021 | if test "${opsys}" = "mingw32"; then |
| 6016 | ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-w32 | 6022 | ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-w32 |
| 6023 | elif test "$EN_NS_SELF_CONTAINED" = "yes"; then | ||
| 6024 | ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-ns-self-contained | ||
| 6017 | else | 6025 | else |
| 6018 | ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force | 6026 | ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force |
| 6019 | fi || AC_MSG_ERROR(['src/epaths.h' could not be made.]) | 6027 | fi || AC_MSG_ERROR(['src/epaths.h' could not be made.]) |
| 6020 | ], [GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys"]) | 6028 | ], [GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys" |
| 6029 | EN_NS_SELF_CONTAINED="$EN_NS_SELF_CONTAINED"]) | ||
| 6021 | 6030 | ||
| 6022 | dnl NB we have to cheat and use the ac_... version because abs_top_srcdir | 6031 | dnl NB we have to cheat and use the ac_... version because abs_top_srcdir |
| 6023 | dnl is not yet set, sigh. Or we could use ../$srcdir/src/.gdbinit, | 6032 | dnl is not yet set, sigh. Or we could use ../$srcdir/src/.gdbinit, |
diff --git a/nextstep/Makefile.in b/nextstep/Makefile.in index 3168fee76c0..42b2ab2715d 100644 --- a/nextstep/Makefile.in +++ b/nextstep/Makefile.in | |||
| @@ -36,6 +36,7 @@ MKDIR_P = @MKDIR_P@ | |||
| 36 | ns_appdir = @ns_appdir@ | 36 | ns_appdir = @ns_appdir@ |
| 37 | ## GNUstep: ns_appdir; macOS: ns_appdir/Contents/MacOS | 37 | ## GNUstep: ns_appdir; macOS: ns_appdir/Contents/MacOS |
| 38 | ns_appbindir = @ns_appbindir@ | 38 | ns_appbindir = @ns_appbindir@ |
| 39 | ns_applibexecdir = @ns_applibexecdir@ | ||
| 39 | ## GNUstep/Emacs.base or Cocoa/Emacs.base. | 40 | ## GNUstep/Emacs.base or Cocoa/Emacs.base. |
| 40 | ns_appsrc = @ns_appsrc@ | 41 | ns_appsrc = @ns_appsrc@ |
| 41 | ## GNUstep: GNUstep/Emacs.base/Resources/Info-gnustep.plist | 42 | ## GNUstep: GNUstep/Emacs.base/Resources/Info-gnustep.plist |
| @@ -44,7 +45,7 @@ ns_check_file = @ns_appdir@/@ns_check_file@ | |||
| 44 | 45 | ||
| 45 | .PHONY: all | 46 | .PHONY: all |
| 46 | 47 | ||
| 47 | all: ${ns_appdir} ${ns_appbindir}/Emacs ${ns_appbindir}/Emacs.pdmp | 48 | all: ${ns_appdir} ${ns_appbindir}/Emacs ${ns_applibexecdir}/Emacs.pdmp |
| 48 | 49 | ||
| 49 | ${ns_check_file} ${ns_appdir}: ${srcdir}/${ns_appsrc} ${ns_appsrc} | 50 | ${ns_check_file} ${ns_appdir}: ${srcdir}/${ns_appsrc} ${ns_appsrc} |
| 50 | rm -rf ${ns_appdir} | 51 | rm -rf ${ns_appdir} |
| @@ -63,8 +64,10 @@ ${ns_appbindir}/Emacs: ${ns_appdir} ${ns_check_file} ../src/emacs${EXEEXT} | |||
| 63 | ${MKDIR_P} ${ns_appbindir} | 64 | ${MKDIR_P} ${ns_appbindir} |
| 64 | cp -f ../src/emacs${EXEEXT} $@ | 65 | cp -f ../src/emacs${EXEEXT} $@ |
| 65 | 66 | ||
| 66 | ${ns_appbindir}/Emacs.pdmp: ${ns_appdir} ${ns_check_file} ../src/emacs${EXEEXT}.pdmp | 67 | # FIXME: Don't install the dump file into the app bundle when |
| 67 | ${MKDIR_P} ${ns_appbindir} | 68 | # self-contained install is disabled. |
| 69 | ${ns_applibexecdir}/Emacs.pdmp: ${ns_appdir} ${ns_check_file} ../src/emacs${EXEEXT}.pdmp | ||
| 70 | ${MKDIR_P} ${ns_applibexecdir} | ||
| 68 | cp -f ../src/emacs${EXEEXT}.pdmp $@ | 71 | cp -f ../src/emacs${EXEEXT}.pdmp $@ |
| 69 | 72 | ||
| 70 | .PHONY: FORCE | 73 | .PHONY: FORCE |
| @@ -85,9 +88,8 @@ links: ../src/emacs${EXEEXT} | |||
| 85 | ln -s $(top_srcdir_abs)/info ${ns_appdir}/Contents/Resources | 88 | ln -s $(top_srcdir_abs)/info ${ns_appdir}/Contents/Resources |
| 86 | ${MKDIR_P} ${ns_appbindir} | 89 | ${MKDIR_P} ${ns_appbindir} |
| 87 | ln -s $(abs_top_builddir)/src/emacs${EXEEXT} ${ns_appbindir}/Emacs | 90 | ln -s $(abs_top_builddir)/src/emacs${EXEEXT} ${ns_appbindir}/Emacs |
| 88 | ln -s $(abs_top_builddir)/src/emacs${EXEEXT}.pdmp ${ns_appbindir}/Emacs.pdmp | ||
| 89 | ln -s $(abs_top_builddir)/lib-src ${ns_appbindir}/bin | 91 | ln -s $(abs_top_builddir)/lib-src ${ns_appbindir}/bin |
| 90 | ln -s $(abs_top_builddir)/lib-src ${ns_appbindir}/libexec | 92 | ln -s $(abs_top_builddir)/lib-src ${ns_applibexecdir} |
| 91 | ${MKDIR_P} ${ns_appdir}/Contents/Resources/etc | 93 | ${MKDIR_P} ${ns_appdir}/Contents/Resources/etc |
| 92 | for f in $(shell cd $(top_srcdir_abs)/etc; ls); do ln -s $(top_srcdir_abs)/etc/$$f ${ns_appdir}/Contents/Resources/etc; done | 94 | for f in $(shell cd $(top_srcdir_abs)/etc; ls); do ln -s $(top_srcdir_abs)/etc/$$f ${ns_appdir}/Contents/Resources/etc; done |
| 93 | ln -s $(abs_top_builddir)/etc/DOC ${ns_appdir}/Contents/Resources/etc | 95 | ln -s $(abs_top_builddir)/etc/DOC ${ns_appdir}/Contents/Resources/etc |
diff --git a/src/Makefile.in b/src/Makefile.in index 79cddb35b55..22c7aeed5c6 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -55,7 +55,7 @@ lwlibdir = ../lwlib | |||
| 55 | # Configuration files for .o files to depend on. | 55 | # Configuration files for .o files to depend on. |
| 56 | config_h = config.h $(srcdir)/conf_post.h | 56 | config_h = config.h $(srcdir)/conf_post.h |
| 57 | 57 | ||
| 58 | ## ns-app if HAVE_NS, else empty. | 58 | ## ns-app if NS self contained app, else empty. |
| 59 | OTHER_FILES = @OTHER_FILES@ | 59 | OTHER_FILES = @OTHER_FILES@ |
| 60 | 60 | ||
| 61 | ## Flags to pass for profiling builds | 61 | ## Flags to pass for profiling builds |
diff --git a/src/callproc.c b/src/callproc.c index e44e243680d..aabc39313b8 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -1661,32 +1661,15 @@ make_environment_block (Lisp_Object current_dir) | |||
| 1661 | void | 1661 | void |
| 1662 | init_callproc_1 (void) | 1662 | init_callproc_1 (void) |
| 1663 | { | 1663 | { |
| 1664 | #ifdef HAVE_NS | 1664 | Vdata_directory = decode_env_path ("EMACSDATA", PATH_DATA, 0); |
| 1665 | const char *etc_dir = ns_etc_directory (); | ||
| 1666 | const char *path_exec = ns_exec_path (); | ||
| 1667 | #endif | ||
| 1668 | |||
| 1669 | Vdata_directory = decode_env_path ("EMACSDATA", | ||
| 1670 | #ifdef HAVE_NS | ||
| 1671 | etc_dir ? etc_dir : | ||
| 1672 | #endif | ||
| 1673 | PATH_DATA, 0); | ||
| 1674 | Vdata_directory = Ffile_name_as_directory (Fcar (Vdata_directory)); | 1665 | Vdata_directory = Ffile_name_as_directory (Fcar (Vdata_directory)); |
| 1675 | 1666 | ||
| 1676 | Vdoc_directory = decode_env_path ("EMACSDOC", | 1667 | Vdoc_directory = decode_env_path ("EMACSDOC", PATH_DOC, 0); |
| 1677 | #ifdef HAVE_NS | ||
| 1678 | etc_dir ? etc_dir : | ||
| 1679 | #endif | ||
| 1680 | PATH_DOC, 0); | ||
| 1681 | Vdoc_directory = Ffile_name_as_directory (Fcar (Vdoc_directory)); | 1668 | Vdoc_directory = Ffile_name_as_directory (Fcar (Vdoc_directory)); |
| 1682 | 1669 | ||
| 1683 | /* Check the EMACSPATH environment variable, defaulting to the | 1670 | /* Check the EMACSPATH environment variable, defaulting to the |
| 1684 | PATH_EXEC path from epaths.h. */ | 1671 | PATH_EXEC path from epaths.h. */ |
| 1685 | Vexec_path = decode_env_path ("EMACSPATH", | 1672 | Vexec_path = decode_env_path ("EMACSPATH", PATH_EXEC, 0); |
| 1686 | #ifdef HAVE_NS | ||
| 1687 | path_exec ? path_exec : | ||
| 1688 | #endif | ||
| 1689 | PATH_EXEC, 0); | ||
| 1690 | Vexec_directory = Ffile_name_as_directory (Fcar (Vexec_path)); | 1673 | Vexec_directory = Ffile_name_as_directory (Fcar (Vexec_path)); |
| 1691 | /* FIXME? For ns, path_exec should go at the front? */ | 1674 | /* FIXME? For ns, path_exec should go at the front? */ |
| 1692 | Vexec_path = nconc2 (decode_env_path ("PATH", "", 0), Vexec_path); | 1675 | Vexec_path = nconc2 (decode_env_path ("PATH", "", 0), Vexec_path); |
| @@ -1701,10 +1684,6 @@ init_callproc (void) | |||
| 1701 | 1684 | ||
| 1702 | char *sh; | 1685 | char *sh; |
| 1703 | Lisp_Object tempdir; | 1686 | Lisp_Object tempdir; |
| 1704 | #ifdef HAVE_NS | ||
| 1705 | if (data_dir == 0) | ||
| 1706 | data_dir = ns_etc_directory () != 0; | ||
| 1707 | #endif | ||
| 1708 | 1687 | ||
| 1709 | if (!NILP (Vinstallation_directory)) | 1688 | if (!NILP (Vinstallation_directory)) |
| 1710 | { | 1689 | { |
| @@ -1716,15 +1695,8 @@ init_callproc (void) | |||
| 1716 | /* MSDOS uses wrapped binaries, so don't do this. */ | 1695 | /* MSDOS uses wrapped binaries, so don't do this. */ |
| 1717 | if (NILP (Fmember (tem, Vexec_path))) | 1696 | if (NILP (Fmember (tem, Vexec_path))) |
| 1718 | { | 1697 | { |
| 1719 | #ifdef HAVE_NS | ||
| 1720 | const char *path_exec = ns_exec_path (); | ||
| 1721 | #endif | ||
| 1722 | /* Running uninstalled, so default to tem rather than PATH_EXEC. */ | 1698 | /* Running uninstalled, so default to tem rather than PATH_EXEC. */ |
| 1723 | Vexec_path = decode_env_path ("EMACSPATH", | 1699 | Vexec_path = decode_env_path ("EMACSPATH", SSDATA (tem), 0); |
| 1724 | #ifdef HAVE_NS | ||
| 1725 | path_exec ? path_exec : | ||
| 1726 | #endif | ||
| 1727 | SSDATA (tem), 0); | ||
| 1728 | Vexec_path = nconc2 (decode_env_path ("PATH", "", 0), Vexec_path); | 1700 | Vexec_path = nconc2 (decode_env_path ("PATH", "", 0), Vexec_path); |
| 1729 | } | 1701 | } |
| 1730 | 1702 | ||
diff --git a/src/emacs.c b/src/emacs.c index 60a57a693ce..b7982ece646 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -835,7 +835,13 @@ load_pdump (int argc, char **argv) | |||
| 835 | NULL | 835 | NULL |
| 836 | #endif | 836 | #endif |
| 837 | ; | 837 | ; |
| 838 | const char *argv0_base = "emacs"; | 838 | const char *argv0_base = |
| 839 | #ifdef NS_SELF_CONTAINED | ||
| 840 | "Emacs" | ||
| 841 | #else | ||
| 842 | "emacs" | ||
| 843 | #endif | ||
| 844 | ; | ||
| 839 | 845 | ||
| 840 | /* TODO: maybe more thoroughly scrub process environment in order to | 846 | /* TODO: maybe more thoroughly scrub process environment in order to |
| 841 | make this use case (loading a dump file in an unexeced emacs) | 847 | make this use case (loading a dump file in an unexeced emacs) |
| @@ -912,6 +918,8 @@ load_pdump (int argc, char **argv) | |||
| 912 | /* On MS-Windows, PATH_EXEC normally starts with a literal | 918 | /* On MS-Windows, PATH_EXEC normally starts with a literal |
| 913 | "%emacs_dir%", so it will never work without some tweaking. */ | 919 | "%emacs_dir%", so it will never work without some tweaking. */ |
| 914 | path_exec = w32_relocate (path_exec); | 920 | path_exec = w32_relocate (path_exec); |
| 921 | #elif defined (HAVE_NS) | ||
| 922 | path_exec = ns_relocate (path_exec); | ||
| 915 | #endif | 923 | #endif |
| 916 | 924 | ||
| 917 | /* Look for "emacs.pdmp" in PATH_EXEC. We hardcode "emacs" in | 925 | /* Look for "emacs.pdmp" in PATH_EXEC. We hardcode "emacs" in |
| @@ -929,6 +937,7 @@ load_pdump (int argc, char **argv) | |||
| 929 | } | 937 | } |
| 930 | sprintf (dump_file, "%s%c%s%s", | 938 | sprintf (dump_file, "%s%c%s%s", |
| 931 | path_exec, DIRECTORY_SEP, argv0_base, suffix); | 939 | path_exec, DIRECTORY_SEP, argv0_base, suffix); |
| 940 | #if !defined (NS_SELF_CONTAINED) | ||
| 932 | /* Assume the Emacs binary lives in a sibling directory as set up by | 941 | /* Assume the Emacs binary lives in a sibling directory as set up by |
| 933 | the default installation configuration. */ | 942 | the default installation configuration. */ |
| 934 | const char *go_up = "../../../../bin/"; | 943 | const char *go_up = "../../../../bin/"; |
| @@ -943,6 +952,7 @@ load_pdump (int argc, char **argv) | |||
| 943 | sprintf (emacs_executable, "%s%c%s%s%s", | 952 | sprintf (emacs_executable, "%s%c%s%s%s", |
| 944 | path_exec, DIRECTORY_SEP, go_up, argv0_base, | 953 | path_exec, DIRECTORY_SEP, go_up, argv0_base, |
| 945 | strip_suffix ? strip_suffix : ""); | 954 | strip_suffix ? strip_suffix : ""); |
| 955 | #endif | ||
| 946 | result = pdumper_load (dump_file, emacs_executable); | 956 | result = pdumper_load (dump_file, emacs_executable); |
| 947 | 957 | ||
| 948 | if (result == PDUMPER_LOAD_FILE_NOT_FOUND) | 958 | if (result == PDUMPER_LOAD_FILE_NOT_FOUND) |
| @@ -2960,7 +2970,11 @@ decode_env_path (const char *evarname, const char *defalt, bool empty) | |||
| 2960 | path = 0; | 2970 | path = 0; |
| 2961 | if (!path) | 2971 | if (!path) |
| 2962 | { | 2972 | { |
| 2973 | #ifdef NS_SELF_CONTAINED | ||
| 2974 | path = ns_relocate (defalt); | ||
| 2975 | #else | ||
| 2963 | path = defalt; | 2976 | path = defalt; |
| 2977 | #endif | ||
| 2964 | #ifdef WINDOWSNT | 2978 | #ifdef WINDOWSNT |
| 2965 | defaulted = 1; | 2979 | defaulted = 1; |
| 2966 | #endif | 2980 | #endif |
diff --git a/src/lread.c b/src/lread.c index 0b33fd0f254..4617ffd6265 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -4769,14 +4769,9 @@ load_path_default (void) | |||
| 4769 | return decode_env_path (0, PATH_DUMPLOADSEARCH, 0); | 4769 | return decode_env_path (0, PATH_DUMPLOADSEARCH, 0); |
| 4770 | 4770 | ||
| 4771 | Lisp_Object lpath = Qnil; | 4771 | Lisp_Object lpath = Qnil; |
| 4772 | const char *normal = PATH_LOADSEARCH; | ||
| 4773 | const char *loadpath = NULL; | 4772 | const char *loadpath = NULL; |
| 4774 | 4773 | ||
| 4775 | #ifdef HAVE_NS | 4774 | lpath = decode_env_path (0, PATH_LOADSEARCH, 0); |
| 4776 | loadpath = ns_load_path (); | ||
| 4777 | #endif | ||
| 4778 | |||
| 4779 | lpath = decode_env_path (0, loadpath ? loadpath : normal, 0); | ||
| 4780 | 4775 | ||
| 4781 | if (!NILP (Vinstallation_directory)) | 4776 | if (!NILP (Vinstallation_directory)) |
| 4782 | { | 4777 | { |
diff --git a/src/nsterm.h b/src/nsterm.h index f64354b8a7b..b29e76cc63f 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -1190,9 +1190,7 @@ extern void ns_run_ascript (void); | |||
| 1190 | #define NSAPP_DATA2_RUNFILEDIALOG 11 | 1190 | #define NSAPP_DATA2_RUNFILEDIALOG 11 |
| 1191 | extern void ns_run_file_dialog (void); | 1191 | extern void ns_run_file_dialog (void); |
| 1192 | 1192 | ||
| 1193 | extern const char *ns_etc_directory (void); | 1193 | extern const char *ns_relocate (const char *epath); |
| 1194 | extern const char *ns_exec_path (void); | ||
| 1195 | extern const char *ns_load_path (void); | ||
| 1196 | extern void syms_of_nsterm (void); | 1194 | extern void syms_of_nsterm (void); |
| 1197 | extern void syms_of_nsfns (void); | 1195 | extern void syms_of_nsfns (void); |
| 1198 | extern void syms_of_nsmenu (void); | 1196 | extern void syms_of_nsmenu (void); |
diff --git a/src/nsterm.m b/src/nsterm.m index e81a4cbc0dc..8497138039c 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -499,118 +499,35 @@ append2 (Lisp_Object list, Lisp_Object item) | |||
| 499 | 499 | ||
| 500 | 500 | ||
| 501 | const char * | 501 | const char * |
| 502 | ns_etc_directory (void) | 502 | ns_relocate (const char *epath) |
| 503 | /* If running as a self-contained app bundle, return as a string the | 503 | /* If we're running in a self-contained app bundle some hard-coded |
| 504 | filename of the etc directory, if present; else nil. */ | 504 | paths are relative to the root of the bundle, so work out the full |
| 505 | { | 505 | path. |
| 506 | NSBundle *bundle = [NSBundle mainBundle]; | ||
| 507 | NSString *resourceDir = [bundle resourcePath]; | ||
| 508 | NSString *resourcePath; | ||
| 509 | NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
| 510 | BOOL isDir; | ||
| 511 | 506 | ||
| 512 | resourcePath = [resourceDir stringByAppendingPathComponent: @"etc"]; | 507 | FIXME: I think this should be able to handle cases where multiple |
| 513 | if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir]) | 508 | directories are separated by colons. */ |
| 514 | { | ||
| 515 | if (isDir) return [resourcePath UTF8String]; | ||
| 516 | } | ||
| 517 | return NULL; | ||
| 518 | } | ||
| 519 | |||
| 520 | |||
| 521 | const char * | ||
| 522 | ns_exec_path (void) | ||
| 523 | /* If running as a self-contained app bundle, return as a path string | ||
| 524 | the filenames of the libexec and bin directories, ie libexec:bin. | ||
| 525 | Otherwise, return nil. | ||
| 526 | Normally, Emacs does not add its own bin/ directory to the PATH. | ||
| 527 | However, a self-contained NS build has a different layout, with | ||
| 528 | bin/ and libexec/ subdirectories in the directory that contains | ||
| 529 | Emacs.app itself. | ||
| 530 | We put libexec first, because init_callproc_1 uses the first | ||
| 531 | element to initialize exec-directory. An alternative would be | ||
| 532 | for init_callproc to check for invocation-directory/libexec. | ||
| 533 | */ | ||
| 534 | { | 509 | { |
| 510 | #ifdef NS_SELF_CONTAINED | ||
| 535 | NSBundle *bundle = [NSBundle mainBundle]; | 511 | NSBundle *bundle = [NSBundle mainBundle]; |
| 536 | NSString *resourceDir = [bundle resourcePath]; | 512 | NSString *root = [bundle bundlePath]; |
| 537 | NSString *binDir = [bundle bundlePath]; | 513 | NSString *original = [NSString stringWithUTF8String:epath]; |
| 538 | NSString *resourcePath, *resourcePaths; | 514 | NSString *fixedPath = [NSString pathWithComponents:@[root, original]]; |
| 539 | NSRange range; | ||
| 540 | NSString *pathSeparator = [NSString stringWithFormat: @"%c", SEPCHAR]; | ||
| 541 | NSFileManager *fileManager = [NSFileManager defaultManager]; | 515 | NSFileManager *fileManager = [NSFileManager defaultManager]; |
| 542 | NSArray *paths; | ||
| 543 | NSEnumerator *pathEnum; | ||
| 544 | BOOL isDir; | ||
| 545 | 516 | ||
| 546 | range = [resourceDir rangeOfString: @"Contents"]; | 517 | if (![original isAbsolutePath] |
| 547 | if (range.location != NSNotFound) | 518 | && [fileManager fileExistsAtPath:fixedPath isDirectory:NULL]) |
| 548 | { | 519 | return [fixedPath UTF8String]; |
| 549 | binDir = [binDir stringByAppendingPathComponent: @"Contents"]; | ||
| 550 | #ifdef NS_IMPL_COCOA | ||
| 551 | binDir = [binDir stringByAppendingPathComponent: @"MacOS"]; | ||
| 552 | #endif | ||
| 553 | } | ||
| 554 | 520 | ||
| 555 | paths = [binDir stringsByAppendingPaths: | 521 | /* If we reach here either the path is absolute and therefore we |
| 556 | [NSArray arrayWithObjects: @"libexec", @"bin", nil]]; | 522 | don't need to complete it, or we're unable to relocate the |
| 557 | pathEnum = [paths objectEnumerator]; | 523 | file/directory. If it's the latter it may be because the user is |
| 558 | resourcePaths = @""; | 524 | trying to use a bundled app as though it's a Unix style install |
| 525 | and we have no way to guess what was intended, so return the | ||
| 526 | original string unaltered. */ | ||
| 559 | 527 | ||
| 560 | while ((resourcePath = [pathEnum nextObject])) | 528 | #endif |
| 561 | { | ||
| 562 | if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir]) | ||
| 563 | if (isDir) | ||
| 564 | { | ||
| 565 | if ([resourcePaths length] > 0) | ||
| 566 | resourcePaths | ||
| 567 | = [resourcePaths stringByAppendingString: pathSeparator]; | ||
| 568 | resourcePaths | ||
| 569 | = [resourcePaths stringByAppendingString: resourcePath]; | ||
| 570 | } | ||
| 571 | } | ||
| 572 | if ([resourcePaths length] > 0) return [resourcePaths UTF8String]; | ||
| 573 | |||
| 574 | return NULL; | ||
| 575 | } | ||
| 576 | |||
| 577 | |||
| 578 | const char * | ||
| 579 | ns_load_path (void) | ||
| 580 | /* If running as a self-contained app bundle, return as a path string | ||
| 581 | the filenames of the site-lisp and lisp directories. | ||
| 582 | Ie, site-lisp:lisp. Otherwise, return nil. */ | ||
| 583 | { | ||
| 584 | NSBundle *bundle = [NSBundle mainBundle]; | ||
| 585 | NSString *resourceDir = [bundle resourcePath]; | ||
| 586 | NSString *resourcePath, *resourcePaths; | ||
| 587 | NSString *pathSeparator = [NSString stringWithFormat: @"%c", SEPCHAR]; | ||
| 588 | NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
| 589 | BOOL isDir; | ||
| 590 | NSArray *paths = [resourceDir stringsByAppendingPaths: | ||
| 591 | [NSArray arrayWithObjects: | ||
| 592 | @"site-lisp", @"lisp", nil]]; | ||
| 593 | NSEnumerator *pathEnum = [paths objectEnumerator]; | ||
| 594 | resourcePaths = @""; | ||
| 595 | |||
| 596 | /* Hack to skip site-lisp. */ | ||
| 597 | if (no_site_lisp) resourcePath = [pathEnum nextObject]; | ||
| 598 | |||
| 599 | while ((resourcePath = [pathEnum nextObject])) | ||
| 600 | { | ||
| 601 | if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir]) | ||
| 602 | if (isDir) | ||
| 603 | { | ||
| 604 | if ([resourcePaths length] > 0) | ||
| 605 | resourcePaths | ||
| 606 | = [resourcePaths stringByAppendingString: pathSeparator]; | ||
| 607 | resourcePaths | ||
| 608 | = [resourcePaths stringByAppendingString: resourcePath]; | ||
| 609 | } | ||
| 610 | } | ||
| 611 | if ([resourcePaths length] > 0) return [resourcePaths UTF8String]; | ||
| 612 | 529 | ||
| 613 | return NULL; | 530 | return epath; |
| 614 | } | 531 | } |
| 615 | 532 | ||
| 616 | 533 | ||