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.1.1 a
41 CELLNAME_DEFAULT=Your Cell Name
42 CELLSERVDB_INSTALL=CellServDB.GrandCentral
43 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
49 # Check that build type is correctly specified.
51 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
52 # Build type ignored when profiling or tuning.
53 AFSDEV_BUILDTYPE = NONE
56 # Build type must be checked or free.
57 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
58 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
63 # Limit default include and library directories to those specified for build.
65 !IFNDEF AFSDEV_INCLUDE
66 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
69 !IF ((!DEFINED(INCLUDE)) && ([set INCLUDE=$(AFSDEV_INCLUDE)] != 0))
70 # If env. var. INCLUDE not defined then macro assignment won't set it.
71 !ERROR Failed setting environment variable INCLUDE.
73 INCLUDE = $(AFSDEV_INCLUDE)
77 !ERROR Must define AFSDEV_LIB to be the default library directories.
80 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
81 # If env. var. LIB not defined then macro assignment won't set it.
82 !ERROR Failed setting environment variable LIB.
87 # Put default build binary directories at front of path.
90 !ERROR Must define AFSDEV_BIN to be the default build binary directories.
93 !IF ((!DEFINED(PATH)) && ([set PATH=$(AFSDEV_BIN)] != 0))
94 # If env. var. PATH not defined then macro assignment won't set it.
95 !ERROR Failed setting environment variable PATH.
97 PATH = $(AFSDEV_BIN);$(PATH)
100 # Undefine WIN32.MAK NODEBUG macro.
101 # Always generate full debug info, unless profiling or tuning (see below).
105 # Include WIN32.MAK nmake file
111 # Extend and/or supplement definitions in WIN32.MAK.
113 # Standard install directory.
114 !IFDEF AFSDEV_DESTDIR
115 DESTDIR = $(AFSDEV_DESTDIR)
117 DESTDIR = $(AFSROOT)\DEST
123 #DEL = $(DESTDIR)\BIN\rmbat # win 98 must use batch file
131 COMPILE_ET = $(DESTDIR)\bin\compile_et
132 RXGEN = $(DESTDIR)\bin\rxgen
135 # Common clean target.
136 # Double colon (::) syntax allows supplemental clean target to be specified.
138 $(DEL) /q *.obj *.lib *.dll *.exe
139 $(DEL) /q *_component_version_number.*
141 # Common lang target.
142 # Double colon (::) syntax allows supplemental lang target to be specified.
146 # Compiler include paths and preprocessor defines
150 -I$(DESTDIR)\include \
151 -I$(DESTDIR)\include\afs \
152 -I$(DESTDIR)\include\rx \
153 -DWIN32_LEAN_AND_MEAN \
157 -DAFS_FREELANCE_CLIENT
159 afscdefs = $(afscdefs) $(AFSDEV_AUXCDEFINES)
162 # Compiler switches (except include paths and preprocessor defines)
164 # Note: if conflicting options are specified, rightmost option applies.
166 # /Oy- specifies no frame-pointer omission
167 # /GF pool strings and place in read-only memory
168 # /Gd use cdecl calling convention by default
169 # /Gy enable function-level linking
170 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
171 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
181 # Set optimization and debugging level based on build type.
183 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
184 # Apply full optimization; generate full debug info in obj.
185 afscflags = $(afscflags) /Ox /Z7
186 ldebug = $(ldebug) -debugtype:both
187 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
189 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
190 # Disable optimization; generate full debug info in obj.
191 afscflags = $(afscflags) /Od /Z7
192 ldebug = $(ldebug) -debugtype:both
195 # Set compiler warning level
197 !IFNDEF AFSDEV_WARNLEVEL
200 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
201 "$(AFSDEV_WARNLEVEL)" != "1" && \
202 "$(AFSDEV_WARNLEVEL)" != "2" && \
203 "$(AFSDEV_WARNLEVEL)" != "3" && \
204 "$(AFSDEV_WARNLEVEL)" != "4")
205 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
209 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
214 # /FIXED:NO generates a relocation section in the executable
221 # For checked builds, define DEBUG (but not the MS control flag _DEBUG).
223 !IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
224 afscdefs = $(afscdefs) -DDEBUG
227 # Utilize the debug version of the MSVC runtime, if requested.
229 !IFDEF AFSDEV_CRTDEBUG
230 afscdefs = $(afscdefs) -D_DEBUG
231 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
232 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
235 # Link with binmode.obj; files will be opened in binary mode by default.
237 !IFNDEF AFSDEV_TEXTMODE
238 conlibsdll = $(conlibsdll) binmode.obj
239 guilibsdll = $(guilibsdll) binmode.obj
243 # Define MFC link and library macros
244 # Note that MFC seems to make extensive use of default libraries,
245 # thus we do not specify a general /NODEFAULTLIB.
247 mfclflags = $(guilflags)
248 mfclflags = $(mfclflags:/NODEFAULTLIB=)
250 mfcdlllflags = $(dlllflags)
251 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
253 mfclibsdll = $(guilibsdll)
254 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
255 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
257 !IFNDEF AFSDEV_CRTDEBUG
258 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
259 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
261 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrt.lib
262 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrt.lib
266 # Macros for creating/modifying binary targets
268 # EXE link macro for console applications
269 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) $**
271 # EXE link macro for GUI applications
272 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
274 # EXE link macro for MFC applications
275 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
277 # DLL link macro for console applications
278 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
280 # DLL link macro for GUI applications
281 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
283 # DLL link macro for MFC applications
284 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
286 # DLL link macro for resource-only DLLs
287 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
289 # Library archive macro
290 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
292 # Language selection macro
293 NTLANG = $(DESTDIR)\bin\NTLang.bat
296 # EXE\DLL preparation macros
297 # Rebase to avoid conflicts; strip symbols in free build.
298 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
299 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
300 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
301 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
302 EXEPREP = rebase -b 0x00400000 -q $@
303 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
306 # C/C++ compilation macros
307 C2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
308 CPP2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
310 # Resource compiler macro
311 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS)
317 # Inference rules for building and installing targets
327 # Compile .rc (resource) files
331 # Install header files
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