win95-initial-port-20010430
[openafs.git] / src / config / NTMakefile.i386_nt40
1 # Copyright 2000, International Business Machines Corporation and others.
2 # All Rights Reserved.
3
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
7
8 # Common nmake file to be included in each NTMakfile.
9 #
10 # Required definitions:
11 #     AFSDEV_BUILDTYPE = [ CHECKED | FREE ]
12 #     AFSDEV_INCLUDE = <default include directories>
13 #     AFSDEV_LIB = <default library directories>
14 #     AFSDEV_BIN = <default build binary directories>
15 #
16 # Optional definitions:
17 #     AFSDEV_DESTDIR = <top-level install directory>  (default is $(AFSROOT)\DEST)
18 #     AFSDEV_WARNLEVEL = [0 | 1 | 2 | 3 | 4]  (default is 3)
19 #     AFSDEV_AUXCDEFINES = <auxiliary C preprocessor defs> (default is null)
20 #     AFSDEV_AUXRCFLAGS = <auxiliary resource compiler flags> (default is null)
21 #     AFSDEV_TEXTMODE = <text mode is default if defined>  (default is null)
22 #     AFSDEV_CRTDEBUG = <utilize debug C runtime if define> (default is null)
23 #
24 ############################################################################
25
26
27 # Definitions provided here are based on WIN32.MAK, a common nmake
28 # file included with the MS SDK and MS VC distributions.
29 # WIN32.MAK, and this nmake file, are targeted to the MSVC compiler;
30 # port this nmake file if additional compiler support is required.
31
32 # Define default target-type macros required by WIN32.MAK.
33 # Allow them to be overriden in an NTMakefile or via an environment variable.
34
35 !IFNDEF APPVER
36 APPVER = 4.0
37 !ENDIF
38
39 !IFNDEF TARGETOS
40 TARGETOS = WINNT
41 !ENDIF
42
43 # Check that build type is correctly specified.
44
45 !IF (DEFINED(PROFILE) || DEFINED(TUNE))
46 #    Build type ignored when profiling or tuning.
47 AFSDEV_BUILDTYPE = NONE
48
49 !ELSE
50 #    Build type must be checked or free.
51 !IF ("$(AFSDEV_BUILDTYPE)" != "CHECKED" && "$(AFSDEV_BUILDTYPE)" != "FREE")
52 !ERROR Must define AFSDEV_BUILDTYPE to be CHECKED or FREE.
53 !ENDIF
54
55 !ENDIF
56
57 # Limit default include and library directories to those specified for build.
58
59 !IFNDEF AFSDEV_INCLUDE
60 !ERROR Must define AFSDEV_INCLUDE to be the default include directories.
61 !ENDIF
62
63 !IF ((!DEFINED(INCLUDE)) && ([set INCLUDE=$(AFSDEV_INCLUDE)] != 0))
64 #    If env. var. INCLUDE not defined then macro assignment won't set it.
65 !ERROR Failed setting environment variable INCLUDE.
66 !ENDIF
67 INCLUDE = $(AFSDEV_INCLUDE)
68
69
70 !IFNDEF AFSDEV_LIB
71 !ERROR Must define AFSDEV_LIB to be the default library directories.
72 !ENDIF
73
74 !IF ((!DEFINED(LIB)) && ([set LIB=$(AFSDEV_LIB)] != 0))
75 #    If env. var. LIB not defined then macro assignment won't set it.
76 !ERROR Failed setting environment variable LIB.
77 !ENDIF
78 LIB = $(AFSDEV_LIB)
79
80
81 # Put default build binary directories at front of path.
82
83 !IFNDEF AFSDEV_BIN
84 !ERROR Must define AFSDEV_BIN to be the default build binary directories.
85 !ENDIF
86
87 !IF ((!DEFINED(PATH)) && ([set PATH=$(AFSDEV_BIN)] != 0))
88 #    If env. var. PATH not defined then macro assignment won't set it.
89 !ERROR Failed setting environment variable PATH.
90 !ENDIF
91 PATH = $(AFSDEV_BIN);$(PATH)
92
93
94 # Undefine WIN32.MAK NODEBUG macro.
95 # Always generate full debug info, unless profiling or tuning (see below).
96
97 !UNDEF NODEBUG
98
99 # Include WIN32.MAK nmake file
100
101 !INCLUDE <WIN32.MAK>
102
103
104
105 # Extend and/or supplement definitions in WIN32.MAK.
106
107 # Standard install directory.
108 !IFDEF AFSDEV_DESTDIR
109 DESTDIR = $(AFSDEV_DESTDIR)
110 !ELSE
111 DESTDIR = $(AFSROOT)\DEST
112 !ENDIF
113
114 # Command macros.
115 COPY = copy
116 DEL = -del
117 MKDIR = mkdir
118 REN = ren
119 ECHO = echo
120 CD = cd
121 MC = mc -vcsU
122 MAKECMD = nmake.exe
123
124 COMPILE_ET = $(DESTDIR)\bin\compile_et
125 RXGEN = $(DESTDIR)\bin\rxgen
126 MIDL  = midl
127
128 # Common clean target.
129 # Double colon (::) syntax allows supplemental clean target to be specified.
130 clean::
131         $(DEL) /q *.obj *.lib *.dll *.exe
132         $(DEL) /q *_component_version_number.*
133
134 # Common lang target.
135 # Double colon (::) syntax allows supplemental lang target to be specified.
136 lang::
137
138
139 # Compiler include paths and preprocessor defines
140
141 afscdefs =\
142         -I. \
143         -I$(DESTDIR)\include \
144         -I$(DESTDIR)\include\afs \
145         -I$(DESTDIR)\include\rx \
146         -DWIN32_LEAN_AND_MEAN \
147         -DSTRICT \
148         -D_WIN32_IE=0x0400
149
150 afscdefs = $(afscdefs) $(AFSDEV_AUXCDEFINES)
151
152
153 # Compiler switches (except include paths and preprocessor defines)
154 #
155 # Note: if conflicting options are specified, rightmost option applies.
156 #
157 # /Oy-  specifies no frame-pointer omission
158 # /GF   pool strings and place in read-only memory
159 # /Gd   use cdecl calling convention by default
160 # /Gy   enable function-level linking
161 # /GX   enable C++ exceptions (assumes extern C funcs never throw exceptions)
162 # /Os   favor small (over fast) code; seems to avoid 64-bit bugs in VC compiler
163
164 afscflags =\
165         /Oy- \
166         /GF \
167         /Gd \
168         /Gy \
169         /GX \
170         /Os
171
172 # Set optimization and debugging level based on build type.
173
174 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
175 #    Apply full optimization; generate full debug info in obj.
176 afscflags = $(afscflags) /Ox /Z7
177 ldebug = $(ldebug) -debugtype:both
178 cdebug = $(cdebug:-Od=)  # avoid annoying override warning (D4025)
179
180 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
181 #    Disable optimization; generate full debug info in obj.
182 afscflags = $(afscflags) /Od /Z7
183 ldebug = $(ldebug) -debugtype:both
184 !ENDIF
185
186 # Set compiler warning level
187
188 !IFNDEF AFSDEV_WARNLEVEL
189 AFSDEV_WARNLEVEL = 3
190 !ELSE
191 !IF ("$(AFSDEV_WARNLEVEL)" != "0" && \
192      "$(AFSDEV_WARNLEVEL)" != "1" && \
193      "$(AFSDEV_WARNLEVEL)" != "2" && \
194      "$(AFSDEV_WARNLEVEL)" != "3" && \
195      "$(AFSDEV_WARNLEVEL)" != "4")
196 !ERROR Must define AFSDEV_WARNLEVEL to be one of 0 through 4.
197 !ENDIF
198 !ENDIF
199
200 afscflags = $(afscflags) /W$(AFSDEV_WARNLEVEL)
201
202
203 # Linker switches
204 #
205 # /FIXED:NO   generates a relocation section in the executable
206
207 afslflags =\
208         /FIXED:NO
209
210
211
212 # For checked builds, define DEBUG (but not the MS control flag _DEBUG).
213
214 !IF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
215 afscdefs = $(afscdefs) -DDEBUG
216 !ENDIF
217
218 # Utilize the debug version of the MSVC runtime, if requested.
219
220 !IFDEF AFSDEV_CRTDEBUG
221 afscdefs = $(afscdefs) -D_DEBUG
222 conlibsdll = $(conlibsdll:msvcrt.lib=msvcrtd.lib)
223 guilibsdll = $(guilibsdll:msvcrt.lib=msvcrtd.lib)
224 !ENDIF
225
226 # Link with binmode.obj; files will be opened in binary mode by default.
227
228 !IFNDEF AFSDEV_TEXTMODE
229 conlibsdll = $(conlibsdll) binmode.obj
230 guilibsdll = $(guilibsdll) binmode.obj
231 !ENDIF
232
233
234 # Define MFC link and library macros
235 #     Note that MFC seems to make extensive use of default libraries,
236 #     thus we do not specify a general /NODEFAULTLIB.
237
238 mfclflags = $(guilflags)
239 mfclflags = $(mfclflags:/NODEFAULTLIB=)
240
241 mfcdlllflags = $(dlllflags)
242 mfcdlllflags = $(mfcdlllflags:/NODEFAULTLIB=)
243
244 mfclibsdll = $(guilibsdll)
245 mfclibsdll = $(mfclibsdll:msvcrtd.lib=)
246 mfclibsdll = $(mfclibsdll:msvcrt.lib=)
247
248 !IFNDEF AFSDEV_CRTDEBUG
249 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrtd.lib
250 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrtd.lib
251 !ELSE
252 mfclflags = $(mfclflags) /NODEFAULTLIB:msvcrt.lib
253 mfcdlllflags = $(mfcdlllflags) /NODEFAULTLIB:msvcrt.lib
254 !ENDIF
255
256
257 # Macros for creating/modifying binary targets
258
259 # EXE link macro for console applications
260 EXECONLINK = $(link) /OUT:$@ $(ldebug) $(conlflags) $(afslflags) $(conlibsdll) $**
261
262 # EXE link macro for GUI applications
263 EXEGUILINK = $(link) /OUT:$@ $(ldebug) $(guilflags) $(afslflags) $(guilibsdll) $**
264
265 # EXE link macro for MFC applications
266 EXEMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfclflags) $(afslflags) $(mfclibsdll) $**
267
268 # DLL link macro for console applications
269 DLLCONLINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(conlibsdll) $**
270
271 # DLL link macro for GUI applications
272 DLLGUILINK = $(link) /OUT:$@ $(ldebug) $(dlllflags) $(afslflags) $(guilibsdll) $**
273
274 # DLL link macro for MFC applications
275 DLLMFCLINK = $(link) /OUT:$@ $(ldebug) $(mfcdlllflags) $(afslflags) $(mfclibsdll) $**
276
277 # DLL link macro for resource-only DLLs
278 DLLRESLINK = $(link) /OUT:$@ $(dlllflags:-entry:_DllMainCRTStartup@12=-noentry) $(afslflags) $**
279
280 # Library archive macro
281 LIBARCH = $(implib) /NOLOGO /OUT:$@ $**
282
283 # Language selection macro
284 NTLANG = $(DESTDIR)\bin\NTLang.bat
285
286
287 # EXE\DLL preparation macros
288 #     Rebase to avoid conflicts; strip symbols in free build.
289 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
290 EXEPREP = rebase -b 0x00400000 -x $(@D) -q $@
291 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -x $(@D) -q $@
292 !ELSEIF ("$(AFSDEV_BUILDTYPE)" == "CHECKED")
293 EXEPREP = rebase -b 0x00400000 -q $@
294 DLLPREP = rebase -i $(DESTDIR)\NTDllmap.txt -q $@
295 !ENDIF
296
297 # C/C++ compilation macros
298 C2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
299 CPP2OBJ = $(cc) $(cflags) $(cdebug) $(cvarsdll) $(afscflags) $(afscdefs) /c
300
301 # Resource compiler macro
302 RC = $(rc) $(rcvars) $(rcflags) $(AFSDEV_AUXRCFLAGS)
303
304 # Lex/Yacc macros
305 LEX = flex -l
306 YACC = bison
307
308 # Inference rules for building and installing targets
309
310 # Compile .c files
311 .c.obj:
312         $(C2OBJ) $*.c
313
314 # Compile .cpp files
315 .cpp.obj:
316         $(CPP2OBJ) $*.cpp
317
318 # Compile .rc (resource) files
319 .rc.res:
320         $(RC) $*.rc
321
322 # Install header files
323 .SUFFIXES: .h
324
325 .h.{$(DESTDIR)\include}.h:
326         $(COPY) $(*B).h $(DESTDIR)\include
327
328 .h.{$(DESTDIR)\include\afs}.h:
329         $(COPY) $(*B).h $(DESTDIR)\include\afs
330
331 .h.{$(DESTDIR)\include\rx}.h:
332         $(COPY) $(*B).h $(DESTDIR)\include\rx
333
334 .h.{$(DESTDIR)\include\WINNT}.h:
335         $(COPY) $(*B).h $(DESTDIR)\include\WINNT