Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.ca
[bpt/emacs.git] / nt / nmake.defs
1 # -*- Makefile -*- definition file for building GNU Emacs on Windows NT.
2 # Copyright (C) 2000-2013 Free Software Foundation, Inc.
3
4 # This file is part of GNU Emacs.
5
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.
10
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.
15
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/>.
18
19
20 # Ensure 'all' is the default target
21 all:
22
23 THE_SHELL = $(COMSPEC)
24 SHELLTYPE=CMD
25 SWITCHCHAR=/
26
27 MAKETYPE=nmake
28
29 CURDIR = $(MAKEDIR:\=/)
30 THISDIR = $(MAKEDIR)
31 DIRNAME =
32
33 ALL_DEPS = $**
34
35 SUBSYSTEM_WINDOWS=-subsystem:windows
36 SUBSYSTEM_CONSOLE=-subsystem:console
37
38 # INSTALL_DIR is the directory into which emacs will be installed.
39 #
40 !ifndef INSTALL_DIR
41 INSTALL_DIR = $(CURDIR)/..
42 !endif
43
44 # Ensure EMACSLOADPATH is defined in the environment.
45 #
46 !if [set EMACSLOADPATH=foo]
47 !endif
48
49 # Allow detection of builds with MSVC 5 or later, so we can
50 # speed up compiles (see rule at end).
51 #
52 _NMAKE_VER_5=162
53 _NMAKE_VER_4=0
54
55 !IFNDEF _NMAKE_VER
56 _NMAKE_VER=$(_NMAKE_VER_4)
57 !ENDIF
58
59 # Check that the INCLUDE and LIB environment variables are set.
60 #
61 !ifndef INCLUDE
62 !error The INCLUDE environment variable needs to be set.
63 !endif
64 !ifndef LIB
65 !error The LIB environment variable needs to be set.
66 !endif
67
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;
72 #
73 !ifdef PROCESSOR_ARCHITECTURE
74 # We're on Windows NT
75 CPU = $(PROCESSOR_ARCHITECTURE)
76 CONFIG_H = config.nt
77 OS_TYPE = windowsnt
78 ! if "$(PROCESSOR_ARCHITECTURE)" == "x86"
79 ARCH = i386
80 CPU = i386
81 ! else
82 ! if "$(PROCESSOR_ARCHITECTURE)" == "MIPS"
83 ARCH = mips
84 ! else
85 ! if "$(PROCESSOR_ARCHITECTURE)" == "ALPHA"
86 ARCH = alpha
87 ! else
88 ! if "$(PROCESSOR_ARCHITECTURE)" == "PPC"
89 ARCH = ppc
90 ! else
91 ! if "$(PROCESSOR_ARCHITECTURE)" == "AMD64"
92 ARCH = AMD64
93 ! else
94 ! error Unknown architecture type "$(PROCESSOR_ARCHITECTURE)"
95 ! endif
96 ! endif
97 ! endif
98 ! endif
99 ! endif
100 !else
101 # We're on Windows 95
102 ARCH = i386
103 CPU = i386
104 CONFIG_H = config.nt
105 OS_TYPE = windows95
106 !endif
107
108 AR = lib
109 AR_OUT = -out:
110 CC = cl
111 CC_OUT = -Fo
112 LINK = link
113 LINK_OUT = -out:
114 RC = rc $(ARCH_RCFLAGS)
115 RC_OUT = -Fo
116 RC_INCLUDE = -i
117
118 USE_CRT_DLL = 1
119
120 !if USE_CRT_DLL
121 libc = msvcrt$(D).lib
122 EMACS_EXTRA_C_FLAGS= -D_DLL -D_MT -DUSE_CRT_DLL=1
123 !else
124 libc = libcmt$(D).lib
125 EMACS_EXTRA_C_FLAGS= -D_MT
126 !endif
127 baselibs =
128 O = obj
129 A = lib
130
131 BASE_LIBS = $(libc) $(baselibs) oldnames.lib
132
133 ADVAPI32 = advapi32.lib
134 COMCTL32 = comctl32.lib
135 COMDLG32 = comdlg32.lib
136 GDI32 = gdi32.lib
137 MPR = mpr.lib
138 SHELL32 = shell32.lib
139 USER32 = user32.lib
140 WSOCK32 = wsock32.lib
141 WINMM = winmm.lib
142 WINSPOOL = winspool.lib
143 OLE32 = ole32.lib
144 UNISCRIBE = usp10.lib
145 UUID = uuid.lib
146
147 !ifdef NOOPT
148 DEBUG_CFLAGS = -DEMACSDEBUG
149 !else
150 DEBUG_CFLAGS =
151 !endif
152
153 MWINDOWS = -subsystem:windows -entry:mainCRTStartup
154
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)
159
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
162
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)
169 !endif
170
171 !ifdef NOOPT
172 OBJDIR = obj
173 !else
174 OBJDIR = obj-spd
175 !endif
176 $(OBJDIR):; -mkdir $(OBJDIR)
177 BLD = $(OBJDIR)/$(ARCH)
178 stamp_BLD: $(OBJDIR)
179 -mkdir "$(BLD)"
180 echo $(BLD) > $@
181
182 COMPILER_TEMP_FILES = *.pdb
183
184 CP = cp -f
185 CP_DIR = cp -rf
186 IFNOTSAMEDIR = if not exist ..\$(DIRNAME)_same-dir.tst
187 ENDIF =
188 FOREACH = for %%f in (
189 FORVAR = %%f
190 FORDO = ) do
191 ENDFOR =
192 ARGQUOTE = "
193 # "
194 DQUOTE = \"
195 DEL = rm
196 DEL_TREE = rm -r
197
198 !ifdef NODEBUG
199 DEBUG_FLAG =
200 DEBUG_LINK =
201 D =
202 !else
203 DEBUG_FLAG = -Zi
204 DEBUG_LINK = -debug
205 D = d
206 !endif
207
208 # gcc-specific pragma (ignore for MSVC)
209 PRAGMA_SYSTEM_HEADER =
210
211 !if "$(ARCH)" == "i386"
212 !ifdef NOOPT
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)
215 !else
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)
218 !endif
219 ARCH_LDFLAGS = $(SYS_LDFLAGS)
220 EMACS_HEAPSIZE = 27
221 EMACS_PURESIZE = 5000000
222 EMACS_MANIFEST = emacs-x86.manifest
223
224 !else
225 !if "$(ARCH)" == "mips"
226 ARCH_CFLAGS = -D_MIPS_=1 -c -W2 -Zi -Od -Gt0
227 ARCH_LDFLAGS = $(SYS_LDFLAGS)
228 EMACS_HEAPSIZE = 27
229 EMACS_PURESIZE = 5000000
230 EMACS_MANIFEST = emacs-mips.manifest
231
232 !else
233 !if "$(ARCH)" == "alpha"
234 !if "$(BUILD_TYPE)" == "spd"
235 ARCH_CFLAGS = -D_ALPHA_=1 -c -Ze -Zi -W2 -Od -D__stdcall= -D__cdecl=
236 !else
237 ARCH_CFLAGS = -D_ALPHA_=1 -c -Ze -Zi -W2 -O1 -D__stdcall= -D__cdecl=
238 !endif
239 ARCH_LDFLAGS = $(SYS_LDFLAGS)
240 EMACS_HEAPSIZE = 27
241 EMACS_PURESIZE = 5000000
242 EMACS_MANIFEST = emacs-alpha.manifest
243
244 !else
245 !if "$(ARCH)" == "ppc"
246 # These flags are a guess...if they don't work, please send me mail.
247 ARCH_LDFLAGS = $(SYS_LDFLAGS)
248 EMACS_HEAPSIZE = 27
249 EMACS_PURESIZE = 5000000
250 EMACS_MANIFEST = emacs-ppc.manifest
251
252 !else
253 !if "$(ARCH)" == "AMD64"
254 !ifdef NOOPT
255 ARCH_CFLAGS = -nologo -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -c -Zl -Zp8 -W2 -Od -Gd -Wp64 $(DEBUG_FLAG)
256 !else
257 ARCH_CFLAGS = -nologo -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -c -Zl -Zp8 -W2 -O2x -GF -Gy -Gd $(DEBUG_FLAG)
258 !endif
259 ARCH_LDFLAGS = $(SYS_LDFLAGS) -machine:x64
260 ARCH_RCFLAGS = -DWIN64
261 EMACS_HEAPSIZE = 42
262 EMACS_PURESIZE = 10000000
263 EMACS_MANIFEST = emacs-x64.manifest
264
265 !else
266 !ERROR Unknown architecture type "$(ARCH)".
267 !endif
268 !endif
269 !endif
270 !endif
271 !endif
272
273 LINK_FLAGS = $(ARCH_LDFLAGS) $(DEBUG_LINK) $(USER_LDFLAGS)
274
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)")
279 EXTRA_LINK =
280 !ELSE
281 EXTRA_LINK = -profile
282 !ENDIF
283
284 #
285 # If the compiler supports compiling multiple .c files to .o files at
286 # one time, use this feature.
287 #
288 !IF ("$(_NMAKE_VER)" == "$(_NMAKE_VER_4)")
289 .c{$(BLD)}.obj:
290 $(CC) $(CFLAGS) -Fo$(BLD)\ $<
291 !ELSE
292 .c{$(BLD)}.obj::
293 $(CC) $(CFLAGS) -Fo$(BLD)\ $<
294 !ENDIF