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)
74 !ERROR Must define AFSDEV_LIB to be the default library directories.
77 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
78 # If env. var. LIB not defined then macro assignment won't set it.
79 !ERROR Failed setting environment variable LIB.
83 #define used in WinNT/2000 installation and program version display
84 !IF !DEFINED(AFSPRODUCT_VER_MAJOR)
85 AFSPRODUCT_VER_MAJOR=1
87 !IF !DEFINED(AFSPRODUCT_VER_MINOR)
88 AFSPRODUCT_VER_MINOR=5
90 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
91 AFSPRODUCT_VER_PATCH=7600
93 !IF !DEFINED(AFSPRODUCT_VER_BUILD)
94 AFSPRODUCT_VER_BUILD=0
97 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
98 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
99 # Set CELLNAME_DEFAULT to "your cell name"
100 !IF !DEFINED(CELLNAME_DEFAULT)
101 CELLNAME_DEFAULT=openafs.org
103 CELLSERVDB_INSTALL=CellServDB.GrandCentral
104 CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
107 # Define defaults folder locations
121 !IF ("$(AFS_OBJDIR)"=="")
122 ######### AFS_OBJDIR is NOT used use default locations
123 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
124 DESTDIR=$(DEST)\$(SYS_NAME)\checked
125 OJT=$(OBJ)\$(SYS_NAME)\checked
127 DESTDIR=$(AFSROOT)\$(DEST)\$(SYS_NAME)\free
128 OJT=$(OBJ)\$(SYS_NAME)\free
130 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
132 ######### AFS_OBJDIR is defined, use specific locations for obj and dest
133 # there is a special case for config because util_cr is not defined yet!
134 ! IF (EXIST($(AFSROOT)\$(AFS_OBJDIR)))
135 # AFS_OBJDIR is relative path
136 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
137 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
138 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
140 OJT=$(AFSROOT)\$(AFS_OBJDIR)\$(SYS_NAME)\free\config
141 DESTDIR=$(AFSROOT)\$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
144 ! IF (EXIST($(AFS_OBJDIR)))
145 # AFS_OBJDIR is full path
146 ! IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
147 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\checked
148 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\checked\config
150 DESTDIR=$(AFS_OBJDIR)\$(DEST)\$(SYS_NAME)\free
151 OJT=$(AFS_OBJDIR)\$(SYS_NAME)\free\config
154 !ERROR Can't find location of DEST directory!
157 UTIL_CR = $(DESTDIR)\bin\util_cr.exe
159 ! IF ("$(MAKEDIR:\config=)"=="$(MAKEDIR)")
160 # we are NOT doing a config make, use util_cr to generate object directory
161 ! IF ( !EXIST($(UTIL_CR)) || (!EXIST($(TMP)\home) && !EXIST($(TEMP)\home)) || (([$(UTIL_CR) _dir "!$(AFSDEV_BUILDTYPE)!src!$(AFS_OBJDIR)!"])!=0))
162 !ERROR Can't produce object paths, util_cr not working , TMP or TEMP environment variables not defined
165 ! IF EXIST($(TMP)\home)
168 !INCLUDE $(TEMP)\home
173 !IF ("$(RELDIR)"=="")
179 !MESSAGE Directory assignments:
180 !MESSAGE OJT=[$(OJT)]
181 !MESSAGE OUT=[$(OUT)]
182 !MESSAGE DESTDIR=[$(DESTDIR)]
184 # Definitions provided here are based on WIN32.MAK, a common nmake
185 # file included with the MS SDK and MS VC distributions.
186 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
187 # port this nmake file if additional compiler support is required.
189 # !IF ("$(AFSVER_CL)"=="1300")
190 # afslflags = $(afslflags) /DEBUG
193 !IF ("$(APPVER)" == "")
197 PATH = $(AFSDEV_BIN);$(DESTDIR)\lib;$(PATH)
201 # Extend and/or supplement definitions in WIN32.MAK.
225 !IF !DEFINED(MAKECMD)
232 COMPILE_ET = $(DESTDIR)\bin\compile_et
233 RXGEN = $(DESTDIR)\bin\rxgen
235 # Common clean target.
237 $(DEL) /q $(OUT)\*.obj $(OUT)\*.lib $(OUT)\*.dll $(OUT)\*.exe $(OUT)\*.pdb $(OUT)\*.res $(OUT)\*.manifest $(OUT)\*.exp
238 $(DEL) /q $(OUT)\*_component_version_number.* *_component_version_number.*
240 # Common lang target.
244 #################### Compile optional build flags set ###########
248 -I$(DESTDIR)\include \
249 -DWIN32_LEAN_AND_MEAN \
252 -D_WIN32_WINNT=0x0500 \
254 -DNTDDI_VERSION=0x05000000 \
255 -DREGISTER_POWER_NOTIFICATIONS \
256 -DAFS_FREELANCE_CLIENT \
258 $(AFSDEV_AUXCDEFINES)
260 # Compiler switches (except include paths and preprocessor defines)
262 # Note: if conflicting options are specified, rightmost option applies.
264 # /Oy- specifies no frame-pointer omission
265 # /GF pool strings and place in read-only memory
266 # /Gd use cdecl calling convention by default
267 # /Gy enable function-level linking
268 # /GX enable C++ exceptions (assumes extern C funcs never throw exceptions)
269 # /Os favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
278 !IF ("$(AFSVER_CL)"=="1400")
279 afscflags = $(afscflags) /EHsc /wd4996
281 afscflags = $(afscflags) /GX
284 !IF ("$(AFSVER_CL)"!="1200")
285 afscdefs = $(afscdefs) /GT /GS
287 !IF ("$(AFSVER_CL)"!="1400")
288 afscdefs = $(afscdefs) /G7
292 !IF ("$(AFSIFS)" == "TRUE")
293 afscdefs = $(afscdefs) -DAFSIFS
296 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
298 afscflags = $(afscflags) /Ox /Zi
299 cdebug = $(cdebug:-Od=) # avoid annoying override warning (D4025)
300 cvarsdll = $(cvarsdll:-MDd=-MD)
303 !ELSE # CHECKED BUILD
304 cdebug = $(cdebug:-Z7=-Zi) # avoid annoying override warning (D4025)
306 !IF ("$(AFSVER_CL)"=="1200")
307 afscdefs = $(afscdefs) -DDEBUG
308 afscflags = $(afscflags) /GZ
310 afscdefs = $(afscdefs) -DDEBUG
311 afscflags = $(afscflags) /RTCs /RTCu
314 !IFDEF _CRTDBG_MAP_ALLOC
315 afscdefs = $(afscdefs) -D_DEBUG -D_CRTDBG_MAP_ALLOC
321 # Set compiler warning level
323 !IFNDEF AFSDEV_WARNLEVEL
326 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
327 "$(AFSDEV_WARNLEVEL)" != "1" && \
328 "$(AFSDEV_WARNLEVEL)" != "2" && \
329 "$(AFSDEV_WARNLEVEL)" != "3" && \
330 "$(AFSDEV_WARNLEVEL)" != "4")
331 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
335 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
337 # C/C++ compilation macros
338 C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(dafsifs) $(cvarsdll) $(afscflags) $(afscdefs) /c
340 # Inference rules for building and installing targets
341 # Compile .c files, from current directory to defined by OUT
355 $(RC) /fo$(OUT)\$(<B).res $<
357 # Compile .rc (resource) files
363 .h.{$(DESTDIR)\include\afs}.h:
364 $(COPY) $< $(DESTDIR)\include\afs
366 .h.{$(DESTDIR)\include\rx}.h:
367 $(COPY) $< $(DESTDIR)\include\rx
369 .h.{$(DESTDIR)\include\opr}.h:
370 $(COPY) $< $(DESTDIR)\include\opr
372 .h.{$(DESTDIR)\include\des}.h:
373 $(COPY) $< $(DESTDIR)\include
375 .h.{$(DESTDIR)\include\hcrypto}.h:
376 $(COPY) $< $(DESTDIR)\include\hcrypto
378 .h.{$(DESTDIR)\include}.h:
379 $(COPY) $< $(DESTDIR)\include
381 .h.{$(DESTDIR)\include\WINNT}.h:
382 $(COPY) $< $(DESTDIR)\include\WINNT
384 .h.{$(DESTDIR)\include}.h:
385 $(COPY) $(*B).h $(DESTDIR)\include
387 .h.{$(DESTDIR)\include\afs}.h:
388 $(COPY) $(*B).h $(DESTDIR)\include\afs
390 .h.{$(DESTDIR)\include\rx}.h:
391 $(COPY) $(*B).h $(DESTDIR)\include\rx
393 .h.{$(DESTDIR)\include\opr}.h:
394 $(COPY) $(*B).h $(DESTDIR)\include\opr
396 .h.{$(DESTDIR)\include\des}.h:
397 $(COPY) $(*B).h $(DESTDIR)\include
399 .h.{$(DESTDIR)\include\hcrypto}.h:
400 $(COPY) $(*B).h $(DESTDIR)\include\hcrypto
402 .h.{$(DESTDIR)\include\WINNT}.h:
403 $(COPY) $(*B).h $(DESTDIR)\include\WINNT
405 # Resource compiler macro
406 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS) /d "AFSPRODUCT_VERSION=\"$(AFSPRODUCT_VERSION)\""
408 #################### Link optional build flags set ###########
411 /FIXED:NO /VERBOSE:LIB
413 mfclflags = $(guilflags)
414 mfclflags = $(mfclflags:/NODEFAULTLIB=)
416 mfcdlllflags = $(dlllflags)
417 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
419 mfclibsdll = $(guilibsdll)
420 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
421 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
423 # Link with binmode.obj; files will be opened in binary mode by default.
424 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
426 ldebug=/DEBUG /PDB:$*.pdb
427 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
428 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
432 # Generate debug information and pdb files
433 ldebug = /DEBUG /PDB:$*.pdb /NODEFAULTLIB:LIBC
435 #!IF ("AFSVER_CL"=="1200")
436 #ldebug = $(ldebug) -debugtype:cv
439 # Disable optimization; generate full debug info in obj.
440 afscflags = $(afscflags) /Od /Zi
443 !IF ("AFSVER_CL"=="1200")
444 ldebug = $(ldebug) -debugtype:both
445 ldebug = $(ldebug:-debugtype:cv=)
446 !ENDIF #AFSVER_CL == 1200
449 !IFNDEF _CRTDBG_MAP_ALLOC
450 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
451 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
453 #v6.0 doesn't work using msvcrtd.lib unless _CRTDBG_MAP_ALLOC is defined, v7.0 requires it
454 !IF ("$(AFSVER_CL)"=="1200")
455 EXEMFCLINK=$(EXEMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
456 DLLMFCLINK=$(DLLMFCLINK:/NODEFAULTLIB:msvcrtd.lib=)
457 !ENDIF #AFSVER_CL == 1200
459 !ELSE #_CRTDBG_MAP_ALLOC
460 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
461 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
462 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
463 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
464 !ENDIF #_CRTDBG_MAP_ALLOC
466 EXEPREP = rebase -b 0x00400000 -q $@
467 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
469 !ENDIF #CHECKED BUILD
472 # EXE link macro for console applications
473 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) user32.lib version.lib $**
475 # EXE link macro for GUI applications
476 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
478 # EXE link macro for MFC applications
479 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
481 # DLL link macro for console applications
482 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
484 # DLL link macro for GUI applications
485 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
486 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) user32.lib version.lib $**
487 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
489 # DLL link macro for resource-only DLLs
490 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
492 # Library archive macro
493 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
495 # Language selection macro
496 NTLANG = $(DESTDIR)\bin\NTLang.bat
500 AFSDEV_AUXMIDLFLAGS=/env win32 /win32 /no_robust
502 AFSDEV_AUXMIDLFLAGS=$(AFSDEV_AUXMIDLFLAGS) /Oi
509 ######### Create Cygwin .a files
510 # This macro should be invoked as a build step for a DLL target.
513 for %%C in (as.exe) do \
514 if exist %%~$$PATH:C \
515 dlltool --dllname $(@B).dll --output-lib $(@R).a --temp-prefix $(OUT) -S %%~$$PATH:C
517 MAKECYGLIB=echo Skipping Cygwin archive