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
31 !IFNDEF NO_CRTDBG #don't set _CRTDBG_MAP_ALLOC flag for some module compliations
39 !IF EXISTS("TOOLS.INI")
40 !MESSAGE ************CAUTION TOOLS.INI IN EFFECT**********
42 !IF ("$(AFSROOT)"=="")
43 !ERROR AFSROOT is not set
45 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
46 AFSDEV_BUILDTYPE = NONE
48 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
49 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
52 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
53 !UNDEF _CRTDBG_MAP_ALLOC
56 # Limit default include and library directories to those specified for build.
58 !IFNDEF AFSDEV_INCLUDE
59 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
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.
66 INCLUDE = $(AFSDEV_INCLUDE)
70 !ERROR Must define AFSDEV_LIB to be the default library directories.
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.
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=7001
83 AFSPRODUCT_VER_BUILD=0
85 # For MSI installer, each major release should have a different GUID
86 AFSPRODUCT_VER_GUID=CCAF9E14-976E-46C0-8A1B-A218EAB7ADC5
88 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
89 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
90 # Set CELLNAME_DEFAULT to "your cell name"
91 CELLNAME_DEFAULT=openafs.org
92 CELLSERVDB_INSTALL=CellServDB.GrandCentral
93 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
96 # Define defaults folder locations
101 !IF ("$(AFS_OBJDIR)"=="")
102 ######### AFS_OBJDIR is NOT used use default locations
103 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
104 DESTDIR=$(AFSROOT)\$(DEST)\checked
105 OJT=$(AFSROOT)\$(OBJ)\checked
107 DESTDIR=$(AFSROOT)\$(DEST)\free
108 OJT=$(AFSROOT)\$(OBJ)\free
110 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
112 ######### AFS_OBJDIR is defined, use specific locations for obj and dest
113 # there is a special case for config because util_cr is not defined yet!
114 ! IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
115 # AFS_OBJDIR is relative path
116 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
117 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\checked
118 OJT=$(AFSROOT)\$(AFS_OBJDIR)\checked\config
120 OJT=$(AFSROOT)\$(AFS_OBJDIR)\free\config
121 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\free
124 ! IF (EXIST($(AFS_OBJDIR)))
125 # AFS_OBJDIR is full path
126 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
127 DESTDIR=$(AFS_OBJDIR)\$(DEST)\checked
128 OJT=$(AFS_OBJDIR)\checked\config
130 DESTDIR=$(AFS_OBJDIR)\$(DEST)\free
131 OJT=$(AFS_OBJDIR)\free\config
134 !ERROR Can't find location of DEST directory!
137 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
139 ! IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)")
140 # we are NOT doing a config make, use util_cr to generate object directory
141 ! IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
142 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
145 ! IF EXIST($(TMP)\home)
148 !INCLUDE $(TEMP)\home
153 !IF ("$(RELDIR)"=="")
159 !MESSAGE Directory assignments:
160 !MESSAGE OJT=[$(OJT)]
161 !MESSAGE OUT=[$(OUT)]
162 !MESSAGE DESTDIR=[$(DESTDIR)]
164 # Definitions provided here are based on WIN32.MAK, a common nmake
165 # file included with the MS SDK and MS VC distributions.
166 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
167 # port this nmake file if additional compiler support is required.
169 # !IF ("$(AFSVER_CL)"=="1300")
170 # afslflags = $(afslflags) /DEBUG
173 !IF ("$(APPVER)" == "")
181 # Extend and/or supplement definitions in WIN32.MAK.
193 COMPILE_ET = $(DESTDIR)\bin\compile_et
194 RXGEN = $(DESTDIR)\bin\rxgen
197 # Common clean target.
199 $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb
200 $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
202 # Common lang target.
206 #################### Compile optional build flags set ###########
210 -I$(DESTDIR)\include \
211 -I$(DESTDIR)\include\afs \
212 -I$(DESTDIR)\include\rx \
213 -DWIN32_LEAN_AND_MEAN \
216 -D_WIN32_WINNT=0x0500 \
218 -DREGISTER_POWER_NOTIFICATIONS \
220 -DAFS_FREELANCE_CLIENT \
223 $(AFSDEV_AUXCDEFINES)
225 # Compiler switches (except include paths and preprocessor defines)
227 # Note: if conflicting options are specified, rightmost option applies.
229 # /Oy- specifies no frame-pointer omission
230 # /GF pool strings and place in read-only memory
231 # /Gd use cdecl calling convention by default
232 # /Gy enable function-level linking
233 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
234 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
243 !IF ("$(AFSVER_CL)"=="1400")
244 afscflags = $(afscflags) /EHsc /wd4996
246 afscflags = $(afscflags) /GX
249 !IF ("$(AFSVER_CL)"!="1200")
250 afscdefs = $(afscdefs) /GT /GS
252 !IF ("$(AFSVER_CL)"!="1400")
253 afscdefs = $(afscdefs) /G7
257 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
259 afscflags = $(afscflags) /Ox /Zi
260 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
261 cvarsdll = $(cvarsdll:-MDd=-MD)
264 !ELSE # CHECKED BUILD
265 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
267 !IF ("$(AFSVER_CL)"=="1200")
268 afscdefs = $(afscdefs) -DDEBUG /GZ
270 afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
273 !IFDEF _CRTDBG_MAP_ALLOC
274 afscflags = $(afscflags) -D_DEBUG -D_CRTDBG_MAP_ALLOC
280 # Set compiler warning level
282 !IFNDEF AFSDEV_WARNLEVEL
285 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
286 "$(AFSDEV_WARNLEVEL)" != "1" && \
287 "$(AFSDEV_WARNLEVEL)" != "2" && \
288 "$(AFSDEV_WARNLEVEL)" != "3" && \
289 "$(AFSDEV_WARNLEVEL)" != "4")
290 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
294 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
296 # C/C++ compilation macros
297 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
299 # Inference rules for building and installing targets
300 # Compile .c files, from current directory to defined by OUT
314 $(RC) /fo$(OUT)\$(<B).res $<
316 # Compile .rc (resource) files
322 .h.{$(DESTDIR)\include\afs}.h:
323 $(COPY) $< $(DESTDIR)\include\afs
325 .h.{$(DESTDIR)\include\rx}.h:
326 $(COPY) $< $(DESTDIR)\include\rx
328 .h.{$(DESTDIR)\include}.h:
329 $(COPY) $< $(DESTDIR)\include
331 .h.{$(DESTDIR)\include\WINNT}.h:
332 $(COPY) $< $(DESTDIR)\include\WINNT
334 .h.{$(DESTDIR)\include}.h:
335 $(COPY) $(*B).h $(DESTDIR)\include
337 .h.{$(DESTDIR)\include\afs}.h:
338 $(COPY) $(*B).h $(DESTDIR)\include\afs
340 .h.{$(DESTDIR)\include\rx}.h:
341 $(COPY) $(*B).h $(DESTDIR)\include\rx
343 .h.{$(DESTDIR)\include\WINNT}.h:
344 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
346 # Resource compiler macro
347 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
349 #################### Link optional build flags set ###########
352 /FIXED:NO /VERBOSE:LIB
354 mfclflags = $(guilflags)
355 mfclflags = $(mfclflags:/NODEFAULTLIB=)
357 mfcdlllflags = $(dlllflags)
358 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
360 mfclibsdll = $(guilibsdll)
361 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
362 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
364 # Link with binmode.obj; files will be opened in binary mode by default.
365 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
367 ldebug=/DEBUG /PDB:$*.pdb
368 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
369 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
373 # Generate debug information and pdb files
374 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
376 #!IF ("AFSVER_CL"=="1200")
377 #ldebug = $(ldebug) -debugtype:cv
380 # Disable optimization; generate full debug info in obj.
381 afscflags = $(afscflags) /Od /Zi
384 !IF ("AFSVER_CL"=="1200")
385 ldebug = $(ldebug) -debugtype:both
386 ldebug = $(ldebug:-debugtype:cv=)
387 !ENDIF #AFSVER_CL == 1200
390 !IFNDEF _CRTDBG_MAP_ALLOC
391 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
392 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
394 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
395 !IF ("$(AFSVER_CL)"=="1200")
396 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
397 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
398 !ENDIF #AFSVER_CL == 1200
400 !ELSE #_CRTDBG_MAP_ALLOC
401 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
402 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
403 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
404 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
405 !ENDIF #_CRTDBG_MAP_ALLOC
407 EXEPREP = rebase -b 0x00400000 -q $@
408 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
410 !ENDIF #CHECKED BUILD
413 # EXE link macro for console applications
414 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
416 # EXE link macro for GUI applications
417 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
419 # EXE link macro for MFC applications
420 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
422 # DLL link macro for console applications
423 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
425 # DLL link macro for GUI applications
426 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
427 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
428 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
430 # DLL link macro for resource-only DLLs
431 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
433 # Library archive macro
434 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
436 # Language selection macro
437 NTLANG = $(DESTDIR)\bin\NTLang.bat
442 AFSDEV_AUXMIDLFLAGS=/Oi