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 ]
12 # AFSDEV_INCLUDE = <default include directories>
13 # AFSDEV_LIB = <default library directories>
14 # AFSDEV_BIN = <default build binary directories>
16 # Optional definitions:
17 # AFSDEV_DESTDIR = <top-level install directory> (default is $(AFSROOT)\DEST)
18 # AFSDEV_WARNLEVEL = [0 | 1 | 2 | 3 | 4] (default is 3)
19 # AFSDEV_AUXCDEFINES = <auxiliary C preprocessor defs> (default is null)
20 # AFSDEV_AUXRCFLAGS = <auxiliary resource compiler flags> (default is null)
21 # AFSDEV_TEXTMODE = <text mode is default if defined> (default is null)
22 # AFSDEV_CRTDEBUG = <utilize debug C runtime if define> (default is null)
24 ############################################################################
27 # Definitions provided here are based on WIN32.MAK, a common nmake
28 # file included with the MS SDK and MS VC distributions.
29 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
30 # port this nmake file if additional compiler support is required.
32 # Define default target-type macros required by WIN32.MAK.
33 # Allow them to be overriden in an NTMakefile or via an environment variable.
39 #define used in WinNT/2000 installation and program version display
40 AFSPRODUCT_VERSION=1.2.2 a
41 CELLNAME_DEFAULT=Your Cell Name
42 CELLSERVDB_INSTALL=CellServDB.GrandCentral
43 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
44 #NMAKE_DEFINES=-DDEBUG_VERBOSE
50 # Check that build type is correctly specified.
52 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
53 # Build type ignored when profiling or tuning.
54 AFSDEV_BUILDTYPE = NONE
57 # Build type must be checked or free.
58 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
59 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
64 # Limit default include and library directories to those specified for build.
66 !IFNDEF AFSDEV_INCLUDE
67 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
70 !IF ((!DEFINED(INCLUDE)) && ([set INCLUDE=$(AFSDEV_INCLUDE)] != 0))
71 # If env. var. INCLUDE not defined then macro assignment won't set it.
72 !ERROR Failed setting environment variable INCLUDE.
74 INCLUDE = $(AFSDEV_INCLUDE)
78 !ERROR Must define AFSDEV_LIB to be the default library directories.
81 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
82 # If env. var. LIB not defined then macro assignment won't set it.
83 !ERROR Failed setting environment variable LIB.
88 # Put default build binary directories at front of path.
91 !ERROR Must define AFSDEV_BIN to be the default build binary directories.
94 !IF ((!DEFINED(PATH)) && ([set PATH=$(AFSDEV_BIN)] != 0))
95 # If env. var. PATH not defined then macro assignment won't set it.
96 !ERROR Failed setting environment variable PATH.
98 PATH = $(AFSDEV_BIN);$(PATH)
101 # Undefine WIN32.MAK NODEBUG macro.
102 # Always generate full debug info, unless profiling or tuning (see below).
106 # Include WIN32.MAK nmake file
112 # Extend and/or supplement definitions in WIN32.MAK.
114 # Standard install directory.
115 !IFDEF AFSDEV_DESTDIR
116 DESTDIR = $(AFSDEV_DESTDIR)
118 DESTDIR = $(AFSROOT)\DEST
124 #DEL = $(DESTDIR)\BIN\rmbat # win 98 must use batch file
132 COMPILE_ET = $(DESTDIR)\bin\compile_et
133 RXGEN = $(DESTDIR)\bin\rxgen
136 # Common clean target.
137 # Double colon (::) syntax allows supplemental clean target to be specified.
139 $(DEL) /q *.obj *.lib *.dll *.exe
140 $(DEL) /q *_component_version_number.*
142 # Common lang target.
143 # Double colon (::) syntax allows supplemental lang target to be specified.
147 # Compiler include paths and preprocessor defines
151 -I$(DESTDIR)\include \
152 -I$(DESTDIR)\include\afs \
153 -I$(DESTDIR)\include\rx \
154 -DWIN32_LEAN_AND_MEAN \
158 -DAFS_FREELANCE_CLIENT
160 afscdefs = $(afscdefs) $(AFSDEV_AUXCDEFINES) $(NMAKE_DEFINES)
163 # Compiler switches (except include paths and preprocessor defines)
165 # Note: if conflicting options are specified, rightmost option applies.
167 # /Oy- specifies no frame-pointer omission
168 # /GF pool strings and place in read-only memory
169 # /Gd use cdecl calling convention by default
170 # /Gy enable function-level linking
171 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
172 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
182 # Set optimization and debugging level based on build type.
184 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
185 # Apply full optimization; generate full debug info in obj.
186 afscflags = $(afscflags) /Ox /Z7
187 ldebug = $(ldebug) -debugtype:both
188 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
190 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
191 # Disable optimization; generate full debug info in obj.
192 afscflags = $(afscflags) /Od /Z7
193 ldebug = $(ldebug) -debugtype:both
196 # Set compiler warning level
198 !IFNDEF AFSDEV_WARNLEVEL
201 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
202 "$(AFSDEV_WARNLEVEL)" != "1" && \
203 "$(AFSDEV_WARNLEVEL)" != "2" && \
204 "$(AFSDEV_WARNLEVEL)" != "3" && \
205 "$(AFSDEV_WARNLEVEL)" != "4")
206 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
210 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
215 # /FIXED:NO generates a relocation section in the executable
222 # For checked builds, define DEBUG (but not the MS control flag _DEBUG).
224 !IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
225 afscdefs = $(afscdefs) -DDEBUG
228 # Utilize the debug version of the MSVC runtime, if requested.
230 !IFDEF AFSDEV_CRTDEBUG
231 afscdefs = $(afscdefs) -D_DEBUG
232 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
233 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
236 # Link with binmode.obj; files will be opened in binary mode by default.
238 !IFNDEF AFSDEV_TEXTMODE
239 conlibsdll = $(conlibsdll) binmode.obj
240 guilibsdll = $(guilibsdll) binmode.obj
244 # Define MFC link and library macros
245 # Note that MFC seems to make extensive use of default libraries,
246 # thus we do not specify a general /NODEFAULTLIB.
248 mfclflags = $(guilflags)
249 mfclflags = $(mfclflags:/NODEFAULTLIB=)
251 mfcdlllflags = $(dlllflags)
252 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
254 mfclibsdll = $(guilibsdll)
255 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
256 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
258 !IFNDEF AFSDEV_CRTDEBUG
259 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
260 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
262 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrt.lib
263 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrt.lib
267 # Macros for creating/modifying binary targets
269 # EXE link macro for console applications
270 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) $**
272 # EXE link macro for GUI applications
273 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
275 # EXE link macro for MFC applications
276 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
278 # DLL link macro for console applications
279 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
281 # DLL link macro for GUI applications
282 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
284 # DLL link macro for MFC applications
285 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
287 # DLL link macro for resource-only DLLs
288 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
290 # Library archive macro
291 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
293 # Language selection macro
294 NTLANG = $(DESTDIR)\bin\NTLang.bat
297 # EXE\DLL preparation macros
298 # Rebase to avoid conflicts; strip symbols in free build.
299 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
300 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
301 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
302 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
303 EXEPREP = rebase -b 0x00400000 -q $@
304 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
307 # C/C++ compilation macros
308 C2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
309 CPP2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
311 # Resource compiler macro
312 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
318 # Inference rules for building and installing targets
328 # Compile .rc (resource) files
332 # Install header files
335 .h.{$(DESTDIR)\include}.h:
336 $(COPY) $(*B).h $(DESTDIR)\include
338 .h.{$(DESTDIR)\include\afs}.h:
339 $(COPY) $(*B).h $(DESTDIR)\include\afs
341 .h.{$(DESTDIR)\include\rx}.h:
342 $(COPY) $(*B).h $(DESTDIR)\include\rx
344 .h.{$(DESTDIR)\include\WINNT}.h:
345 $(COPY) $(*B).h $(DESTDIR)\include\WINNT