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)
73 PATH = $(AFSDEV_BIN);$(PATH)
76 !ERROR Must define AFSDEV_LIB to be the default library directories.
79 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
80 # If env. var. LIB not defined then macro assignment won't set it.
81 !ERROR Failed setting environment variable LIB.
85 #define used in WinNT/2000 installation and program version display
86 !IF !DEFINED(AFSPRODUCT_VER_MAJOR)
87 AFSPRODUCT_VER_MAJOR=1
89 !IF !DEFINED(AFSPRODUCT_VER_MINOR)
90 AFSPRODUCT_VER_MINOR=6
92 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
93 AFSPRODUCT_VER_PATCH=2200
95 !IF !DEFINED(AFSPRODUCT_VER_BUILD)
96 AFSPRODUCT_VER_BUILD=0
99 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
100 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
101 # Set CELLNAME_DEFAULT to "your cell name"
102 !IF !DEFINED(CELLNAME_DEFAULT)
103 CELLNAME_DEFAULT=openafs.org
105 CELLSERVDB_INSTALL=CellServDB.GrandCentral
106 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
109 # Define defaults folder locations
123 !IF ("$(AFS_OBJDIR)"=="")
124 ######### AFS_OBJDIR is NOT used use default locations
125 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
126 DESTDIR=$(DEST)\$(SYS_NAME)\checked
127 OJT=$(OBJ)\$(SYS_NAME)\checked
129 DESTDIR=$(DEST)\$(SYS_NAME)\free
130 OJT=$(OBJ)\$(SYS_NAME)\free
132 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
134 ######### AFS_OBJDIR is defined, use specific locations for obj and dest
135 # there is a special case for config because util_cr is not defined yet!
136 ! IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
137 # AFS_OBJDIR is relative path
138 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
139 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\dest\$(SYS_NAME)\checked
140 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
142 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\free\config
143 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\dest\$(SYS_NAME)\free
146 ! IF (EXIST($(AFS_OBJDIR)))
147 # AFS_OBJDIR is full path
148 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
149 DESTDIR=$(AFS_OBJDIR)\dest\$(SYS_NAME)\checked
150 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
152 DESTDIR=$(AFS_OBJDIR)\dest\$(SYS_NAME)\free
153 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\free\config
156 !ERROR Can't find location of DEST directory!
159 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
161 ! IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)")
162 # we are NOT doing a config make, use util_cr to generate object directory
163 ! IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
164 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
167 ! IF EXIST($(TMP)\home)
170 !INCLUDE $(TEMP)\home
175 !IF ("$(RELDIR)"=="")
181 !MESSAGE Directory assignments:
182 !MESSAGE OJT=[$(OJT)]
183 !MESSAGE OUT=[$(OUT)]
184 !MESSAGE DESTDIR=[$(DESTDIR)]
186 # Definitions provided here are based on WIN32.MAK, a common nmake
187 # file included with the MS SDK and MS VC distributions.
188 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
189 # port this nmake file if additional compiler support is required.
191 !IF ("$(APPVER)" == "")
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 \
260 -D_USE_DECLSPECS_FOR_SAL=0 \
261 -D_USE_ATTRIBUTES_FOR_SAL=0 \
262 -D_ATL_SECURE_NO_DEPRECATE \
263 -D_AFX_DISABLE_DEPRECATED \
264 -D_AFX_SECURE_NO_WARNINGS \
265 $(AFSDEV_AUXCDEFINES)
267 # Compiler switches (except include paths and preprocessor defines)
269 # Note: if conflicting options are specified, rightmost option applies.
271 # /Oy- specifies no frame-pointer omission
272 # /GF pool strings and place in read-only memory
273 # /Gd use cdecl calling convention by default
274 # /Gy enable function-level linking
275 # /EHsc enable C++ exceptions (assumes extern C funcs never throw exceptions)
276 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
285 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
286 afscflags = $(afscflags) /EHsc /wd4996
288 afscflags = $(afscflags) /GX
291 !IF ("$(AFSVER_CL)"!="1200")
292 afscflags = $(afscflags) /GT /GS
294 !IF ("$(AFSVER_CL)"!="1400" && "$(AFSVER_CL)"!="1500")
295 afscflags = $(afscflags) /G7
299 !IF ("$(AFSIFS)" == "TRUE")
300 afscdefs = $(afscdefs) -DAFSIFS
303 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
304 afscflags = $(afscflags) /Ox /Zi
305 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
306 cvarsdll = $(cvarsdll:-MDd=-MD)
308 _VC_MANIFEST_BASENAME = __OAFW
309 !ELSE # CHECKED BUILD
310 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
312 !IF ("$(AFSVER_CL)"=="1200")
313 afscdefs = $(afscdefs) -DDEBUG /GZ
315 afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
318 !IFDEF _CRTDBG_MAP_ALLOC
319 afscflags = $(afscflags) -D_DEBUG -D_CRTDBG_MAP_ALLOC
323 _VC_MANIFEST_BASENAME = __OAFW.Debug
326 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
327 _VC_MANIFEST_EMBED_EXE= \
328 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;1
330 _VC_MANIFEST_EMBED_DLL= \
331 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;2
333 _VC_MANIFEST_EMBED_EXE=
334 _VC_MANIFEST_EMBED_DLL=
337 !IF "$(SIGNTOOL)" == ""
338 SIGNTOOL=signtool.exe
341 !IF DEFINED(CODESIGN_TIMESTAMP)
342 !IF DEFINED(CODESIGN_DESC) && DEFINED(CODESIGN_URL)
343 CODESIGN_USERLAND= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /t $(CODESIGN_TIMESTAMP) /v $(CODESIGN_OTHER) $@
344 !IF "$(CODESIGN_CROSS_CERT)" != ""
345 CODESIGN_KERNEL= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /t $(CODESIGN_TIMESTAMP) $(CODESIGN_OTHER) /ac "$(CODESIGN_CROSS_CERT)" /v $@
349 !IF DEFINED(CODESIGN_DESC) && DEFINED(CODESIGN_URL)
350 CODESIGN_USERLAND= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /v $(CODESIGN_OTHER) $@
351 !IF "$(CODESIGN_CROSS_CERT)" != ""
352 CODESIGN_KERNEL= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /v $(CODESIGN_OTHER) /ac "$(CODESIGN_CROSS_CERT)" $@
357 !IF DEFINED(SYMSTORE_EXE) && DEFINED(SYMSTORE_ROOT)
358 !IF "$(SYMSTORE_COMMENT)" != ""
359 SYMSTORE_COMMENT = |$(SYMSTORE_COMMENT)
362 $(SYMSTORE_EXE) add /s $(SYMSTORE_ROOT) /t "OpenAFS for Windows" /v "$(AFSBLD_TYPE)-$(CPU)-$(AFSPRODUCT_VERSION)" /c "$(@F)$(SYMSTORE_COMMENT)" /f $*.*
367 # Set compiler warning level
369 !IFNDEF AFSDEV_WARNLEVEL
372 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
373 "$(AFSDEV_WARNLEVEL)" != "1" && \
374 "$(AFSDEV_WARNLEVEL)" != "2" && \
375 "$(AFSDEV_WARNLEVEL)" != "3" && \
376 "$(AFSDEV_WARNLEVEL)" != "4")
377 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
380 !IF ("$(AFSDEV_WARNLEVEL)" == "4" && "$(AFSVER_CL)" == "1500")
384 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
386 # C/C++ compilation macros
387 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
389 # Inference rules for building and installing targets
390 # Compile .c files, from current directory to defined by OUT
404 $(RC) /fo$(OUT)\$(<B).res $<
408 .h.{$(DESTDIR)\include\afs}.h:
409 $(COPY) $< $(DESTDIR)\include\afs
411 .h.{$(DESTDIR)\include\rx}.h:
412 $(COPY) $< $(DESTDIR)\include\rx
414 .h.{$(DESTDIR)\include\des}.h:
415 $(COPY) $< $(DESTDIR)\include
417 .h.{$(DESTDIR)\include\hcrypto}.h:
418 $(COPY) $< $(DESTDIR)\include\hcrypto
420 .h.{$(DESTDIR)\include}.h:
421 $(COPY) $< $(DESTDIR)\include
423 .h.{$(DESTDIR)\include\WINNT}.h:
424 $(COPY) $< $(DESTDIR)\include\WINNT
426 .h.{$(DESTDIR)\include}.h:
427 $(COPY) $(*B).h $(DESTDIR)\include
429 .h.{$(DESTDIR)\include\afs}.h:
430 $(COPY) $(*B).h $(DESTDIR)\include\afs
432 .h.{$(DESTDIR)\include\rx}.h:
433 $(COPY) $(*B).h $(DESTDIR)\include\rx
435 .h.{$(DESTDIR)\include\des}.h:
436 $(COPY) $(*B).h $(DESTDIR)\include
438 .h.{$(DESTDIR)\include\hcrypto}.h:
439 $(COPY) $(*B).h $(DESTDIR)\include\hcrypto
441 .h.{$(DESTDIR)\include\WINNT}.h:
442 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
444 # Resource compiler macro
445 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
447 #################### Link optional build flags set ###########
449 afslflags = $(afslflags) /FIXED:NO /VERBOSE:LIB
450 !IF ("$(AFSVER_CL)"=="1500")
451 afslflags = $(afslflags) /MACHINE:AMD64
453 afslflags = $(afslflags) /MACHINE:X64
456 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
457 afslflags = $(afslflags) /MANIFEST
461 mfclflags = $(guilflags)
462 mfclflags = $(mfclflags:/NODEFAULTLIB=)
464 mfcdlllflags = $(dlllflags)
465 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
467 mfclibsdll = $(guilibsdll)
468 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
469 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
471 # Link with binmode.obj; files will be opened in binary mode by default.
472 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
474 ldebug=/DEBUG /PDB:$*.pdb
475 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
476 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
480 # Generate debug information and pdb files
481 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
483 #!IF ("AFSVER_CL"=="1200")
484 #ldebug = $(ldebug) -debugtype:cv
487 # Disable optimization; generate full debug info in obj.
488 afscflags = $(afscflags) /Od /Zi
491 !IF ("AFSVER_CL"=="1200")
492 ldebug = $(ldebug) -debugtype:both
493 ldebug = $(ldebug:-debugtype:cv=)
494 !ENDIF #AFSVER_CL == 1200
497 !IFNDEF _CRTDBG_MAP_ALLOC
498 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
499 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
501 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
502 !IF ("$(AFSVER_CL)"=="1200")
503 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
504 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
505 !ENDIF #AFSVER_CL == 1200
507 !ELSE #_CRTDBG_MAP_ALLOC
508 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
509 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
510 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
511 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
512 !ENDIF #_CRTDBG_MAP_ALLOC
514 EXEPREP = rebase -b 0x00400000 -q $@
515 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
517 !ENDIF #CHECKED BUILD
519 # EXE link macro for console applications
520 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) user32.lib version.lib $**
522 # EXE link macro for GUI applications
523 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
525 # EXE link macro for MFC applications
526 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
528 # DLL link macro for console applications
529 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
531 # DLL link macro for GUI applications
532 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
534 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) user32.lib version.lib $**
536 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
538 # DLL link macro for resource-only DLLs
539 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup=-noentry) $(afslflags) $**
541 # Library archive macro
542 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
544 # Language selection macro
545 NTLANG = $(DESTDIR)\bin\NTLang.bat
549 AFSDEV_AUXMIDLFLAGS=/env x64 /x64 /Oicf
555 ######### Create Cygwin .a files
556 # This macro should be invoked as a build step for a DLL target.
559 for %%C in (as.exe) do \
560 if exist %%~$$PATH:C \
561 dlltool --dllname $(@B).dll --output-lib $(@R).a --temp-prefix $(OUT) -S %%~$$PATH:C
563 MAKECYGLIB=echo Skipping Cygwin archive