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)
74 !ERROR Must define AFSDEV_LIB to be the default library directories.
77 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
78 # If env. var. LIB not defined then macro assignment won't set it.
79 !ERROR Failed setting environment variable LIB.
83 #define used in WinNT/2000 installation and program version display
84 !IF !DEFINED(AFSPRODUCT_VER_MAJOR)
85 AFSPRODUCT_VER_MAJOR=1
87 !IF !DEFINED(AFSPRODUCT_VER_MINOR)
88 AFSPRODUCT_VER_MINOR=7
90 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
91 AFSPRODUCT_VER_PATCH=9903
93 !IF !DEFINED(AFSPRODUCT_VER_BUILD)
94 AFSPRODUCT_VER_BUILD=0
97 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
98 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
99 # Set CELLNAME_DEFAULT to "your cell name"
100 !IF !DEFINED(CELLNAME_DEFAULT)
101 CELLNAME_DEFAULT=grand.central.org
103 CELLSERVDB_INSTALL=CellServDB.GrandCentral
104 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
107 # Define defaults folder locations
121 !IF ("$(AFS_OBJDIR)"=="")
122 ######### AFS_OBJDIR is NOT used use default locations
123 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
124 DESTDIR=$(DEST)\$(SYS_NAME)\checked
125 OJT=$(OBJ)\$(SYS_NAME)\checked
127 DESTDIR=$(DEST)\$(SYS_NAME)\free
128 OJT=$(OBJ)\$(SYS_NAME)\free
130 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
132 ######### AFS_OBJDIR is defined, use specific locations for obj and dest
133 # there is a special case for config because util_cr is not defined yet!
134 ! IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
135 # AFS_OBJDIR is relative path
136 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
137 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\dest\$(SYS_NAME)\checked
138 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
140 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\free\config
141 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\dest\$(SYS_NAME)\free
144 ! IF (EXIST($(AFS_OBJDIR)))
145 # AFS_OBJDIR is full path
146 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
147 DESTDIR=$(AFS_OBJDIR)\dest\$(SYS_NAME)\checked
148 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
150 DESTDIR=$(AFS_OBJDIR)\dest\$(SYS_NAME)\free
151 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\free\config
154 !ERROR Can't find location of DEST directory!
157 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
159 ! IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)")
160 # we are NOT doing a config make, use util_cr to generate object directory
161 ! IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
162 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
165 ! IF EXIST($(TMP)\home)
168 !INCLUDE $(TEMP)\home
173 !IF ("$(RELDIR)"=="")
179 !MESSAGE Directory assignments:
180 !MESSAGE OJT=[$(OJT)]
181 !MESSAGE OUT=[$(OUT)]
182 !MESSAGE DESTDIR=[$(DESTDIR)]
184 # Definitions provided here are based on WIN32.MAK, a common nmake
185 # file included with the MS SDK and MS VC distributions.
186 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
187 # port this nmake file if additional compiler support is required.
189 !IF ("$(APPVER)" == "")
193 PATH = $(AFSDEV_BIN);$(DESTDIR)\lib;$(PATH)
197 # Extend and/or supplement definitions in WIN32.MAK.
221 !IF !DEFINED(MAKECMD)
231 COMPILE_ET = $(DESTDIR)\bin\compile_et
232 RXGEN = $(DESTDIR)\bin\rxgen
234 # Common clean target.
236 $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb $(OUT)\*.res $(OUT)\*.manifest $(OUT)\*.exp
237 $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
239 # Common lang target.
243 #################### Compile optional build flags set ###########
247 -I$(DESTDIR)\include \
248 -DWIN32_LEAN_AND_MEAN \
251 -D_WIN32_WINNT=0x0502 \
253 -DNTDDI_VERSION=0x05020000 \
254 -DREGISTER_POWER_NOTIFICATIONS \
255 -DAFS_FREELANCE_CLIENT \
256 -DAFS_64BITPOINTER_ENV \
257 -DAFS_64BITUSERPOINTER_ENV \
259 -D_USE_DECLSPECS_FOR_SAL=0 \
260 -D_USE_ATTRIBUTES_FOR_SAL=0 \
261 -D_ATL_SECURE_NO_DEPRECATE \
262 -D_AFX_DISABLE_DEPRECATED \
263 -D_AFX_SECURE_NO_WARNINGS \
264 $(AFSDEV_AUXCDEFINES)
266 # Compiler switches (except include paths and preprocessor defines)
268 # Note: if conflicting options are specified, rightmost option applies.
270 # /Oy- specifies no frame-pointer omission
271 # /GF pool strings and place in read-only memory
272 # /Gd use cdecl calling convention by default
273 # /Gy enable function-level linking
274 # /EHsc enable C++ exceptions (assumes extern C funcs never throw exceptions)
275 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
284 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
285 afscflags = $(afscflags) /EHsc /wd4996
287 afscflags = $(afscflags) /GX
290 !IF ("$(AFSVER_CL)"!="1200")
291 afscflags = $(afscflags) /GT /GS
293 !IF ("$(AFSVER_CL)"!="1400" && "$(AFSVER_CL)"!="1500")
294 afscflags = $(afscflags) /G7
298 !IF ("$(AFSIFS)" == "TRUE")
299 afscdefs = $(afscdefs) -DAFSIFS
302 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
303 afscflags = $(afscflags) /Ox /Zi
304 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
305 cvarsdll = $(cvarsdll:-MDd=-MD)
307 _VC_MANIFEST_BASENAME = __OAFW
308 !ELSE # CHECKED BUILD
309 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
311 !IF ("$(AFSVER_CL)"=="1200")
312 afscdefs = $(afscdefs) -DDEBUG /GZ
314 afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
317 !IFDEF _CRTDBG_MAP_ALLOC
318 afscflags = $(afscflags) -D_DEBUG -D_CRTDBG_MAP_ALLOC
322 _VC_MANIFEST_BASENAME = __OAFW.Debug
325 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
326 _VC_MANIFEST_EMBED_EXE= \
327 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;1
329 _VC_MANIFEST_EMBED_DLL= \
330 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;2
332 _VC_MANIFEST_EMBED_EXE=
333 _VC_MANIFEST_EMBED_DLL=
336 !IF "$(SIGNTOOL)" == ""
337 SIGNTOOL=signtool.exe
340 !IF DEFINED(CODESIGN_TIMESTAMP)
341 !IF DEFINED(CODESIGN_DESC) && DEFINED(CODESIGN_URL)
342 CODESIGN_USERLAND= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /t $(CODESIGN_TIMESTAMP) /v $(CODESIGN_OTHER) $@
343 !IF "$(CODESIGN_CROSS_CERT)" != ""
344 CODESIGN_KERNEL= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /t $(CODESIGN_TIMESTAMP) $(CODESIGN_OTHER) /ac "$(CODESIGN_CROSS_CERT)" /v $@
348 !IF DEFINED(CODESIGN_DESC) && DEFINED(CODESIGN_URL)
349 CODESIGN_USERLAND= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /v $(CODESIGN_OTHER) $@
350 !IF "$(CODESIGN_CROSS_CERT)" != ""
351 CODESIGN_KERNEL= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /v $(CODESIGN_OTHER) /ac "$(CODESIGN_CROSS_CERT)" $@
356 !IF DEFINED(SYMSTORE_EXE) && DEFINED(SYMSTORE_ROOT)
357 !IF "$(SYMSTORE_COMMENT)" != ""
358 SYMSTORE_COMMENT = |$(SYMSTORE_COMMENT)
361 $(SYMSTORE_EXE) add /s $(SYMSTORE_ROOT) /t "OpenAFS for Windows" /v "$(AFSBLD_TYPE)-$(CPU)-$(AFSPRODUCT_VERSION)" /c "$(@F)$(SYMSTORE_COMMENT)" /f $*.*
366 # Set compiler warning level
368 !IFNDEF AFSDEV_WARNLEVEL
371 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
372 "$(AFSDEV_WARNLEVEL)" != "1" && \
373 "$(AFSDEV_WARNLEVEL)" != "2" && \
374 "$(AFSDEV_WARNLEVEL)" != "3" && \
375 "$(AFSDEV_WARNLEVEL)" != "4")
376 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
379 !IF ("$(AFSDEV_WARNLEVEL)" == "4" && "$(AFSVER_CL)" == "1500")
383 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
385 # C/C++ compilation macros
386 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
388 # Inference rules for building and installing targets
389 # Compile .c files, from current directory to defined by OUT
403 $(RC) /fo$(OUT)\$(<B).res $<
407 .h.{$(DESTDIR)\include\afs}.h:
408 $(COPY) $< $(DESTDIR)\include\afs
410 .h.{$(DESTDIR)\include\rx}.h:
411 $(COPY) $< $(DESTDIR)\include\rx
413 .h.{$(DESTDIR)\include\opr}.h:
414 $(COPY) $< $(DESTDIR)\include\opr
416 .h.{$(DESTDIR)\include\des}.h:
417 $(COPY) $< $(DESTDIR)\include
419 .h.{$(DESTDIR)\include\hcrypto}.h:
420 $(COPY) $< $(DESTDIR)\include\hcrypto
422 .h.{$(DESTDIR)\include}.h:
423 $(COPY) $< $(DESTDIR)\include
425 .h.{$(DESTDIR)\include\WINNT}.h:
426 $(COPY) $< $(DESTDIR)\include\WINNT
428 .h.{$(DESTDIR)\include}.h:
429 $(COPY) $(*B).h $(DESTDIR)\include
431 .h.{$(DESTDIR)\include\afs}.h:
432 $(COPY) $(*B).h $(DESTDIR)\include\afs
434 .h.{$(DESTDIR)\include\rx}.h:
435 $(COPY) $(*B).h $(DESTDIR)\include\rx
437 .h.{$(DESTDIR)\include\opr}.h:
438 $(COPY) $(*B).h $(DESTDIR)\include\opr
440 .h.{$(DESTDIR)\include\des}.h:
441 $(COPY) $(*B).h $(DESTDIR)\include
443 .h.{$(DESTDIR)\include\hcrypto}.h:
444 $(COPY) $(*B).h $(DESTDIR)\include\hcrypto
446 .h.{$(DESTDIR)\include\WINNT}.h:
447 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
449 # Resource compiler macro
450 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
452 #################### Link optional build flags set ###########
454 afslflags = $(afslflags) /FIXED:NO /VERBOSE:LIB
455 !IF ("$(AFSVER_CL)"=="1500")
456 afslflags = $(afslflags) /MACHINE:AMD64
458 afslflags = $(afslflags) /MACHINE:X64
461 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
462 afslflags = $(afslflags) /MANIFEST
466 mfclflags = $(guilflags)
467 mfclflags = $(mfclflags:/NODEFAULTLIB=)
469 mfcdlllflags = $(dlllflags)
470 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
472 mfclibsdll = $(guilibsdll)
473 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
474 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
476 # Link with binmode.obj; files will be opened in binary mode by default.
477 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
479 ldebug=/DEBUG /PDB:$*.pdb
480 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
481 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
485 # Generate debug information and pdb files
486 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
488 #!IF ("AFSVER_CL"=="1200")
489 #ldebug = $(ldebug) -debugtype:cv
492 # Disable optimization; generate full debug info in obj.
493 afscflags = $(afscflags) /Od /Zi
496 !IF ("AFSVER_CL"=="1200")
497 ldebug = $(ldebug) -debugtype:both
498 ldebug = $(ldebug:-debugtype:cv=)
499 !ENDIF #AFSVER_CL == 1200
502 !IFNDEF _CRTDBG_MAP_ALLOC
503 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
504 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
506 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
507 !IF ("$(AFSVER_CL)"=="1200")
508 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
509 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
510 !ENDIF #AFSVER_CL == 1200
512 !ELSE #_CRTDBG_MAP_ALLOC
513 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
514 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
515 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
516 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
517 !ENDIF #_CRTDBG_MAP_ALLOC
519 EXEPREP = rebase -b 0x00400000 -q $@
520 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
522 !ENDIF #CHECKED BUILD
524 # EXE link macro for console applications
525 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) user32.lib version.lib $**
527 # EXE link macro for GUI applications
528 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
530 # EXE link macro for MFC applications
531 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
533 # DLL link macro for console applications
534 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
536 # DLL link macro for GUI applications
537 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
539 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) user32.lib version.lib $**
541 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
543 # DLL link macro for resource-only DLLs
544 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup=-noentry) $(afslflags) $**
546 # Library archive macro
547 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
549 # Language selection macro
550 NTLANG = $(DESTDIR)\bin\NTLang.bat
554 AFSDEV_AUXMIDLFLAGS=/env x64 /x64 /Oicf
560 ######### Create Cygwin .a files
561 # This macro should be invoked as a build step for a DLL target.
564 for %%C in (as.exe) do \
565 if exist %%~$$PATH:C \
566 dlltool --dllname $(@B).dll --output-lib $(@R).a --temp-prefix $(OUT) -S %%~$$PATH:C
568 MAKECYGLIB=echo Skipping Cygwin archive
571 ######### Heimdal compatibility support
573 !IFNDEF HEIMDALSDKDIR
574 !IFDEF KERBEROSCOMPATSDKROOT
575 HEIMDALSDKDIR=$(KERBEROSCOMPATSDKROOT)\1.0
577 !ERROR HEIMDALSDKDIR or KERBEROSCOMPATSDKROOT needs to be defined
581 HEIMINC=$(HEIMDALSDKDIR)\inc
582 HEIMLIB=$(HEIMDALSDKDIR)\lib\$(CPU)
584 afscdefs=$(afscdefs) -I$(HEIMINC) -I$(HEIMINC)\krb5
586 HEIMDEPS=$(HEIMLIB)\heimdal.lib $(DESTDIR)\lib\krbcompat_delayload.obj
587 HEIMLINKOPTS=/DELAYLOAD:heimdal.dll