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.
43 # Check that build type is correctly specified.
45 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
46 # Build type ignored when profiling or tuning.
47 AFSDEV_BUILDTYPE = NONE
50 # Build type must be checked or free.
51 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
52 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
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.
81 # Put default build binary directories at front of path.
84 !ERROR Must define AFSDEV_BIN to be the default build binary directories.
87 !IF ((!DEFINED(PATH)) && ([set PATH=$(AFSDEV_BIN)] != 0))
88 # If env. var. PATH not defined then macro assignment won't set it.
89 !ERROR Failed setting environment variable PATH.
91 PATH = $(AFSDEV_BIN);$(PATH)
94 # Undefine WIN32.MAK NODEBUG macro.
95 # Always generate full debug info, unless profiling or tuning (see below).
99 # Include WIN32.MAK nmake file
105 # Extend and/or supplement definitions in WIN32.MAK.
107 # Standard install directory.
108 !IFDEF AFSDEV_DESTDIR
109 DESTDIR = $(AFSDEV_DESTDIR)
111 DESTDIR = $(AFSROOT)\DEST
117 #DEL = $(DESTDIR)\BIN\rmbat # win 98 must use batch file
125 COMPILE_ET = $(DESTDIR)\bin\compile_et
126 RXGEN = $(DESTDIR)\bin\rxgen
129 # Common clean target.
130 # Double colon (::) syntax allows supplemental clean target to be specified.
132 $(DEL) /q *.obj *.lib *.dll *.exe
133 $(DEL) /q *_component_version_number.*
135 # Common lang target.
136 # Double colon (::) syntax allows supplemental lang target to be specified.
140 # Compiler include paths and preprocessor defines
144 -I$(DESTDIR)\include \
145 -I$(DESTDIR)\include\afs \
146 -I$(DESTDIR)\include\rx \
147 -DWIN32_LEAN_AND_MEAN \
151 afscdefs = $(afscdefs) $(AFSDEV_AUXCDEFINES)
154 # Compiler switches (except include paths and preprocessor defines)
156 # Note: if conflicting options are specified, rightmost option applies.
158 # /Oy- specifies no frame-pointer omission
159 # /GF pool strings and place in read-only memory
160 # /Gd use cdecl calling convention by default
161 # /Gy enable function-level linking
162 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
163 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
173 # Set optimization and debugging level based on build type.
175 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
176 # Apply full optimization; generate full debug info in obj.
177 afscflags = $(afscflags) /Ox /Z7
178 ldebug = $(ldebug) -debugtype:both
179 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
181 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
182 # Disable optimization; generate full debug info in obj.
183 afscflags = $(afscflags) /Od /Z7
184 ldebug = $(ldebug) -debugtype:both
187 # Set compiler warning level
189 !IFNDEF AFSDEV_WARNLEVEL
192 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
193 "$(AFSDEV_WARNLEVEL)" != "1" && \
194 "$(AFSDEV_WARNLEVEL)" != "2" && \
195 "$(AFSDEV_WARNLEVEL)" != "3" && \
196 "$(AFSDEV_WARNLEVEL)" != "4")
197 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
201 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
206 # /FIXED:NO generates a relocation section in the executable
213 # For checked builds, define DEBUG (but not the MS control flag _DEBUG).
215 !IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
216 afscdefs = $(afscdefs) -DDEBUG
219 # Utilize the debug version of the MSVC runtime, if requested.
221 !IFDEF AFSDEV_CRTDEBUG
222 afscdefs = $(afscdefs) -D_DEBUG
223 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
224 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
227 # Link with binmode.obj; files will be opened in binary mode by default.
229 !IFNDEF AFSDEV_TEXTMODE
230 conlibsdll = $(conlibsdll) binmode.obj
231 guilibsdll = $(guilibsdll) binmode.obj
235 # Define MFC link and library macros
236 # Note that MFC seems to make extensive use of default libraries,
237 # thus we do not specify a general /NODEFAULTLIB.
239 mfclflags = $(guilflags)
240 mfclflags = $(mfclflags:/NODEFAULTLIB=)
242 mfcdlllflags = $(dlllflags)
243 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
245 mfclibsdll = $(guilibsdll)
246 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
247 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
249 !IFNDEF AFSDEV_CRTDEBUG
250 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
251 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
253 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrt.lib
254 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrt.lib
258 # Macros for creating/modifying binary targets
260 # EXE link macro for console applications
261 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) $**
263 # EXE link macro for GUI applications
264 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
266 # EXE link macro for MFC applications
267 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
269 # DLL link macro for console applications
270 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
272 # DLL link macro for GUI applications
273 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
275 # DLL link macro for MFC applications
276 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
278 # DLL link macro for resource-only DLLs
279 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
281 # Library archive macro
282 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
284 # Language selection macro
285 NTLANG = $(DESTDIR)\bin\NTLang.bat
288 # EXE\DLL preparation macros
289 # Rebase to avoid conflicts; strip symbols in free build.
290 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
291 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
292 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
293 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
294 EXEPREP = rebase -b 0x00400000 -q $@
295 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
298 # C/C++ compilation macros
299 C2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
300 CPP2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
302 # Resource compiler macro
303 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS)
309 # Inference rules for building and installing targets
319 # Compile .rc (resource) files
323 # Install header files
326 .h.{$(DESTDIR)\include}.h:
327 $(COPY) $(*B).h $(DESTDIR)\include
329 .h.{$(DESTDIR)\include\afs}.h:
330 $(COPY) $(*B).h $(DESTDIR)\include\afs
332 .h.{$(DESTDIR)\include\rx}.h:
333 $(COPY) $(*B).h $(DESTDIR)\include\rx
335 .h.{$(DESTDIR)\include\WINNT}.h:
336 $(COPY) $(*B).h $(DESTDIR)\include\WINNT