STABLE14101-linux-mmap-antirecursion-fix-20090512
[openafs.git] / README-NT
1 This software has been released under the terms of the IBM Public
2 License.  For details, see the LICENSE file in the top-level source
3 directory or on-line at http://www.openafs.org/dl/license10.html
4
5 The document now provides a step by step procedure that takes the user 
6 from a basic Windows 2000/XP/2003 workstation to an OpenAFS development 
7 environment.   Details are provided so that a 'beginning' windows 
8 developer can build an OpenAFS installable package for Windows 2000/XP/2003.
9
10 NOTE 1:
11 As of the OpenAFS 1.3 release series, Windows platforms released
12 prior to Windows 2000 are not being supported.  The InstallShield
13 installer is still in the source tree but is no longer supported.
14 A new open source installer based on NSIS 2.07 replaces it.
15
16 ***********   Windows 2000/XP/2003 Build Process ****************
17
18 Building OpenAFS for Windows requires configuring a Windows
19 development system by installing compilation tools and header files.
20 Open AFS Software development can be done on Windows 2000 or XP.  The
21 target system, where OpenAFS will be installed, should be either
22 Windows 2000, Windows XP, or Windows 2003.  The building process is 
23 controlled by a nmake file that generates the necessary binaries and 
24 binds them into an install package.
25
26 The following steps describe how to configure Windows 2000/XP:
27
28    A. Obtain a copy of the OpenAFS Source Tree
29    B. Install Compiler and Development tools.
30    C. Install SDK header files
31    D. Configure NTBUILD.BAT
32    E. Set program version Level
33    F. Build Win2000 binaries
34    G. Install NSIS 2.07
35    H. Build NSIS Install Package
36    I. Install Wix 2.0
37    J. Build Wix MSI Install Package
38    K. Final Results
39    L. Optional Items
40         
41 The Microsoft development tools require anywhere from 660 MB to 1.8GB
42 of storage depending on which compilers are selected.  The following 
43 versions are supported:
44
45     Microsoft Visual Studio .NET 
46       available via a MSDN subscription
47
48     Microsoft Visual Studio .NET 2003 (recommended)
49       available via a MSDN subscription
50
51     Microsoft Visual Studio .NET 2005 (do not use for production)
52       available via a MSDN subscription
53
54 The following Microsoft SDK is required:
55
56     Microsoft Platform SDK for Windows XP SP2 [Core, Data Access and Installer SDKs are required]
57       http://www.microsoft.com/msdownload/platformsdk/sdkupdate/downlevel.htm [IE required]
58       http://www.microsoft.com/msdownload/platformsdk/sdkupdate/XPSP2FULLInstall.htm
59
60 The following Microsoft DDK is required:
61
62     Microsoft Windows Server 2003 SP1 DDK
63       available via a MSDN subscription or via free CD
64       http://www.microsoft.com/whdc/devtools/ddk/orderddkcd.mspx
65
66 The NSIS installer requires about 14 MB of storage. The following 
67 version is supported:
68
69     Nullsoft Scriptable Installation System 2.07 
70       http://nsis.sourceforge.net/home/
71
72 The WiX installer requires about 18 MB of storage.  The following 
73 version is supported:
74
75     Wix 2.0.2217.0
76       http://prdownloads.sourceforge.net/wix/sources-2.0.2217.0.zip
77
78 The InstallShield scripts (although not supported) require version 5.5
79 of InstallShiled. Version 6.0 or higher of InstallShield are not 
80 compatible.
81
82 The OpenAFS Source directory requires about 360 MB storage. The Source
83 directory size includes additional space for files that will be
84 generated during the build process.
85
86
87 STEP A. Obtain a copy of the Open AFS Source Tree.
88
89 Transfer OpenAFS source tree onto your hardrive.  The source can be
90 downloaded from the OpenAFS web site:
91         http://www.OpenAFS.org/release/snapindex.html.
92
93 For this example, download source for version 1.3.74 using the
94 following URL:
95 http://www.openafs.org/dl/openafs/1.3.74/openafs-1.3.74-src.tar
96
97 HINT: DailySnapShots are pre-release source trees and much more
98 likely to have compilation errors. If this is your first attempt, do
99 your build based on a release version of the source, e.g. 1.3.74. Once
100 you have completed a build process successfully, you can experiment with
101 other source trees.
102
103 You will need an unzip utility that can expand compressed tar files.
104 For example "Pkzip for Windows" from Pkware will uncompress tar files.
105 (http://www.pkware.com/)
106
107 Expand the downloaded tar file (openafs-1.3.74-src.tar) into target
108 directory (c:\OpenAFS), the unzip routine will expand the source into a
109 subdirectory tree:
110     c:\OpenAFS\OpenAFS-1.3.74\src
111
112 Copy the files 'NTMakefile' and 'ntbuild.bat' from 'src' to the OpenAFS 
113 base directory (aka %AFSROOT%):
114
115   From a DOS command prompt window, enter the following copy commands:
116
117     cd c:\OpenAFS\OpenAFS-1.3.74
118     copy src\NTMakefile .
119     copy src\ntbuild.bat .
120
121
122 The AFS base directory should look something like the following:
123
124   c:\OpenAFS\OpenAFS-1.3.74\
125     NTMakefile
126     ntbuild.bat
127     src
128           
129
130 STEP B. Install compiler and development tools.
131
132 Install a copy of Microsoft Visual Studio .NET, Visual Studio .NET 2003, 
133 or Visual Studio .NET 2005.  The "Typical" install setting is sufficient.
134
135 (1) You can reduce the installation size by selecting "Custom" install
136 and remove all but the following Options:
137
138         Microsoft Visual C++
139         Data Access
140
141 (2) When asked, Select to Register Environment Variables.
142
143
144 STEP C. Install SDK header files.
145
146 Files from Microsoft's Platform SDK for Windows XP SP2 is required to
147 complete a build on Windows 2000/XP/2003.   You can install the "Core, Data
148 Access and Installer SDKs" from
149
150   http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
151
152 by using Internet Explorer 5.x or higher.  (Active X controls are required)
153 If you do not which to use IE a complete SDK package is available from
154
155   http://www.microsoft.com/msdownload/platformsdk/sdkupdate/XPSP2FULLInstall.htm
156
157 The header files that are required are found from a Microsoft SDK are:
158
159    npapi.h    (Windows 2000,XP,2003 builds)
160    netcfgx.h  (NSIS Loopback Adapter installer - Windows 2000,XP,2003 builds)
161    netcfgn.h  (NSIS Loopback Adapter installer - Windows 2000,XP,2003 builds)
162
163 These files come from the following Microsoft DDKs/SDKs:
164
165    npapi.h:
166         Windows XP SP2 Platform SDK - include/
167
168    netcfgn.h, netcfgx.h:
169         Windows XP/2003 DDK - inc/wxp/
170
171
172 STEP D. Configure NTBUILD.BAT.
173
174 The NTBUILD.BAT file copied to the OpenAFS base directory must be 
175 customized for use on your development system.  The following variables
176 must be defined to match your configuration:
177
178   AFSVER_CL: Set to 1200 if using MS Visual C++ 6.0
179              Set to 1300 if using MS Visual Studio .NET
180              Set to 1310 if using MS Visual Studio .NET 2003
181              Set to 1400 if using MS Visual Studio .NET 2005
182
183   MSVCDIR: Set to the short name version of the directory into which
184            the visual C++ compiler was installed regardless of version
185
186   MSSDKDIR: Set to the short name of the directory into which
187             the Platform SDK was installed
188
189   NTDDKDIR: Set the short name of the directory containing the npapi.h file
190
191   AFSROOT: Set to the short name of the OpenAFS Base directory.  This
192            cannot be set to a UNC path.
193
194
195 STEP E. Set version and installation options (optional)
196
197 Add a CellServDB file to install area. CellServDB contains the entries
198 for the various cell names.  You can download a general purpose one
199 from:
200         http://grand.central.org/dl/cellservdb/CellServDB
201 then copy it to %AFSROOT%\src\WINNT\install\NSIS and name it afsdcell.ini
202
203 Edit file %AFSROOT%\src\config\NTMakefile.i386_w2k
204     AFSPRODUCT_VER_MAJOR - Version Major Number
205     AFSPRODUCT_VER_MINOR - Version Minor Number
206     AFSPRODUCT_VER_PATCH - Version Patch Number
207     AFSPRODUCT_VER_BUILD - Version Build Number
208     CELLSERVDB_INSTALL   - The default file name for the CellServDB
209                            included in the install Package.
210     CELLNAME_DEFAULT     - The default home cell name.
211     CELLSERVDB_WEB       - The default web address to obtain CellServDB
212
213 For example: in the file %AFSROOT%\src\config\NTMakefile.i386_nt40 you would
214 see the following:
215
216    AFSPRODUCT_VER_MAJOR=1
217    AFSPRODUCT_VER_MINOR=3
218    AFSPRODUCT_VER_PATCH=7400
219    AFSPRODUCT_VER_BUILD=0
220    CELLNAME_DEFAULT=openafs.org
221    CELLSERVDB_INSTALL=CellServDB.GrandCentral
222    CELLSERVDB_WEB=http://grand.central.org/dl/cellservdb/CellServDB
223
224 During the Open AFS installation process the user will be presented
225 with two choices for the CellServDB: Local copy (CELLSERVDB_INSTALL) and
226 one that can be downloaded from the web (CELLSERVDB_WEB).
227
228 STEP F. Begin the build
229
230 (1) From Windows 2000/XP/2003 open up a DOS prompt window.
231
232 (2) Change to the %AFSROOT% directory
233
234 (3) Configure the environment variables:
235
236     For a release build:
237
238     (a) Execute the VCVARS32.BAT or VSVARS32.BAT file which part of the
239         Visual Studio environment you installed.
240
241     (b) Execute the SETENV.BAT file with the parameters "/2000 /RETAIL"
242
243     (c) Execute the NTBUILD.BAT file with the parameter "free"
244
245     For a debug build:
246
247     (a) Execute the VCVARS32.BAT or VSVARS32.BAT file which part of the
248         Visual Studio environment you installed.
249
250     (b) Execute the SETENV.BAT file with the parameters "/2000 /DEBUG"
251
252     (c) Execute the NTBUILD.BAT file with the parameter "checked"
253
254 (4) Clean the work area:
255
256     nmake /f NTMakefile clean
257
258 (5) Build the complete Windows 2000/XP/2003 development environment.
259
260     nmake /f NTMakefile install
261
262 While the build is running you will see many compile warnings. This
263 behavior is normal; the build process is successful as long as the build
264 process doesn't terminate with an error ("nmake.exe return code 0x2")
265 and it displays 'Build Finished Successfully'.
266
267
268 STEP G. Install NSIS 2.07 (optional).
269
270 Download the Nullsoft Scriptable Installation System (NSIS) 2.07 from
271
272     http://nsis.sourceforge.net/home/
273
274 Run the nsis20.exe installer.
275
276 NOTE: The NSIS installer may be rebuilt from source files 
277    
278     C:\Program Files\NSIS\Source
279
280 to enable options not built into the default configuration.  The 
281 OpenAFS installers are built using a modified version of the NSIS
282 sources.  The following changes were made to exehead\config.h.
283
284     NSIS_MAX_STRLEN set to 4096
285     NSIS_CONFIG_LOG defined
286     NSIS_CONFIG_LOG_ODS defined
287     
288
289 STEP H.  Build OpenAFS NSIS install package
290
291 From the %AFSROOT% directory execute:
292
293     nmake /f NTMakefile NSIS
294
295
296 STEP I.  Install Wix MSI Installer
297
298 Download the Wix 2.0.2217.0 installer from 
299
300     http://prdownloads.sourceforge.net/wix/sources-2.0.2217.0.zip
301
302 Apply the following patches to the source tree and execute 
303
304     make ship
305
306 from the \src\wix directory.  
307
308 Index: src/wix/Common.cs
309 ===================================================================
310 RCS file: /cvsroot/wix/wix/src/wix/Common.cs,v
311 retrieving revision 1.7
312 diff -w -r1.7 Common.cs
313 140a141,146
314 >               public static long GetFileTimeFromDateTime(string dateTime) 
315 >               {
316 >                       System.DateTime sdt = System.Xml.XmlConvert.ToDateTime(dateTime);
317 >                       return sdt.ToFileTime();
318 >               }
319
320 Index: src/wix/Compiler.cs
321 ===================================================================
322 RCS file: /cvsroot/wix/wix/src/wix/Compiler.cs,v
323 retrieving revision 1.14
324 diff -w -r1.14 Compiler.cs
325 847c847
326 <                     this.AddRegistryKey(sourceLineNumbers, null, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\", context[i]), String.Empty, String.Concat("\"[!", fileServer, "]", argument == null ? String.Empty : " ", argument, "\""), componentId); // ClassId context
327 ---
328 >                     this.AddRegistryKey(sourceLineNumbers, null, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\", context[i]), String.Empty, String.Concat("\"[#", fileServer, "]", argument == null ? String.Empty : " ", argument, "\""), componentId); // ClassId context
329 2352a2353,2358
330 >                       // if a Value attribute was given by itself, make this a type 19 custom action
331 >                       if( sourceBits == 0 && targetBits == MsiInterop.MsidbCustomActionTypeTextData ) 
332 >                       {
333 >                               sourceBits = MsiInterop.MsidbCustomActionTypeSourceFile;
334 >                       }
335
336 3881c3887
337 <                         minDate = attrib.Value;
338 ---
339 >                         minDate = Common.GetFileTimeFromDateTime( attrib.Value ).ToString();
340 3884c3890
341 <                         maxDate = attrib.Value;
342 ---
343 >                         maxDate = Common.GetFileTimeFromDateTime( attrib.Value ).ToString();
344 8187a8194,8207
345 >                                       case "Delete":
346 >                                               switch (attrib.Value)
347 >                                               {
348 >                                                       case "install":
349 >                                                               events |= MsiInterop.MsidbServiceControlEventDelete;
350 >                                                               break;
351 >                                                       case "uninstall":
352 >                                                               events |= MsiInterop.MsidbServiceControlEventUninstallDelete;
353 >                                                               break;
354 >                                                       case "both":
355 >                                                               events |= MsiInterop.MsidbServiceControlEventDelete | MsiInterop.MsidbServiceControlEventUninstallDelete;
356 >                                                               break;
357 >                                               }
358 >                                               break;
359 9685a9706
360
361 Index: src/wix/Preprocessor.cs
362 ===================================================================
363 RCS file: /cvsroot/wix/wix/src/wix/Preprocessor.cs,v
364 retrieving revision 1.6
365 diff -w -r1.6 Preprocessor.cs
366 274c274
367 <                             context = new IfContext(context.IsTrue & context.Active, this.variables.ContainsKey(reader.Value.Trim()), IfState.If);
368 ---
369 >                             context = new IfContext(context.IsTrue & context.Active, this.IsDefined(reader.Value.Trim()), IfState.If);
370 279c279
371 <                             context = new IfContext(context.IsTrue & context.Active, !this.variables.ContainsKey(reader.Value.Trim()), IfState.If);
372 ---
373 >                             context = new IfContext(context.IsTrue & context.Active, !this.IsDefined(reader.Value.Trim()), IfState.If);
374 360a361,362
375 >                                               case "error":
376 >                                                       throw new WixPreprocessorException(this.GetCurrentSourceLineNumbers(), this.PreprocessVariables(reader.Value));
377 419a422,437
378 >               /// Returns true if the symbol exists.
379 >               /// </summary>
380 >               /// <param name="symbol">symbol name to check</param>
381 >               /// <returns>true if symbol is defined</returns>
382 >               private bool IsDefined(string symbol)
383 >               {
384 >                       if( symbol.StartsWith("env.") )
385 >                               return Environment.GetEnvironmentVariable(symbol.Substring(4)) != null;
386 >                       if( symbol.StartsWith("var.") )
387 >                               return this.variables.ContainsKey(symbol.Substring(4));
388 >                       if( symbol.StartsWith("sys.") )
389 >                               return this.systemVariables.ContainsKey(symbol.Substring(4));
390 >                       return this.variables.ContainsKey(symbol);
391 >               }
392
393 >         /// <summary>
394 Index: src/wix/wix.csproj
395 ===================================================================
396 RCS file: /cvsroot/wix/wix/src/wix/wix.csproj,v
397 retrieving revision 1.4
398 diff -w -r1.4 wix.csproj
399 661a662,666
400 >                     RelPath = "Xsd\wix.xsx"
401 >                     DependentUpon = "wix.xsd"
402 >                     BuildAction = "None"
403 >                 />
404 >                 <File
405 664a670,674
406 >                 <File
407 >                     RelPath = "Xsd\wixloc.xsx"
408 >                     DependentUpon = "wixloc.xsd"
409 >                     BuildAction = "None"
410 >                 />
411
412
413 STEP J.  Build Wix MSI install package
414
415 From the %AFSROOT% directory execute:
416
417     nmake /f NTMakefile wix
418
419 Make sure the binaries installed to \src\wix\release\ship are
420 available in the PATH environment variable
421
422
423 STEP K. Final Results
424
425 The build process generates its binaries in %AFSROOT%\DEST. The subdirectory
426 would look like the following:
427
428 %AFSROOT%\DEST\{checked,free}\
429         bin
430         etc
431         include
432         lib
433         root.client
434         root.server
435         WinInstall
436
437     Bin - contains build utilities.
438     root.client - contains Open AFS binaries
439     root.server - contain Open AFS Server binaries
440     WinInstall\OpenAFSforWindows.exe - is the NSIS install package
441     WinInstall\openafs-en_US.msi - is the WiX MSI install package
442
443
444 STEP L. Optional Items
445
446 The build process has an error table that is compiled for many OpenAFS
447 applications.  This table is generated by Unix based tools.  It is not
448 normally necessary to modify this table so pre-generated source files
449 are included in the OpenAFS source.  If you need to make modifications
450 in these areas the Unix base tools that run on Windows can be found on
451 the web. For example:
452
453         http://cygwin.com/
454
455 Below is a short explanation how to update the error table.
456
457 (1) Install flex and bison from a Unix based tool provider.
458
459 (2) Make changes to the source files.
460
461 There are two files in the source tree that are processed with lex
462 and yacc on UNIX systems, src/comerr/et_lex.lex.l and
463 src/comerr/error_table.y, that when processed produce the files
464 et_lex.lex_nt.c, error_table_nt.c, and error_table_nt.h.
465
466 Since NT does not include lex and yacc or any equivalent tools, we
467 have provided the output files that lex and yacc produce (using Win32
468 ports of flex and bison). This will allow builds to work for anyone
469 who does not need to change the .l and .y files.
470
471 If you do need to change et_lex.lex.l, then you will need to install
472 Win32 port of flex on your system. Put flex.exe in a directory on the
473 path and rebuild.
474
475 If you do need to change error_table.y, then you will need to install
476 a Win32 port of bison on your system. Put bison.exe in a directory on
477 the path, configure bison as explained in step 5, and rebuild.
478
479 You can also attempt to use other replacements for lex and yacc. This
480 will require modifying the LEX and YACC settings in
481 /config/NTMakefile.i386_nt40. If the replacements require different
482 command line options than flex and bison, then you may also need to
483 change src/comerr/NTMakefile.
484
485 (3) Generate new OpenAFS binaries