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 -DAFS_FREELANCE_CLIENT
171 ! IF ((EXIST($(MSSDK)\include)) && (("$(SYS_NAME)"=="i386_win95" ) || ("$(SYS_NAME)"=="I386_WIN95" )))
172 afscdefs=$(afscdefs) -I$(MSSDK)\include $(afscppdefs) \
175 afscdefs = $(afscdefs) $(AFSDEV_AUXCDEFINES)
177 #add a few defines for win9xpanel
178 afscppdefs = -D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_WINNT" /D "_AFXDLL"
180 # Compiler switches (except include paths and preprocessor defines)
182 # Note: if conflicting options are specified, rightmost option applies.
184 # /Oy- specifies no frame-pointer omission
185 # /GF pool strings and place in read-only memory
186 # /Gd use cdecl calling convention by default
187 # /Gy enable function-level linking
188 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
189 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
199 # Set optimization and debugging level based on build type.
201 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
202 # Apply full optimization; generate full debug info in obj.
203 afscflags = $(afscflags) /Ox /Z7
204 ldebug = $(ldebug) -debugtype:both
205 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
207 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
208 # Disable optimization; generate full debug info in obj.
209 afscflags = $(afscflags) /Od /Z7
210 ldebug = $(ldebug) -debugtype:both
213 # Set compiler warning level
215 !IFNDEF AFSDEV_WARNLEVEL
218 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
219 "$(AFSDEV_WARNLEVEL)" != "1" && \
220 "$(AFSDEV_WARNLEVEL)" != "2" && \
221 "$(AFSDEV_WARNLEVEL)" != "3" && \
222 "$(AFSDEV_WARNLEVEL)" != "4")
223 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
227 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
232 # /FIXED:NO generates a relocation section in the executable
239 # For checked builds, define DEBUG (but not the MS control flag _DEBUG).
241 !IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
242 afscdefs = $(afscdefs) -DDEBUG
245 # Utilize the debug version of the MSVC runtime, if requested.
247 !IFDEF AFSDEV_CRTDEBUG
248 afscdefs = $(afscdefs) -D_DEBUG
249 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
250 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
253 # Link with binmode.obj; files will be opened in binary mode by default.
255 !IFNDEF AFSDEV_TEXTMODE
256 conlibsdll = $(conlibsdll) binmode.obj
257 guilibsdll = $(guilibsdll) binmode.obj
261 # Define MFC link and library macros
262 # Note that MFC seems to make extensive use of default libraries,
263 # thus we do not specify a general /NODEFAULTLIB.
265 mfclflags = $(guilflags)
266 mfclflags = $(mfclflags:/NODEFAULTLIB=)
268 mfcdlllflags = $(dlllflags)
269 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
271 mfclibsdll = $(guilibsdll)
272 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
273 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
275 !IFNDEF AFSDEV_CRTDEBUG
276 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
277 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
279 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrt.lib
280 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrt.lib
284 # Macros for creating/modifying binary targets
286 # EXE link macro for console applications
287 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) $**
289 # EXE link macro for GUI applications
290 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
292 # EXE link macro for MFC applications
293 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
295 # DLL link macro for console applications
296 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
298 # DLL link macro for GUI applications
299 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
301 # DLL link macro for MFC applications
302 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
304 # DLL link macro for resource-only DLLs
305 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
307 # Library archive macro
308 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
310 # Language selection macro
311 NTLANG = $(DESTDIR)\bin\NTLang.bat
314 # EXE\DLL preparation macros
315 # Rebase to avoid conflicts; strip symbols in free build.
316 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
317 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
318 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
319 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
320 EXEPREP = rebase -b 0x00400000 -q $@
321 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
324 # C/C++ compilation macros
326 C2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
327 CPP2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) $(afscppdefs) /c
329 # Resource compiler macro
330 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS)
336 # Inference rules for building and installing targets
346 # Compile .rc (resource) files
350 # Install header files
353 .h.{$(DESTDIR)\include}.h:
354 $(COPY) $(*B).h $(DESTDIR)\include
356 .h.{$(DESTDIR)\include\afs}.h:
357 $(COPY) $(*B).h $(DESTDIR)\include\afs
359 .h.{$(DESTDIR)\include\rx}.h:
360 $(COPY) $(*B).h $(DESTDIR)\include\rx
362 .h.{$(DESTDIR)\include\WINNT}.h:
363 $(COPY) $(*B).h $(DESTDIR)\include\WINNT