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=5900
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.
199 COMPILE_ET = $(DESTDIR)\bin\compile_et
200 RXGEN = $(DESTDIR)\bin\rxgen
203 # Common clean target.
205 $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb
206 $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
208 # Common lang target.
212 #################### Compile optional build flags set ###########
216 -I$(DESTDIR)\include \
217 -I$(DESTDIR)\include\afs \
218 -I$(DESTDIR)\include\rx \
219 -DWIN32_LEAN_AND_MEAN \
222 -D_WIN32_WINNT=0x0500 \
224 -DREGISTER_POWER_NOTIFICATIONS \
226 -DAFS_FREELANCE_CLIENT \
229 -DAFS_LARGEFILE_ENV \
230 $(AFSDEV_AUXCDEFINES)
232 # Compiler switches (except include paths and preprocessor defines)
234 # Note: if conflicting options are specified, rightmost option applies.
236 # /Oy- specifies no frame-pointer omission
237 # /GF pool strings and place in read-only memory
238 # /Gd use cdecl calling convention by default
239 # /Gy enable function-level linking
240 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
241 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
242 # /Wp64 enable 64-bit porting warnings (conflicts with warnings as errors
243 # due to SDK mapping of Get/SetWindowLongPtr to Get/SetWindowLong
252 !IF ("$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1500")
253 afscflags = $(afscflags) /EHsc /wd4996
255 afscflags = $(afscflags) /GX
258 !IF ("$(AFSVER_CL)"!="1200")
259 afscflags = $(afscflags) /GT /GS
261 !IF ("$(AFSVER_CL)"!="1400" && "$(AFSVER_CL)"!="1500")
262 afscflags = $(afscflags) /G7
266 !IF ("$(AFSIFS)" == "TRUE")
267 afscdefs = $(afscdefs) -DAFSIFS
270 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
272 afscflags = $(afscflags) /Ox /Zi
273 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
274 cvarsdll = $(cvarsdll:-MDd=-MD)
276 _VC_MANIFEST_BASENAME = __OAFW
278 !ELSE # CHECKED BUILD
279 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
281 !IF ("$(AFSVER_CL)"=="1200")
282 afscdefs = $(afscdefs) -DDEBUG /GZ
284 afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
287 !IFDEF _CRTDBG_MAP_ALLOC
288 afscflags = $(afscflags) -D_DEBUG -D_CRTDBG_MAP_ALLOC
292 _VC_MANIFEST_BASENAME = __OAFW.Debug
295 !IF ("$(AFSVER_CL)"=="1500"|| "$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)" == "1310")
296 _VC_MANIFEST_EMBED_EXE= \
297 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;1
299 _VC_MANIFEST_EMBED_DLL= \
300 if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;2
302 _VC_MANIFEST_EMBED_EXE=
303 _VC_MANIFEST_EMBED_DLL=
306 !IF DEFINED(CODESIGN_DESC) && DEFINED(CODESIGN_URL) && DEFINED(CODESIGN_TIMESTAMP)
307 CODESIGN_USERLAND= signtool.exe sign /a /d "$(CODESIGN_DESC)" /du $(CODESIGN_URL) \
308 /t $(CODESIGN_TIMESTAMP) /v $@
313 # Set compiler warning level
315 !IFNDEF AFSDEV_WARNLEVEL
318 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
319 "$(AFSDEV_WARNLEVEL)" != "1" && \
320 "$(AFSDEV_WARNLEVEL)" != "2" && \
321 "$(AFSDEV_WARNLEVEL)" != "3" && \
322 "$(AFSDEV_WARNLEVEL)" != "4")
323 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
327 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
329 # C/C++ compilation macros
330 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
332 # Inference rules for building and installing targets
333 # Compile .c files, from current directory to defined by OUT
347 $(RC) /fo$(OUT)\$(<B).res $<
349 # Compile .rc (resource) files
355 .h.{$(DESTDIR)\include\afs}.h:
356 $(COPY) $< $(DESTDIR)\include\afs
358 .h.{$(DESTDIR)\include\rx}.h:
359 $(COPY) $< $(DESTDIR)\include\rx
361 .h.{$(DESTDIR)\include}.h:
362 $(COPY) $< $(DESTDIR)\include
364 .h.{$(DESTDIR)\include\WINNT}.h:
365 $(COPY) $< $(DESTDIR)\include\WINNT
367 .h.{$(DESTDIR)\include}.h:
368 $(COPY) $(*B).h $(DESTDIR)\include
370 .h.{$(DESTDIR)\include\afs}.h:
371 $(COPY) $(*B).h $(DESTDIR)\include\afs
373 .h.{$(DESTDIR)\include\rx}.h:
374 $(COPY) $(*B).h $(DESTDIR)\include\rx
376 .h.{$(DESTDIR)\include\WINNT}.h:
377 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
379 # Resource compiler macro
380 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
382 #################### Link optional build flags set ###########
385 /FIXED:NO /VERBOSE:LIB /MACHINE:I386
387 !IF ("$(AFSVER_CL)"=="1500" || "$(AFSVER_CL)"=="1400" || "$(AFSVER_CL)"=="1310")
388 afslflags = $(afslflags) /MANIFEST
391 mfclflags = $(guilflags)
392 mfclflags = $(mfclflags:/NODEFAULTLIB=)
394 mfcdlllflags = $(dlllflags)
395 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
397 mfclibsdll = $(guilibsdll)
398 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
399 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
401 # Link with binmode.obj; files will be opened in binary mode by default.
402 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
404 ldebug=/DEBUG /PDB:$*.pdb
405 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
406 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
410 # Generate debug information and pdb files
411 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
413 #!IF ("AFSVER_CL"=="1200")
414 #ldebug = $(ldebug) -debugtype:cv
417 # Disable optimization; generate full debug info in obj.
418 afscflags = $(afscflags) /Od /Zi
421 !IF ("AFSVER_CL"=="1200")
422 ldebug = $(ldebug) -debugtype:both
423 ldebug = $(ldebug:-debugtype:cv=)
424 !ENDIF #AFSVER_CL == 1200
427 !IFNDEF _CRTDBG_MAP_ALLOC
428 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
429 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
431 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
432 !IF ("$(AFSVER_CL)"=="1200")
433 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
434 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
435 !ENDIF #AFSVER_CL == 1200
437 !ELSE #_CRTDBG_MAP_ALLOC
438 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
439 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
440 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
441 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
442 !ENDIF #_CRTDBG_MAP_ALLOC
444 EXEPREP = rebase -b 0x00400000 -q $@
445 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
447 !ENDIF #CHECKED BUILD
450 # EXE link macro for console applications
451 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
453 # EXE link macro for GUI applications
454 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
456 # EXE link macro for MFC applications
457 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
459 # DLL link macro for console applications
460 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
462 # DLL link macro for GUI applications
463 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
464 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
465 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
467 # DLL link macro for resource-only DLLs
468 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
470 # Library archive macro
471 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
473 # Language selection macro
474 NTLANG = $(DESTDIR)\bin\NTLang.bat
478 AFSDEV_AUXMIDLFLAGS=/env win32 /win32 /no_robust /Oicf
485 ######### Create Cygwin .a files
486 # This macro should be invoked as a build step for a DLL target.
489 for %%C in (as.exe) do \
490 if exist %%~$$PATH:C \
491 dlltool --dllname $(@B).dll --output-lib $(@R).a --temp-prefix $(OUT) -S %%~$$PATH:C
493 MAKECYGLIB=echo Skipping Cygwin archive