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>
15 # Optional definitions:
16 # AFSDEV_DESTDIR = <top-level install directory> (default is $(AFSROOT)\DEST)
17 # AFSDEV_WARNLEVEL = [0 | 1 | 2 | 3 | 4] (default is 3)
18 # AFSDEV_AUXCDEFINES = <auxiliary C preprocessor defs> (default is null)
19 # AFSDEV_AUXRCFLAGS = <auxiliary resource compiler flags> (default is null)
20 # AFSDEV_TEXTMODE = <text mode is default if defined> (default is null)
21 # AFSDEV_CRTDEBUG = <utilize debug C runtime if define> (default is null)
23 ############################################################################
26 # Definitions provided here are based on WIN32.MAK, a common nmake
27 # file included with the MS SDK and MS VC distributions.
28 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
29 # port this nmake file if additional compiler support is required.
31 # Define default target-type macros required by WIN32.MAK.
32 # Allow them to be overriden in an NTMakefile or via an environment variable.
38 #define used in WinNT/2000 installation and program version display
39 AFSPRODUCT_VERSION=1.2.6 a
40 CELLNAME_DEFAULT=Your Cell Name
41 CELLSERVDB_INSTALL=CellServDB.GrandCentral
42 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
43 #NMAKE_DEFINES=-DDEBUG_VERBOSE
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.
86 # Undefine WIN32.MAK NODEBUG macro.
87 # Always generate full debug info, unless profiling or tuning (see below).
91 # Include WIN32.MAK nmake file
95 # Extend and/or supplement definitions in WIN32.MAK.
97 # Standard install directory.
99 DESTDIR = $(AFSDEV_DESTDIR)
101 DESTDIR = $(AFSROOT)\DEST
107 #DEL = $(DESTDIR)\BIN\rmbat # win 98 must use batch file
115 COMPILE_ET = $(DESTDIR)\bin\compile_et
116 RXGEN = $(DESTDIR)\bin\rxgen
119 # Common clean target.
120 # Double colon (::) syntax allows supplemental clean target to be specified.
122 $(DEL) /q *.obj *.lib *.dll *.exe
123 $(DEL) /q *_component_version_number.*
125 # Common lang target.
126 # Double colon (::) syntax allows supplemental lang target to be specified.
130 # Compiler include paths and preprocessor defines
134 -I$(DESTDIR)\include \
135 -I$(DESTDIR)\include\afs \
136 -I$(DESTDIR)\include\rx \
137 -DWIN32_LEAN_AND_MEAN \
141 -DAFS_FREELANCE_CLIENT
143 afscdefs = $(afscdefs) $(AFSDEV_AUXCDEFINES) $(NMAKE_DEFINES)
146 # Compiler switches (except include paths and preprocessor defines)
148 # Note: if conflicting options are specified, rightmost option applies.
150 # /Oy- specifies no frame-pointer omission
151 # /GF pool strings and place in read-only memory
152 # /Gd use cdecl calling convention by default
153 # /Gy enable function-level linking
154 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
155 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
165 # Set optimization and debugging level based on build type.
167 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
168 # Apply full optimization; generate full debug info in obj.
169 afscflags = $(afscflags) /Ox /Zi
170 # ldebug = $(ldebug) -debugtype:both
172 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
173 cvarsdll = $(cvarsdll:-MDd=-MD)
175 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
176 # Disable optimization; generate full debug info in obj.
177 afscflags = $(afscflags) /Od /Zi
178 ldebug = $(ldebug) -debugtype:both
181 # Set compiler warning level
183 !IFNDEF AFSDEV_WARNLEVEL
186 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
187 "$(AFSDEV_WARNLEVEL)" != "1" && \
188 "$(AFSDEV_WARNLEVEL)" != "2" && \
189 "$(AFSDEV_WARNLEVEL)" != "3" && \
190 "$(AFSDEV_WARNLEVEL)" != "4")
191 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
195 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
200 # /FIXED:NO generates a relocation section in the executable
203 /FIXED:NO /VERBOSE:LIB /DEBUG
207 # For checked builds, define DEBUG (but not the MS control flag _DEBUG).
209 !IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
210 #afscdefs = $(afscdefs) -DDEBUG
213 # Utilize the debug version of the MSVC runtime, if requested.
215 !IFDEF AFSDEV_CRTDEBUG
216 afscdefs = $(afscdefs) -D_DEBUG
217 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
218 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
221 # Link with binmode.obj; files will be opened in binary mode by default.
223 !IFNDEF AFSDEV_TEXTMODE
224 conlibsdll = $(conlibsdll) binmode.obj
225 guilibsdll = $(guilibsdll) binmode.obj
229 # Define MFC link and library macros
230 # Note that MFC seems to make extensive use of default libraries,
231 # thus we do not specify a general /NODEFAULTLIB.
233 mfclflags = $(guilflags)
234 mfclflags = $(mfclflags:/NODEFAULTLIB=)
236 mfcdlllflags = $(dlllflags)
237 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
239 mfclibsdll = $(guilibsdll)
240 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
241 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
243 !IFNDEF AFSDEV_CRTDEBUG
244 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
245 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
247 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrt.lib
248 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrt.lib
252 # Macros for creating/modifying binary targets
254 # EXE link macro for console applications
255 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) $**
257 # EXE link macro for GUI applications
258 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
260 # EXE link macro for MFC applications
261 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
263 # DLL link macro for console applications
264 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
266 # DLL link macro for GUI applications
267 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
269 # DLL link macro for MFC applications
270 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
272 # DLL link macro for resource-only DLLs
273 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
275 # Library archive macro
276 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
278 # Language selection macro
279 NTLANG = $(DESTDIR)\bin\NTLang.bat
282 # EXE\DLL preparation macros
283 # Rebase to avoid conflicts; strip symbols in free build.
284 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
285 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
286 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
287 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
288 EXEPREP = rebase -b 0x00400000 -q $@
289 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
292 # C/C++ compilation macros
293 C2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
294 CPP2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
296 # Resource compiler macro
297 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
303 # Inference rules for building and installing targets
313 # Compile .rc (resource) files
317 # Install header files
320 .h.{$(DESTDIR)\include}.h:
321 $(COPY) $(*B).h $(DESTDIR)\include
323 .h.{$(DESTDIR)\include\afs}.h:
324 $(COPY) $(*B).h $(DESTDIR)\include\afs
326 .h.{$(DESTDIR)\include\rx}.h:
327 $(COPY) $(*B).h $(DESTDIR)\include\rx
329 .h.{$(DESTDIR)\include\WINNT}.h:
330 $(COPY) $(*B).h $(DESTDIR)\include\WINNT