debug-changes-20040406
[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 #
13 # Optional definitions:
14 #     AFSDEV_WARNLEVEL = [0 | 1 | 2 | 3 | 4]  (default is 3)
15 #     AFSDEV_AUXCDEFINES = <auxiliary C preprocessor defs> (default is null)
16 #     AFSDEV_AUXRCFLAGS = <auxiliary resource compiler flags> (default is null)
17 #     AFSDEV_AUXMIDLFLAGS = auxiliary midl flags
18 #     AFSDEV_TEXTMODE = <text mode is default if defined>  (default is null)
19 #     DEBUG_VERBOSE = optional debug statements for testing
20 #         AFS_OBJDIR - Location of object directory, either absolute or relative
21 #     AFSROOT - ROOT Directory so that $(AFSROOT)\scr is location of source
22 #
23 ############################################################################
24 #               Optional compliation flags
25 #               NO_CRTDBG - used to disable some builds for CFTDBG allocate mapping
26 #       _CRTDBG_MAP_ALLOC = <utilize crt debug C runtime if define> (default is null)
27 #               VADUMP - define VADUMP=1 if you are going to use the vadump utility and you are using V6.0
28 #
29 ####### Special optional defines
30
31 !IFNDEF NO_CRTDBG               #don't set _CRTDBG_MAP_ALLOC flag for some module compliations
32 #_CRTDBG_MAP_ALLOC=1
33 !ENDIF
34
35 #######
36
37 #sanity checks 
38
39 !IF EXISTS("TOOLS.INI")
40 !MESSAGE ************CAUTION TOOLS.INI IN EFFECT**********
41 !ENDIF
42 !IF ("$(AFSROOT)"=="")
43 !ERROR AFSROOT is not set
44 !ENDIF
45 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
46 AFSDEV_BUILDTYPE = NONE
47 !ELSE
48 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
49 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
50 !ENDIF
51 !ENDIF
52 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
53 !UNDEF _CRTDBG_MAP_ALLOC
54 !ENDIF
55
56 # Limit default include and library directories to those specified for build.
57
58 !IFNDEF AFSDEV_INCLUDE
59 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
60 !ENDIF
61
62 !IF ((!DEFINED(INCLUDE)) && ([set INCLUDE=$(AFSDEV_INCLUDE)] != 0))
63 #    If env. var. INCLUDE not defined then macro assignment won't set it.
64 !ERROR Failed setting environment variable INCLUDE.
65 !ENDIF
66 INCLUDE = $(AFSDEV_INCLUDE)
67
68
69 !IFNDEF AFSDEV_LIB
70 !ERROR Must define AFSDEV_LIB to be the default library directories.
71 !ENDIF
72
73 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
74 #    If env. var. LIB not defined then macro assignment won't set it.
75 !ERROR Failed setting environment variable LIB.
76 !ENDIF
77 LIB = $(AFSDEV_LIB)
78
79 #define used in WinNT/2000 installation and program version display
80 AFSPRODUCT_VER_MAJOR=1
81 AFSPRODUCT_VER_MINOR=3
82 AFSPRODUCT_VER_PATCH=6300
83 AFSPRODUCT_VER_BUILD=0
84 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
85 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
86 CELLNAME_DEFAULT=Your Cell Name
87 CELLSERVDB_INSTALL=CellServDB.GrandCentral
88 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
89 TARGETOS = WINNT
90
91 #               Define defaults folder locations
92 DEST=dest
93 SRC=src
94 OBJ=obj
95
96 !IF ("$(AFS_OBJDIR)"=="") 
97 #########  AFS_OBJDIR is NOT used use default locations
98 !  IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
99 DESTDIR=$(AFSROOT)\$(DEST)\checked
100 OJT=$(AFSROOT)\$(OBJ)\checked
101 !  ELSE
102 DESTDIR=$(AFSROOT)\$(DEST)\free
103 OJT=$(AFSROOT)\$(OBJ)\free
104 !  ENDIF
105 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
106 !ELSE
107 #########  AFS_OBJDIR is defined, use specific locations for obj and dest
108 # there is a special case for config because util_cr is not defined yet!
109 !  IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
110 #  AFS_OBJDIR is relative path
111 !    IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
112 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\checked
113 OJT=$(AFSROOT)\$(AFS_OBJDIR)\checked\config
114 !    ELSE
115 OJT=$(AFSROOT)\$(AFS_OBJDIR)\free\config
116 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\free
117 !    ENDIF
118 !  ELSE
119 !    IF (EXIST($(AFS_OBJDIR)))
120 #   AFS_OBJDIR is full path
121 !    IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
122 DESTDIR=$(AFS_OBJDIR)\$(DEST)\checked
123 OJT=$(AFS_OBJDIR)\checked\config
124 !      ELSE
125 DESTDIR=$(AFS_OBJDIR)\$(DEST)\free
126 OJT=$(AFS_OBJDIR)\free\config
127 !      ENDIF
128 !    ELSE
129 !ERROR Can't find location of DEST directory!
130 !    ENDIF
131 !  ENDIF
132 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
133
134 !  IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)") 
135 #    we are NOT doing a config make, use util_cr to generate object directory
136 !    IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
137 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
138 !    ENDIF
139
140 !    IF EXIST($(TMP)\home)
141 !INCLUDE $(TMP)\home
142 !    ELSE
143 !INCLUDE $(TEMP)\home
144 !    ENDIF
145 !  ENDIF
146 !ENDIF  #AFS_OBJDIR
147
148 !IF ("$(RELDIR)"=="")
149 OUT=$(OJT)
150 !ELSE
151 OUT=$(OJT)\$(RELDIR)
152 !ENDIF
153
154 !MESSAGE Directory assignments: 
155 !MESSAGE     OJT=[$(OJT)]
156 !MESSAGE     OUT=[$(OUT)] 
157 !MESSAGE DESTDIR=[$(DESTDIR)]
158
159 # Definitions provided here are based on WIN32.MAK, a common nmake
160 # file included with the MS SDK and MS VC distributions.
161 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
162 # port this nmake file if additional compiler support is required.
163
164 # !IF ("$(AFSVER_CL)"=="1300")
165 # afslflags = $(afslflags) /DEBUG
166 # !ENDIF
167
168 !IF ("$(APPVER)" == "")
169 APPVER=4.0
170 !ENDIF
171
172
173
174 !INCLUDE <WIN32.MAK>
175
176 # Extend and/or supplement definitions in WIN32.MAK.
177
178 # Command macros.
179 COPY = -copy
180 DEL = -del
181 MKDIR = -mkdir
182 REN = ren
183 ECHO = echo
184 CD = cd
185 MC = mc -vcsU
186 MAKECMD = nmake.exe
187
188 COMPILE_ET = $(DESTDIR)\bin\compile_et
189 RXGEN = $(DESTDIR)\bin\rxgen
190 MIDL  = midl
191
192 # Common clean target.
193 clean::
194         $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb
195         $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
196
197 # Common lang target.
198 lang::
199
200
201 #################### Compile optional build flags set ###########
202
203 afscdefs =\
204         -I. \
205         -I$(DESTDIR)\include \
206         -I$(DESTDIR)\include\afs \
207         -I$(DESTDIR)\include\rx \
208         -DWIN32_LEAN_AND_MEAN \
209         -DSTRICT \
210         -D_WIN32_IE=0x0500 \
211         -D_WIN32_WINNT=0x0500 \
212     -DWINVER=0x0500 \
213     -DREGISTER_POWER_NOTIFICATIONS \
214     -DAFS_AFSDB_ENV \
215     -DAFS_FREELANCE_CLIENT \
216     -DAFS_64BIT_ENV \
217         -DAFS_64BIT_CLIENT \
218          $(AFSDEV_AUXCDEFINES)
219
220 # Compiler switches (except include paths and preprocessor defines)
221 #
222 # Note: if conflicting options are specified, rightmost option applies.
223 #
224 # /Oy-  specifies no frame-pointer omission
225 # /GF   pool strings and place in read-only memory
226 # /Gd   use cdecl calling convention by default
227 # /Gy   enable function-level linking
228 # /GX   enable C++ exceptions (assumes extern C funcs never throw exceptions)
229 # /Os   favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
230
231 afscflags =\
232     /Oy- \
233         /GF \
234         /Gd \
235         /Gy \
236         /GX \
237         /Os
238
239 !IF ("$(AFSVER_CL)"!="1200")
240 afscdefs = $(afscdefs) /G7 /GT /GS /GZ /RTCs /RTCu
241 !ENDIF
242
243 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
244
245 afscflags = $(afscflags) /Ox
246 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
247 cvarsdll = $(cvarsdll:-MDd=-MD)
248 NODEBUG=1
249
250 !ELSE           # CHECKED BUILD
251 cdebug = $(cdebug:-Z7=-Zi)  # avoid annoying override warning (D4025)
252
253 !IF ("$(AFSVER_CL)"=="1200")
254 afscdefs = $(afscdefs) -DDEBUG
255 !ENDIF
256
257 !IFDEF _CRTDBG_MAP_ALLOC
258 afscflags = $(afscflags) -D_DEBUG -D_CRTDBG_MAP_ALLOC
259 !ENDIF
260
261 !UNDEF NODEBUG
262 !ENDIF
263
264 # Set compiler warning level
265
266 !IFNDEF AFSDEV_WARNLEVEL
267 AFSDEV_WARNLEVEL = 3
268 !ELSE
269 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
270      "$(AFSDEV_WARNLEVEL)" != "1" && \
271      "$(AFSDEV_WARNLEVEL)" != "2" && \
272      "$(AFSDEV_WARNLEVEL)" != "3" && \
273      "$(AFSDEV_WARNLEVEL)" != "4")
274 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
275 !ENDIF
276 !ENDIF
277
278 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
279
280 # C/C++ compilation macros
281 C2OBJ   = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c  
282 CPP2OBJ = $(C2OBJ)
283 # Inference rules for building and installing targets
284 # Compile .c files, from current directory to defined by OUT
285
286 .SUFFIXES: .c .rc 
287
288 .c{$(OUT)\}.obj:
289         $(C2OBJ) $<
290    
291 .c.obj:
292    $(C2OBJ) $<
293
294 .cpp{$(OUT)\}.obj:
295         $(CPP2OBJ) $<
296
297 .rc{$(OUT)\}.res:
298         $(RC) /fo$(OUT)\$(<B).res $<
299
300 # Compile .rc (resource) files
301 #.rc.res:
302 #       $(RC) $*.rc
303
304 .SUFFIXES: .h
305
306 .h.{$(DESTDIR)\include\afs}.h:
307         $(COPY) $< $(DESTDIR)\include\afs
308
309 .h.{$(DESTDIR)\include\rx}.h:
310         $(COPY) $< $(DESTDIR)\include\rx
311
312 .h.{$(DESTDIR)\include}.h:
313         $(COPY) $< $(DESTDIR)\include
314
315 .h.{$(DESTDIR)\include\WINNT}.h:
316         $(COPY) $< $(DESTDIR)\include\WINNT
317
318 .h.{$(DESTDIR)\include}.h:
319         $(COPY) $(*B).h $(DESTDIR)\include
320
321 .h.{$(DESTDIR)\include\afs}.h:
322         $(COPY) $(*B).h $(DESTDIR)\include\afs
323
324 .h.{$(DESTDIR)\include\rx}.h:
325         $(COPY) $(*B).h $(DESTDIR)\include\rx
326
327 .h.{$(DESTDIR)\include\WINNT}.h:
328         $(COPY) $(*B).h $(DESTDIR)\include\WINNT
329
330 # Resource compiler macro
331 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
332
333 #################### Link optional build flags set ###########
334
335 afslflags =\
336         /FIXED:NO /VERBOSE:LIB
337
338 mfclflags = $(guilflags)
339 mfclflags = $(mfclflags:/NODEFAULTLIB=)
340
341 mfcdlllflags = $(dlllflags)
342 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
343
344 mfclibsdll = $(guilibsdll)
345 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
346 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
347
348 # Link with binmode.obj; files will be opened in binary mode by default.
349 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
350
351 ldebug=
352 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
353 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
354
355 !ELSE   #CHECKED BUILD
356
357 # Generate debug information and pdb files 
358 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC 
359
360 #!IF ("AFSVER_CL"=="1200")
361 #ldebug = $(ldebug) -debugtype:cv 
362 #!ENDIF
363
364 # Disable optimization; generate full debug info in obj.
365 afscflags = $(afscflags) /Od /Zi
366
367 !IFDEF VADUMP
368 !IF ("AFSVER_CL"=="1200")
369 ldebug = $(ldebug) -debugtype:both
370 ldebug = $(ldebug:-debugtype:cv=)
371 !ENDIF #AFSVER_CL == 1200
372 !ENDIF #VADUMPT
373
374 !IFNDEF _CRTDBG_MAP_ALLOC
375 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
376 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
377
378 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
379 !IF ("$(AFSVER_CL)"=="1200")
380 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
381 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
382 !ENDIF #AFSVER_CL == 1200
383
384 !ELSE #_CRTDBG_MAP_ALLOC
385 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
386 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
387 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
388 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
389 !ENDIF #_CRTDBG_MAP_ALLOC
390
391 EXEPREP = rebase -b 0x00400000 -q $@
392 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
393
394 !ENDIF #CHECKED BUILD
395
396
397 # EXE link macro for console applications
398 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib  version.lib $**
399
400 # EXE link macro for GUI applications
401 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
402
403 # EXE link macro for MFC applications
404 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
405
406 # DLL link macro for console applications
407 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
408
409 # DLL link macro for GUI applications
410 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll)  $**
411 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
412 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
413
414 # DLL link macro for resource-only DLLs
415 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
416
417 # Library archive macro
418 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
419
420 # Language selection macro
421 NTLANG = $(DESTDIR)\bin\NTLang.bat
422
423 ######### MIDL FLAGS
424
425 !IFDEF OSISXP
426 AFSDEV_AUXMIDLFLAGS=/Oi
427 !ENDIF
428
429 # Lex/Yacc macros
430 LEX = flex -l
431 YACC = bison
432