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)" != "i386")
41 !ERROR Platform SDK not configured for i386
44 !IF EXISTS("TOOLS.INI")
45 !MESSAGE ************CAUTION TOOLS.INI IN EFFECT**********
47 !IF ("$(AFSROOT)"=="")
48 !ERROR AFSROOT is not set
50 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
51 AFSDEV_BUILDTYPE = NONE
53 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
54 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
57 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
58 !UNDEF _CRTDBG_MAP_ALLOC
61 # Limit default include and library directories to those specified for build.
63 !IFNDEF AFSDEV_INCLUDE
64 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
67 !IF ((!DEFINED(INCLUDE)) && ([set INCLUDE=$(AFSDEV_INCLUDE)] != 0))
68 # If env. var. INCLUDE not defined then macro assignment won't set it.
69 !ERROR Failed setting environment variable INCLUDE.
71 INCLUDE = $(AFSDEV_INCLUDE)
75 !ERROR Must define AFSDEV_LIB to be the default library directories.
78 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
79 # If env. var. LIB not defined then macro assignment won't set it.
80 !ERROR Failed setting environment variable LIB.
84 #define used in WinNT/2000 installation and program version display
85 !IF !DEFINED(AFSPRODUCT_VER_MAJOR)
86 AFSPRODUCT_VER_MAJOR=1
88 !IF !DEFINED(AFSPRODUCT_VER_MINOR)
89 AFSPRODUCT_VER_MINOR=5
91 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
92 AFSPRODUCT_VER_PATCH=7401
94 !IF !DEFINED(AFSPRODUCT_VER_BUILD)
95 AFSPRODUCT_VER_BUILD=0
98 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
99 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
100 # Set CELLNAME_DEFAULT to "your cell name"
101 !IF !DEFINED(CELLNAME_DEFAULT)
102 CELLNAME_DEFAULT=openafs.org
104 CELLSERVDB_INSTALL=CellServDB.GrandCentral
105 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
108 # Define defaults folder locations
113 !IF ("$(AFS_OBJDIR)"=="")
114 ######### AFS_OBJDIR is NOT used use default locations
115 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
116 DESTDIR=$(AFSROOT)\$(DEST)\$(SYS_NAME)\checked
117 OJT=$(AFSROOT)\$(OBJ)\$(SYS_NAME)\checked
119 DESTDIR=$(AFSROOT)\$(DEST)\$(SYS_NAME)\free
120 OJT=$(AFSROOT)\$(OBJ)\$(SYS_NAME)\free
122 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
124 ######### AFS_OBJDIR is defined, use specific locations for obj and dest
125 # there is a special case for config because util_cr is not defined yet!
126 ! IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
127 # AFS_OBJDIR is relative path
128 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
129 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
130 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
132 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\free\config
133 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
136 ! IF (EXIST($(AFS_OBJDIR)))
137 # AFS_OBJDIR is full path
138 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
139 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
140 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
142 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
143 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\free\config
146 !ERROR Can't find location of DEST directory!
149 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
151 ! IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)")
152 # we are NOT doing a config make, use util_cr to generate object directory
153 ! IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
154 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
157 ! IF EXIST($(TMP)\home)
160 !INCLUDE $(TEMP)\home
165 !IF ("$(RELDIR)"=="")
171 !MESSAGE Directory assignments:
172 !MESSAGE OJT=[$(OJT)]
173 !MESSAGE OUT=[$(OUT)]
174 !MESSAGE DESTDIR=[$(DESTDIR)]
176 # Definitions provided here are based on WIN32.MAK, a common nmake
177 # file included with the MS SDK and MS VC distributions.
178 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
179 # port this nmake file if additional compiler support is required.
181 # !IF ("$(AFSVER_CL)"=="1300")
182 # afslflags = $(afslflags) /DEBUG
185 !IF ("$(APPVER)" == "")
193 # Extend and/or supplement definitions in WIN32.MAK.
217 !IF !DEFINED(MAKECMD)
224 COMPILE_ET = $(DESTDIR)\bin\compile_et
225 RXGEN = $(DESTDIR)\bin\rxgen
227 # Common clean target.
229 $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb $(OUT)\*.res $(OUT)\*.manifest $(OUT)\*.exp
230 $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
232 # Common lang target.
236 #################### Compile optional build flags set ###########
240 -I$(DESTDIR)\include \
241 -I$(DESTDIR)\include\afs \
242 -I$(DESTDIR)\include\rx \
243 -DWIN32_LEAN_AND_MEAN \
246 -D_WIN32_WINNT=0x0500 \
248 -DREGISTER_POWER_NOTIFICATIONS \
249 -DAFS_FREELANCE_CLIENT \
252 $(AFSDEV_AUXCDEFINES)
254 # Compiler switches (except include paths and preprocessor defines)
256 # Note: if conflicting options are specified, rightmost option applies.
258 # /Oy- specifies no frame-pointer omission
259 # /GF pool strings and place in read-only memory
260 # /Gd use cdecl calling convention by default
261 # /Gy enable function-level linking
262 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
263 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
272 !IF ("$(AFSVER_CL)"=="1400")
273 afscflags = $(afscflags) /EHsc /wd4996
275 afscflags = $(afscflags) /GX
278 !IF ("$(AFSVER_CL)"!="1200")
279 afscdefs = $(afscdefs) /GT /GS
281 !IF ("$(AFSVER_CL)"!="1400")
282 afscdefs = $(afscdefs) /G7
286 !IF ("$(AFSIFS)" == "TRUE")
287 afscdefs = $(afscdefs) -DAFSIFS
290 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
292 afscflags = $(afscflags) /Ox /Zi
293 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
294 cvarsdll = $(cvarsdll:-MDd=-MD)
297 !ELSE # CHECKED BUILD
298 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
300 !IF ("$(AFSVER_CL)"=="1200")
301 afscdefs = $(afscdefs) -DDEBUG
302 afscflags = $(afscflags) /GZ
304 afscdefs = $(afscdefs) -DDEBUG
305 afscflags = $(afscflags) /RTCs /RTCu
308 !IFDEF _CRTDBG_MAP_ALLOC
309 afscdefs = $(afscdefs) -D_DEBUG -D_CRTDBG_MAP_ALLOC
315 # Set compiler warning level
317 !IFNDEF AFSDEV_WARNLEVEL
320 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
321 "$(AFSDEV_WARNLEVEL)" != "1" && \
322 "$(AFSDEV_WARNLEVEL)" != "2" && \
323 "$(AFSDEV_WARNLEVEL)" != "3" && \
324 "$(AFSDEV_WARNLEVEL)" != "4")
325 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
329 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
331 # C/C++ compilation macros
332 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(dafsifs) $(cvarsdll) $(afscflags) $(afscdefs) /c
334 # Inference rules for building and installing targets
335 # Compile .c files, from current directory to defined by OUT
349 $(RC) /fo$(OUT)\$(<B).res $<
351 # Compile .rc (resource) files
357 .h.{$(DESTDIR)\include\afs}.h:
358 $(COPY) $< $(DESTDIR)\include\afs
360 .h.{$(DESTDIR)\include\rx}.h:
361 $(COPY) $< $(DESTDIR)\include\rx
363 .h.{$(DESTDIR)\include}.h:
364 $(COPY) $< $(DESTDIR)\include
366 .h.{$(DESTDIR)\include\WINNT}.h:
367 $(COPY) $< $(DESTDIR)\include\WINNT
369 .h.{$(DESTDIR)\include}.h:
370 $(COPY) $(*B).h $(DESTDIR)\include
372 .h.{$(DESTDIR)\include\afs}.h:
373 $(COPY) $(*B).h $(DESTDIR)\include\afs
375 .h.{$(DESTDIR)\include\rx}.h:
376 $(COPY) $(*B).h $(DESTDIR)\include\rx
378 .h.{$(DESTDIR)\include\WINNT}.h:
379 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
381 # Resource compiler macro
382 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
384 #################### Link optional build flags set ###########
387 /FIXED:NO /VERBOSE:LIB
389 mfclflags = $(guilflags)
390 mfclflags = $(mfclflags:/NODEFAULTLIB=)
392 mfcdlllflags = $(dlllflags)
393 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
395 mfclibsdll = $(guilibsdll)
396 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
397 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
399 # Link with binmode.obj; files will be opened in binary mode by default.
400 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
402 ldebug=/DEBUG /PDB:$*.pdb
403 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
404 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
408 # Generate debug information and pdb files
409 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
411 #!IF ("AFSVER_CL"=="1200")
412 #ldebug = $(ldebug) -debugtype:cv
415 # Disable optimization; generate full debug info in obj.
416 afscflags = $(afscflags) /Od /Zi
419 !IF ("AFSVER_CL"=="1200")
420 ldebug = $(ldebug) -debugtype:both
421 ldebug = $(ldebug:-debugtype:cv=)
422 !ENDIF #AFSVER_CL == 1200
425 !IFNDEF _CRTDBG_MAP_ALLOC
426 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
427 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
429 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
430 !IF ("$(AFSVER_CL)"=="1200")
431 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
432 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
433 !ENDIF #AFSVER_CL == 1200
435 !ELSE #_CRTDBG_MAP_ALLOC
436 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
437 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
438 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
439 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
440 !ENDIF #_CRTDBG_MAP_ALLOC
442 EXEPREP = rebase -b 0x00400000 -q $@
443 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
445 !ENDIF #CHECKED BUILD
448 # EXE link macro for console applications
449 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
451 # EXE link macro for GUI applications
452 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
454 # EXE link macro for MFC applications
455 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
457 # DLL link macro for console applications
458 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
460 # DLL link macro for GUI applications
461 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
462 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
463 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
465 # DLL link macro for resource-only DLLs
466 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
468 # Library archive macro
469 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
471 # Language selection macro
472 NTLANG = $(DESTDIR)\bin\NTLang.bat
476 AFSDEV_AUXMIDLFLAGS=/env win32 /win32 /no_robust
478 AFSDEV_AUXMIDLFLAGS=$(AFSDEV_AUXMIDLFLAGS) /Oi
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