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