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