Lots of minor, mostly layout fixes.
[Samba/gebeck_regimport.git] / docs / docbook / projdoc / Compiling.xml
blobfb59dead02a0d7c99774acb0443bca4d3008fb04
1 <chapter id="compiling">
2 <chapterinfo>
3         <author>
4                 <affiliation>
5                         <orgname>Samba Team</orgname>
6                 </affiliation>
7         </author>
8         &author.jelmer;
9         
10         <pubdate> 22 May 2001 </pubdate>
11         <pubdate> 18 March 2003 </pubdate>
12 </chapterinfo>
14 <title>How to compile SAMBA</title>
16 <para>
17 You can obtain the samba source from the <ulink url="http://samba.org/">samba website</ulink>. To obtain a development version, 
18 you can download samba from CVS or using rsync.
19 </para>
21 <sect1>
22 <title>Access Samba source code via CVS</title>
24 <sect2>
25 <title>Introduction</title>
27 <para>
28 Samba is developed in an open environment.  Developers use CVS
29 (Concurrent Versioning System) to "checkin" (also known as 
30 "commit") new source code.  Samba's various CVS branches can
31 be accessed via anonymous CVS using the instructions
32 detailed in this chapter.
33 </para>
35 <para>
36 This chapter is a modified version of the instructions found at
37 <ulink url="http://samba.org/samba/cvs.html">http://samba.org/samba/cvs.html</ulink>
38 </para>
40 </sect2>
42 <sect2>
43 <title>CVS Access to samba.org</title>
45 <para>
46 The machine samba.org runs a publicly accessible CVS 
47 repository for access to the source code of several packages, 
48 including samba, rsync, distcc, ccache and jitterbug. There are two main ways
49 of accessing the CVS server on this host.
50 </para>
52 <sect3>
53 <title>Access via CVSweb</title>
55 <para>
56 You can access the source code via your 
57 favourite WWW browser. This allows you to access the contents of 
58 individual files in the repository and also to look at the revision 
59 history and commit logs of individual files. You can also ask for a diff 
60 listing between any two versions on the repository.
61 </para>
63 <para>
64 Use the URL : <ulink
65 url="http://samba.org/cgi-bin/cvsweb">http://samba.org/cgi-bin/cvsweb</ulink>
66 </para>
67 </sect3>
69 <sect3>
70 <title>Access via cvs</title>
72 <para>
73 You can also access the source code via a 
74 normal cvs client.  This gives you much more control over what you can 
75 do with the repository and allows you to checkout whole source trees 
76 and keep them up to date via normal cvs commands. This is the 
77 preferred method of access if you are a developer and not
78 just a casual browser.
79 </para>
81 <para>
82 To download the latest cvs source code, point your
83 browser at the URL :
84 <ulink url="http://www.cyclic.com/">http://www.cyclic.com/</ulink>.
85 and click on the 'How to get cvs' link. CVS is free software under 
86 the GNU GPL (as is Samba).  Note that there are several graphical CVS clients
87 which provide a graphical interface to the sometimes mundane CVS commands.
88 Links to theses clients are also available from the Cyclic website.
89 </para>
91 <para>
92 To gain access via anonymous cvs use the following steps. 
93 For this example it is assumed that you want a copy of the 
94 samba source code. For the other source code repositories 
95 on this system just substitute the correct package name
96 </para>
98 <procedure>
99         <title>Retrieving samba using CVS</title>
101         <step>
102         <para>
103         Install a recent copy of cvs. All you really need is a 
104         copy of the cvs client binary. 
105         </para>
106         </step>
108         <step>
109         <para>
110         Run the command 
111         </para>
113         <para>
114         <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot login</userinput>
115         </para>
116         </step>
118         <step>
119         
120         <para>
121         When it asks you for a password type <userinput>cvs</userinput>.
122         </para>
123         </step>
125         <step>
126         <para>
127         Run the command 
128         </para>
129         
130         <para>
131         <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot co samba</userinput>
132         </para>
133         
134         <para>
135         This will create a directory called samba containing the 
136         latest samba source code (i.e. the HEAD tagged cvs branch). This 
137         currently corresponds to the 3.0 development tree. 
138         </para>
139         
140         <para>
141         CVS branches other then HEAD can be obtained by using the
142         <option>-r</option> and defining a tag name.  A list of branch tag names 
143         can be found on the "Development" page of the samba web site.  A common
144         request is to obtain the latest 3.0 release code.  This could be done by 
145         using the following userinput.
146         </para>
147         
148         <para>
149         <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot co -r SAMBA_3_0 samba</userinput>
150         </para>
151         </step>
153         <step>
154         <para>
155         Whenever you want to merge in the latest code changes use 
156         the following command from within the samba directory: 
157         </para>
158         
159         <para>
160         <userinput>cvs update -d -P</userinput>
161         </para>
162         </step>
163 </procedure>
164         
165 </sect3>
166 </sect2>
168 </sect1>
170 <sect1>
171         <title>Accessing the samba sources via rsync and ftp</title>
173         <para>
174         pserver.samba.org also exports unpacked copies of most parts of the CVS
175         tree at <ulink url="ftp://pserver.samba.org/pub/unpacked">ftp://pserver.samba.org/pub/unpacked</ulink> and also via anonymous rsync at 
176         <ulink url="rsync://pserver.samba.org/ftp/unpacked/">rsync://pserver.samba.org/ftp/unpacked/</ulink>. I recommend using rsync rather than ftp.
177         See <ulink url="http://rsync.samba.org/">the rsync homepage</ulink> for more info on rsync.                       
178         </para>
180         <para>
181         The disadvantage of the unpacked trees is that they do not support automatic
182         merging of local changes like CVS does.  rsync access is most convenient 
183         for an initial install.                       
184         </para>
185 </sect1>
187 <sect1>
188 <title>Verifying Samba's PGP signature</title>
190 <para>
191 In these days of insecurity, it's strongly recommended that you verify the PGP
192 signature for any source file before installing it. Even if you're not 
193 downloading from a mirror site, verifying PGP signatures should be a
194 standard reflex.
195 </para>
198 <para>
199 With that said, go ahead and download the following files:
200 </para>
202 <para><screen>
203 <prompt>$ </prompt><userinput> wget http://us1.samba.org/samba/ftp/samba-2.2.8a.tar.asc</userinput>
204 <prompt>$ </prompt><userinput> wget http://us1.samba.org/samba/ftp/samba-pubkey.asc</userinput>
205 </screen></para>
207 <para>
208 The first file is the PGP signature for the Samba source file; the other is the Samba public
209 PGP key itself. Import the public PGP key with:
210 </para>
212 <screen>
213         <prompt>$ </prompt><userinput>gpg --import samba-pubkey.asc</userinput>
214 </screen>
216 <para>
217 And verify the Samba source code integrity with:
218 </para>
220 <screen>
221         <prompt>$ </prompt><userinput>gzip -d samba-2.2.8a.tar.gz</userinput>
222         <prompt>$ </prompt><userinput>gpg --verify samba-2.2.8a.tar.asc</userinput>
223 </screen>
225 <para>
226 If you receive a message like, "Good signature from Samba Distribution 
227 Verification Key..."
228 then all is well. The warnings about trust relationships can be ignored. An
229 example of what you would not want to see would be:
230 </para>
232 <computeroutput>
233      gpg: BAD signature from "Samba Distribution Verification Key"
234 </computeroutput>
236 </sect1>
238 <sect1>
239         <title>Building the Binaries</title>
240         
241         <para>To do this, first run the program <userinput>./configure
242         </userinput> in the source directory. This should automatically 
243         configure Samba for your operating system. If you have unusual 
244         needs then you may wish to run</para>
245         
246         <para><prompt>root# </prompt><userinput>./configure --help
247         </userinput></para>
248         
249         <para>first to see what special options you can enable.
250         Then executing</para>
251         
252         <para><prompt>root# </prompt><userinput>make</userinput></para>
253         
254         <para>will create the binaries. Once it's successfully 
255         compiled you can use </para>
256         
257         <para><prompt>root# </prompt><userinput>make install</userinput></para>
258         
259         <para>to install the binaries and manual pages. You can 
260         separately install the binaries and/or man pages using</para>
261         
262         <para><prompt>root# </prompt><userinput>make installbin
263         </userinput></para>
264         
265         <para>and</para>
266         
267         <para><prompt>root# </prompt><userinput>make installman
268         </userinput></para>
270         <para>Note that if you are upgrading for a previous version 
271         of Samba you might like to know that the old versions of 
272         the binaries will be renamed with a ".old" extension. You 
273         can go back to the previous version with</para>
274         
275         <para><prompt>root# </prompt><userinput>make revert
276         </userinput></para>
277         
278         <para>if you find this version a disaster!</para>
280         <sect2>
281         <title>Compiling samba with Active Directory support</title>
282         
283         <para>In order to compile samba with ADS support, you need to have installed
284         on your system:</para>
285         <itemizedlist>
286         
287             <listitem><para>the MIT kerberos development libraries
288             (either install from the sources or use a package). The
289             heimdal libraries will not work.</para></listitem>
290         
291             <listitem><para>the OpenLDAP development libraries.</para></listitem>
292             
293         </itemizedlist>
295         <para>If your kerberos libraries are in a non-standard location then
296                 remember to add the configure option 
297                 <option>--with-krb5=<replaceable>DIR</replaceable></option>.</para>
299         <para>After you run configure make sure that 
300                 <filename>include/config.h</filename> it generates contains lines like 
301                 this:</para>
303 <para><programlisting>
304 #define HAVE_KRB5 1
305 #define HAVE_LDAP 1
306 </programlisting></para>
308         <para>If it doesn't then configure did not find your krb5 libraries or
309         your ldap libraries. Look in <filename>config.log</filename> to figure
310         out why and fix it.</para>
312         <sect3>
313         <title>Installing the required packages for Debian</title>
315         <para>On Debian you need to install the following packages:</para>
316         <para>
317                 <simplelist>
318                         <member>libkrb5-dev</member>
319                         <member>krb5-user</member>
320                 </simplelist>
321         </para>
322         </sect3>
324         <sect3>
325         <title>Installing the required packages for RedHat</title>
327         <para>On RedHat this means you should have at least: </para>
328         <para>
329                 <simplelist>
330                         <member>krb5-workstation (for kinit)</member>
331                         <member>krb5-libs (for linking with)</member>
332                         <member>krb5-devel (because you are compiling from source)</member>
333                 </simplelist>
334         </para>
336         <para>in addition to the standard development environment.</para>
338         <para>Note that these are not standard on a RedHat install, and you may need
339         to get them off CD2.</para>
341         </sect3>
342         
343         </sect2>
344                           
345 </sect1>
347 <sect1>
348         <title>Starting the &smbd; and &nmbd;</title>
350         <para>You must choose to start &smbd; and &nmbd; either
351         as daemons or from <application>inetd</application>Don't try
352         to do both!  Either you can put them in <filename>
353         inetd.conf</filename> and have them started on demand
354         by <application>inetd</application>, or you can start them as
355         daemons either from the command line or in <filename>
356         /etc/rc.local</filename>. See the man pages for details
357         on the command line options. Take particular care to read
358         the bit about what user you need to be in order to start
359         Samba.  In many cases you must be root.</para>
361         <para>The main advantage of starting &smbd;
362         and &nmbd; using the recommended daemon method
363         is that they will respond slightly more quickly to an initial connection
364         request.</para>
366         <sect2>
367                 <title>Starting from inetd.conf</title>
369                 <note>
370                 <para>The following will be different if 
371                 you use NIS, NIS+ or LDAP to distribute services maps.</para>
372                 </note>
373                 
374                 <para>Look at your <filename>/etc/services</filename>. 
375                 What is defined at port 139/tcp. If nothing is defined 
376                 then add a line like this:</para>
378                 <para><programlisting>netbios-ssn     139/tcp</programlisting></para>
380                 <para>similarly for 137/udp you should have an entry like:</para>
382                 <para><programlisting>netbios-ns        137/udp</programlisting></para>
384                 <para>Next edit your <filename>/etc/inetd.conf</filename> 
385                 and add two lines something like this:</para>
387                 <para><programlisting>
388                 netbios-ssn stream tcp nowait root /usr/local/samba/bin/smbd smbd 
389                 netbios-ns dgram udp wait root /usr/local/samba/bin/nmbd nmbd 
390                 </programlisting></para>
392                 <para>The exact syntax of <filename>/etc/inetd.conf</filename> 
393                 varies between unixes. Look at the other entries in inetd.conf 
394                 for a guide.</para>
396                 <note><para>Some unixes already have entries like netbios_ns 
397                 (note the underscore) in <filename>/etc/services</filename>. 
398                 You must either edit <filename>/etc/services</filename> or
399                 <filename>/etc/inetd.conf</filename> to make them consistent.
400                 </para></note>
402                 <note><para>On many systems you may need to use the 
403                 <parameter>interfaces</parameter> option in &smb.conf; to specify the IP
404                 address and netmask of your interfaces. Run 
405                 <application>ifconfig</application> 
406                 as root if you don't know what the broadcast is for your
407                 net. &nmbd; tries to determine it at run 
408                 time, but fails on some unixes. 
409                 </para></note>
411                 <warning><para>Many unixes only accept around 5 
412                 parameters on the command line in <filename>inetd.conf</filename>. 
413                 This means you shouldn't use spaces between the options and 
414                 arguments, or you should use a script, and start the script 
415                 from <command>inetd</command>.</para></warning>
417                 <para>Restart <application>inetd</application>, perhaps just send 
418                         it a HUP. If you have installed an earlier version of &nmbd; then
419                         you may need to kill &nmbd; as well.</para>
420         </sect2>
421         
422         <sect2>
423                 <title>Alternative: starting it as a daemon</title>
425                 <para>To start the server as a daemon you should create 
426                 a script something like this one, perhaps calling 
427                 it <filename>startsmb</filename>.</para>
429                 <para><programlisting>
430                 #!/bin/sh
431                 /usr/local/samba/bin/smbd -D 
432                 /usr/local/samba/bin/nmbd -D 
433                 </programlisting></para>
435                 <para>then make it executable with <command>chmod 
436                 +x startsmb</command></para>
438                 <para>You can then run <command>startsmb</command> by 
439                 hand or execute it from <filename>/etc/rc.local</filename>
440                 </para>
442                 <para>To kill it send a kill signal to the processes 
443                         &nmbd; and &smbd;.</para>
445                 <note><para>If you use the SVR4 style init system then 
446                 you may like to look at the <filename>examples/svr4-startup</filename>
447                 script to make Samba fit into that system.</para></note>
448         </sect2>
449 </sect1>
450 </chapter>