1 # -*- Makefile -*- definition file for building GNU Emacs on Windows NT.
2 # Copyright (C) 2000-2015 Free Software Foundation, Inc.
4 # This file is part of GNU Emacs.
6 # GNU Emacs is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # GNU Emacs is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
20 # Ensure 'all' is the default target
23 THE_SHELL = $(COMSPEC)
29 CURDIR = $(MAKEDIR:\=/)
35 SUBSYSTEM_WINDOWS=-subsystem:windows
36 SUBSYSTEM_CONSOLE=-subsystem:console
38 # INSTALL_DIR is the directory into which emacs will be installed.
41 INSTALL_DIR = $(CURDIR)/..
44 # Ensure EMACSLOADPATH is defined in the environment.
46 !if [set EMACSLOADPATH=foo]
49 # Allow detection of builds with MSVC 5 or later, so we can
50 # speed up compiles (see rule at end).
56 _NMAKE_VER=$(_NMAKE_VER_4)
59 # Check that the INCLUDE and LIB environment variables are set.
62 !error The INCLUDE environment variable needs to be set.
65 !error The LIB environment variable needs to be set.
68 # Determine the architecture we're running on.
69 # Define ARCH for our purposes;
70 # Define CPU for use by ntwin32.mak;
71 # Define CONFIG_H to the appropriate config.h for the system;
73 !ifdef PROCESSOR_ARCHITECTURE
75 CPU = $(PROCESSOR_ARCHITECTURE)
78 ! if "$(PROCESSOR_ARCHITECTURE)" == "x86"
82 ! if "$(PROCESSOR_ARCHITECTURE)" == "MIPS"
85 ! if "$(PROCESSOR_ARCHITECTURE)" == "ALPHA"
88 ! if "$(PROCESSOR_ARCHITECTURE)" == "PPC"
91 ! if "$(PROCESSOR_ARCHITECTURE)" == "AMD64"
94 ! error Unknown architecture type "$(PROCESSOR_ARCHITECTURE)"
101 # We're on Windows 95
114 RC = rc $(ARCH_RCFLAGS)
121 libc = msvcrt$(D).lib
122 EMACS_EXTRA_C_FLAGS= -D_DLL -D_MT -DUSE_CRT_DLL=1
124 libc = libcmt$(D).lib
125 EMACS_EXTRA_C_FLAGS= -D_MT
131 BASE_LIBS = $(libc) $(baselibs) oldnames.lib
133 ADVAPI32 = advapi32.lib
134 COMCTL32 = comctl32.lib
135 COMDLG32 = comdlg32.lib
138 SHELL32 = shell32.lib
140 WSOCK32 = wsock32.lib
142 WINSPOOL = winspool.lib
144 UNISCRIBE = usp10.lib
148 DEBUG_CFLAGS = -DEMACSDEBUG
153 MWINDOWS = -subsystem:windows -entry:mainCRTStartup
155 CFLAGS = -I. $(ARCH_CFLAGS) -D_CRT_SECURE_NO_WARNINGS \
156 $(DEBUG_CFLAGS) $(USER_CFLAGS) $(LOCAL_FLAGS)
157 ESC_CFLAGS = -I. $(ARCH_CFLAGS) -D_CRT_SECURE_NO_WARNINGS \
158 $(DEBUG_CFLAGS) $(ESC_USER_CFLAGS) $(LOCAL_FLAGS)
160 #SYS_LDFLAGS = -nologo -release -incremental:no -version:3.10 -swaprun:cd -swaprun:net setargv.obj
161 SYS_LDFLAGS = -nologo -manifest -dynamicbase:no -incremental:no -version:3.10 -swaprun:cd -swaprun:net setargv.obj
163 # see comments in allocate_heap in w32heap.c before changing any of the
164 # -stack, -heap, or -base settings.
165 !if "$(ARCH)" == "i386"
166 TEMACS_EXTRA_LINK = -stack:0x00800000 -heap:0x00100000 -base:0x01000000 -pdb:$(BLD)\temacs.pdb -machine:x86 $(SUBSYSTEM_CONSOLE) -entry:_start -map:$(BLD)\temacs.map $(EXTRA_LINK)
167 !elseif "$(ARCH)" == "AMD64"
168 TEMACS_EXTRA_LINK = -stack:0x00800000 -heap:0x00100000 -base:0x400000000 -pdb:$(BLD)\temacs.pdb -machine:x64 $(SUBSYSTEM_CONSOLE) -entry:_start -map:$(BLD)\temacs.map $(EXTRA_LINK)
176 $(OBJDIR):; -mkdir $(OBJDIR)
177 BLD = $(OBJDIR)/$(ARCH)
182 COMPILER_TEMP_FILES = *.pdb
186 IFNOTSAMEDIR = if not exist ..\$(DIRNAME)_same-dir.tst
188 FOREACH = for %%f in (
208 # gcc-specific pragma (ignore for MSVC)
209 PRAGMA_SYSTEM_HEADER =
211 !if "$(ARCH)" == "i386"
213 #ARCH_CFLAGS = -nologo -c -Zel -W2 -H63 -Od -G3d -Zp8 $(DEBUG_FLAG)
214 ARCH_CFLAGS = -nologo -D_X86_=1 -c -Zl -Zp8 -W2 -Od -Gd $(DEBUG_FLAG)
216 #ARCH_CFLAGS = -nologo -c -Zel -W2 -H63 -Oxsb2 -Oy- -G6dF -Zp8 $(DEBUG_FLAG)
217 ARCH_CFLAGS = -nologo -D_X86_=1 -c -Zl -Zp8 -W2 -Oi -Ot -Oy- -Ob2 -GF -Gy -Gd $(DEBUG_FLAG)
219 ARCH_LDFLAGS = $(SYS_LDFLAGS)
221 EMACS_PURESIZE = 5000000
222 EMACS_MANIFEST = emacs-x86.manifest
225 !if "$(ARCH)" == "mips"
226 ARCH_CFLAGS = -D_MIPS_=1 -c -W2 -Zi -Od -Gt0
227 ARCH_LDFLAGS = $(SYS_LDFLAGS)
229 EMACS_PURESIZE = 5000000
230 EMACS_MANIFEST = emacs-mips.manifest
233 !if "$(ARCH)" == "alpha"
234 !if "$(BUILD_TYPE)" == "spd"
235 ARCH_CFLAGS = -D_ALPHA_=1 -c -Ze -Zi -W2 -Od -D__stdcall= -D__cdecl=
237 ARCH_CFLAGS = -D_ALPHA_=1 -c -Ze -Zi -W2 -O1 -D__stdcall= -D__cdecl=
239 ARCH_LDFLAGS = $(SYS_LDFLAGS)
241 EMACS_PURESIZE = 5000000
242 EMACS_MANIFEST = emacs-alpha.manifest
245 !if "$(ARCH)" == "ppc"
246 # These flags are a guess...if they don't work, please send me mail.
247 ARCH_LDFLAGS = $(SYS_LDFLAGS)
249 EMACS_PURESIZE = 5000000
250 EMACS_MANIFEST = emacs-ppc.manifest
253 !if "$(ARCH)" == "AMD64"
255 ARCH_CFLAGS = -nologo -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -c -Zl -Zp8 -W2 -Od -Gd -Wp64 $(DEBUG_FLAG)
257 ARCH_CFLAGS = -nologo -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -c -Zl -Zp8 -W2 -O2x -GF -Gy -Gd $(DEBUG_FLAG)
259 ARCH_LDFLAGS = $(SYS_LDFLAGS) -machine:x64
260 ARCH_RCFLAGS = -DWIN64
262 EMACS_PURESIZE = 10000000
263 EMACS_MANIFEST = emacs-x64.manifest
266 !ERROR Unknown architecture type "$(ARCH)".
273 LINK_FLAGS = $(ARCH_LDFLAGS) $(DEBUG_LINK) $(USER_LDFLAGS)
275 # From MSVC 5.0 onwards, it seem base relocation information is not included,
276 # at least in release builds. We need to ensure the reloc info is included
277 # in order to use the MSVC profiler.
278 !IF ("$(_NMAKE_VER)" == "$(_NMAKE_VER_4)")
281 EXTRA_LINK = -profile
285 # If the compiler supports compiling multiple .c files to .o files at
286 # one time, use this feature.
288 !IF ("$(_NMAKE_VER)" == "$(_NMAKE_VER_4)")
290 $(CC) $(CFLAGS) -Fo$(BLD)\ $<
293 $(CC) $(CFLAGS) -Fo$(BLD)\ $<