Standardize License information
[openafs.git] / src / config / NTMakefile.i386_nt40
1 # Copyright 2000, International Business Machines Corporation and others.
2 # All Rights Reserved.
3
4 # This software has been released under the terms of the IBM Public
5 # License.  For details, see the LICENSE file in the top-level source
6 # directory or online at http://www.openafs.org/dl/license10.html
7
8 # Common nmake file to be included in each NTMakfile.
9 #
10 # Required definitions:
11 #     AFSDEV_BUILDTYPE = [ CHECKED | FREE ]
12 #     AFSDEV_INCLUDE = <default include directories>
13 #     AFSDEV_LIB = <default library directories>
14 #     AFSDEV_BIN = <default build binary directories>
15 #
16 # Optional definitions:
17 #     AFSDEV_DESTDIR = <top-level install directory>  (default is $(AFSROOT)\DEST)
18 #     AFSDEV_WARNLEVEL = [0 | 1 | 2 | 3 | 4]  (default is 3)
19 #     AFSDEV_AUXCDEFINES = <auxiliary C preprocessor defs> (default is null)
20 #     AFSDEV_AUXRCFLAGS = <auxiliary resource compiler flags> (default is null)
21 #     AFSDEV_TEXTMODE = <text mode is default if defined>  (default is null)
22 #     AFSDEV_CRTDEBUG = <utilize debug C runtime if define> (default is null)
23 #
24 ############################################################################
25
26
27 # Definitions provided here are based on WIN32.MAK, a common nmake
28 # file included with the MS SDK and MS VC distributions.
29 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
30 # port this nmake file if additional compiler support is required.
31
32 # Define default target-type macros required by WIN32.MAK.
33 # Allow them to be overriden in an NTMakefile or via an environment variable.
34
35 !IFNDEF APPVER
36 APPVER = 4.0
37 !ENDIF
38
39 !IFNDEF TARGETOS
40 TARGETOS = WINNT
41 !ENDIF
42
43 # Check that build type is correctly specified.
44
45 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
46 #    Build type ignored when profiling or tuning.
47 AFSDEV_BUILDTYPE = NONE
48
49 !ELSE
50 #    Build type must be checked or free.
51 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
52 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
53 !ENDIF
54
55 !ENDIF
56
57 # Limit default include and library directories to those specified for build.
58
59 !IFNDEF AFSDEV_INCLUDE
60 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
61 !ENDIF
62
63 !IF ((!DEFINED(INCLUDE)) && ([set INCLUDE=$(AFSDEV_INCLUDE)] != 0))
64 #    If env. var. INCLUDE not defined then macro assignment won't set it.
65 !ERROR Failed setting environment variable INCLUDE.
66 !ENDIF
67 INCLUDE = $(AFSDEV_INCLUDE)
68
69
70 !IFNDEF AFSDEV_LIB
71 !ERROR Must define AFSDEV_LIB to be the default library directories.
72 !ENDIF
73
74 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
75 #    If env. var. LIB not defined then macro assignment won't set it.
76 !ERROR Failed setting environment variable LIB.
77 !ENDIF
78 LIB = $(AFSDEV_LIB)
79
80
81 # Put default build binary directories at front of path.
82
83 !IFNDEF AFSDEV_BIN
84 !ERROR Must define AFSDEV_BIN to be the default build binary directories.
85 !ENDIF
86
87 !IF ((!DEFINED(PATH)) && ([set PATH=$(AFSDEV_BIN)] != 0))
88 #    If env. var. PATH not defined then macro assignment won't set it.
89 !ERROR Failed setting environment variable PATH.
90 !ENDIF
91 PATH = $(AFSDEV_BIN);$(PATH)
92
93
94 # Undefine WIN32.MAK NODEBUG macro.
95 # Always generate full debug info, unless profiling or tuning (see below).
96
97 !UNDEF NODEBUG
98
99 # Include WIN32.MAK nmake file
100
101 !INCLUDE <WIN32.MAK>
102
103
104
105 # Extend and/or supplement definitions in WIN32.MAK.
106
107 # Standard install directory.
108 !IFDEF AFSDEV_DESTDIR
109 DESTDIR = $(AFSDEV_DESTDIR)
110 !ELSE
111 DESTDIR = $(AFSROOT)\DEST
112 !ENDIF
113
114 # Command macros.
115 COPY = copy
116 DEL = del
117 MKDIR = mkdir
118 REN = ren
119 ECHO = echo
120 CD = cd
121 MC = mc -vcsU
122 MAKECMD = nmake.exe
123
124 COMPILE_ET = $(DESTDIR)\bin\compile_et
125 RXGEN = $(DESTDIR)\bin\rxgen
126 MIDL  = midl
127
128 # Common clean target.
129 # Double colon (::) syntax allows supplemental clean target to be specified.
130 clean::
131         $(DEL) *.obj *.lib *.dll *.exe
132         $(DEL) *_component_version_number.*
133
134 # Common lang target.
135 # Double colon (::) syntax allows supplemental lang target to be specified.
136 lang::
137
138
139 # Compiler include paths and preprocessor defines
140
141 afscdefs =\
142         -I. \
143         -I$(DESTDIR)\include \
144         -I$(DESTDIR)\include\afs \
145         -I$(DESTDIR)\include\rx \
146         -DWIN32_LEAN_AND_MEAN \
147         -DSTRICT
148
149 afscdefs = $(afscdefs) $(AFSDEV_AUXCDEFINES)
150
151
152 # Compiler switches (except include paths and preprocessor defines)
153 #
154 # Note: if conflicting options are specified, rightmost option applies.
155 #
156 # /Oy-  specifies no frame-pointer omission
157 # /GF   pool strings and place in read-only memory
158 # /Gd   use cdecl calling convention by default
159 # /Gy   enable function-level linking
160 # /GX   enable C++ exceptions (assumes extern C funcs never throw exceptions)
161 # /Os   favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
162
163 afscflags =\
164         /Oy- \
165         /GF \
166         /Gd \
167         /Gy \
168         /GX \
169         /Os
170
171 # Set optimization and debugging level based on build type.
172
173 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
174 #    Apply full optimization; generate full debug info in obj.
175 afscflags = $(afscflags) /Ox /Z7
176 ldebug = $(ldebug) -debugtype:both
177 cdebug = $(cdebug:-Od=)  # avoid annoying override warning (D4025)
178
179 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
180 #    Disable optimization; generate full debug info in obj.
181 afscflags = $(afscflags) /Od /Z7
182 ldebug = $(ldebug) -debugtype:both
183 !ENDIF
184
185 # Set compiler warning level
186
187 !IFNDEF AFSDEV_WARNLEVEL
188 AFSDEV_WARNLEVEL = 3
189 !ELSE
190 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
191      "$(AFSDEV_WARNLEVEL)" != "1" && \
192      "$(AFSDEV_WARNLEVEL)" != "2" && \
193      "$(AFSDEV_WARNLEVEL)" != "3" && \
194      "$(AFSDEV_WARNLEVEL)" != "4")
195 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
196 !ENDIF
197 !ENDIF
198
199 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
200
201
202 # Linker switches
203 #
204 # /FIXED:NO   generates a relocation section in the executable
205
206 afslflags =\
207         /FIXED:NO
208
209
210
211 # For checked builds, define DEBUG (but not the MS control flag _DEBUG).
212
213 !IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
214 afscdefs = $(afscdefs) -DDEBUG
215 !ENDIF
216
217 # Utilize the debug version of the MSVC runtime, if requested.
218
219 !IFDEF AFSDEV_CRTDEBUG
220 afscdefs = $(afscdefs) -D_DEBUG
221 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
222 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
223 !ENDIF
224
225 # Link with binmode.obj; files will be opened in binary mode by default.
226
227 !IFNDEF AFSDEV_TEXTMODE
228 conlibsdll = $(conlibsdll) binmode.obj
229 guilibsdll = $(guilibsdll) binmode.obj
230 !ENDIF
231
232
233 # Define MFC link and library macros
234 #     Note that MFC seems to make extensive use of default libraries,
235 #     thus we do not specify a general /NODEFAULTLIB.
236
237 mfclflags = $(guilflags)
238 mfclflags = $(mfclflags:/NODEFAULTLIB=)
239
240 mfcdlllflags = $(dlllflags)
241 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
242
243 mfclibsdll = $(guilibsdll)
244 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
245 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
246
247 !IFNDEF AFSDEV_CRTDEBUG
248 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
249 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
250 !ELSE
251 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrt.lib
252 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrt.lib
253 !ENDIF
254
255
256 # Macros for creating/modifying binary targets
257
258 # EXE link macro for console applications
259 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) $**
260
261 # EXE link macro for GUI applications
262 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
263
264 # EXE link macro for MFC applications
265 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
266
267 # DLL link macro for console applications
268 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
269
270 # DLL link macro for GUI applications
271 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
272
273 # DLL link macro for MFC applications
274 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
275
276 # DLL link macro for resource-only DLLs
277 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
278
279 # Library archive macro
280 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
281
282 # Language selection macro
283 NTLANG = $(DESTDIR)\bin\NTLang.bat
284
285
286 # EXE\DLL preparation macros
287 #     Rebase to avoid conflicts; strip symbols in free build.
288 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
289 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
290 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
291 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
292 EXEPREP = rebase -b 0x00400000 -q $@
293 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
294 !ENDIF
295
296 # C/C++ compilation macros
297 C2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
298 CPP2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
299
300 # Resource compiler macro
301 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS)
302
303 # Lex/Yacc macros
304 LEX = flex -l
305 YACC = bison
306
307 # Inference rules for building and installing targets
308
309 # Compile .c files
310 .c.obj:
311         $(C2OBJ) $*.c
312
313 # Compile .cpp files
314 .cpp.obj:
315         $(CPP2OBJ) $*.cpp
316
317 # Compile .rc (resource) files
318 .rc.res:
319         $(RC) $*.rc
320
321 # Install header files
322 .SUFFIXES: .h
323
324 .h.{$(DESTDIR)\include}.h:
325         $(COPY) $(*B).h $(DESTDIR)\include
326
327 .h.{$(DESTDIR)\include\afs}.h:
328         $(COPY) $(*B).h $(DESTDIR)\include\afs
329
330 .h.{$(DESTDIR)\include\rx}.h:
331         $(COPY) $(*B).h $(DESTDIR)\include\rx
332
333 .h.{$(DESTDIR)\include\WINNT}.h:
334         $(COPY) $(*B).h $(DESTDIR)\include\WINNT