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=7600
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 -DNTDDI_VERSION=0x05000000 \
249 -DREGISTER_POWER_NOTIFICATIONS \
250 -DAFS_FREELANCE_CLIENT \
253 $(AFSDEV_AUXCDEFINES)
255 # Compiler switches (except include paths and preprocessor defines)
257 # Note: if conflicting options are specified, rightmost option applies.
259 # /Oy- specifies no frame-pointer omission
260 # /GF pool strings and place in read-only memory
261 # /Gd use cdecl calling convention by default
262 # /Gy enable function-level linking
263 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
264 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
273 !IF ("$(AFSVER_CL)"=="1400")
274 afscflags = $(afscflags) /EHsc /wd4996
276 afscflags = $(afscflags) /GX
279 !IF ("$(AFSVER_CL)"!="1200")
280 afscdefs = $(afscdefs) /GT /GS
282 !IF ("$(AFSVER_CL)"!="1400")
283 afscdefs = $(afscdefs) /G7
287 !IF ("$(AFSIFS)" == "TRUE")
288 afscdefs = $(afscdefs) -DAFSIFS
291 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
293 afscflags = $(afscflags) /Ox /Zi
294 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
295 cvarsdll = $(cvarsdll:-MDd=-MD)
298 !ELSE # CHECKED BUILD
299 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
301 !IF ("$(AFSVER_CL)"=="1200")
302 afscdefs = $(afscdefs) -DDEBUG
303 afscflags = $(afscflags) /GZ
305 afscdefs = $(afscdefs) -DDEBUG
306 afscflags = $(afscflags) /RTCs /RTCu
309 !IFDEF _CRTDBG_MAP_ALLOC
310 afscdefs = $(afscdefs) -D_DEBUG -D_CRTDBG_MAP_ALLOC
316 # Set compiler warning level
318 !IFNDEF AFSDEV_WARNLEVEL
321 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
322 "$(AFSDEV_WARNLEVEL)" != "1" && \
323 "$(AFSDEV_WARNLEVEL)" != "2" && \
324 "$(AFSDEV_WARNLEVEL)" != "3" && \
325 "$(AFSDEV_WARNLEVEL)" != "4")
326 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
330 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
332 # C/C++ compilation macros
333 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(dafsifs) $(cvarsdll) $(afscflags) $(afscdefs) /c
335 # Inference rules for building and installing targets
336 # Compile .c files, from current directory to defined by OUT
350 $(RC) /fo$(OUT)\$(<B).res $<
352 # Compile .rc (resource) files
358 .h.{$(DESTDIR)\include\afs}.h:
359 $(COPY) $< $(DESTDIR)\include\afs
361 .h.{$(DESTDIR)\include\rx}.h:
362 $(COPY) $< $(DESTDIR)\include\rx
364 .h.{$(DESTDIR)\include}.h:
365 $(COPY) $< $(DESTDIR)\include
367 .h.{$(DESTDIR)\include\WINNT}.h:
368 $(COPY) $< $(DESTDIR)\include\WINNT
370 .h.{$(DESTDIR)\include}.h:
371 $(COPY) $(*B).h $(DESTDIR)\include
373 .h.{$(DESTDIR)\include\afs}.h:
374 $(COPY) $(*B).h $(DESTDIR)\include\afs
376 .h.{$(DESTDIR)\include\rx}.h:
377 $(COPY) $(*B).h $(DESTDIR)\include\rx
379 .h.{$(DESTDIR)\include\WINNT}.h:
380 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
382 # Resource compiler macro
383 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
385 #################### Link optional build flags set ###########
388 /FIXED:NO /VERBOSE:LIB
390 mfclflags = $(guilflags)
391 mfclflags = $(mfclflags:/NODEFAULTLIB=)
393 mfcdlllflags = $(dlllflags)
394 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
396 mfclibsdll = $(guilibsdll)
397 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
398 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
400 # Link with binmode.obj; files will be opened in binary mode by default.
401 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
403 ldebug=/DEBUG /PDB:$*.pdb
404 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
405 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
409 # Generate debug information and pdb files
410 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
412 #!IF ("AFSVER_CL"=="1200")
413 #ldebug = $(ldebug) -debugtype:cv
416 # Disable optimization; generate full debug info in obj.
417 afscflags = $(afscflags) /Od /Zi
420 !IF ("AFSVER_CL"=="1200")
421 ldebug = $(ldebug) -debugtype:both
422 ldebug = $(ldebug:-debugtype:cv=)
423 !ENDIF #AFSVER_CL == 1200
426 !IFNDEF _CRTDBG_MAP_ALLOC
427 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
428 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
430 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
431 !IF ("$(AFSVER_CL)"=="1200")
432 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
433 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
434 !ENDIF #AFSVER_CL == 1200
436 !ELSE #_CRTDBG_MAP_ALLOC
437 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
438 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
439 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
440 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
441 !ENDIF #_CRTDBG_MAP_ALLOC
443 EXEPREP = rebase -b 0x00400000 -q $@
444 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
446 !ENDIF #CHECKED BUILD
449 # EXE link macro for console applications
450 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
452 # EXE link macro for GUI applications
453 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
455 # EXE link macro for MFC applications
456 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
458 # DLL link macro for console applications
459 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
461 # DLL link macro for GUI applications
462 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
463 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) Advapi32.lib user32.lib version.lib $**
464 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
466 # DLL link macro for resource-only DLLs
467 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
469 # Library archive macro
470 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
472 # Language selection macro
473 NTLANG = $(DESTDIR)\bin\NTLang.bat
477 AFSDEV_AUXMIDLFLAGS=/env win32 /win32 /no_robust
479 AFSDEV_AUXMIDLFLAGS=$(AFSDEV_AUXMIDLFLAGS) /Oi
486 ######### Create Cygwin .a files
487 # This macro should be invoked as a build step for a DLL target.
490 for %%C in (as.exe) do \
491 if exist %%~$$PATH:C \
492 dlltool --dllname $(@B).dll --output-lib $(@R).a --temp-prefix $(OUT) -S %%~$$PATH:C
494 MAKECYGLIB=echo Skipping Cygwin archive