Merge from trunk.
[bpt/emacs.git] / nt / nmake.defs
1 # -*- Makefile -*- definition file for building GNU Emacs on Windows NT.
2 # Copyright (C) 2000-2011 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
26 MAKETYPE=nmake
27
28 CURDIR = $(MAKEDIR:\=/)
29 THISDIR = $(MAKEDIR)
30
31 ALL_DEPS = $**
32
33 SUBSYSTEM_WINDOWS=-subsystem:windows
34 SUBSYSTEM_CONSOLE=-subsystem:console
35
36 # INSTALL_DIR is the directory into which emacs will be installed.
37 #
38 !ifndef INSTALL_DIR
39 INSTALL_DIR = $(CURDIR)/..
40 !endif
41
42 # Ensure EMACSLOADPATH is defined in the environment.
43 #
44 !if [set EMACSLOADPATH=foo]
45 !endif
46
47 # Allow detection of builds with MSVC 5 or later, so we can
48 # speed up compiles (see rule at end).
49 #
50 _NMAKE_VER_5=162
51 _NMAKE_VER_4=0
52
53 !IFNDEF _NMAKE_VER
54 _NMAKE_VER=$(_NMAKE_VER_4)
55 !ENDIF
56
57 # Check that the INCLUDE and LIB environment variables are set.
58 #
59 !ifndef INCLUDE
60 !error The INCLUDE environment variable needs to be set.
61 !endif
62 !ifndef LIB
63 !error The LIB environment variable needs to be set.
64 !endif
65
66 # Determine the architecture we're running on.
67 # Define ARCH for our purposes;
68 # Define CPU for use by ntwin32.mak;
69 # Define CONFIG_H to the appropriate config.h for the system;
70 #
71 !ifdef PROCESSOR_ARCHITECTURE
72 # We're on Windows NT
73 CPU = $(PROCESSOR_ARCHITECTURE)
74 CONFIG_H = config.nt
75 OS_TYPE = windowsnt
76 ! if "$(PROCESSOR_ARCHITECTURE)" == "x86"
77 ARCH = i386
78 CPU = i386
79 ! else
80 ! if "$(PROCESSOR_ARCHITECTURE)" == "MIPS"
81 ARCH = mips
82 ! else
83 ! if "$(PROCESSOR_ARCHITECTURE)" == "ALPHA"
84 ARCH = alpha
85 ! else
86 ! if "$(PROCESSOR_ARCHITECTURE)" == "PPC"
87 ARCH = ppc
88 ! else
89 ! error Unknown architecture type "$(PROCESSOR_ARCHITECTURE)"
90 ! endif
91 ! endif
92 ! endif
93 ! endif
94 !else
95 # We're on Windows 95
96 ARCH = i386
97 CPU = i386
98 CONFIG_H = config.nt
99 OS_TYPE = windows95
100 !endif
101
102 AR = lib
103 AR_OUT = -out:
104 CC = cl
105 CC_OUT = -Fo
106 LINK = link
107 LINK_OUT = -out:
108 RC = rc
109 RC_OUT = -Fo
110 RC_INCLUDE = -i
111
112 libc = libc.lib
113 baselibs =
114 O = obj
115 A = lib
116
117 BASE_LIBS = $(libc) $(baselibs) oldnames.lib
118
119 ADVAPI32 = advapi32.lib
120 COMCTL32 = comctl32.lib
121 COMDLG32 = comdlg32.lib
122 GDI32 = gdi32.lib
123 MPR = mpr.lib
124 SHELL32 = shell32.lib
125 USER32 = user32.lib
126 WSOCK32 = wsock32.lib
127 WINMM = winmm.lib
128 WINSPOOL = winspool.lib
129 OLE32 = ole32.lib
130 UNISCRIBE = usp10.lib
131 UUID = uuid.lib
132
133 !ifdef NOOPT
134 DEBUG_CFLAGS = -DEMACSDEBUG
135 !else
136 DEBUG_CFLAGS =
137 !endif
138
139 !ifdef ENABLECHECKS
140 CHECKING_CFLAGS = -DENABLE_CHECKING -DXASSERTS
141 !else
142 CHECKING_CFLAGS =
143 !endif
144
145 CFLAGS = -I. $(ARCH_CFLAGS) \
146 $(DEBUG_CFLAGS) $(CHECKING_CFLAGS) $(USER_CFLAGS) $(LOCAL_FLAGS)
147 ESC_CFLAGS = -I. $(ARCH_CFLAGS) \
148 $(DEBUG_CFLAGS) $(CHECKING_CFLAGS) $(ESC_USER_CFLAGS) $(LOCAL_FLAGS)
149 EMACS_EXTRA_C_FLAGS =
150
151 SYS_LDFLAGS = -nologo -release -incremental:no -version:3.10 -swaprun:cd -swaprun:net setargv.obj
152
153 # see comments in allocate_heap in w32heap.c before changing any of the
154 # -stack, -heap, or -base settings.
155 TEMACS_EXTRA_LINK = -stack:0x00800000 -heap:0x00100000 -base:0x01000000 -pdb:$(BLD)\temacs.pdb -machine:$(ARCH) $(SUBSYSTEM_CONSOLE) -entry:_start -map:$(BLD)\temacs.map $(EXTRA_LINK)
156
157 !ifdef NOOPT
158 OBJDIR = obj
159 !else
160 OBJDIR = obj-spd
161 !endif
162 $(OBJDIR):; -mkdir $(OBJDIR)
163 BLD = $(OBJDIR)/$(ARCH)
164 stamp_BLD: $(OBJDIR)
165 -mkdir "$(BLD)"
166 echo $(BLD) > $@
167
168 COMPILER_TEMP_FILES = *.pdb
169
170 CP = cp -f
171 CP_DIR = cp -rf
172 IFNOTSAMEDIR = if not exist ..\same-dir.tst
173 ENDIF =
174 FOREACH = for %%f in (
175 FORVAR = %%f
176 FORDO = ) do
177 ENDFOR =
178 ARGQUOTE = "
179 # "
180 DQUOTE = \"
181 DEL = rm
182 DEL_TREE = rm -r
183
184 !ifdef NODEBUG
185 DEBUG_FLAG =
186 DEBUG_LINK =
187 !else
188 DEBUG_FLAG = -Zi
189 DEBUG_LINK = -debug:full
190 !endif
191
192 !if "$(ARCH)" == "i386"
193 !ifdef NOOPT
194 ARCH_CFLAGS = -nologo -c -Zel -W2 -H63 -Od -G3d -Zp8 $(DEBUG_FLAG)
195 !else
196 ARCH_CFLAGS = -nologo -c -Zel -W2 -H63 -Oxsb2 -Oy- -G6dF -Zp8 $(DEBUG_FLAG)
197 !endif
198 ARCH_LDFLAGS = $(SYS_LDFLAGS)
199
200 !else
201 !if "$(ARCH)" == "mips"
202 ARCH_CFLAGS = -D_MIPS_=1 -c -W2 -Zi -Od -Gt0
203 ARCH_LDFLAGS = $(SYS_LDFLAGS)
204
205 !else
206 !if "$(ARCH)" == "alpha"
207 !if "$(BUILD_TYPE)" == "spd"
208 ARCH_CFLAGS = -D_ALPHA_=1 -c -Ze -Zi -W2 -Od -D__stdcall= -D__cdecl=
209 !else
210 ARCH_CFLAGS = -D_ALPHA_=1 -c -Ze -Zi -W2 -O1 -D__stdcall= -D__cdecl=
211 !endif
212 ARCH_LDFLAGS = $(SYS_LDFLAGS)
213
214 !else
215 !if "$(ARCH)" == "ppc"
216 # These flags are a guess...if they don't work, please send me mail.
217 ARCH_CFLAGS = -D_PPC_=1 -c -Ze -Zi -W2 -Od
218 ARCH_LDFLAGS = $(SYS_LDFLAGS)
219
220 !else
221 !ERROR Unknown architecture type "$(ARCH)".
222 !endif
223 !endif
224 !endif
225 !endif
226
227 LINK_FLAGS = $(ARCH_LDFLAGS) $(DEBUG_LINK) $(USER_LDFLAGS)
228
229 # From MSVC 5.0 onwards, it seem base relocation information is not included,
230 # at least in release builds. We need to ensure the reloc info is included
231 # in order to use the MSVC profiler.
232 !IF ("$(_NMAKE_VER)" == "$(_NMAKE_VER_4)")
233 EXTRA_LINK =
234 !ELSE
235 EXTRA_LINK = -profile
236 !ENDIF
237
238 #
239 # If the compiler supports compiling multiple .c files to .o files at
240 # one time, use this feature.
241 #
242 !IF ("$(_NMAKE_VER)" == "$(_NMAKE_VER_4)")
243 .c{$(BLD)}.obj:
244 $(CC) $(CFLAGS) -Fo$(BLD)\ $<
245 !ELSE
246 .c{$(BLD)}.obj::
247 $(CC) $(CFLAGS) -Fo$(BLD)\ $<
248 !ENDIF
249