b8471508f6592567f1580639e71c3c480beefa1a
[ira/wip.git] / docs / docbook / projdoc / Compiling.sgml
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>
13
14 <title>How to compile SAMBA</title>
15
16 <para>You can obtain the samba source from the <ulink url="http://samba.org/">samba website</ulink>. To obtain a development version, 
17 you can download samba from CVS or using rsync. </para>
18
19 <sect1>
20 <title>Access Samba source code via CVS</title>
21
22 <sect2>
23 <title>Introduction</title>
24
25 <para>
26 Samba is developed in an open environment.  Developers use CVS
27 (Concurrent Versioning System) to "checkin" (also known as 
28 "commit") new source code.  Samba's various CVS branches can
29 be accessed via anonymous CVS using the instructions
30 detailed in this chapter.
31 </para>
32
33 <para>
34 This chapter is a modified version of the instructions found at
35 <ulink url="http://samba.org/samba/cvs.html">http://samba.org/samba/cvs.html</ulink>
36 </para>
37
38 </sect2>
39
40 <sect2>
41 <title>CVS Access to samba.org</title>
42
43 <para>
44 The machine samba.org runs a publicly accessible CVS 
45 repository for access to the source code of several packages, 
46 including samba, rsync and jitterbug. There are two main ways of 
47 accessing the CVS server on this host.
48 </para>
49
50 <sect3>
51 <title>Access via CVSweb</title>
52
53 <para>
54 You can access the source code via your 
55 favourite WWW browser. This allows you to access the contents of 
56 individual files in the repository and also to look at the revision 
57 history and commit logs of individual files. You can also ask for a diff 
58 listing between any two versions on the repository.
59 </para>
60
61 <para>
62 Use the URL : <ulink
63 url="http://samba.org/cgi-bin/cvsweb">http://samba.org/cgi-bin/cvsweb</ulink>
64 </para>
65 </sect3>
66
67 <sect3>
68 <title>Access via cvs</title>
69
70 <para>
71 You can also access the source code via a 
72 normal cvs client.  This gives you much more control over you can 
73 do with the repository and allows you to checkout whole source trees 
74 and keep them up to date via normal cvs commands. This is the 
75 preferred method of access if you are a developer and not
76 just a casual browser.
77 </para>
78
79 <para>
80 To download the latest cvs source code, point your
81 browser at the URL : <ulink url="http://www.cyclic.com/">http://www.cyclic.com/</ulink>.
82 and click on the 'How to get cvs' link. CVS is free software under 
83 the GNU GPL (as is Samba).  Note that there are several graphical CVS clients
84 which provide a graphical interface to the sometimes mundane CVS commands.
85 Links to theses clients are also available from http://www.cyclic.com.
86 </para>
87
88 <para>
89 To gain access via anonymous cvs use the following steps. 
90 For this example it is assumed that you want a copy of the 
91 samba source code. For the other source code repositories 
92 on this system just substitute the correct package name
93 </para>
94
95 <orderedlist>
96 <listitem>
97         <para>
98         Install a recent copy of cvs. All you really need is a 
99         copy of the cvs client binary. 
100         </para>
101 </listitem>
102
103
104 <listitem>
105         <para>
106         Run the command 
107         </para>
108
109         <para>
110         <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot login</userinput>
111         </para>
112         
113         <para>
114         When it asks you for a password type <userinput>cvs</userinput>.
115         </para>
116 </listitem>
117
118
119 <listitem>
120         <para>
121         Run the command 
122         </para>
123         
124         <para>
125         <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot co samba</userinput>
126         </para>
127         
128         <para>
129         This will create a directory called samba containing the 
130         latest samba source code (i.e. the HEAD tagged cvs branch). This 
131         currently corresponds to the 3.0 development tree. 
132         </para>
133         
134         <para>
135         CVS branches other HEAD can be obtained by using the <parameter>-r</parameter>
136         and defining a tag name.  A list of branch tag names can be found on the
137         "Development" page of the samba web site.  A common request is to obtain the
138         latest 2.2 release code.  This could be done by using the following userinput.
139         </para>
140         
141         <para>
142         <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot co -r SAMBA_2_2 samba</userinput>
143         </para>
144 </listitem>
145
146 <listitem>
147         <para>
148         Whenever you want to merge in the latest code changes use 
149         the following command from within the samba directory: 
150         </para>
151         
152         <para>
153         <userinput>cvs update -d -P</userinput>
154         </para>
155 </listitem>
156 </orderedlist>
157         
158 </sect3>
159 </sect2>
160
161 </sect1>
162
163 <sect1>
164         <title>Accessing the samba sources via rsync and ftp</title>
165
166         <para>
167         pserver.samba.org also exports unpacked copies of most parts of the CVS tree at <ulink url="ftp://pserver.samba.org/pub/unpacked">ftp://pserver.samba.org/pub/unpacked</ulink> and also via anonymous rsync at rsync://pserver.samba.org/ftp/unpacked/. I recommend using rsync rather than ftp.
168         See <ulink url="http://rsync.samba.org/">the rsync homepage</ulink> for more info on rsync.                       
169         </para>
170
171         <para>
172         The disadvantage of the unpacked trees
173         is that they do not support automatic
174         merging of local changes like CVS does.
175         rsync access is most convenient for an 
176         initial install.                       
177         </para>
178 </sect1>
179
180 <sect1>
181         <title>Building the Binaries</title>
182         
183         <para>To do this, first run the program <userinput>./configure
184         </userinput> in the source directory. This should automatically 
185         configure Samba for your operating system. If you have unusual 
186         needs then you may wish to run</para>
187         
188         <para><prompt>root# </prompt><userinput>./configure --help
189         </userinput></para>
190         
191         <para>first to see what special options you can enable.
192         Then executing</para>
193         
194         <para><prompt>root# </prompt><userinput>make</userinput></para>
195         
196         <para>will create the binaries. Once it's successfully 
197         compiled you can use </para>
198         
199         <para><prompt>root# </prompt><userinput>make install</userinput></para>
200         
201         <para>to install the binaries and manual pages. You can 
202         separately install the binaries and/or man pages using</para>
203         
204         <para><prompt>root# </prompt><userinput>make installbin
205         </userinput></para>
206         
207         <para>and</para>
208         
209         <para><prompt>root# </prompt><userinput>make installman
210         </userinput></para>
211
212         <para>Note that if you are upgrading for a previous version 
213         of Samba you might like to know that the old versions of 
214         the binaries will be renamed with a ".old" extension. You 
215         can go back to the previous version with</para>
216         
217         <para><prompt>root# </prompt><userinput>make revert
218         </userinput></para>
219         
220         <para>if you find this version a disaster!</para>
221
222         <sect2>
223         <title>Compiling samba with Active Directory support</title>
224         
225         <para>In order to compile samba with ADS support, you need to have installed
226         on your system: 
227         <simplelist>
228         <member>the MIT kerberos development libraries (either install from the sources or use a package). The heimdal libraries will not work.</member>
229         <member>the OpenLDAP development libraries.</member>
230 </simplelist></para>
231
232         <para>If your kerberos libraries are in a non-standard location then
233           remember to add the configure option --with-krb5=DIR.</para>
234
235     <para>After you run configure make sure that <filename>include/config.h</filename> it generates contains lines like this:</para>
236
237                   <para><programlisting>
238 #define HAVE_KRB5 1
239 #define HAVE_LDAP 1
240                   </programlisting></para>
241
242           <para>If it doesn't then configure did not find your krb5 libraries or
243             your ldap libraries. Look in config.log to figure out why and fix
244                   it.</para>
245
246         <sect3>
247         <title>Installing the required packages for Debian</title>
248
249         <para>On Debian you need to install the following packages:</para>
250         <para>
251         <simplelist>
252         <member>libkrb5-dev</member>
253         <member>krb5-user</member>
254         </simplelist>
255         </para>
256         </sect3>
257
258         <sect3>
259         <title>Installing the required packages for RedHat</title>
260
261         <para>On RedHat this means you should have at least: </para>
262         <para>
263         <simplelist>
264         <member>krb5-workstation (for kinit)</member>
265         <member>krb5-libs (for linking with)</member>
266         <member>krb5-devel (because you are compiling from source)</member>
267         </simplelist>
268         </para>
269
270         <para>in addition to the standard development environment.</para>
271
272         <para>Note that these are not standard on a RedHat install, and you may need
273         to get them off CD2.</para>
274
275         </sect3>
276         
277         </sect2>
278                           
279 </sect1>
280
281 <sect1>
282         <title>Starting the smbd and nmbd</title>
283
284         <para>You must choose to start smbd and nmbd either
285         as daemons or from <application>inetd</application>Don't try
286         to do both!  Either you can put them in <filename>
287         inetd.conf</filename> and have them started on demand
288         by <application>inetd</application>, or you can start them as
289         daemons either from the command line or in <filename>
290         /etc/rc.local</filename>. See the man pages for details
291         on the command line options. Take particular care to read
292         the bit about what user you need to be in order to start
293         Samba.  In many cases you must be root.</para>
294
295         <para>The main advantage of starting <application>smbd</application>
296         and <application>nmbd</application> using the recommended daemon method
297         is that they will respond slightly more quickly to an initial connection
298         request.</para>
299
300         <sect2>
301                 <title>Starting from inetd.conf</title>
302
303                 <para>NOTE; The following will be different if 
304                 you use NIS, NIS+ or LDAP to distribute services maps.</para>
305                 
306                 <para>Look at your <filename>/etc/services</filename>. 
307                 What is defined at port 139/tcp. If nothing is defined 
308                 then add a line like this:</para>
309
310                 <para><userinput>netbios-ssn     139/tcp</userinput></para>
311
312                 <para>similarly for 137/udp you should have an entry like:</para>
313
314                 <para><userinput>netbios-ns     137/udp</userinput></para>
315
316                 <para>Next edit your <filename>/etc/inetd.conf</filename> 
317                 and add two lines something like this:</para>
318
319                 <para><programlisting>
320                 netbios-ssn stream tcp nowait root /usr/local/samba/bin/smbd smbd 
321                 netbios-ns dgram udp wait root /usr/local/samba/bin/nmbd nmbd 
322                 </programlisting></para>
323
324                 <para>The exact syntax of <filename>/etc/inetd.conf</filename> 
325                 varies between unixes. Look at the other entries in inetd.conf 
326                 for a guide.</para>
327
328                 <note><para>Some unixes already have entries like netbios_ns 
329                 (note the underscore) in <filename>/etc/services</filename>. 
330                 You must either edit <filename>/etc/services</filename> or
331                 <filename>/etc/inetd.conf</filename> to make them consistent.</para></note>
332
333                 <note><para>On many systems you may need to use the 
334                 <command>interfaces</command> option in &smb.conf; to specify the IP address 
335                 and netmask of your interfaces. Run <application>ifconfig</application> 
336                 as root if you don't know what the broadcast is for your
337                 net. &nmbd; tries to determine it at run 
338                 time, but fails on some unixes. 
339                 </para></note>
340
341                 <warning><para>Many unixes only accept around 5 
342                 parameters on the command line in <filename>inetd.conf</filename>. 
343                 This means you shouldn't use spaces between the options and 
344                 arguments, or you should use a script, and start the script 
345                 from <command>inetd</command>.</para></warning>
346
347                 <para>Restart <command>inetd</command>, perhaps just send 
348                 it a HUP. If you have installed an earlier version of <application>
349                 nmbd</application> then you may need to kill nmbd as well.</para>
350         </sect2>
351         
352         <sect2>
353                 <title>Alternative: starting it as a daemon</title>
354
355                 <para>To start the server as a daemon you should create 
356                 a script something like this one, perhaps calling 
357                 it <filename>startsmb</filename>.</para>
358
359                 <para><programlisting>
360                 #!/bin/sh
361                 /usr/local/samba/bin/smbd -D 
362                 /usr/local/samba/bin/nmbd -D 
363                 </programlisting></para>
364
365                 <para>then make it executable with <command>chmod 
366                 +x startsmb</command></para>
367
368                 <para>You can then run <command>startsmb</command> by 
369                 hand or execute it from <filename>/etc/rc.local</filename>
370                 </para>
371
372                 <para>To kill it send a kill signal to the processes 
373                 <command>nmbd</command> and <command>smbd</command>.</para>
374
375                 <note><para>If you use the SVR4 style init system then 
376                 you may like to look at the <filename>examples/svr4-startup</filename>
377                 script to make Samba fit into that system.</para></note>
378         </sect2>
379 </sect1>
380 </chapter>