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)
79 !ERROR Must define AFSDEV_LIB to be the default library directories.
82 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
83 # If env. var. LIB not defined then macro assignment won't set it.
84 !ERROR Failed setting environment variable LIB.
88 #define used in WinNT/2000 installation and program version display
89 !IF !DEFINED(AFSPRODUCT_VER_MAJOR)
90 AFSPRODUCT_VER_MAJOR=1
92 !IF !DEFINED(AFSPRODUCT_VER_MINOR)
93 AFSPRODUCT_VER_MINOR=5
95 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
96 AFSPRODUCT_VER_PATCH=7600
98 !IF !DEFINED(AFSPRODUCT_VER_BUILD)
99 AFSPRODUCT_VER_BUILD=0
102 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
103 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
104 # Set CELLNAME_DEFAULT to "your cell name"
105 !IF !DEFINED(CELLNAME_DEFAULT)
106 CELLNAME_DEFAULT=openafs.org
108 CELLSERVDB_INSTALL=CellServDB.GrandCentral
109 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
112 # Define defaults folder locations
117 !IF ("$(AFS_OBJDIR)"=="")
118 ######### AFS_OBJDIR is NOT used use default locations
119 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
120 DESTDIR=$(AFSROOT)\$(DEST)\$(SYS_NAME)\checked
121 OJT=$(AFSROOT)\$(OBJ)\$(SYS_NAME)\checked
123 DESTDIR=$(AFSROOT)\$(DEST)\$(SYS_NAME)\free
124 OJT=$(AFSROOT)\$(OBJ)\$(SYS_NAME)\free
126 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
128 ######### AFS_OBJDIR is defined, use specific locations for obj and dest
129 # there is a special case for config because util_cr is not defined yet!
130 ! IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
131 # AFS_OBJDIR is relative path
132 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
133 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
134 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
136 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\free\config
137 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
140 ! IF (EXIST($(AFS_OBJDIR)))
141 # AFS_OBJDIR is full path
142 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
143 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
144 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
146 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
147 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\free\config
150 !ERROR Can't find location of DEST directory!
153 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
155 ! IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)")
156 # we are NOT doing a config make, use util_cr to generate object directory
157 ! IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
158 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
161 ! IF EXIST($(TMP)\home)
164 !INCLUDE $(TEMP)\home
169 !IF ("$(RELDIR)"=="")
175 !MESSAGE Directory assignments:
176 !MESSAGE OJT=[$(OJT)]
177 !MESSAGE OUT=[$(OUT)]
178 !MESSAGE DESTDIR=[$(DESTDIR)]
180 # Definitions provided here are based on WIN32.MAK, a common nmake
181 # file included with the MS SDK and MS VC distributions.
182 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
183 # port this nmake file if additional compiler support is required.
185 # !IF ("$(AFSVER_CL)"=="1300")
186 # afslflags = $(afslflags) /DEBUG
189 !IF ("$(APPVER)" == "")
197 # Extend and/or supplement definitions in WIN32.MAK.
221 !IF !DEFINED(MAKECMD)
228 COMPILE_ET = $(DESTDIR)\bin\compile_et
229 RXGEN = $(DESTDIR)\bin\rxgen
231 # Common clean target.
233 $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb $(OUT)\*.res $(OUT)\*.manifest $(OUT)\*.exp
234 $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
236 # Common lang target.
240 #################### Compile optional build flags set ###########
244 -I$(DESTDIR)\include \
245 -I$(DESTDIR)\include\afs \
246 -I$(DESTDIR)\include\rx \
247 -DWIN32_LEAN_AND_MEAN \
250 -D_WIN32_WINNT=0x0500 \
251 -DNTDDI_VERSION=0x05000000 \
253 -DREGISTER_POWER_NOTIFICATIONS \
254 -DAFS_FREELANCE_CLIENT \
256 $(AFSDEV_AUXCDEFINES)
258 # Compiler switches (except include paths and preprocessor defines)
260 # Note: if conflicting options are specified, rightmost option applies.
262 # /Oy- specifies no frame-pointer omission
263 # /GF pool strings and place in read-only memory
264 # /Gd use cdecl calling convention by default
265 # /Gy enable function-level linking
266 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
267 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
268 # /Wp64 enable 64-bit porting warnings (conflicts with warnings as errors
269 # due to SDK mapping of Get/SetWindowLongPtr to Get/SetWindowLong
278 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
279 afscflags = $(afscflags) /EHsc /wd4996
281 afscflags = $(afscflags) /GX
284 !IF ("$(AFSVER_CL)"!="1200")
285 afscflags = $(afscflags) /GT /GS
287 !IF ("$(AFSVER_CL)"!="1400" && "$(AFSVER_CL)"!="1500")
288 afscflags = $(afscflags) /G7
292 !IF ("$(AFSIFS)" == "TRUE")
293 afscdefs = $(afscdefs) -DAFSIFS
296 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
298 afscflags = $(afscflags) /Ox /Zi
299 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
300 cvarsdll = $(cvarsdll:-MDd=-MD)
302 _VC_MANIFEST_BASENAME = __OAFW
304 !ELSE # CHECKED BUILD
305 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
307 !IF ("$(AFSVER_CL)"=="1200")
308 afscdefs = $(afscdefs) -DDEBUG /GZ
310 afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
313 !IFDEF _CRTDBG_MAP_ALLOC
314 afscflags = $(afscflags) -D_DEBUG -D_CRTDBG_MAP_ALLOC
318 _VC_MANIFEST_BASENAME = __OAFW.Debug
321 !IF ("$(AFSVER_CL)"=="1500"|| "$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)" == "1310")
322 _VC_MANIFEST_EMBED_EXE= \
323 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;1
325 _VC_MANIFEST_EMBED_DLL= \
326 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;2
328 _VC_MANIFEST_EMBED_EXE=
329 _VC_MANIFEST_EMBED_DLL=
332 !IF "$(SIGNTOOL)" == ""
333 SIGNTOOL=signtool.exe
336 !IF DEFINED(CODESIGN_DESC) && DEFINED(CODESIGN_URL) && DEFINED(CODESIGN_TIMESTAMP)
337 CODESIGN_USERLAND= $(SIGNTOOL) sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) \
338 /t $(CODESIGN_TIMESTAMP) /v $@
339 !IF "$(CODESIGN_CROSS_CERT)" != ""
340 CODESIGN_KERNEL= $(SIGNTOOL) sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) \
341 /t $(CODESIGN_TIMESTAMP) /ac "$(CODESIGN_CROSS_CERT)" /v
347 !IF DEFINED(SYMSTORE_EXE) && DEFINED(SYMSTORE_ROOT)
348 !IF "$(SYMSTORE_COMMENT)" != ""
349 SYMSTORE_COMMENT = |$(SYMSTORE_COMMENT)
352 $(SYMSTORE_EXE) add /s $(SYMSTORE_ROOT) /t "OpenAFS for Windows" /v "$(AFSBLD_TYPE)-$(CPU)-$(AFSPRODUCT_VERSION)" /c "$(@F)$(SYMSTORE_COMMENT)" /f $*.*
357 # Set compiler warning level
359 !IFNDEF AFSDEV_WARNLEVEL
362 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
363 "$(AFSDEV_WARNLEVEL)" != "1" && \
364 "$(AFSDEV_WARNLEVEL)" != "2" && \
365 "$(AFSDEV_WARNLEVEL)" != "3" && \
366 "$(AFSDEV_WARNLEVEL)" != "4")
367 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
371 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
373 # C/C++ compilation macros
374 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
376 # Inference rules for building and installing targets
377 # Compile .c files, from current directory to defined by OUT
391 $(RC) /fo$(OUT)\$(<B).res $<
393 # Compile .rc (resource) files
399 .h.{$(DESTDIR)\include\afs}.h:
400 $(COPY) $< $(DESTDIR)\include\afs
402 .h.{$(DESTDIR)\include\rx}.h:
403 $(COPY) $< $(DESTDIR)\include\rx
405 .h.{$(DESTDIR)\include}.h:
406 $(COPY) $< $(DESTDIR)\include
408 .h.{$(DESTDIR)\include\WINNT}.h:
409 $(COPY) $< $(DESTDIR)\include\WINNT
411 .h.{$(DESTDIR)\include}.h:
412 $(COPY) $(*B).h $(DESTDIR)\include
414 .h.{$(DESTDIR)\include\afs}.h:
415 $(COPY) $(*B).h $(DESTDIR)\include\afs
417 .h.{$(DESTDIR)\include\rx}.h:
418 $(COPY) $(*B).h $(DESTDIR)\include\rx
420 .h.{$(DESTDIR)\include\WINNT}.h:
421 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
423 # Resource compiler macro
424 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
426 #################### Link optional build flags set ###########
429 /FIXED:NO /VERBOSE:LIB /MACHINE:I386
431 !IF ("$(AFSVER_CL)"=="1500" || "$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1310")
432 afslflags = $(afslflags) /MANIFEST
435 mfclflags = $(guilflags)
436 mfclflags = $(mfclflags:/NODEFAULTLIB=)
438 mfcdlllflags = $(dlllflags)
439 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
441 mfclibsdll = $(guilibsdll)
442 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
443 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
445 # Link with binmode.obj; files will be opened in binary mode by default.
446 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
448 ldebug=/DEBUG /PDB:$*.pdb
449 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
450 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
454 # Generate debug information and pdb files
455 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
457 #!IF ("AFSVER_CL"=="1200")
458 #ldebug = $(ldebug) -debugtype:cv
461 # Disable optimization; generate full debug info in obj.
462 afscflags = $(afscflags) /Od /Zi
465 !IF ("AFSVER_CL"=="1200")
466 ldebug = $(ldebug) -debugtype:both
467 ldebug = $(ldebug:-debugtype:cv=)
468 !ENDIF #AFSVER_CL == 1200
471 !IFNDEF _CRTDBG_MAP_ALLOC
472 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
473 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
475 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
476 !IF ("$(AFSVER_CL)"=="1200")
477 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
478 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
479 !ENDIF #AFSVER_CL == 1200
481 !ELSE #_CRTDBG_MAP_ALLOC
482 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
483 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
484 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
485 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
486 !ENDIF #_CRTDBG_MAP_ALLOC
488 EXEPREP = rebase -b 0x00400000 -q $@
489 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
491 !ENDIF #CHECKED BUILD
494 # EXE link macro for console applications
495 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
497 # EXE link macro for GUI applications
498 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
500 # EXE link macro for MFC applications
501 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
503 # DLL link macro for console applications
504 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
506 # DLL link macro for GUI applications
507 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
508 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
509 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
511 # DLL link macro for resource-only DLLs
512 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
514 # Library archive macro
515 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
517 # Language selection macro
518 NTLANG = $(DESTDIR)\bin\NTLang.bat
522 AFSDEV_AUXMIDLFLAGS=/env win32 /win32 /no_robust /Oicf
529 ######### Create Cygwin .a files
530 # This macro should be invoked as a build step for a DLL target.
533 for %%C in (as.exe) do \
534 if exist %%~$$PATH:C \
535 dlltool --dllname $(@B).dll --output-lib $(@R).a --temp-prefix $(OUT) -S %%~$$PATH:C
537 MAKECYGLIB=echo Skipping Cygwin archive