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)
77 PATH = $(AFSDEV_BIN);$(PATH)
80 !ERROR Must define AFSDEV_LIB to be the default library directories.
83 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
84 # If env. var. LIB not defined then macro assignment won't set it.
85 !ERROR Failed setting environment variable LIB.
89 #define used in WinNT/2000 installation and program version display
90 !IF !DEFINED(AFSPRODUCT_VER_MAJOR)
91 AFSPRODUCT_VER_MAJOR=1
93 !IF !DEFINED(AFSPRODUCT_VER_MINOR)
94 AFSPRODUCT_VER_MINOR=6
96 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
97 AFSPRODUCT_VER_PATCH=2200
99 !IF !DEFINED(AFSPRODUCT_VER_BUILD)
100 AFSPRODUCT_VER_BUILD=0
103 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
104 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
105 # Set CELLNAME_DEFAULT to "your cell name"
106 !IF !DEFINED(CELLNAME_DEFAULT)
107 CELLNAME_DEFAULT=openafs.org
109 CELLSERVDB_INSTALL=CellServDB.GrandCentral
110 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
113 # Define defaults folder locations
127 !IF ("$(AFS_OBJDIR)"=="")
128 ######### AFS_OBJDIR is NOT used use default locations
129 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
130 DESTDIR=$(DEST)\$(SYS_NAME)\checked
131 OJT=$(OBJ)\$(SYS_NAME)\checked
133 DESTDIR=$(DEST)\$(SYS_NAME)\free
134 OJT=$(OBJ)\$(SYS_NAME)\free
136 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
138 ######### AFS_OBJDIR is defined, use specific locations for obj and dest
139 # there is a special case for config because util_cr is not defined yet!
140 ! IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
141 # AFS_OBJDIR is relative path
142 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
143 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
144 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
146 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\free\config
147 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
150 ! IF (EXIST($(AFS_OBJDIR)))
151 # AFS_OBJDIR is full path
152 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
153 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
154 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
156 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
157 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\free\config
160 !ERROR Can't find location of DEST directory!
163 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
165 ! IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)")
166 # we are NOT doing a config make, use util_cr to generate object directory
167 ! IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
168 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
171 ! IF EXIST($(TMP)\home)
174 !INCLUDE $(TEMP)\home
179 !IF ("$(RELDIR)"=="")
185 !MESSAGE Directory assignments:
186 !MESSAGE OJT=[$(OJT)]
187 !MESSAGE OUT=[$(OUT)]
188 !MESSAGE DESTDIR=[$(DESTDIR)]
190 # Definitions provided here are based on WIN32.MAK, a common nmake
191 # file included with the MS SDK and MS VC distributions.
192 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
193 # port this nmake file if additional compiler support is required.
195 # !IF ("$(AFSVER_CL)"=="1300")
196 # afslflags = $(afslflags) /DEBUG
199 !IF ("$(APPVER)" == "")
207 # Extend and/or supplement definitions in WIN32.MAK.
231 !IF !DEFINED(MAKECMD)
241 COMPILE_ET = $(DESTDIR)\bin\compile_et
242 RXGEN = $(DESTDIR)\bin\rxgen
244 # Common clean target.
246 $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb $(OUT)\*.res $(OUT)\*.manifest $(OUT)\*.exp
247 $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
249 # Common lang target.
253 #################### Compile optional build flags set ###########
257 -I$(DESTDIR)\include \
258 -DWIN32_LEAN_AND_MEAN \
261 -D_WIN32_WINNT=0x0500 \
262 -DNTDDI_VERSION=0x05000000 \
264 -DREGISTER_POWER_NOTIFICATIONS \
265 -DAFS_FREELANCE_CLIENT \
268 $(AFSDEV_AUXCDEFINES)
270 # Compiler switches (except include paths and preprocessor defines)
272 # Note: if conflicting options are specified, rightmost option applies.
274 # /Oy- specifies no frame-pointer omission
275 # /GF pool strings and place in read-only memory
276 # /Gd use cdecl calling convention by default
277 # /Gy enable function-level linking
278 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
279 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
280 # /Wp64 enable 64-bit porting warnings (conflicts with warnings as errors
281 # due to SDK mapping of Get/SetWindowLongPtr to Get/SetWindowLong
290 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
291 afscflags = $(afscflags) /EHsc /wd4996
293 afscflags = $(afscflags) /GX
296 !IF ("$(AFSVER_CL)"!="1200")
297 afscflags = $(afscflags) /GT /GS
299 !IF ("$(AFSVER_CL)"!="1400" && "$(AFSVER_CL)"!="1500")
300 afscflags = $(afscflags) /G7
304 !IF ("$(AFSIFS)" == "TRUE")
305 afscdefs = $(afscdefs) -DAFSIFS
308 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
310 afscflags = $(afscflags) /Ox /Zi
311 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
312 cvarsdll = $(cvarsdll:-MDd=-MD)
314 _VC_MANIFEST_BASENAME = __OAFW
316 !ELSE # CHECKED BUILD
317 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
319 !IF ("$(AFSVER_CL)"=="1200")
320 afscdefs = $(afscdefs) -DDEBUG /GZ
322 afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
325 !IFDEF _CRTDBG_MAP_ALLOC
326 afscflags = $(afscflags) -D_DEBUG -D_CRTDBG_MAP_ALLOC
330 _VC_MANIFEST_BASENAME = __OAFW.Debug
333 !IF ("$(AFSVER_CL)"=="1500"|| "$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)" == "1310")
334 _VC_MANIFEST_EMBED_EXE= \
335 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;1
337 _VC_MANIFEST_EMBED_DLL= \
338 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;2
340 _VC_MANIFEST_EMBED_EXE=
341 _VC_MANIFEST_EMBED_DLL=
344 !IF "$(SIGNTOOL)" == ""
345 SIGNTOOL=signtool.exe
348 !IF DEFINED(CODESIGN_TIMESTAMP)
349 !IF DEFINED(CODESIGN_DESC) && DEFINED(CODESIGN_URL)
350 CODESIGN_USERLAND= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /t $(CODESIGN_TIMESTAMP) /v $(CODESIGN_OTHER) $@
351 !IF "$(CODESIGN_CROSS_CERT)" != ""
352 CODESIGN_KERNEL= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /t $(CODESIGN_TIMESTAMP) $(CODESIGN_OTHER) /ac "$(CODESIGN_CROSS_CERT)" /v $@
356 !IF DEFINED(CODESIGN_DESC) && DEFINED(CODESIGN_URL)
357 CODESIGN_USERLAND= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /v $(CODESIGN_OTHER) $@
358 !IF "$(CODESIGN_CROSS_CERT)" != ""
359 CODESIGN_KERNEL= "$(SIGNTOOL)" sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) /v $(CODESIGN_OTHER) /ac "$(CODESIGN_CROSS_CERT)" $@
365 !IF DEFINED(SYMSTORE_EXE) && DEFINED(SYMSTORE_ROOT)
366 !IF "$(SYMSTORE_COMMENT)" != ""
367 SYMSTORE_COMMENT = |$(SYMSTORE_COMMENT)
370 $(SYMSTORE_EXE) add /s $(SYMSTORE_ROOT) /t "OpenAFS for Windows" /v "$(AFSBLD_TYPE)-$(CPU)-$(AFSPRODUCT_VERSION)" /c "$(@F)$(SYMSTORE_COMMENT)" /f $*.*
375 # Set compiler warning level
377 !IFNDEF AFSDEV_WARNLEVEL
380 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
381 "$(AFSDEV_WARNLEVEL)" != "1" && \
382 "$(AFSDEV_WARNLEVEL)" != "2" && \
383 "$(AFSDEV_WARNLEVEL)" != "3" && \
384 "$(AFSDEV_WARNLEVEL)" != "4")
385 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
389 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
391 # C/C++ compilation macros
392 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
394 # Inference rules for building and installing targets
395 # Compile .c files, from current directory to defined by OUT
409 $(RC) /fo$(OUT)\$(<B).res $<
411 # Compile .rc (resource) files
417 .h.{$(DESTDIR)\include\afs}.h:
418 $(COPY) $< $(DESTDIR)\include\afs
420 .h.{$(DESTDIR)\include\rx}.h:
421 $(COPY) $< $(DESTDIR)\include\rx
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\rx}.h:
442 $(COPY) $(*B).h $(DESTDIR)\include\rx
444 .h.{$(DESTDIR)\include\des}.h:
445 $(COPY) $(*B).h $(DESTDIR)\include
447 .h.{$(DESTDIR)\include\hcrypto}.h:
448 $(COPY) $(*B).h $(DESTDIR)\include\hcrypto
450 .h.{$(DESTDIR)\include\WINNT}.h:
451 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
453 # Resource compiler macro
454 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
456 #################### Link optional build flags set ###########
459 /FIXED:NO /VERBOSE:LIB /MACHINE:I386
461 !IF ("$(AFSVER_CL)"=="1500" || "$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1310")
462 afslflags = $(afslflags) /MANIFEST
465 mfclflags = $(guilflags)
466 mfclflags = $(mfclflags:/NODEFAULTLIB=)
468 mfcdlllflags = $(dlllflags)
469 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
471 mfclibsdll = $(guilibsdll)
472 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
473 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
475 # Link with binmode.obj; files will be opened in binary mode by default.
476 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
478 ldebug=/DEBUG /PDB:$*.pdb
479 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
480 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
484 # Generate debug information and pdb files
485 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
487 #!IF ("AFSVER_CL"=="1200")
488 #ldebug = $(ldebug) -debugtype:cv
491 # Disable optimization; generate full debug info in obj.
492 afscflags = $(afscflags) /Od /Zi
495 !IF ("AFSVER_CL"=="1200")
496 ldebug = $(ldebug) -debugtype:both
497 ldebug = $(ldebug:-debugtype:cv=)
498 !ENDIF #AFSVER_CL == 1200
501 !IFNDEF _CRTDBG_MAP_ALLOC
502 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
503 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
505 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
506 !IF ("$(AFSVER_CL)"=="1200")
507 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
508 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
509 !ENDIF #AFSVER_CL == 1200
511 !ELSE #_CRTDBG_MAP_ALLOC
512 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
513 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
514 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
515 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
516 !ENDIF #_CRTDBG_MAP_ALLOC
518 EXEPREP = rebase -b 0x00400000 -q $@
519 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
521 !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) $**
538 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) user32.lib version.lib $**
539 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
541 # DLL link macro for resource-only DLLs
542 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
544 # Library archive macro
545 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
547 # Language selection macro
548 NTLANG = $(DESTDIR)\bin\NTLang.bat
552 AFSDEV_AUXMIDLFLAGS=/env win32 /win32 /no_robust /Oicf
559 ######### Create Cygwin .a files
560 # This macro should be invoked as a build step for a DLL target.
563 for %%C in (as.exe) do \
564 if exist %%~$$PATH:C \
565 dlltool --dllname $(@B).dll --output-lib $(@R).a --temp-prefix $(OUT) -S %%~$$PATH:C
567 MAKECYGLIB=echo Skipping Cygwin archive