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)" == "x86")
44 !IF ("$(CPU)" != "i386")
45 !ERROR Platform SDK not configured for i386
48 !IF EXISTS("TOOLS.INI")
49 !MESSAGE ************CAUTION TOOLS.INI IN EFFECT**********
51 !IF ("$(AFSROOT)"=="")
52 !ERROR AFSROOT is not set
54 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
55 AFSDEV_BUILDTYPE = NONE
57 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
58 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
61 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
62 !UNDEF _CRTDBG_MAP_ALLOC
65 # Limit default include and library directories to those specified for build.
67 !IFNDEF AFSDEV_INCLUDE
68 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
71 !IF ((!DEFINED(INCLUDE)) && ([set INCLUDE=$(AFSDEV_INCLUDE)] != 0))
72 # If env. var. INCLUDE not defined then macro assignment won't set it.
73 !ERROR Failed setting environment variable INCLUDE.
75 INCLUDE = $(AFSDEV_INCLUDE)
78 !ERROR Must define AFSDEV_LIB to be the default library directories.
81 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
82 # If env. var. LIB not defined then macro assignment won't set it.
83 !ERROR Failed setting environment variable LIB.
87 #define used in WinNT/2000 installation and program version display
88 !IF !DEFINED(AFSPRODUCT_VER_MAJOR)
89 AFSPRODUCT_VER_MAJOR=1
91 !IF !DEFINED(AFSPRODUCT_VER_MINOR)
92 AFSPRODUCT_VER_MINOR=7
94 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
95 AFSPRODUCT_VER_PATCH=9903
97 !IF !DEFINED(AFSPRODUCT_VER_BUILD)
98 AFSPRODUCT_VER_BUILD=0
101 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
102 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
103 # Set CELLNAME_DEFAULT to "your cell name"
104 !IF !DEFINED(CELLNAME_DEFAULT)
105 CELLNAME_DEFAULT=grand.central.org
107 CELLSERVDB_INSTALL=CellServDB.GrandCentral
108 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
111 # Define defaults folder locations
125 !IF ("$(AFS_OBJDIR)"=="")
126 ######### AFS_OBJDIR is NOT used use default locations
127 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
128 DESTDIR=$(DEST)\$(SYS_NAME)\checked
129 OJT=$(OBJ)\$(SYS_NAME)\checked
131 DESTDIR=$(DEST)\$(SYS_NAME)\free
132 OJT=$(OBJ)\$(SYS_NAME)\free
134 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
136 ######### AFS_OBJDIR is defined, use specific locations for obj and dest
137 # there is a special case for config because util_cr is not defined yet!
138 ! IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
139 # AFS_OBJDIR is relative path
140 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
141 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
142 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
144 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\free\config
145 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
148 ! IF (EXIST($(AFS_OBJDIR)))
149 # AFS_OBJDIR is full path
150 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
151 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
152 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
154 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
155 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\free\config
158 !ERROR Can't find location of DEST directory!
161 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
163 ! IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)")
164 # we are NOT doing a config make, use util_cr to generate object directory
165 ! IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
166 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
169 ! IF EXIST($(TMP)\home)
172 !INCLUDE $(TEMP)\home
177 !IF ("$(RELDIR)"=="")
183 !MESSAGE Directory assignments:
184 !MESSAGE OJT=[$(OJT)]
185 !MESSAGE OUT=[$(OUT)]
186 !MESSAGE DESTDIR=[$(DESTDIR)]
188 # Definitions provided here are based on WIN32.MAK, a common nmake
189 # file included with the MS SDK and MS VC distributions.
190 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
191 # port this nmake file if additional compiler support is required.
193 # !IF ("$(AFSVER_CL)"=="1300")
194 # afslflags = $(afslflags) /DEBUG
197 !IF ("$(APPVER)" == "")
201 PATH = $(AFSDEV_BIN);$(DESTDIR)\lib;$(PATH)
205 # Extend and/or supplement definitions in WIN32.MAK.
229 !IF !DEFINED(MAKECMD)
239 COMPILE_ET = $(DESTDIR)\bin\compile_et
240 RXGEN = $(DESTDIR)\bin\rxgen
242 # Common clean target.
244 $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb $(OUT)\*.res $(OUT)\*.manifest $(OUT)\*.exp
245 $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
247 # Common lang target.
251 #################### Compile optional build flags set ###########
255 -I$(DESTDIR)\include \
256 -DWIN32_LEAN_AND_MEAN \
259 -D_WIN32_WINNT=0x0500 \
260 -DNTDDI_VERSION=0x05000000 \
262 -DREGISTER_POWER_NOTIFICATIONS \
263 -DAFS_FREELANCE_CLIENT \
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 # /GX 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
277 # /Wp64 enable 64-bit porting warnings (conflicts with warnings as errors
278 # due to SDK mapping of Get/SetWindowLongPtr to Get/SetWindowLong
287 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
288 afscflags = $(afscflags) /EHsc /wd4996
290 afscflags = $(afscflags) /GX
293 !IF ("$(AFSVER_CL)"!="1200")
294 afscflags = $(afscflags) /GT /GS
296 !IF ("$(AFSVER_CL)"!="1400" && "$(AFSVER_CL)"!="1500")
297 afscflags = $(afscflags) /G7
301 !IF ("$(AFSIFS)" == "TRUE")
302 afscdefs = $(afscdefs) -DAFSIFS
305 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
307 afscflags = $(afscflags) /Ox /Zi
308 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
309 cvarsdll = $(cvarsdll:-MDd=-MD)
311 _VC_MANIFEST_BASENAME = __OAFW
313 !ELSE # CHECKED BUILD
314 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
316 !IF ("$(AFSVER_CL)"=="1200")
317 afscdefs = $(afscdefs) -DDEBUG /GZ
319 afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
322 !IFDEF _CRTDBG_MAP_ALLOC
323 afscflags = $(afscflags) -D_DEBUG -D_CRTDBG_MAP_ALLOC
327 _VC_MANIFEST_BASENAME = __OAFW.Debug
330 !IF ("$(AFSVER_CL)"=="1500"|| "$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)" == "1310")
331 _VC_MANIFEST_EMBED_EXE= \
332 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;1
334 _VC_MANIFEST_EMBED_DLL= \
335 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;2
337 _VC_MANIFEST_EMBED_EXE=
338 _VC_MANIFEST_EMBED_DLL=
341 !IF "$(SIGNTOOL)" == ""
342 SIGNTOOL=signtool.exe
345 !IF DEFINED(CODESIGN_TIMESTAMP)
346 !IF DEFINED(CODESIGN_DESC) && DEFINED(CODESIGN_URL)
347 CODESIGN_USERLAND= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /t $(CODESIGN_TIMESTAMP) /v $(CODESIGN_OTHER) $@
348 !IF "$(CODESIGN_CROSS_CERT)" != ""
349 CODESIGN_KERNEL= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /t $(CODESIGN_TIMESTAMP) $(CODESIGN_OTHER) /ac "$(CODESIGN_CROSS_CERT)" /v $@
353 !IF DEFINED(CODESIGN_DESC) && DEFINED(CODESIGN_URL)
354 CODESIGN_USERLAND= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /v $(CODESIGN_OTHER) $@
355 !IF "$(CODESIGN_CROSS_CERT)" != ""
356 CODESIGN_KERNEL= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /v $(CODESIGN_OTHER) /ac "$(CODESIGN_CROSS_CERT)" $@
362 !IF DEFINED(SYMSTORE_EXE) && DEFINED(SYMSTORE_ROOT)
363 !IF "$(SYMSTORE_COMMENT)" != ""
364 SYMSTORE_COMMENT = |$(SYMSTORE_COMMENT)
367 $(SYMSTORE_EXE) add /s $(SYMSTORE_ROOT) /t "OpenAFS for Windows" /v "$(AFSBLD_TYPE)-$(CPU)-$(AFSPRODUCT_VERSION)" /c "$(@F)$(SYMSTORE_COMMENT)" /f $*.*
372 # Set compiler warning level
374 !IFNDEF AFSDEV_WARNLEVEL
377 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
378 "$(AFSDEV_WARNLEVEL)" != "1" && \
379 "$(AFSDEV_WARNLEVEL)" != "2" && \
380 "$(AFSDEV_WARNLEVEL)" != "3" && \
381 "$(AFSDEV_WARNLEVEL)" != "4")
382 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
386 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
388 # C/C++ compilation macros
389 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
391 # Inference rules for building and installing targets
392 # Compile .c files, from current directory to defined by OUT
406 $(RC) /fo$(OUT)\$(<B).res $<
408 # Compile .rc (resource) files
414 .h.{$(DESTDIR)\include\afs}.h:
415 $(COPY) $< $(DESTDIR)\include\afs
417 .h.{$(DESTDIR)\include\rx}.h:
418 $(COPY) $< $(DESTDIR)\include\rx
420 .h.{$(DESTDIR)\include\opr}.h:
421 $(COPY) $< $(DESTDIR)\include\opr
423 .h.{$(DESTDIR)\include\des}.h:
424 $(COPY) $< $(DESTDIR)\include
426 .h.{$(DESTDIR)\include\hcrypto}.h:
427 $(COPY) $< $(DESTDIR)\include\hcrypto
429 .h.{$(DESTDIR)\include}.h:
430 $(COPY) $< $(DESTDIR)\include
432 .h.{$(DESTDIR)\include\WINNT}.h:
433 $(COPY) $< $(DESTDIR)\include\WINNT
435 .h.{$(DESTDIR)\include}.h:
436 $(COPY) $(*B).h $(DESTDIR)\include
438 .h.{$(DESTDIR)\include\afs}.h:
439 $(COPY) $(*B).h $(DESTDIR)\include\afs
441 .h.{$(DESTDIR)\include\opr}.h:
442 $(COPY) $(*B).h $(DESTDIR)\include\opr
444 .h.{$(DESTDIR)\include\rx}.h:
445 $(COPY) $(*B).h $(DESTDIR)\include\rx
447 .h.{$(DESTDIR)\include\des}.h:
448 $(COPY) $(*B).h $(DESTDIR)\include
450 .h.{$(DESTDIR)\include\hcrypto}.h:
451 $(COPY) $(*B).h $(DESTDIR)\include\hcrypto
453 .h.{$(DESTDIR)\include\WINNT}.h:
454 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
456 # Resource compiler macro
457 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
459 #################### Link optional build flags set ###########
462 /FIXED:NO /VERBOSE:LIB /MACHINE:I386
464 !IF ("$(AFSVER_CL)"=="1500" || "$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1310")
465 afslflags = $(afslflags) /MANIFEST
468 mfclflags = $(guilflags)
469 mfclflags = $(mfclflags:/NODEFAULTLIB=)
471 mfcdlllflags = $(dlllflags)
472 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
474 mfclibsdll = $(guilibsdll)
475 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
476 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
478 # Link with binmode.obj; files will be opened in binary mode by default.
479 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
481 ldebug=/DEBUG /PDB:$*.pdb
482 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
483 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
487 # Generate debug information and pdb files
488 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
490 #!IF ("AFSVER_CL"=="1200")
491 #ldebug = $(ldebug) -debugtype:cv
494 # Disable optimization; generate full debug info in obj.
495 afscflags = $(afscflags) /Od /Zi
498 !IF ("AFSVER_CL"=="1200")
499 ldebug = $(ldebug) -debugtype:both
500 ldebug = $(ldebug:-debugtype:cv=)
501 !ENDIF #AFSVER_CL == 1200
504 !IFNDEF _CRTDBG_MAP_ALLOC
505 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
506 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
508 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
509 !IF ("$(AFSVER_CL)"=="1200")
510 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
511 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
512 !ENDIF #AFSVER_CL == 1200
514 !ELSE #_CRTDBG_MAP_ALLOC
515 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
516 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
517 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
518 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
519 !ENDIF #_CRTDBG_MAP_ALLOC
521 EXEPREP = rebase -b 0x00400000 -q $@
522 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
524 !ENDIF #CHECKED BUILD
527 # EXE link macro for console applications
528 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) user32.lib version.lib $**
530 # EXE link macro for GUI applications
531 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
533 # EXE link macro for MFC applications
534 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
536 # DLL link macro for console applications
537 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
539 # DLL link macro for GUI applications
540 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
541 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) user32.lib version.lib $**
542 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
544 # DLL link macro for resource-only DLLs
545 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
547 # Library archive macro
548 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
550 # Language selection macro
551 NTLANG = $(DESTDIR)\bin\NTLang.bat
555 AFSDEV_AUXMIDLFLAGS=/env win32 /win32 /no_robust /Oicf
562 ######### Create Cygwin .a files
563 # This macro should be invoked as a build step for a DLL target.
566 for %%C in (as.exe) do \
567 if exist %%~$$PATH:C \
568 dlltool --dllname $(@B).dll --output-lib $(@R).a --temp-prefix $(OUT) -S %%~$$PATH:C
570 MAKECYGLIB=echo Skipping Cygwin archive
573 ######### Heimdal compatibility support
575 !IFNDEF HEIMDALSDKDIR
576 !IFDEF KERBEROSCOMPATSDKROOT
577 HEIMDALSDKDIR=$(KERBEROSCOMPATSDKROOT)\1.0
579 !ERROR HEIMDALSDKDIR or KERBEROSCOMPATSDKROOT needs to be defined
583 HEIMINC=$(HEIMDALSDKDIR)\inc
584 HEIMLIB=$(HEIMDALSDKDIR)\lib\$(CPU)
586 afscdefs=$(afscdefs) -I$(HEIMINC) -I$(HEIMINC)\krb5
588 HEIMDEPS=$(HEIMLIB)\heimdal.lib $(DESTDIR)\lib\krbcompat_delayload.obj
589 HEIMLINKOPTS=/DELAYLOAD:heimdal.dll