winnt-win2000-win98-afs-client-updates-20010623
[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 #DEL = $(DESTDIR)\BIN\rmbat        # win 98 must use batch file
118 MKDIR = mkdir
119 REN = ren
120 ECHO = echo
121 CD = cd
122 MC = mc -vcsU
123 MAKECMD = nmake.exe
124
125 COMPILE_ET = $(DESTDIR)\bin\compile_et
126 RXGEN = $(DESTDIR)\bin\rxgen
127 MIDL  = midl
128
129 # Common clean target.
130 # Double colon (::) syntax allows supplemental clean target to be specified.
131 clean::
132         $(DEL) /q *.obj *.lib *.dll *.exe
133         $(DEL) /q *_component_version_number.*
134
135 # Common lang target.
136 # Double colon (::) syntax allows supplemental lang target to be specified.
137 lang::
138
139
140 # Compiler include paths and preprocessor defines
141
142 afscdefs =\
143         -I. \
144         -I$(DESTDIR)\include \
145         -I$(DESTDIR)\include\afs \
146         -I$(DESTDIR)\include\rx \
147         -DWIN32_LEAN_AND_MEAN \
148         -DSTRICT \
149         -D_WIN32_IE=0x0400
150
151 afscdefs = $(afscdefs) $(AFSDEV_AUXCDEFINES)
152
153
154 # Compiler switches (except include paths and preprocessor defines)
155 #
156 # Note: if conflicting options are specified, rightmost option applies.
157 #
158 # /Oy-  specifies no frame-pointer omission
159 # /GF   pool strings and place in read-only memory
160 # /Gd   use cdecl calling convention by default
161 # /Gy   enable function-level linking
162 # /GX   enable C++ exceptions (assumes extern C funcs never throw exceptions)
163 # /Os   favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
164
165 afscflags =\
166         /Oy- \
167         /GF \
168         /Gd \
169         /Gy \
170         /GX \
171         /Os
172
173 # Set optimization and debugging level based on build type.
174
175 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
176 #    Apply full optimization; generate full debug info in obj.
177 afscflags = $(afscflags) /Ox /Z7
178 ldebug = $(ldebug) -debugtype:both
179 cdebug = $(cdebug:-Od=)  # avoid annoying override warning (D4025)
180
181 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
182 #    Disable optimization; generate full debug info in obj.
183 afscflags = $(afscflags) /Od /Z7
184 ldebug = $(ldebug) -debugtype:both
185 !ENDIF
186
187 # Set compiler warning level
188
189 !IFNDEF AFSDEV_WARNLEVEL
190 AFSDEV_WARNLEVEL = 3
191 !ELSE
192 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
193      "$(AFSDEV_WARNLEVEL)" != "1" && \
194      "$(AFSDEV_WARNLEVEL)" != "2" && \
195      "$(AFSDEV_WARNLEVEL)" != "3" && \
196      "$(AFSDEV_WARNLEVEL)" != "4")
197 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
198 !ENDIF
199 !ENDIF
200
201 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
202
203
204 # Linker switches
205 #
206 # /FIXED:NO   generates a relocation section in the executable
207
208 afslflags =\
209         /FIXED:NO
210
211
212
213 # For checked builds, define DEBUG (but not the MS control flag _DEBUG).
214
215 !IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
216 afscdefs = $(afscdefs) -DDEBUG
217 !ENDIF
218
219 # Utilize the debug version of the MSVC runtime, if requested.
220
221 !IFDEF AFSDEV_CRTDEBUG
222 afscdefs = $(afscdefs) -D_DEBUG
223 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
224 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
225 !ENDIF
226
227 # Link with binmode.obj; files will be opened in binary mode by default.
228
229 !IFNDEF AFSDEV_TEXTMODE
230 conlibsdll = $(conlibsdll) binmode.obj
231 guilibsdll = $(guilibsdll) binmode.obj
232 !ENDIF
233
234
235 # Define MFC link and library macros
236 #     Note that MFC seems to make extensive use of default libraries,
237 #     thus we do not specify a general /NODEFAULTLIB.
238
239 mfclflags = $(guilflags)
240 mfclflags = $(mfclflags:/NODEFAULTLIB=)
241
242 mfcdlllflags = $(dlllflags)
243 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
244
245 mfclibsdll = $(guilibsdll)
246 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
247 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
248
249 !IFNDEF AFSDEV_CRTDEBUG
250 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
251 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
252 !ELSE
253 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrt.lib
254 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrt.lib
255 !ENDIF
256
257
258 # Macros for creating/modifying binary targets
259
260 # EXE link macro for console applications
261 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) $**
262
263 # EXE link macro for GUI applications
264 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
265
266 # EXE link macro for MFC applications
267 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
268
269 # DLL link macro for console applications
270 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
271
272 # DLL link macro for GUI applications
273 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
274
275 # DLL link macro for MFC applications
276 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
277
278 # DLL link macro for resource-only DLLs
279 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
280
281 # Library archive macro
282 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
283
284 # Language selection macro
285 NTLANG = $(DESTDIR)\bin\NTLang.bat
286
287
288 # EXE\DLL preparation macros
289 #     Rebase to avoid conflicts; strip symbols in free build.
290 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
291 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
292 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
293 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
294 EXEPREP = rebase -b 0x00400000 -q $@
295 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
296 !ENDIF
297
298 # C/C++ compilation macros
299 C2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
300 CPP2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
301
302 # Resource compiler macro
303 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS)
304
305 # Lex/Yacc macros
306 LEX = flex -l
307 YACC = bison
308
309 # Inference rules for building and installing targets
310
311 # Compile .c files
312 .c.obj:
313         $(C2OBJ) $*.c
314
315 # Compile .cpp files
316 .cpp.obj:
317         $(CPP2OBJ) $*.cpp
318
319 # Compile .rc (resource) files
320 .rc.res:
321         $(RC) $*.rc
322
323 # Install header files
324 .SUFFIXES: .h
325
326 .h.{$(DESTDIR)\include}.h:
327         $(COPY) $(*B).h $(DESTDIR)\include
328
329 .h.{$(DESTDIR)\include\afs}.h:
330         $(COPY) $(*B).h $(DESTDIR)\include\afs
331
332 .h.{$(DESTDIR)\include\rx}.h:
333         $(COPY) $(*B).h $(DESTDIR)\include\rx
334
335 .h.{$(DESTDIR)\include\WINNT}.h:
336         $(COPY) $(*B).h $(DESTDIR)\include\WINNT