1 # Copyright 2000, International Business Machines Corporation and others.
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
8 # Common nmake file to be included in each NTMakfile.
10 # Required definitions:
11 # AFSDEV_BUILDTYPE = [ CHECKED | FREE ]
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
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
29 ####### Special optional defines
32 #don't set _CRTDBG_MAP_ALLOC flag for some module compliations
40 !IF ("$(CPU)" != "x86")
44 !IF ("$(CPU)" != "i386")
45 !ERROR Platform SDK not configured for i386
48 !IF EXISTS("TOOLS.INI")
49 !MESSAGE ************CAUTION TOOLS.INI IN EFFECT**********
51 !IF ("$(AFSROOT)"=="")
52 !ERROR AFSROOT is not set
54 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
55 AFSDEV_BUILDTYPE = NONE
57 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
58 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
61 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
62 !UNDEF _CRTDBG_MAP_ALLOC
65 # Limit default include and library directories to those specified for build.
67 !IFNDEF AFSDEV_INCLUDE
68 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
71 !IF ((!DEFINED(INCLUDE)) && ([set INCLUDE=$(AFSDEV_INCLUDE)] != 0))
72 # If env. var. INCLUDE not defined then macro assignment won't set it.
73 !ERROR Failed setting environment variable INCLUDE.
75 INCLUDE = $(AFSDEV_INCLUDE)
79 !ERROR Must define AFSDEV_LIB to be the default library directories.
82 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
83 # If env. var. LIB not defined then macro assignment won't set it.
84 !ERROR Failed setting environment variable LIB.
88 #define used in WinNT/2000 installation and program version display
89 AFSPRODUCT_VER_MAJOR=2
90 AFSPRODUCT_VER_MINOR=0
91 AFSPRODUCT_VER_PATCH=0
92 AFSPRODUCT_VER_BUILD=0
94 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
95 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
96 # Set CELLNAME_DEFAULT to "your cell name"
97 CELLNAME_DEFAULT=openafs.org
98 CELLSERVDB_INSTALL=CellServDB.GrandCentral
99 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
102 # Define defaults folder locations
107 !IF ("$(AFS_OBJDIR)"=="")
108 ######### AFS_OBJDIR is NOT used use default locations
109 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
110 DESTDIR=$(AFSROOT)\$(DEST)\$(SYS_NAME)\checked
111 OJT=$(AFSROOT)\$(OBJ)\$(SYS_NAME)\checked
113 DESTDIR=$(AFSROOT)\$(DEST)\$(SYS_NAME)\free
114 OJT=$(AFSROOT)\$(OBJ)\$(SYS_NAME)\free
116 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
118 ######### AFS_OBJDIR is defined, use specific locations for obj and dest
119 # there is a special case for config because util_cr is not defined yet!
120 ! IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
121 # AFS_OBJDIR is relative path
122 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
123 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
124 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
126 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\free\config
127 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
130 ! IF (EXIST($(AFS_OBJDIR)))
131 # AFS_OBJDIR is full path
132 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
133 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
134 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
136 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
137 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\free\config
140 !ERROR Can't find location of DEST directory!
143 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
145 ! IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)")
146 # we are NOT doing a config make, use util_cr to generate object directory
147 ! IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
148 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
151 ! IF EXIST($(TMP)\home)
154 !INCLUDE $(TEMP)\home
159 !IF ("$(RELDIR)"=="")
165 !MESSAGE Directory assignments:
166 !MESSAGE OJT=[$(OJT)]
167 !MESSAGE OUT=[$(OUT)]
168 !MESSAGE DESTDIR=[$(DESTDIR)]
170 # Definitions provided here are based on WIN32.MAK, a common nmake
171 # file included with the MS SDK and MS VC distributions.
172 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
173 # port this nmake file if additional compiler support is required.
175 # !IF ("$(AFSVER_CL)"=="1300")
176 # afslflags = $(afslflags) /DEBUG
179 !IF ("$(APPVER)" == "")
187 # Extend and/or supplement definitions in WIN32.MAK.
199 COMPILE_ET = $(DESTDIR)\bin\compile_et
200 RXGEN = $(DESTDIR)\bin\rxgen
203 # Common clean target.
205 $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb
206 $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
208 # Common lang target.
212 #################### Compile optional build flags set ###########
216 -I$(DESTDIR)\include \
217 -I$(DESTDIR)\include\afs \
218 -I$(DESTDIR)\include\rx \
219 -DWIN32_LEAN_AND_MEAN \
222 -D_WIN32_WINNT=0x0500 \
224 -DREGISTER_POWER_NOTIFICATIONS \
226 -DAFS_FREELANCE_CLIENT \
229 -DAFS_LARGEFILE_ENV \
231 $(AFSDEV_AUXCDEFINES)
233 # Compiler switches (except include paths and preprocessor defines)
235 # Note: if conflicting options are specified, rightmost option applies.
237 # /Oy- specifies no frame-pointer omission
238 # /GF pool strings and place in read-only memory
239 # /Gd use cdecl calling convention by default
240 # /Gy enable function-level linking
241 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
242 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
243 # /Wp64 enable 64-bit porting warnings (conflicts with warnings as errors
244 # due to SDK mapping of Get/SetWindowLongPtr to Get/SetWindowLong
253 !IF ("$(AFSVER_CL)"=="1400")
254 afscflags = $(afscflags) /EHsc /wd4996
256 afscflags = $(afscflags) /GX
259 !IF ("$(AFSVER_CL)"!="1200")
260 afscflags = $(afscflags) /GT /GS
262 !IF ("$(AFSVER_CL)"!="1400")
263 afscflags = $(afscflags) /G7
267 !IF ("$(AFSIFS)" == "TRUE")
268 afscdefs = $(afscdefs) -DAFSIFS
271 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
273 afscflags = $(afscflags) /Ox /Zi
274 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
275 cvarsdll = $(cvarsdll:-MDd=-MD)
277 _VC_MANIFEST_BASENAME = __OAFW
279 !ELSE # CHECKED BUILD
280 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
282 !IF ("$(AFSVER_CL)"=="1200")
283 afscdefs = $(afscdefs) -DDEBUG /GZ
285 afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
288 !IFDEF _CRTDBG_MAP_ALLOC
289 afscflags = $(afscflags) -D_DEBUG -D_CRTDBG_MAP_ALLOC
293 _VC_MANIFEST_BASENAME = __OAFW.Debug
296 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)" == "1310")
297 _VC_MANIFEST_EMBED_EXE= \
298 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;1
300 _VC_MANIFEST_EMBED_DLL= \
301 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;2
303 _VC_MANIFEST_EMBED_EXE=
304 _VC_MANIFEST_EMBED_DLL=
307 # Set compiler warning level
309 !IFNDEF AFSDEV_WARNLEVEL
312 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
313 "$(AFSDEV_WARNLEVEL)" != "1" && \
314 "$(AFSDEV_WARNLEVEL)" != "2" && \
315 "$(AFSDEV_WARNLEVEL)" != "3" && \
316 "$(AFSDEV_WARNLEVEL)" != "4")
317 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
321 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
323 # C/C++ compilation macros
324 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
326 # Inference rules for building and installing targets
327 # Compile .c files, from current directory to defined by OUT
341 $(RC) /fo$(OUT)\$(<B).res $<
343 # Compile .rc (resource) files
349 .h.{$(DESTDIR)\include\afs}.h:
350 $(COPY) $< $(DESTDIR)\include\afs
352 .h.{$(DESTDIR)\include\rx}.h:
353 $(COPY) $< $(DESTDIR)\include\rx
355 .h.{$(DESTDIR)\include}.h:
356 $(COPY) $< $(DESTDIR)\include
358 .h.{$(DESTDIR)\include\WINNT}.h:
359 $(COPY) $< $(DESTDIR)\include\WINNT
361 .h.{$(DESTDIR)\include}.h:
362 $(COPY) $(*B).h $(DESTDIR)\include
364 .h.{$(DESTDIR)\include\afs}.h:
365 $(COPY) $(*B).h $(DESTDIR)\include\afs
367 .h.{$(DESTDIR)\include\rx}.h:
368 $(COPY) $(*B).h $(DESTDIR)\include\rx
370 .h.{$(DESTDIR)\include\WINNT}.h:
371 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
373 # Resource compiler macro
374 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
376 #################### Link optional build flags set ###########
379 /FIXED:NO /VERBOSE:LIB /MACHINE:I386
381 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1310")
382 afslflags = $(afslflags) /MANIFEST
385 mfclflags = $(guilflags)
386 mfclflags = $(mfclflags:/NODEFAULTLIB=)
388 mfcdlllflags = $(dlllflags)
389 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
391 mfclibsdll = $(guilibsdll)
392 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
393 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
395 # Link with binmode.obj; files will be opened in binary mode by default.
396 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
398 ldebug=/DEBUG /PDB:$*.pdb
399 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
400 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
404 # Generate debug information and pdb files
405 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
407 #!IF ("AFSVER_CL"=="1200")
408 #ldebug = $(ldebug) -debugtype:cv
411 # Disable optimization; generate full debug info in obj.
412 afscflags = $(afscflags) /Od /Zi
415 !IF ("AFSVER_CL"=="1200")
416 ldebug = $(ldebug) -debugtype:both
417 ldebug = $(ldebug:-debugtype:cv=)
418 !ENDIF #AFSVER_CL == 1200
421 !IFNDEF _CRTDBG_MAP_ALLOC
422 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
423 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
425 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
426 !IF ("$(AFSVER_CL)"=="1200")
427 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
428 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
429 !ENDIF #AFSVER_CL == 1200
431 !ELSE #_CRTDBG_MAP_ALLOC
432 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
433 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
434 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
435 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
436 !ENDIF #_CRTDBG_MAP_ALLOC
438 EXEPREP = rebase -b 0x00400000 -q $@
439 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
441 !ENDIF #CHECKED BUILD
444 # EXE link macro for console applications
445 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
447 # EXE link macro for GUI applications
448 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
450 # EXE link macro for MFC applications
451 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
453 # DLL link macro for console applications
454 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
456 # DLL link macro for GUI applications
457 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
458 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
459 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
461 # DLL link macro for resource-only DLLs
462 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
464 # Library archive macro
465 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
467 # Language selection macro
468 NTLANG = $(DESTDIR)\bin\NTLang.bat
472 AFSDEV_AUXMIDLFLAGS=/env win32 /win32 /no_robust /Oicf