]> granicus.if.org Git - apache/blob - docs/manual/platform/win_compiling.xml
cb55fae3d1d0961225ac4a8cb99445d7500d1a8a
[apache] / docs / manual / platform / win_compiling.xml
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
5
6 <!--
7  Licensed to the Apache Software Foundation (ASF) under one or more
8  contributor license agreements.  See the NOTICE file distributed with
9  this work for additional information regarding copyright ownership.
10  The ASF licenses this file to You under the Apache License, Version 2.0
11  (the "License"); you may not use this file except in compliance with
12  the License.  You may obtain a copy of the License at
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
22
23 <manualpage metafile="win_compiling.xml.meta">
24   <parentdocument href="./">Platform Specific Notes</parentdocument>
25
26   <title>Compiling Apache for Microsoft Windows</title>
27
28   <summary>
29
30     <p>There are many important points before you begin compiling
31     Apache. See <a href="windows.html">Using Apache with Microsoft
32     Windows</a> before you begin.</p>
33
34   </summary>
35
36   <section id="requirements">
37
38     <title>Requirements</title>
39
40     <p>Compiling Apache requires the following environment to be
41     properly installed:</p>
42
43     <ul>
44       <li>
45         <p>Disk Space</p>
46         <p>Make sure you have at least 50 MB of free disk space
47         available. After installation Apache requires approximately
48         10 MB of disk space, plus space for log and cache files,
49         which can grow rapidly. The actual disk space requirements
50         will vary considerably based on your chosen configuration and
51         any third-party modules or libraries.</p>
52       </li>
53
54       <li>
55         <p>Microsoft Visual C++ (Microsoft Visual Studio) 5.0 or higher.</p>
56         <p>Apache can be built using the command line tools, or from
57         within the Visual Studio IDE Workbench.  The command line
58         build requires the environment to reflect the <code>PATH</code>,
59         <code>INCLUDE</code>, <code>LIB</code> and other variables
60         that can be configured with the <code>vcvars32</code> batch file:</p>
61
62         <example>
63           "c:\Program Files\DevStudio\VC\Bin\vcvars32.bat"
64         </example>
65       </li>
66
67       <li>
68         <p>The Windows Platform SDK.</p>
69         <p>Apache's APR and APR-util builds require an updated Microsoft
70         Windows Platform SDK, from 2003 or later. For command line
71         builds, the Platform SDK environment is prepared by the
72         <code>setenv</code> batch file:</p>
73
74         <example>
75           "c:\Program Files\Platform SDK\setenv.bat"
76         </example>
77
78         <p>The Platform SDK files distributed with Visual C++ 5.0, 6.0 
79         and Visual Studio .NET (2000) are no longer sufficient.
80         Users of Visual Studio 2003 and later versions (of the full product,
81         not the 'express' flavor) and later versions may skip this 
82         requirement.</p>
83       </li>
84
85       <li>
86         <p>The awk utility (awk, gawk or similar).</p>
87         <p>To install Apache within the build system, several files are
88         modified using the <code>awk.exe</code> utility. awk was chosen since
89         it is a very small download (compared with Perl or WSH/VB) and
90         accomplishes the task of generating files. Brian Kernighan's
91         <a href="http://cm.bell-labs.com/cm/cs/who/bwk/"
92         >http://cm.bell-labs.com/cm/cs/who/bwk/</a>
93         site has a compiled native Win32 binary,
94         <a href="http://cm.bell-labs.com/cm/cs/who/bwk/awk95.exe"
95         >http://cm.bell-labs.com/cm/cs/who/bwk/awk95.exe</a> which
96         you must save with the name <code>awk.exe</code> rather than
97         <code>awk95.exe</code>.</p>
98
99         <note>Note that Developer Studio IDE will only find
100         <code>awk.exe</code> from the Tools menu Options... Directories
101         tab (the Projects - VC++ Directories pane in Developer Studio 7.0)
102         listing Executable file paths. Add the path for <code>awk.exe</code>
103         to this list, and your system <code>PATH</code> environment variable,
104         as needed.</note>
105
106         <note>Also note that if you are using Cygwin tools
107         (<a href="http://www.cygwin.com/">http://www.cygwin.com/</a>) 
108         the awk utility is named <code>gawk.exe</code> and that the file 
109         <code>awk.exe</code> is really a symlink to the <code>gawk.exe</code>
110         file. The Windows command shell does not recognize symlinks, and 
111         because of that building InstallBin will fail. A workaround is 
112         to delete <code>awk.exe</code> from the cygwin installation and 
113         copy <code>gawk.exe</code> to <code>awk.exe</code>.  Also note the
114         cygwin/mingw ports of gawk 3.0.x were buggy, please upgrade to 3.1.x
115         before attempting to use any gawk port.</note>
116       </li>
117
118       <li>
119         <p>[Optional] OpenSSL libraries (for <module>mod_ssl</module>
120         and <code>ab.exe</code> with ssl support)</p>
121         <p><strong>Caution: there are significant restrictions and
122         prohibitions on the use and distribution of strong cryptography
123         and patented intellectual property throughout the world.</strong>
124         OpenSSL includes strong cryptography controlled by both export
125         regulations and domestic law, as well as intellectual property
126         protected by patent, in the United States and elsewhere.  Neither
127         the Apache Software Foundation nor the OpenSSL project can provide
128         legal advise regarding possession, use, or distribution of the code
129         provided by the OpenSSL project. <strong>Consult your own legal
130         counsel, you are responsible for your own actions.</strong></p>
131
132         <p>OpenSSL must be installed into a <code>srclib</code> subdirectory named
133         <code>openssl</code>, obtained from <a href="http://www.openssl.org/source/"
134         >http://www.openssl.org/source/</a>, in order to compile <module>mod_ssl</module>
135         or the abs project (<code>ab.exe</code> with SSL support.) To prepare OpenSSL
136         for both <code>release</code> and <code>debug</code> builds of Apache, and
137         disable the patent protected features in OpenSSL,  you might use the following
138         build commands:</p>
139
140         <example>
141           perl Configure VC-WIN32<br />
142           perl util\mkfiles.pl &gt;MINFO<br />
143           perl util\mk1mf.pl dll no-asm no-mdc2 no-rc5 no-idea VC-WIN32 &gt;makefile.rel<br />
144           perl util\mk1mf.pl dll debug no-asm no-mdc2 no-rc5 no-idea VC-WIN32 &gt;makefile.dbg<br />
145           perl util\mkdef.pl 32 libeay no-asm no-mdc2 no-rc5 no-idea &gt;ms\libeay32.def<br />
146           perl util\mkdef.pl 32 ssleay no-asm no-mdc2 no-rc5 no-idea &gt;ms\ssleay32.def<br />
147           nmake -f makefile.rel<br />
148           nmake -f makefile.dbg
149         </example>
150
151         <p>Note; you can use the scripts in the <code>ms\</code> subdirectory, however,
152         it's rather tricky to force <code>ms\do_masm.bat</code>, for example, to perform
153         the patent encumberances as mentioned above.  Patches to add the $* argument list
154         to the appropriate .bat lines in these scripts aren't incorporated, thus far.</p>
155       </li>
156
157       <li>
158         <p>[Optional] zlib library (for <module>mod_deflate</module>)</p>
159         <p>Zlib must be installed into a <code>srclib</code> subdirectory named
160         <code>zlib</code>.  This must be built in-place.  Zlib can be obtained 
161         from <a href="http://www.zlib.net/">http://www.zlib.net/</a> -- the
162         <module>mod_deflate</module> is confirmed to work correctly with 
163         version 1.2.3.</p>
164
165         <example>
166           nmake -f win32\Makefile.msc<br />
167           nmake -f win32\Makefile.msc test
168         </example>
169       </li>
170
171     </ul>
172
173   </section>
174
175   <section id="commandbuild">
176
177     <title>Command-Line Build</title>
178
179     <p>First, unpack the Apache distribution into an appropriate
180     directory. Open a command-line prompt and <code>cd</code> to that
181     directory.</p>
182
183     <p>The master Apache makefile instructions are contained in the
184     <code>Makefile.win</code> file. To compile Apache on Windows
185     NT, simply use one of the following commands to compiled the
186     <code>release</code> or <code>debug</code> build, respectively:</p>
187
188     <example><pre>
189 nmake /f Makefile.win _apacher
190
191 nmake /f Makefile.win _apached
192     </pre></example>
193
194     <p>Either command will compile Apache. The latter will include
195     debugging information in the resulting files, making it easier
196     to find bugs and track down problems.</p>
197
198   </section>
199
200   <section id="workspacebuild">
201
202     <title>Developer Studio Workspace IDE Build</title>
203
204     <p>Apache can also be compiled using VC++'s Visual Studio
205     development environment. To simplify this process, a
206     Visual Studio workspace, <code>Apache.dsw</code>, is provided.
207     This workspace exposes the entire list of working <code>.dsp</code>
208     projects that are required for the complete Apache binary release.
209     It includes dependencies between the projects to assure that they
210     are built in the appropriate order.</p>
211
212     <p>Open the <code>Apache.dsw</code> workspace, and select
213     <code>InstallBin</code> (<code>Release</code> or <code>Debug</code> build,
214     as desired) as the Active Project. <code>InstallBin</code> causes all
215     related project to be built, and then invokes <code>Makefile.win</code> to
216     move the compiled executables and dlls. You may personalize the
217     <code>INSTDIR=</code> choice by changing <code>InstallBin</code>'s Settings,
218     General tab, Build command line entry. <code>INSTDIR</code> defaults to the
219     <code>/Apache2</code> directory. If you only want a test compile (without
220     installing) you may build the <code>BuildBin</code> project instead.</p>
221
222     <p>The <code>.dsp</code> project files are distributed in Visual
223     C++ 6.0 format. Visual C++ 5.0 (97) will recognize them. Visual C++
224     7.0 (.net) must convert <code>Apache.dsw</code> plus the <code>.dsp</code>
225     files into an <code>Apache.sln</code> plus <code>.msproj</code> files,
226     be sure you reconvert the <code>.msproj</code> file if any of the source
227     <code>.dsp</code> files change! This is really trivial, just open
228     <code>Apache.dsw</code> in the VC++ 7.0 IDE once again.</p>
229
230     <p>Visual C++ 7.0 (.net) users should also use the Build
231     menu, Configuration Manager dialog to uncheck both the <code>Debug</code>
232     and <code>Release</code> Solution modules abs, <module>mod_ssl</module>
233     and <module>mod_deflate</module>.
234     These modules are built by invoking <code>nmake</code> or the IDE directly
235     with the <code>BinBuild</code> target to build those modules explicitly,
236     only if the <code>srclib</code> directories <code>openssl</code>
237     and/or <code>zlib</code> exist.</p>
238
239     <p>Exported <code>.mak</code> files pose a greater hassle, but they are
240     required for Visual C++ 5.0 users to build <module>mod_ssl</module>,
241     abs (<program>ab</program> with SSL support) and/or
242     <module>mod_deflate</module>.
243     VC++ 7.0 (.net) users also benefit, <code>nmake</code> builds
244     are faster than <code>binenv</code> builds.
245     Build the entire project from within the VC++ 5.0 or 6.0 IDE,
246     then use the Project Menu Export for all makefiles.
247     You must build the projects first in order to create all dynamic
248     auto-generated targets, so that dependencies can be parsed
249     correctly. Run the following command to fix the paths so they
250     will build anywhere:</p>
251
252     <example>
253       perl srclib\apr\build\fixwin32mak.pl
254     </example>
255
256     <p>You must type this command from the <em>top level</em>
257     directory of the httpd source tree. Every
258     <code>.mak</code> and <code>.dep</code> project file within
259     the current directory and below will be corrected, and the
260     timestamps adjusted to reflect the <code>.dsp</code>.</p>
261
262     <p>If you contribute back a patch that revises project files, we
263     must commit project files in Visual Studio 6.0 format. Changes
264     should be simple, with minimal compilation and linkage flags that
265     will be recognized by all VC++ 5.0 through 7.0 environments.</p>
266
267   </section>
268
269   <section id="projectcomponents">
270
271     <title>Project Components</title>
272
273     <p>The <code>Apache.dsw</code> workspace and <code>makefile.win</code>
274     <code>nmake</code> script both build the <code>.dsp</code> projects
275     of the Apache server in the following sequence:</p>
276
277     <ol>
278       <li><code>srclib\apr\apr.dsp</code></li>
279
280       <li><code>srclib\apr\libapr.dsp</code></li>
281
282       <li><code>srclib\apr-util\uri\gen_uri_delims.dsp</code></li>
283
284       <li><code>srclib\apr-util\xml\expat\lib\xml.dsp</code></li>
285
286       <li><code>srclib\apr-util\aprutil.dsp</code></li>
287
288       <li><code>srclib\apr-util\libaprutil.dsp</code></li>
289
290       <li><code>srclib\pcre\dftables.dsp</code></li>
291
292       <li><code>srclib\pcre\pcre.dsp</code></li>
293
294       <li><code>srclib\pcre\pcreposix.dsp</code></li>
295
296       <li><code>server\gen_test_char.dsp</code></li>
297
298       <li><code>libhttpd.dsp</code></li>
299
300       <li><code>Apache.dsp</code></li>
301     </ol>
302
303     <p>In addition, the <code>modules\</code> subdirectory tree contains
304     project files for the majority of the modules.</p>
305
306     <p>The <code>support\</code> directory contains project files for
307     additional programs that are not part of the Apache runtime,
308     but are used by the administrator to test Apache and maintain
309     password and log files. Windows-specific support projects are
310     broken out in the <code>support\win32\</code> directory.</p>
311
312     <ol>
313       <li><code>support\ab.dsp</code></li>
314
315       <li><code>support\htdigest.dsp</code></li>
316
317       <li><code>support\htpasswd.dsp</code></li>
318
319       <li><code>support\logresolve.dsp</code></li>
320
321       <li><code>support\rotatelogs.dsp</code></li>
322
323       <li><code>support\win32\ApacheMonitor.dsp</code></li>
324
325       <li><code>support\win32\wintty.dsp</code></li>
326     </ol>
327
328     <p>Once Apache has been compiled, it needs to be installed in
329     its server root directory. The default is the
330     <code>\Apache2</code> directory, of the same drive.</p>
331
332     <p>To build and install all the files into the desired folder
333     <em>dir</em> automatically, use one of the following
334     <code>nmake</code> commands:</p>
335
336     <example><pre>
337 nmake /f Makefile.win installr INSTDIR=<em>dir</em>
338
339 nmake /f Makefile.win installd INSTDIR=<em>dir</em>
340     </pre></example>
341
342     <p>The <em>dir</em> argument to <code>INSTDIR</code> gives
343     the installation directory; it can be omitted if Apache is
344     to be installed into <code>\Apache2</code>.</p>
345
346     <p>This will install the following:</p>
347
348     <ul>
349       <li><code><em>dir</em>\bin\Apache.exe</code> - Apache
350       executable</li>
351
352       <li><code><em>dir</em>\bin\ApacheMonitor.exe</code> - Service
353       monitor taskbar icon utility</li>
354
355       <li><code><em>dir</em>\bin\htdigest.exe</code> - Digest auth
356       password file utility</li>
357
358       <li><code><em>dir</em>\bin\htdbm.exe</code> - SDBM auth
359       database password file utility</li>
360
361       <li><code><em>dir</em>\bin\htpasswd.exe</code> - Basic auth
362       password file utility</li>
363
364       <li><code><em>dir</em>\bin\logresolve.exe</code> - Log file
365       dns name lookup utility</li>
366
367       <li><code><em>dir</em>\bin\rotatelogs.exe</code> - Log file
368       cycling utility</li>
369
370       <li><code><em>dir</em>\bin\wintty.exe</code> - Console window
371       utility</li>
372
373       <li><code><em>dir</em>\bin\libapr.dll</code> - Apache
374       Portable Runtime shared library</li>
375
376       <li><code><em>dir</em>\bin\libaprutil.dll</code> - Apache
377       Utility Runtime shared library</li>
378
379       <li><code><em>dir</em>\bin\libhttpd.dll</code> - Apache Core
380       library</li>
381
382       <li><code><em>dir</em>\modules\mod_*.so</code> - Loadable
383       Apache modules</li>
384
385       <li><code><em>dir</em>\conf</code> - Configuration
386       directory</li>
387
388       <li><code><em>dir</em>\logs</code> - Empty logging
389       directory</li>
390
391       <li><code><em>dir</em>\include</code> - C language header
392       files</li>
393
394       <li><code><em>dir</em>\lib</code> - Link library files</li>
395     </ul>
396
397     <section id="projectcomponents-warn">
398
399       <title>Warning about building Apache from the development tree</title>
400
401       <note>Note only the <code>.dsp</code> files are maintained between <code>release</code>
402       builds. The <code>.mak</code> files are NOT regenerated, due to the tremendous
403       waste of reviewer's time. Therefore, you cannot rely on the <code>NMAKE</code>
404       commands above to build revised <code>.dsp</code> project files unless you
405       then export all <code>.mak</code> files yourself from the project. This is
406       unnecessary if you build from within the Microsoft
407       Developer Studio environment.</note>
408
409       <note>Also note it is very worthwhile to build the <code>BuildBin</code>
410       target project (or the command line <code>_apacher</code> or
411       <code>_apached</code> target) prior to exporting the make files.
412       Many files are autogenerated in the build process. Only a full
413       build provides all of the dependent files required to build proper
414       dependency trees for correct build behavior.</note>
415
416       <p>In order to create distribution <code>.mak</code> files, always review
417       the generated <code>.mak</code> (or <code>.dep</code>) dependencies for
418       Platform SDK or other garbage includes. The <code>DevStudio\SharedIDE\bin\</code>
419       (VC5) or <code>DevStudio\Common\MSDev98\bin\</code> (VC6) directory contains
420       the <code>sysincl.dat</code> file, which must list all exceptions. Update this
421       file (including both forward and backslashed paths, such as both
422       <code>sys/time.h</code> and <code>sys\time.h</code>) to include such dependencies.
423       Including local-install paths in a distributed <code>.mak</code> file will
424       cause the build to fail completely. And don't forget to run
425       <code>srclib/apr/build/fixwin32mak.pl</code> in order to fix absolute
426       paths within the <code>.mak</code> files.</p>
427
428     </section>
429
430   </section>
431
432 </manualpage>
433