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 Win9x installation and program version display
39 AFSPRODUCT_VERSION=1.3.51
40 CELLNAME_DEFAULT=Your Cell Name
41 CELLSERVDB_INSTALL=CellServDB.GrandCentral
42 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
49 !IF "$(OS)" == "Windows_NT"
59 # Check that build type is correctly specified.
61 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
62 # Build type ignored when profiling or tuning.
63 AFSDEV_BUILDTYPE = NONE
66 # Build type must be checked or free.
67 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
68 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
73 # Limit default include and library directories to those specified for build.
75 !IFNDEF AFSDEV_INCLUDE
76 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
79 !IF ((!DEFINED(INCLUDE)) && ([set INCLUDE=$(AFSDEV_INCLUDE)] != 0))
80 # If env. var. INCLUDE not defined then macro assignment won't set it.
81 !ERROR Failed setting environment variable INCLUDE.
83 INCLUDE = $(AFSDEV_INCLUDE)
87 !ERROR Must define AFSDEV_LIB to be the default library directories.
90 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
91 # If env. var. LIB not defined then macro assignment won't set it.
92 !ERROR Failed setting environment variable LIB.
96 # Undefine WIN32.MAK NODEBUG macro.
97 # Always generate full debug info, unless profiling or tuning (see below).
101 # 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 = rm -f # to delete multiple files on one command line
118 DEL = $(DESTDIR)\BIN\rmbat # win 98 must use batch file
128 COMPILE_ET = $(DESTDIR)\bin\compile_et
129 RXGEN = $(DESTDIR)\bin\rxgen
132 # Common clean target.
133 # Double colon (::) syntax allows supplemental clean target to be specified.
135 $(DEL) *.obj *.lib *.dll *.exe
136 $(DEL) *_component_version_number.*
138 # Common lang target.
139 # Double colon (::) syntax allows supplemental lang target to be specified.
143 # Compiler include paths and preprocessor defines
147 -I$(DESTDIR)\include \
148 -I$(DESTDIR)\include\afs \
149 -I$(DESTDIR)\include\rx \
150 -DWIN32_LEAN_AND_MEAN \
154 -DAFS_FREELANCE_CLIENT
156 ! IF ((EXIST($(MSSDK)\include)) && (("$(SYS_NAME)"=="i386_win95" ) || ("$(SYS_NAME)"=="I386_WIN95" )))
157 afscdefs=$(afscdefs) -I$(MSSDK)\include $(afscppdefs) \
160 afscdefs = $(afscdefs) $(AFSDEV_AUXCDEFINES)
162 #add a few defines for win9xpanel
163 afscppdefs = -D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_WINNT" /D "_AFXDLL"
165 # Compiler switches (except include paths and preprocessor defines)
167 # Note: if conflicting options are specified, rightmost option applies.
169 # /Oy- specifies no frame-pointer omission
170 # /GF pool strings and place in read-only memory
171 # /Gd use cdecl calling convention by default
172 # /Gy enable function-level linking
173 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
174 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
184 # Set optimization and debugging level based on build type.
186 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
187 # Apply full optimization; generate full debug info in obj.
188 afscflags = $(afscflags) /Ox /Z7
189 ldebug = $(ldebug) -debugtype:both
190 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
192 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
193 # Disable optimization; generate full debug info in obj.
194 afscflags = $(afscflags) /Od /Z7
195 ldebug = $(ldebug) -debugtype:both
198 # Set compiler warning level
200 !IFNDEF AFSDEV_WARNLEVEL
203 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
204 "$(AFSDEV_WARNLEVEL)" != "1" && \
205 "$(AFSDEV_WARNLEVEL)" != "2" && \
206 "$(AFSDEV_WARNLEVEL)" != "3" && \
207 "$(AFSDEV_WARNLEVEL)" != "4")
208 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
212 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
217 # /FIXED:NO generates a relocation section in the executable
224 # For checked builds, define DEBUG (but not the MS control flag _DEBUG).
226 !IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
227 afscdefs = $(afscdefs) -DDEBUG
230 # Utilize the debug version of the MSVC runtime, if requested.
232 !IFDEF AFSDEV_CRTDEBUG
233 afscdefs = $(afscdefs) -D_DEBUG
234 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
235 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
238 # Link with binmode.obj; files will be opened in binary mode by default.
240 !IFNDEF AFSDEV_TEXTMODE
241 conlibsdll = $(conlibsdll) binmode.obj
242 guilibsdll = $(guilibsdll) binmode.obj
246 # Define MFC link and library macros
247 # Note that MFC seems to make extensive use of default libraries,
248 # thus we do not specify a general /NODEFAULTLIB.
250 mfclflags = $(guilflags)
251 mfclflags = $(mfclflags:/NODEFAULTLIB=)
253 mfcdlllflags = $(dlllflags)
254 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
256 mfclibsdll = $(guilibsdll)
257 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
258 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
260 !IFNDEF AFSDEV_CRTDEBUG
261 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
262 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
264 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrt.lib
265 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrt.lib
269 # Macros for creating/modifying binary targets
271 # EXE link macro for console applications
272 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) $**
274 # EXE link macro for GUI applications
275 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
277 # EXE link macro for MFC applications
278 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
280 # DLL link macro for console applications
281 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
283 # DLL link macro for GUI applications
284 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
286 # DLL link macro for MFC applications
287 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
289 # DLL link macro for resource-only DLLs
290 # DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
291 DLLRESLINK = $(link) /OUT:$@ -noentry $(afslflags) $**
293 # Library archive macro
294 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
296 # Language selection macro
297 NTLANG = $(DESTDIR)\bin\NTLang.bat
300 # EXE\DLL preparation macros
301 # Rebase to avoid conflicts; strip symbols in free build.
302 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
303 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
304 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
305 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
306 EXEPREP = rebase -b 0x00400000 -q $@
307 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
310 # C/C++ compilation macros
312 C2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
313 CPP2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) $(afscppdefs) /c
315 # Resource compiler macro
316 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
322 # Inference rules for building and installing targets
332 # Compile .rc (resource) files
336 # Install header files
339 .h.{$(DESTDIR)\include}.h:
340 $(COPY) $(*B).h $(DESTDIR)\include
342 .h.{$(DESTDIR)\include\afs}.h:
343 $(COPY) $(*B).h $(DESTDIR)\include\afs
345 .h.{$(DESTDIR)\include\rx}.h:
346 $(COPY) $(*B).h $(DESTDIR)\include\rx
348 .h.{$(DESTDIR)\include\WINNT}.h:
349 $(COPY) $(*B).h $(DESTDIR)\include\WINNT