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 AFSPRODUCT_VER_MAJOR=1
90 AFSPRODUCT_VER_MINOR=5
91 AFSPRODUCT_VER_PATCH=6600
92 AFSPRODUCT_VER_BUILD=0
94 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
95 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
96 # Set CELLNAME_DEFAULT to "your cell name"
97 CELLNAME_DEFAULT=openafs.org
98 CELLSERVDB_INSTALL=CellServDB.GrandCentral
99 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
102 # Define defaults folder locations
107 !IF ("$(AFS_OBJDIR)"=="")
108 ######### AFS_OBJDIR is NOT used use default locations
109 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
110 DESTDIR=$(AFSROOT)\$(DEST)\$(SYS_NAME)\checked
111 OJT=$(AFSROOT)\$(OBJ)\$(SYS_NAME)\checked
113 DESTDIR=$(AFSROOT)\$(DEST)\$(SYS_NAME)\free
114 OJT=$(AFSROOT)\$(OBJ)\$(SYS_NAME)\free
116 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
118 ######### AFS_OBJDIR is defined, use specific locations for obj and dest
119 # there is a special case for config because util_cr is not defined yet!
120 ! IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
121 # AFS_OBJDIR is relative path
122 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
123 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
124 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
126 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\free\config
127 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
130 ! IF (EXIST($(AFS_OBJDIR)))
131 # AFS_OBJDIR is full path
132 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
133 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
134 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
136 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
137 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\free\config
140 !ERROR Can't find location of DEST directory!
143 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
145 ! IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)")
146 # we are NOT doing a config make, use util_cr to generate object directory
147 ! IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
148 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
151 ! IF EXIST($(TMP)\home)
154 !INCLUDE $(TEMP)\home
159 !IF ("$(RELDIR)"=="")
165 !MESSAGE Directory assignments:
166 !MESSAGE OJT=[$(OJT)]
167 !MESSAGE OUT=[$(OUT)]
168 !MESSAGE DESTDIR=[$(DESTDIR)]
170 # Definitions provided here are based on WIN32.MAK, a common nmake
171 # file included with the MS SDK and MS VC distributions.
172 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
173 # port this nmake file if additional compiler support is required.
175 # !IF ("$(AFSVER_CL)"=="1300")
176 # afslflags = $(afslflags) /DEBUG
179 !IF ("$(APPVER)" == "")
187 # Extend and/or supplement definitions in WIN32.MAK.
211 !IF !DEFINED(MAKECMD)
218 COMPILE_ET = $(DESTDIR)\bin\compile_et
219 RXGEN = $(DESTDIR)\bin\rxgen
221 # Common clean target.
223 $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb
224 $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
226 # Common lang target.
230 #################### Compile optional build flags set ###########
234 -I$(DESTDIR)\include \
235 -I$(DESTDIR)\include\afs \
236 -I$(DESTDIR)\include\rx \
237 -DWIN32_LEAN_AND_MEAN \
240 -D_WIN32_WINNT=0x0500 \
242 -DREGISTER_POWER_NOTIFICATIONS \
244 -DAFS_FREELANCE_CLIENT \
247 -DAFS_LARGEFILE_ENV \
248 $(AFSDEV_AUXCDEFINES)
250 # Compiler switches (except include paths and preprocessor defines)
252 # Note: if conflicting options are specified, rightmost option applies.
254 # /Oy- specifies no frame-pointer omission
255 # /GF pool strings and place in read-only memory
256 # /Gd use cdecl calling convention by default
257 # /Gy enable function-level linking
258 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
259 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
260 # /Wp64 enable 64-bit porting warnings (conflicts with warnings as errors
261 # due to SDK mapping of Get/SetWindowLongPtr to Get/SetWindowLong
270 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
271 afscflags = $(afscflags) /EHsc /wd4996
273 afscflags = $(afscflags) /GX
276 !IF ("$(AFSVER_CL)"!="1200")
277 afscflags = $(afscflags) /GT /GS
279 !IF ("$(AFSVER_CL)"!="1400" && "$(AFSVER_CL)"!="1500")
280 afscflags = $(afscflags) /G7
284 !IF ("$(AFSIFS)" == "TRUE")
285 afscdefs = $(afscdefs) -DAFSIFS
288 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
290 afscflags = $(afscflags) /Ox /Zi
291 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
292 cvarsdll = $(cvarsdll:-MDd=-MD)
294 _VC_MANIFEST_BASENAME = __OAFW
296 !ELSE # CHECKED BUILD
297 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
299 !IF ("$(AFSVER_CL)"=="1200")
300 afscdefs = $(afscdefs) -DDEBUG /GZ
302 afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
305 !IFDEF _CRTDBG_MAP_ALLOC
306 afscflags = $(afscflags) -D_DEBUG -D_CRTDBG_MAP_ALLOC
310 _VC_MANIFEST_BASENAME = __OAFW.Debug
313 !IF ("$(AFSVER_CL)"=="1500"|| "$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)" == "1310")
314 _VC_MANIFEST_EMBED_EXE= \
315 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;1
317 _VC_MANIFEST_EMBED_DLL= \
318 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;2
320 _VC_MANIFEST_EMBED_EXE=
321 _VC_MANIFEST_EMBED_DLL=
324 !IF DEFINED(CODESIGN_DESC) && DEFINED(CODESIGN_URL) && DEFINED(CODESIGN_TIMESTAMP)
325 CODESIGN_USERLAND= signtool.exe sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) \
326 /t $(CODESIGN_TIMESTAMP) /v $@
331 !IF DEFINED(SYMSTORE_EXE) && DEFINED(SYMSTORE_ROOT)
332 !IF "$(SYMSTORE_COMMENT)" != ""
333 SYMSTORE_COMMENT = |$(SYMSTORE_COMMENT)
336 $(SYMSTORE_EXE) add /s $(SYMSTORE_ROOT) /t "OpenAFS for Windows" /v "$(AFSBLD_TYPE)-$(CPU)-$(AFSPRODUCT_VERSION)" /c "$(@F)$(SYMSTORE_COMMENT)" /f $*.*
341 # Set compiler warning level
343 !IFNDEF AFSDEV_WARNLEVEL
346 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
347 "$(AFSDEV_WARNLEVEL)" != "1" && \
348 "$(AFSDEV_WARNLEVEL)" != "2" && \
349 "$(AFSDEV_WARNLEVEL)" != "3" && \
350 "$(AFSDEV_WARNLEVEL)" != "4")
351 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
355 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
357 # C/C++ compilation macros
358 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
360 # Inference rules for building and installing targets
361 # Compile .c files, from current directory to defined by OUT
375 $(RC) /fo$(OUT)\$(<B).res $<
377 # Compile .rc (resource) files
383 .h.{$(DESTDIR)\include\afs}.h:
384 $(COPY) $< $(DESTDIR)\include\afs
386 .h.{$(DESTDIR)\include\rx}.h:
387 $(COPY) $< $(DESTDIR)\include\rx
389 .h.{$(DESTDIR)\include}.h:
390 $(COPY) $< $(DESTDIR)\include
392 .h.{$(DESTDIR)\include\WINNT}.h:
393 $(COPY) $< $(DESTDIR)\include\WINNT
395 .h.{$(DESTDIR)\include}.h:
396 $(COPY) $(*B).h $(DESTDIR)\include
398 .h.{$(DESTDIR)\include\afs}.h:
399 $(COPY) $(*B).h $(DESTDIR)\include\afs
401 .h.{$(DESTDIR)\include\rx}.h:
402 $(COPY) $(*B).h $(DESTDIR)\include\rx
404 .h.{$(DESTDIR)\include\WINNT}.h:
405 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
407 # Resource compiler macro
408 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
410 #################### Link optional build flags set ###########
413 /FIXED:NO /VERBOSE:LIB /MACHINE:I386
415 !IF ("$(AFSVER_CL)"=="1500" || "$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1310")
416 afslflags = $(afslflags) /MANIFEST
419 mfclflags = $(guilflags)
420 mfclflags = $(mfclflags:/NODEFAULTLIB=)
422 mfcdlllflags = $(dlllflags)
423 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
425 mfclibsdll = $(guilibsdll)
426 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
427 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
429 # Link with binmode.obj; files will be opened in binary mode by default.
430 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
432 ldebug=/DEBUG /PDB:$*.pdb
433 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
434 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
438 # Generate debug information and pdb files
439 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
441 #!IF ("AFSVER_CL"=="1200")
442 #ldebug = $(ldebug) -debugtype:cv
445 # Disable optimization; generate full debug info in obj.
446 afscflags = $(afscflags) /Od /Zi
449 !IF ("AFSVER_CL"=="1200")
450 ldebug = $(ldebug) -debugtype:both
451 ldebug = $(ldebug:-debugtype:cv=)
452 !ENDIF #AFSVER_CL == 1200
455 !IFNDEF _CRTDBG_MAP_ALLOC
456 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
457 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
459 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
460 !IF ("$(AFSVER_CL)"=="1200")
461 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
462 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
463 !ENDIF #AFSVER_CL == 1200
465 !ELSE #_CRTDBG_MAP_ALLOC
466 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
467 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
468 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
469 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
470 !ENDIF #_CRTDBG_MAP_ALLOC
472 EXEPREP = rebase -b 0x00400000 -q $@
473 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
475 !ENDIF #CHECKED BUILD
478 # EXE link macro for console applications
479 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
481 # EXE link macro for GUI applications
482 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
484 # EXE link macro for MFC applications
485 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
487 # DLL link macro for console applications
488 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
490 # DLL link macro for GUI applications
491 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
492 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
493 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
495 # DLL link macro for resource-only DLLs
496 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
498 # Library archive macro
499 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
501 # Language selection macro
502 NTLANG = $(DESTDIR)\bin\NTLang.bat
506 AFSDEV_AUXMIDLFLAGS=/env win32 /win32 /no_robust /Oicf
513 ######### Create Cygwin .a files
514 # This macro should be invoked as a build step for a DLL target.
517 for %%C in (as.exe) do \
518 if exist %%~$$PATH:C \
519 dlltool --dllname $(@B).dll --output-lib $(@R).a --temp-prefix $(OUT) -S %%~$$PATH:C
521 MAKECYGLIB=echo Skipping Cygwin archive