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.
44 !IF "$(OS)" == "Windows_NT"
54 # Check that build type is correctly specified.
56 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
57 # Build type ignored when profiling or tuning.
58 AFSDEV_BUILDTYPE = NONE
61 # Build type must be checked or free.
62 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
63 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
68 # Limit default include and library directories to those specified for build.
70 !IFNDEF AFSDEV_INCLUDE
71 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
74 !IF ((!DEFINED(INCLUDE)) && ([set INCLUDE=$(AFSDEV_INCLUDE)] != 0))
75 # If env. var. INCLUDE not defined then macro assignment won't set it.
76 !ERROR Failed setting environment variable INCLUDE.
78 INCLUDE = $(AFSDEV_INCLUDE)
82 !ERROR Must define AFSDEV_LIB to be the default library directories.
85 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
86 # If env. var. LIB not defined then macro assignment won't set it.
87 !ERROR Failed setting environment variable LIB.
92 # Put default build binary directories at front of path.
95 !ERROR Must define AFSDEV_BIN to be the default build binary directories.
98 !IF ((!DEFINED(PATH)) && ([set PATH=$(AFSDEV_BIN)] != 0))
99 # If env. var. PATH not defined then macro assignment won't set it.
100 !ERROR Failed setting environment variable PATH.
102 PATH = $(AFSDEV_BIN);$(PATH)
105 # Undefine WIN32.MAK NODEBUG macro.
106 # Always generate full debug info, unless profiling or tuning (see below).
110 # Include WIN32.MAK nmake file
114 # Extend and/or supplement definitions in WIN32.MAK.
116 # Standard install directory.
117 !IFDEF AFSDEV_DESTDIR
118 DESTDIR = $(AFSDEV_DESTDIR)
120 DESTDIR = $(AFSROOT)\DEST
126 #DEL = rm -f # to delete multiple files on one command line
127 DEL = $(DESTDIR)\BIN\rmbat # win 98 must use batch file
137 COMPILE_ET = $(DESTDIR)\bin\compile_et
138 RXGEN = $(DESTDIR)\bin\rxgen
141 # Common clean target.
142 # Double colon (::) syntax allows supplemental clean target to be specified.
144 $(DEL) *.obj *.lib *.dll *.exe
145 $(DEL) *_component_version_number.*
147 # Common lang target.
148 # Double colon (::) syntax allows supplemental lang target to be specified.
152 # Compiler include paths and preprocessor defines
156 -I$(DESTDIR)\include \
157 -I$(DESTDIR)\include\afs \
158 -I$(DESTDIR)\include\rx \
159 -DWIN32_LEAN_AND_MEAN \
163 ! IF ((EXIST($(MSSDK)\include)) && (("$(SYS_NAME)"=="i386_win95" ) || ("$(SYS_NAME)"=="I386_WIN95" )))
164 afscdefs=$(afscdefs) -I$(MSSDK)\include $(afscppdefs) \
167 afscdefs = $(afscdefs) $(AFSDEV_AUXCDEFINES)
169 #add a few defines for win9xpanel
170 afscppdefs = -D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_WINNT" /D "_AFXDLL"
172 # Compiler switches (except include paths and preprocessor defines)
174 # Note: if conflicting options are specified, rightmost option applies.
176 # /Oy- specifies no frame-pointer omission
177 # /GF pool strings and place in read-only memory
178 # /Gd use cdecl calling convention by default
179 # /Gy enable function-level linking
180 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
181 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
191 # Set optimization and debugging level based on build type.
193 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
194 # Apply full optimization; generate full debug info in obj.
195 afscflags = $(afscflags) /Ox /Z7
196 ldebug = $(ldebug) -debugtype:both
197 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
199 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
200 # Disable optimization; generate full debug info in obj.
201 afscflags = $(afscflags) /Od /Z7
202 ldebug = $(ldebug) -debugtype:both
205 # Set compiler warning level
207 !IFNDEF AFSDEV_WARNLEVEL
210 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
211 "$(AFSDEV_WARNLEVEL)" != "1" && \
212 "$(AFSDEV_WARNLEVEL)" != "2" && \
213 "$(AFSDEV_WARNLEVEL)" != "3" && \
214 "$(AFSDEV_WARNLEVEL)" != "4")
215 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
219 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
224 # /FIXED:NO generates a relocation section in the executable
231 # For checked builds, define DEBUG (but not the MS control flag _DEBUG).
233 !IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
234 afscdefs = $(afscdefs) -DDEBUG
237 # Utilize the debug version of the MSVC runtime, if requested.
239 !IFDEF AFSDEV_CRTDEBUG
240 afscdefs = $(afscdefs) -D_DEBUG
241 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
242 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
245 # Link with binmode.obj; files will be opened in binary mode by default.
247 !IFNDEF AFSDEV_TEXTMODE
248 conlibsdll = $(conlibsdll) binmode.obj
249 guilibsdll = $(guilibsdll) binmode.obj
253 # Define MFC link and library macros
254 # Note that MFC seems to make extensive use of default libraries,
255 # thus we do not specify a general /NODEFAULTLIB.
257 mfclflags = $(guilflags)
258 mfclflags = $(mfclflags:/NODEFAULTLIB=)
260 mfcdlllflags = $(dlllflags)
261 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
263 mfclibsdll = $(guilibsdll)
264 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
265 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
267 !IFNDEF AFSDEV_CRTDEBUG
268 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
269 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
271 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrt.lib
272 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrt.lib
276 # Macros for creating/modifying binary targets
278 # EXE link macro for console applications
279 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) $**
281 # EXE link macro for GUI applications
282 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
284 # EXE link macro for MFC applications
285 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
287 # DLL link macro for console applications
288 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
290 # DLL link macro for GUI applications
291 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
293 # DLL link macro for MFC applications
294 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
296 # DLL link macro for resource-only DLLs
297 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
299 # Library archive macro
300 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
302 # Language selection macro
303 NTLANG = $(DESTDIR)\bin\NTLang.bat
306 # EXE\DLL preparation macros
307 # Rebase to avoid conflicts; strip symbols in free build.
308 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
309 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
310 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
311 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
312 EXEPREP = rebase -b 0x00400000 -q $@
313 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
316 # C/C++ compilation macros
318 C2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
319 CPP2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) $(afscppdefs) /c
321 # Resource compiler macro
322 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS)
328 # Inference rules for building and installing targets
338 # Compile .rc (resource) files
342 # Install header files
345 .h.{$(DESTDIR)\include}.h:
346 $(COPY) $(*B).h $(DESTDIR)\include
348 .h.{$(DESTDIR)\include\afs}.h:
349 $(COPY) $(*B).h $(DESTDIR)\include\afs
351 .h.{$(DESTDIR)\include\rx}.h:
352 $(COPY) $(*B).h $(DESTDIR)\include\rx
354 .h.{$(DESTDIR)\include\WINNT}.h:
355 $(COPY) $(*B).h $(DESTDIR)\include\WINNT