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 Win9x 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
50 !IF "$(OS)" == "Windows_NT"
60 # Check that build type is correctly specified.
62 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
63 # Build type ignored when profiling or tuning.
64 AFSDEV_BUILDTYPE = NONE
67 # Build type must be checked or free.
68 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
69 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
74 # Limit default include and library directories to those specified for build.
76 !IFNDEF AFSDEV_INCLUDE
77 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
80 !IF ((!DEFINED(INCLUDE)) && ([set INCLUDE=$(AFSDEV_INCLUDE)] != 0))
81 # If env. var. INCLUDE not defined then macro assignment won't set it.
82 !ERROR Failed setting environment variable INCLUDE.
84 INCLUDE = $(AFSDEV_INCLUDE)
88 !ERROR Must define AFSDEV_LIB to be the default library directories.
91 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
92 # If env. var. LIB not defined then macro assignment won't set it.
93 !ERROR Failed setting environment variable LIB.
98 # Put default build binary directories at front of path.
101 !ERROR Must define AFSDEV_BIN to be the default build binary directories.
104 !IF ((!DEFINED(PATH)) && ([set PATH=$(AFSDEV_BIN)] != 0))
105 # If env. var. PATH not defined then macro assignment won't set it.
106 !ERROR Failed setting environment variable PATH.
108 PATH = $(AFSDEV_BIN);$(PATH)
111 # Undefine WIN32.MAK NODEBUG macro.
112 # Always generate full debug info, unless profiling or tuning (see below).
116 # Include WIN32.MAK nmake file
120 # Extend and/or supplement definitions in WIN32.MAK.
122 # Standard install directory.
123 !IFDEF AFSDEV_DESTDIR
124 DESTDIR = $(AFSDEV_DESTDIR)
126 DESTDIR = $(AFSROOT)\DEST
132 #DEL = rm -f # to delete multiple files on one command line
133 DEL = $(DESTDIR)\BIN\rmbat # win 98 must use batch file
143 COMPILE_ET = $(DESTDIR)\bin\compile_et
144 RXGEN = $(DESTDIR)\bin\rxgen
147 # Common clean target.
148 # Double colon (::) syntax allows supplemental clean target to be specified.
150 $(DEL) *.obj *.lib *.dll *.exe
151 $(DEL) *_component_version_number.*
153 # Common lang target.
154 # Double colon (::) syntax allows supplemental lang target to be specified.
158 # Compiler include paths and preprocessor defines
162 -I$(DESTDIR)\include \
163 -I$(DESTDIR)\include\afs \
164 -I$(DESTDIR)\include\rx \
165 -DWIN32_LEAN_AND_MEAN \
169 ! IF ((EXIST($(MSSDK)\include)) && (("$(SYS_NAME)"=="i386_win95" ) || ("$(SYS_NAME)"=="I386_WIN95" )))
170 afscdefs=$(afscdefs) -I$(MSSDK)\include $(afscppdefs) \
173 afscdefs = $(afscdefs) $(AFSDEV_AUXCDEFINES)
175 #add a few defines for win9xpanel
176 afscppdefs = -D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_WINNT" /D "_AFXDLL"
178 # Compiler switches (except include paths and preprocessor defines)
180 # Note: if conflicting options are specified, rightmost option applies.
182 # /Oy- specifies no frame-pointer omission
183 # /GF pool strings and place in read-only memory
184 # /Gd use cdecl calling convention by default
185 # /Gy enable function-level linking
186 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
187 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
197 # Set optimization and debugging level based on build type.
199 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
200 # Apply full optimization; generate full debug info in obj.
201 afscflags = $(afscflags) /Ox /Z7
202 ldebug = $(ldebug) -debugtype:both
203 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
205 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
206 # Disable optimization; generate full debug info in obj.
207 afscflags = $(afscflags) /Od /Z7
208 ldebug = $(ldebug) -debugtype:both
211 # Set compiler warning level
213 !IFNDEF AFSDEV_WARNLEVEL
216 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
217 "$(AFSDEV_WARNLEVEL)" != "1" && \
218 "$(AFSDEV_WARNLEVEL)" != "2" && \
219 "$(AFSDEV_WARNLEVEL)" != "3" && \
220 "$(AFSDEV_WARNLEVEL)" != "4")
221 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
225 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
230 # /FIXED:NO generates a relocation section in the executable
237 # For checked builds, define DEBUG (but not the MS control flag _DEBUG).
239 !IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
240 afscdefs = $(afscdefs) -DDEBUG
243 # Utilize the debug version of the MSVC runtime, if requested.
245 !IFDEF AFSDEV_CRTDEBUG
246 afscdefs = $(afscdefs) -D_DEBUG
247 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
248 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
251 # Link with binmode.obj; files will be opened in binary mode by default.
253 !IFNDEF AFSDEV_TEXTMODE
254 conlibsdll = $(conlibsdll) binmode.obj
255 guilibsdll = $(guilibsdll) binmode.obj
259 # Define MFC link and library macros
260 # Note that MFC seems to make extensive use of default libraries,
261 # thus we do not specify a general /NODEFAULTLIB.
263 mfclflags = $(guilflags)
264 mfclflags = $(mfclflags:/NODEFAULTLIB=)
266 mfcdlllflags = $(dlllflags)
267 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
269 mfclibsdll = $(guilibsdll)
270 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
271 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
273 !IFNDEF AFSDEV_CRTDEBUG
274 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
275 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
277 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrt.lib
278 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrt.lib
282 # Macros for creating/modifying binary targets
284 # EXE link macro for console applications
285 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) $**
287 # EXE link macro for GUI applications
288 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
290 # EXE link macro for MFC applications
291 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
293 # DLL link macro for console applications
294 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
296 # DLL link macro for GUI applications
297 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
299 # DLL link macro for MFC applications
300 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
302 # DLL link macro for resource-only DLLs
303 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
305 # Library archive macro
306 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
308 # Language selection macro
309 NTLANG = $(DESTDIR)\bin\NTLang.bat
312 # EXE\DLL preparation macros
313 # Rebase to avoid conflicts; strip symbols in free build.
314 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
315 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
316 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
317 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
318 EXEPREP = rebase -b 0x00400000 -q $@
319 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
322 # C/C++ compilation macros
324 C2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
325 CPP2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) $(afscppdefs) /c
327 # Resource compiler macro
328 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS)
334 # Inference rules for building and installing targets
344 # Compile .rc (resource) files
348 # Install header files
351 .h.{$(DESTDIR)\include}.h:
352 $(COPY) $(*B).h $(DESTDIR)\include
354 .h.{$(DESTDIR)\include\afs}.h:
355 $(COPY) $(*B).h $(DESTDIR)\include\afs
357 .h.{$(DESTDIR)\include\rx}.h:
358 $(COPY) $(*B).h $(DESTDIR)\include\rx
360 .h.{$(DESTDIR)\include\WINNT}.h:
361 $(COPY) $(*B).h $(DESTDIR)\include\WINNT