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 ]
13 # Optional definitions:
14 # AFSDEV_WARNLEVEL = [0 | 1 | 2 | 3 | 4] (default is 3)
15 # AFSDEV_AUXCDEFINES = <auxiliary C preprocessor defs> (default is null)
16 # AFSDEV_AUXRCFLAGS = <auxiliary resource compiler flags> (default is null)
17 # AFSDEV_AUXMIDLFLAGS = auxiliary midl flags
18 # AFSDEV_TEXTMODE = <text mode is default if defined> (default is null)
19 # DEBUG_VERBOSE = optional debug statements for testing
20 # AFS_OBJDIR - Location of object directory, either absolute or relative
21 # AFSROOT - ROOT Directory so that $(AFSROOT)\scr is location of source
23 ############################################################################
24 # Optional compliation flags
25 # NO_CRTDBG - used to disable some builds for CFTDBG allocate mapping
26 # _CRTDBG_MAP_ALLOC = <utilize crt debug C runtime if define> (default is null)
27 # VADUMP - define VADUMP=1 if you are going to use the vadump utility and you are using V6.0
29 ####### Special optional defines
32 #don't set _CRTDBG_MAP_ALLOC flag for some module compliations
40 !IF ("$(CPU)" != "AMD64")
41 !ERROR Platform SDK not configured for AMD64
44 !IF EXISTS("TOOLS.INI")
45 !MESSAGE ************CAUTION TOOLS.INI IN EFFECT**********
47 !IF ("$(AFSROOT)"=="")
48 !ERROR AFSROOT is not set
50 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
51 AFSDEV_BUILDTYPE = NONE
53 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
54 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
57 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
58 !UNDEF _CRTDBG_MAP_ALLOC
61 # Limit default include and library directories to those specified for build.
63 !IFNDEF AFSDEV_INCLUDE
64 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
67 !IF ((!DEFINED(INCLUDE)) && ([set INCLUDE=$(AFSDEV_INCLUDE)] != 0))
68 # If env. var. INCLUDE not defined then macro assignment won't set it.
69 !ERROR Failed setting environment variable INCLUDE.
71 INCLUDE = $(AFSDEV_INCLUDE)
75 !ERROR Must define AFSDEV_LIB to be the default library directories.
78 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
79 # If env. var. LIB not defined then macro assignment won't set it.
80 !ERROR Failed setting environment variable LIB.
84 #define used in WinNT/2000 installation and program version display
85 AFSPRODUCT_VER_MAJOR=1
86 AFSPRODUCT_VER_MINOR=5
87 AFSPRODUCT_VER_PATCH=6600
88 AFSPRODUCT_VER_BUILD=0
90 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
91 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
92 # Set CELLNAME_DEFAULT to "your cell name"
93 CELLNAME_DEFAULT=openafs.org
94 CELLSERVDB_INSTALL=CellServDB.GrandCentral
95 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
98 # Define defaults folder locations
103 !IF ("$(AFS_OBJDIR)"=="")
104 ######### AFS_OBJDIR is NOT used use default locations
105 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
106 DESTDIR=$(AFSROOT)\$(DEST)\$(SYS_NAME)\checked
107 OJT=$(AFSROOT)\$(OBJ)\$(SYS_NAME)\checked
109 DESTDIR=$(AFSROOT)\$(DEST)\$(SYS_NAME)\free
110 OJT=$(AFSROOT)\$(OBJ)\$(SYS_NAME)\free
112 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
114 ######### AFS_OBJDIR is defined, use specific locations for obj and dest
115 # there is a special case for config because util_cr is not defined yet!
116 ! IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
117 # AFS_OBJDIR is relative path
118 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
119 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
120 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
122 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\free\config
123 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
126 ! IF (EXIST($(AFS_OBJDIR)))
127 # AFS_OBJDIR is full path
128 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
129 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
130 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
132 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
133 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\free\config
136 !ERROR Can't find location of DEST directory!
139 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
141 ! IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)")
142 # we are NOT doing a config make, use util_cr to generate object directory
143 ! IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
144 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
147 ! IF EXIST($(TMP)\home)
150 !INCLUDE $(TEMP)\home
155 !IF ("$(RELDIR)"=="")
161 !MESSAGE Directory assignments:
162 !MESSAGE OJT=[$(OJT)]
163 !MESSAGE OUT=[$(OUT)]
164 !MESSAGE DESTDIR=[$(DESTDIR)]
166 # Definitions provided here are based on WIN32.MAK, a common nmake
167 # file included with the MS SDK and MS VC distributions.
168 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
169 # port this nmake file if additional compiler support is required.
171 !IF ("$(APPVER)" == "")
177 # Extend and/or supplement definitions in WIN32.MAK.
201 !IF !DEFINED(MAKECMD)
208 COMPILE_ET = $(DESTDIR)\bin\compile_et
209 RXGEN = $(DESTDIR)\bin\rxgen
211 # Common clean target.
213 $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb
214 $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
216 # Common lang target.
220 #################### Compile optional build flags set ###########
224 -I$(DESTDIR)\include \
225 -I$(DESTDIR)\include\afs \
226 -I$(DESTDIR)\include\rx \
227 -DWIN32_LEAN_AND_MEAN \
230 -D_WIN32_WINNT=0x0502 \
232 -DREGISTER_POWER_NOTIFICATIONS \
234 -DAFS_FREELANCE_CLIENT \
235 -DAFS_64BITPOINTER_ENV \
236 -DAFS_64BITUSERPOINTER_ENV \
239 -DAFS_LARGEFILE_ENV \
240 -D_USE_DECLSPECS_FOR_SAL=0 \
241 -D_USE_ATTRIBUTES_FOR_SAL=0 \
242 -D_ATL_SECURE_NO_DEPRECATE \
243 -D_AFX_DISABLE_DEPRECATED \
244 -D_AFX_SECURE_NO_WARNINGS \
245 $(AFSDEV_AUXCDEFINES)
247 # Compiler switches (except include paths and preprocessor defines)
249 # Note: if conflicting options are specified, rightmost option applies.
251 # /Oy- specifies no frame-pointer omission
252 # /GF pool strings and place in read-only memory
253 # /Gd use cdecl calling convention by default
254 # /Gy enable function-level linking
255 # /EHsc enable C++ exceptions (assumes extern C funcs never throw exceptions)
256 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
265 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
266 afscflags = $(afscflags) /EHsc /wd4996
268 afscflags = $(afscflags) /GX
271 !IF ("$(AFSVER_CL)"!="1200")
272 afscflags = $(afscflags) /GT /GS
274 !IF ("$(AFSVER_CL)"!="1400" && "$(AFSVER_CL)"!="1500")
275 afscflags = $(afscflags) /G7
279 !IF ("$(AFSIFS)" == "TRUE")
280 afscdefs = $(afscdefs) -DAFSIFS
283 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
284 afscflags = $(afscflags) /Ox /Zi
285 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
286 cvarsdll = $(cvarsdll:-MDd=-MD)
288 _VC_MANIFEST_BASENAME = __OAFW
289 !ELSE # CHECKED BUILD
290 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
292 !IF ("$(AFSVER_CL)"=="1200")
293 afscdefs = $(afscdefs) -DDEBUG /GZ
295 afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
298 !IFDEF _CRTDBG_MAP_ALLOC
299 afscflags = $(afscflags) -D_DEBUG -D_CRTDBG_MAP_ALLOC
303 _VC_MANIFEST_BASENAME = __OAFW.Debug
306 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
307 _VC_MANIFEST_EMBED_EXE= \
308 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;1
310 _VC_MANIFEST_EMBED_DLL= \
311 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;2
313 _VC_MANIFEST_EMBED_EXE=
314 _VC_MANIFEST_EMBED_DLL=
317 !IF "$(SIGNTOOL)" == ""
318 SIGNTOOL=signtool.exe
321 !IF DEFINED(CODESIGN_DESC) && DEFINED(CODESIGN_URL) && DEFINED(CODESIGN_TIMESTAMP)
322 CODESIGN_USERLAND= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /t $(CODESIGN_TIMESTAMP) /v $@
323 !IF "$(CODESIGN_CROSS_CERT)" != ""
324 CODESIGN_KERNEL= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /t $(CODESIGN_TIMESTAMP) /ac "$(CODESIGN_CROSS_CERT)" /v
330 !IF DEFINED(SYMSTORE_EXE) && DEFINED(SYMSTORE_ROOT)
331 !IF "$(SYMSTORE_COMMENT)" != ""
332 SYMSTORE_COMMENT = |$(SYMSTORE_COMMENT)
335 $(SYMSTORE_EXE) add /s $(SYMSTORE_ROOT) /t "OpenAFS for Windows" /v "$(AFSBLD_TYPE)-$(CPU)-$(AFSPRODUCT_VERSION)" /c "$(@F)$(SYMSTORE_COMMENT)" /f $*.*
340 # Set compiler warning level
342 !IFNDEF AFSDEV_WARNLEVEL
345 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
346 "$(AFSDEV_WARNLEVEL)" != "1" && \
347 "$(AFSDEV_WARNLEVEL)" != "2" && \
348 "$(AFSDEV_WARNLEVEL)" != "3" && \
349 "$(AFSDEV_WARNLEVEL)" != "4")
350 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
353 !IF ("$(AFSDEV_WARNLEVEL)" == "4" && "$(AFSVER_CL)" == "1500")
357 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
359 # C/C++ compilation macros
360 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
362 # Inference rules for building and installing targets
363 # Compile .c files, from current directory to defined by OUT
377 $(RC) /fo$(OUT)\$(<B).res $<
381 .h.{$(DESTDIR)\include\afs}.h:
382 $(COPY) $< $(DESTDIR)\include\afs
384 .h.{$(DESTDIR)\include\rx}.h:
385 $(COPY) $< $(DESTDIR)\include\rx
387 .h.{$(DESTDIR)\include}.h:
388 $(COPY) $< $(DESTDIR)\include
390 .h.{$(DESTDIR)\include\WINNT}.h:
391 $(COPY) $< $(DESTDIR)\include\WINNT
393 .h.{$(DESTDIR)\include}.h:
394 $(COPY) $(*B).h $(DESTDIR)\include
396 .h.{$(DESTDIR)\include\afs}.h:
397 $(COPY) $(*B).h $(DESTDIR)\include\afs
399 .h.{$(DESTDIR)\include\rx}.h:
400 $(COPY) $(*B).h $(DESTDIR)\include\rx
402 .h.{$(DESTDIR)\include\WINNT}.h:
403 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
405 # Resource compiler macro
406 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
408 #################### Link optional build flags set ###########
410 afslflags = $(afslflags) /FIXED:NO /VERBOSE:LIB
411 !IF ("$(AFSVER_CL)"=="1500")
412 afslflags = $(afslflags) /MACHINE:AMD64
414 afslflags = $(afslflags) /MACHINE:X64
417 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
418 afslflags = $(afslflags) /MANIFEST
422 mfclflags = $(guilflags)
423 mfclflags = $(mfclflags:/NODEFAULTLIB=)
425 mfcdlllflags = $(dlllflags)
426 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
428 mfclibsdll = $(guilibsdll)
429 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
430 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
432 # Link with binmode.obj; files will be opened in binary mode by default.
433 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
435 ldebug=/DEBUG /PDB:$*.pdb
436 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
437 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
441 # Generate debug information and pdb files
442 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
444 #!IF ("AFSVER_CL"=="1200")
445 #ldebug = $(ldebug) -debugtype:cv
448 # Disable optimization; generate full debug info in obj.
449 afscflags = $(afscflags) /Od /Zi
452 !IF ("AFSVER_CL"=="1200")
453 ldebug = $(ldebug) -debugtype:both
454 ldebug = $(ldebug:-debugtype:cv=)
455 !ENDIF #AFSVER_CL == 1200
458 !IFNDEF _CRTDBG_MAP_ALLOC
459 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
460 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
462 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
463 !IF ("$(AFSVER_CL)"=="1200")
464 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
465 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
466 !ENDIF #AFSVER_CL == 1200
468 !ELSE #_CRTDBG_MAP_ALLOC
469 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
470 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
471 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
472 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
473 !ENDIF #_CRTDBG_MAP_ALLOC
475 EXEPREP = rebase -b 0x00400000 -q $@
476 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
478 !ENDIF #CHECKED BUILD
480 # EXE link macro for console applications
481 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
483 # EXE link macro for GUI applications
484 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
486 # EXE link macro for MFC applications
487 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
489 # DLL link macro for console applications
490 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
492 # DLL link macro for GUI applications
493 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
495 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
497 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
499 # DLL link macro for resource-only DLLs
500 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup=-noentry) $(afslflags) $**
502 # Library archive macro
503 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
505 # Language selection macro
506 NTLANG = $(DESTDIR)\bin\NTLang.bat
510 AFSDEV_AUXMIDLFLAGS=/env x64 /x64 /Oicf
516 ######### Create Cygwin .a files
517 # This macro should be invoked as a build step for a DLL target.
520 for %%C in (as.exe) do \
521 if exist %%~$$PATH:C \
522 dlltool --dllname $(@B).dll --output-lib $(@R).a --temp-prefix $(OUT) -S %%~$$PATH:C
524 MAKECYGLIB=echo Skipping Cygwin archive