diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.in | 42 | ||||
-rw-r--r-- | src/unexw32.c | 8 | ||||
-rw-r--r-- | src/w32.c | 72 |
3 files changed, 103 insertions, 19 deletions
diff --git a/src/Makefile.in b/src/Makefile.in index 80d23b2d58b..c7a18363a5a 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -267,10 +267,13 @@ W32_OBJ=@W32_OBJ@ W32_LIBS=@W32_LIBS@ ## emacs.res if HAVE_W32 -W32_RES=@W32_RES@ +EMACSRES = @EMACSRES@ +## emacs-*.manifest if HAVE_W32 +EMACS_MANIFEST = @EMACS_MANIFEST@ ## If HAVE_W32, compiler arguments for including ## the resource file in the binary. -## XXX -Wl,-b -Wl,pe-i386 -Wl,emacs.res +## Cygwin: -Wl,emacs.res +## MinGW: emacs.res W32_RES_LINK=@W32_RES_LINK@ ## Empty if !HAVE_X_WINDOWS @@ -279,6 +282,9 @@ W32_RES_LINK=@W32_RES_LINK@ ## else xfont.o FONT_OBJ=@FONT_OBJ@ +## Empty for MinGW, cm.o for the rest. +CM_OBJ=@CM_OBJ@ + LIBGPM = @LIBGPM@ ## -lresolv, or empty. @@ -297,6 +303,14 @@ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ RUN_TEMACS = `/bin/pwd`/temacs +## Invoke ../nt/addsection for MinGW, ":" elsewhere. +TEMACS_POST_LINK = @TEMACS_POST_LINK@ +ADDSECTION = @ADDSECTION@ +EMACS_HEAPSIZE = @EMACS_HEAPSIZE@ +MINGW_TEMACS_POST_LINK = \ + mv temacs$(EXEEXT) temacs.tmp; \ + ../nt/addsection temacs.tmp temacs$(EXEEXT) EMHEAP $(EMACS_HEAPSIZE) + UNEXEC_OBJ = @UNEXEC_OBJ@ CANNOT_DUMP=@CANNOT_DUMP@ @@ -339,7 +353,7 @@ ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS) ## be dumped as pure by dump-emacs. base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \ charset.o coding.o category.o ccl.o character.o chartab.o bidi.o \ - cm.o term.o terminal.o xfaces.o $(XOBJ) $(GTK_OBJ) $(DBUS_OBJ) \ + $(CM_OBJ) term.o terminal.o xfaces.o $(XOBJ) $(GTK_OBJ) $(DBUS_OBJ) \ emacs.o keyboard.o macros.o keymap.o sysdep.o \ buffer.o filelock.o insdel.o marker.o \ minibuf.o fileio.o dired.o \ @@ -377,9 +391,9 @@ VMLIMIT_OBJ=@VMLIMIT_OBJ@ ## ralloc.o if !SYSTEM_MALLOC && REL_ALLOC, else empty. RALLOC_OBJ=@RALLOC_OBJ@ -## Empty on Cygwin, lastfile.o elsewhere. +## Empty on Cygwin and MinGW, lastfile.o elsewhere. PRE_ALLOC_OBJ=@PRE_ALLOC_OBJ@ -## lastfile.o on Cygwin, empty elsewhere. +## lastfile.o on Cygwin and MinGW, empty elsewhere. POST_ALLOC_OBJ=@POST_ALLOC_OBJ@ ## List of object files that make-docfile should not be told about. @@ -387,7 +401,9 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \ $(POST_ALLOC_OBJ) $(WIDGET_OBJ) $(LIBOBJS) ## All object files linked into temacs. $(VMLIMIT_OBJ) should be first. -ALLOBJS = $(VMLIMIT_OBJ) $(obj) $(otherobj) +## (On MinGW, firstfile.o should be before vm-limit.o.) +FIRSTFILE_OBJ=@FIRSTFILE_OBJ@ +ALLOBJS = $(FIRSTFILE_OBJ) $(VMLIMIT_OBJ) $(obj) $(otherobj) ## Configure inserts the file lisp.mk at this point, defining $lisp. @lisp_frag@ @@ -416,7 +432,8 @@ $(leimdir)/leim-list.el: bootstrap-emacs$(EXEEXT) ## Strictly speaking, emacs does not depend directly on all of $lisp, ## since not all pieces are used on all platforms. But DOC depends ## on all of $lisp, and emacs depends on DOC, so it is ok to use $lisp here. -emacs$(EXEEXT): temacs$(EXEEXT) $(etc)/DOC $(lisp) $(leimdir)/leim-list.el +emacs$(EXEEXT): temacs$(EXEEXT) $(ADDSECTION) \ + $(etc)/DOC $(lisp) $(leimdir)/leim-list.el if test "$(CANNOT_DUMP)" = "yes"; then \ rm -f emacs$(EXEEXT); \ ln temacs$(EXEEXT) emacs$(EXEEXT); \ @@ -468,10 +485,10 @@ $(lib)/libgnu.a: $(config_h) cd $(lib) && $(MAKE) libgnu.a temacs$(EXEEXT): stamp-oldxmenu $(ALLOBJS) \ - $(lib)/libgnu.a $(W32_RES) + $(lib)/libgnu.a $(EMACSRES) $(CC) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \ - -o temacs $(ALLOBJS) $(lib)/libgnu.a $(LIBES) \ - $(W32_RES_LINK) + -o temacs $(ALLOBJS) $(lib)/libgnu.a $(W32_RES_LINK) $(LIBES) + $(TEMACS_POST_LINK) test "$(CANNOT_DUMP)" = "yes" || \ test "X$(PAXCTL)" = X || $(PAXCTL) -r temacs$(EXEEXT) @@ -514,8 +531,9 @@ doc.o: buildobj.h emacs.res: $(ntsource)/emacs.rc \ $(ntsource)/icons/emacs.ico \ - $(ntsource)/emacs-x86.manifest - $(WINDRES) -O COFF -o $@ $(ntsource)/emacs.rc + $(ntsource)/$(EMACS_MANIFEST) + $(WINDRES) -O COFF --include-dir=$(srcdir)/../nt \ + -o $@ $(ntsource)/emacs.rc ns-app: emacs$(EXEEXT) cd ../nextstep && $(MAKE) $(MFLAGS) all diff --git a/src/unexw32.c b/src/unexw32.c index e8b553a87d3..a01ac799592 100644 --- a/src/unexw32.c +++ b/src/unexw32.c @@ -159,6 +159,14 @@ open_output_file (file_data *p_file, char *filename, unsigned long size) HANDLE file_mapping; void *file_base; + /* We delete any existing FILENAME because loadup.el will create a + hard link to it under the name emacs-XX.YY.ZZ.nn.exe. Evidently, + overwriting a file on Unix breaks any hard links to it, but that + doesn't happen on Windows. If we don't delete the file before + creating it, all the emacs-XX.YY.ZZ.nn.exe end up being hard + links to the same file, which defeats the purpose of these hard + links: being able to run previous builds. */ + DeleteFile (filename); file = CreateFile (filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if (file == INVALID_HANDLE_VALUE) diff --git a/src/w32.c b/src/w32.c index 431826c4b82..7d63c73eb18 100644 --- a/src/w32.c +++ b/src/w32.c @@ -65,6 +65,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #undef localtime #include "lisp.h" +#include "epaths.h" /* for SHELL */ #include <pwd.h> #include <grp.h> @@ -2018,7 +2019,7 @@ init_environment (char ** argv) {"PRELOAD_WINSOCK", NULL}, {"emacs_dir", "C:/emacs"}, {"EMACSLOADPATH", NULL}, - {"SHELL", "%emacs_dir%/bin/cmdproxy.exe"}, + {"SHELL", "cmdproxy.exe"}, /* perhaps it is somewhere on PATH */ {"EMACSDATA", NULL}, {"EMACSPATH", NULL}, {"INFOPATH", NULL}, @@ -2094,9 +2095,12 @@ init_environment (char ** argv) emacs_abort (); *p = 0; - if ((p = _mbsrchr (modname, '\\')) && xstrcasecmp (p, "\\bin") == 0) + if ((p = _mbsrchr (modname, '\\')) + /* From bin means installed Emacs, from src means uninstalled. */ + && (xstrcasecmp (p, "\\bin") == 0 || xstrcasecmp (p, "\\src") == 0)) { char buf[SET_ENV_BUF_SIZE]; + int within_build_tree = xstrcasecmp (p, "\\src") == 0; *p = 0; for (p = modname; *p; p = CharNext (p)) @@ -2104,6 +2108,15 @@ init_environment (char ** argv) _snprintf (buf, sizeof (buf)-1, "emacs_dir=%s", modname); _putenv (strdup (buf)); + /* If we are running from the Posix-like build tree, define + SHELL to point to our own cmdproxy. The loop below will + then disregard PATH_EXEC and the default value. */ + if (within_build_tree) + { + _snprintf (buf, sizeof (buf) - 1, + "SHELL=%s/nt/cmdproxy.exe", modname); + _putenv (strdup (buf)); + } } /* Handle running emacs from the build directory: src/oo-spd/i386/ */ @@ -2139,16 +2152,60 @@ init_environment (char ** argv) if (!getenv (env_vars[i].name)) { int dont_free = 0; + char bufc[SET_ENV_BUF_SIZE]; if ((lpval = w32_get_resource (env_vars[i].name, &dwType)) == NULL /* Also ignore empty environment variables. */ || *lpval == 0) { xfree (lpval); - lpval = env_vars[i].def_value; - dwType = REG_EXPAND_SZ; dont_free = 1; - if (!strcmp (env_vars[i].name, "HOME") && !appdata) + if (strcmp (env_vars[i].name, "SHELL") == 0) + { + /* Look for cmdproxy.exe in every directory in + PATH_EXEC. FIXME: This does not find cmdproxy + in nt/ when we run uninstalled. */ + char fname[MAX_PATH]; + const char *pstart = PATH_EXEC, *pend; + + do { + pend = _mbschr (pstart, ';'); + if (!pend) + pend = pstart + strlen (pstart); + /* Be defensive against series of ;;; characters. */ + if (pend > pstart) + { + strncpy (fname, pstart, pend - pstart); + fname[pend - pstart] = '/'; + strcpy (&fname[pend - pstart + 1], "cmdproxy.exe"); + ExpandEnvironmentStrings ((LPSTR) fname, bufc, + sizeof (bufc)); + if (check_existing (bufc)) + { + lpval = bufc; + dwType = REG_SZ; + break; + } + } + if (*pend) + pstart = pend + 1; + else + pstart = pend; + if (!*pstart) + { + /* If not found in any directory, use the + default as the last resort. */ + lpval = env_vars[i].def_value; + dwType = REG_EXPAND_SZ; + } + } while (*pstart); + } + else + { + lpval = env_vars[i].def_value; + dwType = REG_EXPAND_SZ; + } + if (strcmp (env_vars[i].name, "HOME") == 0 && !appdata) Vdelayed_warnings_list = Fcons (listn (CONSTYPE_HEAP, 2, intern ("initialization"), @@ -2394,8 +2451,8 @@ get_emacs_configuration_options (void) #include <sys/timeb.h> /* Emulate gettimeofday (Ulrich Leodolter, 1/11/95). */ -void -gettimeofday (struct timeval *tv, struct timezone *tz) +int +gettimeofday (struct timeval *restrict tv, struct timezone *restrict tz) { struct _timeb tb; _ftime (&tb); @@ -2413,6 +2470,7 @@ gettimeofday (struct timeval *tv, struct timezone *tz) tz->tz_minuteswest = tb.timezone; /* minutes west of Greenwich */ tz->tz_dsttime = tb.dstflag; /* type of dst correction */ } + return 0; } /* Emulate fdutimens. */ |