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 EXISTS("TOOLS.INI")
41 !MESSAGE ************CAUTION TOOLS.INI IN EFFECT**********
43 !IF ("$(AFSROOT)"=="")
44 !ERROR AFSROOT is not set
46 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
47 AFSDEV_BUILDTYPE = NONE
49 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
50 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
53 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
54 !UNDEF _CRTDBG_MAP_ALLOC
57 # Limit default include and library directories to those specified for build.
59 !IFNDEF AFSDEV_INCLUDE
60 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
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.
67 INCLUDE = $(AFSDEV_INCLUDE)
71 !ERROR Must define AFSDEV_LIB to be the default library directories.
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.
80 #define used in WinNT/2000 installation and program version display
81 AFSPRODUCT_VER_MAJOR=1
82 AFSPRODUCT_VER_MINOR=5
83 AFSPRODUCT_VER_PATCH=0000
84 AFSPRODUCT_VER_BUILD=0
86 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
87 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
88 # Set CELLNAME_DEFAULT to "your cell name"
89 CELLNAME_DEFAULT=openafs.org
90 CELLSERVDB_INSTALL=CellServDB.GrandCentral
91 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
94 # Define defaults folder locations
99 !IF ("$(AFS_OBJDIR)"=="")
100 ######### AFS_OBJDIR is NOT used use default locations
101 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
102 DESTDIR=$(AFSROOT)\$(DEST)\checked
103 OJT=$(AFSROOT)\$(OBJ)\checked
105 DESTDIR=$(AFSROOT)\$(DEST)\free
106 OJT=$(AFSROOT)\$(OBJ)\free
108 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
110 ######### AFS_OBJDIR is defined, use specific locations for obj and dest
111 # there is a special case for config because util_cr is not defined yet!
112 ! IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
113 # AFS_OBJDIR is relative path
114 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
115 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\checked
116 OJT=$(AFSROOT)\$(AFS_OBJDIR)\checked\config
118 OJT=$(AFSROOT)\$(AFS_OBJDIR)\free\config
119 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\free
122 ! IF (EXIST($(AFS_OBJDIR)))
123 # AFS_OBJDIR is full path
124 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
125 DESTDIR=$(AFS_OBJDIR)\$(DEST)\checked
126 OJT=$(AFS_OBJDIR)\checked\config
128 DESTDIR=$(AFS_OBJDIR)\$(DEST)\free
129 OJT=$(AFS_OBJDIR)\free\config
132 !ERROR Can't find location of DEST directory!
135 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
137 ! IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)")
138 # we are NOT doing a config make, use util_cr to generate object directory
139 ! IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
140 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
143 ! IF EXIST($(TMP)\home)
146 !INCLUDE $(TEMP)\home
151 !IF ("$(RELDIR)"=="")
157 !MESSAGE Directory assignments:
158 !MESSAGE OJT=[$(OJT)]
159 !MESSAGE OUT=[$(OUT)]
160 !MESSAGE DESTDIR=[$(DESTDIR)]
162 # Definitions provided here are based on WIN32.MAK, a common nmake
163 # file included with the MS SDK and MS VC distributions.
164 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
165 # port this nmake file if additional compiler support is required.
167 # !IF ("$(AFSVER_CL)"=="1300")
168 # afslflags = $(afslflags) /DEBUG
171 !IF ("$(APPVER)" == "")
179 # Extend and/or supplement definitions in WIN32.MAK.
191 COMPILE_ET = $(DESTDIR)\bin\compile_et
192 RXGEN = $(DESTDIR)\bin\rxgen
195 # Common clean target.
197 $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb
198 $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
200 # Common lang target.
204 #################### Compile optional build flags set ###########
208 -I$(DESTDIR)\include \
209 -I$(DESTDIR)\include\afs \
210 -I$(DESTDIR)\include\rx \
211 -DWIN32_LEAN_AND_MEAN \
214 -D_WIN32_WINNT=0x0500 \
216 -DREGISTER_POWER_NOTIFICATIONS \
218 -DAFS_FREELANCE_CLIENT \
221 $(AFSDEV_AUXCDEFINES)
223 # Compiler switches (except include paths and preprocessor defines)
225 # Note: if conflicting options are specified, rightmost option applies.
227 # /Oy- specifies no frame-pointer omission
228 # /GF pool strings and place in read-only memory
229 # /Gd use cdecl calling convention by default
230 # /Gy enable function-level linking
231 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
232 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
241 !IF ("$(AFSVER_CL)"=="1400")
242 afscflags = $(afscflags) /EHsc /wd4996
244 afscflags = $(afscflags) /GX
247 !IF ("$(AFSVER_CL)"!="1200")
248 afscdefs = $(afscdefs) /GT /GS
250 !IF ("$(AFSVER_CL)"!="1400")
251 afscdefs = $(afscdefs) /G7
255 !IF ("$(AFSIFS)" == "TRUE")
256 afscdefs = $(afscdefs) -DAFSIFS
259 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
261 afscflags = $(afscflags) /Ox /Zi
262 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
263 cvarsdll = $(cvarsdll:-MDd=-MD)
266 !ELSE # CHECKED BUILD
267 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
269 !IF ("$(AFSVER_CL)"=="1200")
270 afscdefs = $(afscdefs) -DDEBUG
271 afscflags = $(afscflags) /GZ
273 afscdefs = $(afscdefs) -DDEBUG
274 afscflags = $(afscflags) /RTCs /RTCu
277 !IFDEF _CRTDBG_MAP_ALLOC
278 afscdefs = $(afscdefs) -D_DEBUG -D_CRTDBG_MAP_ALLOC
284 # Set compiler warning level
286 !IFNDEF AFSDEV_WARNLEVEL
289 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
290 "$(AFSDEV_WARNLEVEL)" != "1" && \
291 "$(AFSDEV_WARNLEVEL)" != "2" && \
292 "$(AFSDEV_WARNLEVEL)" != "3" && \
293 "$(AFSDEV_WARNLEVEL)" != "4")
294 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
298 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
300 # C/C++ compilation macros
301 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(dafsifs) $(cvarsdll) $(afscflags) $(afscdefs) /c
303 # Inference rules for building and installing targets
304 # Compile .c files, from current directory to defined by OUT
318 $(RC) /fo$(OUT)\$(<B).res $<
320 # Compile .rc (resource) files
326 .h.{$(DESTDIR)\include\afs}.h:
327 $(COPY) $< $(DESTDIR)\include\afs
329 .h.{$(DESTDIR)\include\rx}.h:
330 $(COPY) $< $(DESTDIR)\include\rx
332 .h.{$(DESTDIR)\include}.h:
333 $(COPY) $< $(DESTDIR)\include
335 .h.{$(DESTDIR)\include\WINNT}.h:
336 $(COPY) $< $(DESTDIR)\include\WINNT
338 .h.{$(DESTDIR)\include}.h:
339 $(COPY) $(*B).h $(DESTDIR)\include
341 .h.{$(DESTDIR)\include\afs}.h:
342 $(COPY) $(*B).h $(DESTDIR)\include\afs
344 .h.{$(DESTDIR)\include\rx}.h:
345 $(COPY) $(*B).h $(DESTDIR)\include\rx
347 .h.{$(DESTDIR)\include\WINNT}.h:
348 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
350 # Resource compiler macro
351 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
353 #################### Link optional build flags set ###########
356 /FIXED:NO /VERBOSE:LIB
358 mfclflags = $(guilflags)
359 mfclflags = $(mfclflags:/NODEFAULTLIB=)
361 mfcdlllflags = $(dlllflags)
362 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
364 mfclibsdll = $(guilibsdll)
365 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
366 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
368 # Link with binmode.obj; files will be opened in binary mode by default.
369 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
371 ldebug=/DEBUG /PDB:$*.pdb
372 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
373 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
377 # Generate debug information and pdb files
378 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
380 #!IF ("AFSVER_CL"=="1200")
381 #ldebug = $(ldebug) -debugtype:cv
384 # Disable optimization; generate full debug info in obj.
385 afscflags = $(afscflags) /Od /Zi
388 !IF ("AFSVER_CL"=="1200")
389 ldebug = $(ldebug) -debugtype:both
390 ldebug = $(ldebug:-debugtype:cv=)
391 !ENDIF #AFSVER_CL == 1200
394 !IFNDEF _CRTDBG_MAP_ALLOC
395 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
396 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
398 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
399 !IF ("$(AFSVER_CL)"=="1200")
400 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
401 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
402 !ENDIF #AFSVER_CL == 1200
404 !ELSE #_CRTDBG_MAP_ALLOC
405 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
406 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
407 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
408 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
409 !ENDIF #_CRTDBG_MAP_ALLOC
411 EXEPREP = rebase -b 0x00400000 -q $@
412 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
414 !ENDIF #CHECKED BUILD
417 # EXE link macro for console applications
418 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
420 # EXE link macro for GUI applications
421 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
423 # EXE link macro for MFC applications
424 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
426 # DLL link macro for console applications
427 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
429 # DLL link macro for GUI applications
430 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
431 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
432 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
434 # DLL link macro for resource-only DLLs
435 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
437 # Library archive macro
438 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
440 # Language selection macro
441 NTLANG = $(DESTDIR)\bin\NTLang.bat
446 AFSDEV_AUXMIDLFLAGS=/Oi