1 # -*- Makefile -*- definition file for building GNU Emacs on Windows NT.
2 # Copyright (C) 2000-2013 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)
28 CURDIR = $(MAKEDIR:\=/)
34 SUBSYSTEM_WINDOWS=-subsystem:windows
35 SUBSYSTEM_CONSOLE=-subsystem:console
37 # INSTALL_DIR is the directory into which emacs will be installed.
40 INSTALL_DIR = $(CURDIR)/..
43 # Ensure EMACSLOADPATH is defined in the environment.
45 !if [set EMACSLOADPATH=foo]
48 # Allow detection of builds with MSVC 5 or later, so we can
49 # speed up compiles (see rule at end).
55 _NMAKE_VER=$(_NMAKE_VER_4)
58 # Check that the INCLUDE and LIB environment variables are set.
61 !error The INCLUDE environment variable needs to be set.
64 !error The LIB environment variable needs to be set.
67 # Determine the architecture we're running on.
68 # Define ARCH for our purposes;
69 # Define CPU for use by ntwin32.mak;
70 # Define CONFIG_H to the appropriate config.h for the system;
72 !ifdef PROCESSOR_ARCHITECTURE
74 CPU = $(PROCESSOR_ARCHITECTURE)
77 ! if "$(PROCESSOR_ARCHITECTURE)" == "x86"
81 ! if "$(PROCESSOR_ARCHITECTURE)" == "MIPS"
84 ! if "$(PROCESSOR_ARCHITECTURE)" == "ALPHA"
87 ! if "$(PROCESSOR_ARCHITECTURE)" == "PPC"
90 ! if "$(PROCESSOR_ARCHITECTURE)" == "AMD64"
93 ! error Unknown architecture type "$(PROCESSOR_ARCHITECTURE)"
100 # We're on Windows 95
113 RC = rc $(ARCH_RCFLAGS)
120 libc = msvcrt$(D).lib
121 EMACS_EXTRA_C_FLAGS= -D_DLL -D_MT -DUSE_CRT_DLL=1
123 libc = libcmt$(D).lib
124 EMACS_EXTRA_C_FLAGS= -D_MT
130 BASE_LIBS = $(libc) $(baselibs) oldnames.lib
132 ADVAPI32 = advapi32.lib
133 COMCTL32 = comctl32.lib
134 COMDLG32 = comdlg32.lib
137 SHELL32 = shell32.lib
139 WSOCK32 = wsock32.lib
141 WINSPOOL = winspool.lib
143 UNISCRIBE = usp10.lib
147 DEBUG_CFLAGS = -DEMACSDEBUG
152 MWINDOWS = -subsystem:windows -entry:mainCRTStartup
154 CFLAGS = -I. $(ARCH_CFLAGS) -D_CRT_SECURE_NO_WARNINGS \
155 $(DEBUG_CFLAGS) $(USER_CFLAGS) $(LOCAL_FLAGS)
156 ESC_CFLAGS = -I. $(ARCH_CFLAGS) -D_CRT_SECURE_NO_WARNINGS \
157 $(DEBUG_CFLAGS) $(ESC_USER_CFLAGS) $(LOCAL_FLAGS)
159 #SYS_LDFLAGS = -nologo -release -incremental:no -version:3.10 -swaprun:cd -swaprun:net setargv.obj
160 SYS_LDFLAGS = -nologo -manifest -dynamicbase:no -incremental:no -version:3.10 -swaprun:cd -swaprun:net setargv.obj
162 # see comments in allocate_heap in w32heap.c before changing any of the
163 # -stack, -heap, or -base settings.
164 !if "$(ARCH)" == "i386"
165 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)
166 !elseif "$(ARCH)" == "AMD64"
167 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)
175 $(OBJDIR):; -mkdir $(OBJDIR)
176 BLD = $(OBJDIR)/$(ARCH)
181 COMPILER_TEMP_FILES = *.pdb
185 IFNOTSAMEDIR = if not exist ..\$(DIRNAME)_same-dir.tst
187 FOREACH = for %%f in (
207 # gcc-specific pragma (ignore for MSVC)
208 PRAGMA_SYSTEM_HEADER =
210 !if "$(ARCH)" == "i386"
212 #ARCH_CFLAGS = -nologo -c -Zel -W2 -H63 -Od -G3d -Zp8 $(DEBUG_FLAG)
213 ARCH_CFLAGS = -nologo -D_X86_=1 -c -Zl -Zp8 -W2 -Od -Gd $(DEBUG_FLAG)
215 #ARCH_CFLAGS = -nologo -c -Zel -W2 -H63 -Oxsb2 -Oy- -G6dF -Zp8 $(DEBUG_FLAG)
216 ARCH_CFLAGS = -nologo -D_X86_=1 -c -Zl -Zp8 -W2 -Oi -Ot -Oy- -Ob2 -GF -Gy -Gd $(DEBUG_FLAG)
218 ARCH_LDFLAGS = $(SYS_LDFLAGS)
220 EMACS_PURESIZE = 5000000
221 EMACS_MANIFEST = emacs-x86.manifest
224 !if "$(ARCH)" == "mips"
225 ARCH_CFLAGS = -D_MIPS_=1 -c -W2 -Zi -Od -Gt0
226 ARCH_LDFLAGS = $(SYS_LDFLAGS)
228 EMACS_PURESIZE = 5000000
229 EMACS_MANIFEST = emacs-mips.manifest
232 !if "$(ARCH)" == "alpha"
233 !if "$(BUILD_TYPE)" == "spd"
234 ARCH_CFLAGS = -D_ALPHA_=1 -c -Ze -Zi -W2 -Od -D__stdcall= -D__cdecl=
236 ARCH_CFLAGS = -D_ALPHA_=1 -c -Ze -Zi -W2 -O1 -D__stdcall= -D__cdecl=
238 ARCH_LDFLAGS = $(SYS_LDFLAGS)
240 EMACS_PURESIZE = 5000000
241 EMACS_MANIFEST = emacs-alpha.manifest
244 !if "$(ARCH)" == "ppc"
245 # These flags are a guess...if they don't work, please send me mail.
246 ARCH_LDFLAGS = $(SYS_LDFLAGS)
248 EMACS_PURESIZE = 5000000
249 EMACS_MANIFEST = emacs-ppc.manifest
252 !if "$(ARCH)" == "AMD64"
254 ARCH_CFLAGS = -nologo -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -c -Zl -Zp8 -W2 -Od -Gd -Wp64 $(DEBUG_FLAG)
256 ARCH_CFLAGS = -nologo -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -c -Zl -Zp8 -W2 -O2x -GF -Gy -Gd $(DEBUG_FLAG)
258 ARCH_LDFLAGS = $(SYS_LDFLAGS) -machine:x64
259 ARCH_RCFLAGS = -DWIN64
261 EMACS_PURESIZE = 10000000
262 EMACS_MANIFEST = emacs-x64.manifest
265 !ERROR Unknown architecture type "$(ARCH)".
272 LINK_FLAGS = $(ARCH_LDFLAGS) $(DEBUG_LINK) $(USER_LDFLAGS)
274 # From MSVC 5.0 onwards, it seem base relocation information is not included,
275 # at least in release builds. We need to ensure the reloc info is included
276 # in order to use the MSVC profiler.
277 !IF ("$(_NMAKE_VER)" == "$(_NMAKE_VER_4)")
280 EXTRA_LINK = -profile
284 # If the compiler supports compiling multiple .c files to .o files at
285 # one time, use this feature.
287 !IF ("$(_NMAKE_VER)" == "$(_NMAKE_VER_4)")
289 $(CC) $(CFLAGS) -Fo$(BLD)\ $<
292 $(CC) $(CFLAGS) -Fo$(BLD)\ $<