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