syncing up docs, examples, & packaging from 3.0
[bbaumbach/samba-autobuild/.git] / docs / docbook / projdoc / Compiling.xml
1 <chapter id="compiling">
2 <chapterinfo>
3         &author.jelmer;
4         &author.jht;
5         &author.tridge;
6         
7         <pubdate> 22 May 2001 </pubdate>
8         <pubdate> 18 March 2003 </pubdate>
9 </chapterinfo>
10
11 <title>How to Compile Samba</title>
12
13 <para>
14 You can obtain the Samba source from the
15 <ulink url="http://samba.org/">Samba Website.</ulink> To obtain a development version, 
16 you can download Samba from CVS or using <command>rsync</command>.
17 </para>
18
19 <sect1>
20 <title>Access Samba Source Code via CVS</title>
21
22
23 <sect2>
24 <title>Introduction</title>
25
26 <para>
27 <indexterm><primary>CVS</primary></indexterm>
28 Samba is developed in an open environment. Developers use
29 Concurrent Versioning System (CVS) to <quote>checkin</quote> (also known as 
30 <quote>commit</quote>) 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>
34
35 <para>
36 This chapter is a modified version of the instructions found at
37 <ulink noescape="1" url="http://samba.org/samba/cvs.html">http://samba.org/samba/cvs.html</ulink>
38 </para>
39
40 </sect2>
41
42 <sect2>
43 <title>CVS Access to samba.org</title>
44
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>
51
52 <sect3>
53 <title>Access via CVSweb</title>
54
55
56 <para>
57 <indexterm><primary>CVS</primary><secondary>web</secondary></indexterm>
58 You can access the source code via your favorite WWW browser. This allows you to access
59 the contents of individual files in the repository and also to look at the revision 
60 history and commit logs of individual files. You can also ask for a diff 
61 listing between any two versions on the repository.
62 </para>
63
64 <para>
65 Use the URL:
66 <ulink noescape="1" url="http://samba.org/cgi-bin/CVSweb">http://samba.org/cgi-bin/CVSweb</ulink>
67 </para>
68 </sect3>
69
70 <sect3>
71 <title>Access via CVS</title>
72
73 <para>
74 You can also access the source code via a 
75 normal CVS client. This gives you much more control over what you can 
76 do with the repository and allows you to checkout whole source trees 
77 and keep them up-to-date via normal CVS commands. This is the 
78 preferred method of access if you are a developer and not
79 just a casual browser.
80 </para>
81
82 <para>
83 To download the latest CVS source code, point your
84 browser at the URL :
85 <ulink noescape="1" url="http://www.cyclic.com/">http://www.cyclic.com/</ulink>.
86 and click on the <quote>How to get CVS</quote> link. CVS is free software under 
87 the GNU GPL (as is Samba). Note that there are several graphical CVS clients
88 that provide a graphical interface to the sometimes mundane CVS commands.
89 Links to theses clients are also available from the Cyclic Web site.
90 </para>
91
92 <para>
93 To gain access via anonymous CVS, use the following steps. 
94 For this example it is assumed that you want a copy of the 
95 Samba source code. For the other source code repositories 
96 on this system just substitute the correct package name.
97 </para>
98
99 <procedure>
100         <title>Retrieving Samba using CVS</title>
101
102         <step>
103         <para>
104         Install a recent copy of CVS. All you really need is a 
105         copy of the CVS client binary. 
106         </para>
107         </step>
108
109         <step>
110         <para>
111         Run the command:
112         </para>
113
114         <para>
115         <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot login</userinput>
116         </para>
117         </step>
118
119         <step>
120         
121         <para>
122         When it asks you for a password, type <userinput>cvs</userinput>.
123         </para>
124         </step>
125
126         <step>
127         <para>
128         Run the command 
129         </para>
130         
131         <para>
132         <userinput>cvs -d :pserver:CVS@samba.org:/cvsroot co samba</userinput>.
133         </para>
134         
135         <para>
136         This will create a directory called <filename>samba</filename> containing the 
137         latest Samba source code (i.e., the HEAD tagged CVS branch). This 
138         currently corresponds to the 3.0 development tree. 
139         </para>
140         
141         <para>
142         CVS branches other then HEAD can be obtained by using the
143         <option>-r</option> and defining a tag name. A list of branch tag names 
144         can be found on the <quote>Development</quote> page of the Samba Web site. A common
145         request is to obtain the latest 3.0 release code. This could be done by 
146         using the following command:
147         </para>
148         
149         <para>
150         <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot co -r SAMBA_3_0 samba</userinput>.
151         </para>
152         </step>
153
154         <step>
155         <para>
156         Whenever you want to merge in the latest code changes, use 
157         the following command from within the Samba directory: 
158         </para>
159         
160         <para>
161         <userinput>cvs update -d -P</userinput>
162         </para>
163         </step>
164 </procedure>
165         
166 </sect3>
167 </sect2>
168
169 </sect1>
170
171 <sect1>
172         <title>Accessing the Samba Sources via rsync and ftp</title>
173
174
175         <para>
176         <indexterm><primary>rsync</primary></indexterm>
177         <indexterm><primary>ftp</primary></indexterm>
178         <parameter>pserver.samba.org</parameter> also exports unpacked copies of most parts of the CVS
179         tree at <ulink noescape="1" url="ftp://pserver.samba.org/pub/unpacked">ftp://pserver.samba.org/pub/unpacked</ulink> and also via anonymous rsync at 
180         <ulink noescape="1" url="rsync://pserver.samba.org/ftp/unpacked/">rsync://pserver.samba.org/ftp/unpacked/</ulink>. I recommend using rsync rather than ftp.
181         See <ulink noescape="1" url="http://rsync.samba.org/">the rsync homepage</ulink> for more info on rsync.                      
182         </para>
183
184         <para>
185         The disadvantage of the unpacked trees is that they do not support automatic
186         merging of local changes like CVS does. <command>rsync</command> access is most convenient 
187         for an initial install.                      
188         </para>
189 </sect1>
190
191 <sect1>
192 <title>Verifying Samba's PGP Signature</title>
193
194 <para>
195 <indexterm><primary>GPG</primary></indexterm>
196 It is strongly recommended that you verify the PGP signature for any source file before
197 installing it. Even if you're not downloading from a mirror site, verifying PGP signatures
198 should be a standard reflex. Many people today use the GNU GPG toolset in place of PGP.
199 GPG can substitute for PGP.
200 </para>
201
202
203 <para>
204 With that said, go ahead and download the following files:
205 </para>
206
207 <para><screen>
208 &prompt;<userinput>wget http://us1.samba.org/samba/ftp/samba-2.2.8a.tar.asc</userinput>
209 &prompt;<userinput>wget http://us1.samba.org/samba/ftp/samba-pubkey.asc</userinput>
210 </screen></para>
211
212
213 <para>
214 <indexterm><primary>PGP</primary></indexterm>
215 The first file is the PGP signature for the Samba source file; the other is the Samba public
216 PGP key itself. Import the public PGP key with:
217 </para>
218
219 <screen>
220 &prompt;<userinput>gpg --import samba-pubkey.asc</userinput>
221 </screen>
222
223 <para>
224 and verify the Samba source code integrity with:
225 </para>
226
227 <screen>
228 &prompt;<userinput>gzip -d samba-2.2.8a.tar.gz</userinput>
229 &prompt;<userinput>gpg --verify samba-2.2.8a.tar.asc</userinput>
230 </screen>
231
232 <para>
233 If you receive a message like, <quote>Good signature from Samba Distribution Verification Key...</quote>
234 then all is well. The warnings about trust relationships can be ignored. An
235 example of what you would not want to see would be:
236 </para>
237
238 <para><screen>
239      gpg: BAD signature from <quote>Samba Distribution Verification Key</quote>
240 </screen></para>
241
242 </sect1>
243
244 <sect1>
245         <title>Building the Binaries</title>
246         
247
248         <para>
249 <indexterm><primary>configure</primary></indexterm>
250                 To build the binaries, first run the program <userinput>./configure
251         </userinput> in the source directory. This should automatically 
252         configure Samba for your operating system. If you have unusual 
253         needs, then you may wish to run</para>
254         
255 <para><screen>&rootprompt;<userinput>./configure --help
256 </userinput></screen></para>
257         
258 <para>first to see what special options you can enable. Now execute <userinput>./configure</userinput> with any arguments it might need:</para>
259
260 <para><screen>&rootprompt;<userinput>./configure <replaceable>[... arguments ...]</replaceable></userinput></screen></para>
261         
262         <para>Executing</para>
263
264         
265         <para>
266 <indexterm><primary>make</primary></indexterm>
267                 <screen>&rootprompt;<userinput>make</userinput></screen></para>
268         
269         <para>will create the binaries. Once it is successfully 
270         compiled you can use</para>
271         
272 <para><screen>&rootprompt;<userinput>make install</userinput></screen></para>
273         
274         <para>to install the binaries and manual pages. You can 
275         separately install the binaries and/or man pages using</para>
276         
277 <para><screen>&rootprompt;<userinput>make installbin
278 </userinput></screen></para>
279         
280         <para>and</para>
281         
282         <para><screen>&rootprompt;<userinput>make installman
283         </userinput></screen></para>
284
285         <para>Note that if you are upgrading from a previous version 
286         of Samba you might like to know that the old versions of 
287         the binaries will be renamed with an <quote>.old</quote> extension. You 
288         can go back to the previous version with</para>
289         
290 <para><screen>&rootprompt;<userinput>make revert
291 </userinput></screen></para>
292         
293         <para>if you find this version a disaster!</para>
294
295         <sect2>
296         <title>Compiling Samba with Active Directory Support</title>
297         
298         <para>In order to compile Samba with ADS support, you need to have installed
299         on your system:</para>
300         <itemizedlist>
301         
302             <listitem><para>The MIT or Heimdal kerberos development libraries
303             (either install from the sources or use a package).</para></listitem>
304         
305             <listitem><para>The OpenLDAP development libraries.</para></listitem>
306             
307         </itemizedlist>
308
309         <para>If your kerberos libraries are in a non-standard location, then
310                 remember to add the configure option 
311                 <option>--with-krb5=<replaceable>DIR</replaceable></option>.</para>
312
313         <para>After you run configure, make sure that 
314                 <filename>include/config.h</filename> it generates contain lines like 
315                 this:</para>
316
317 <para><programlisting>
318 #define HAVE_KRB5 1
319 #define HAVE_LDAP 1
320 </programlisting></para>
321
322         <para>If it does not, configure did not find your KRB5 libraries or
323         your LDAP libraries. Look in <filename>config.log</filename> to figure
324         out why and fix it.</para>
325
326         <sect3>
327         <title>Installing the Required Packages for Debian</title>
328
329         <para>On Debian, you need to install the following packages:</para>
330         <para>
331                 <itemizedlist>
332                         <listitem>libkrb5-dev</listitem>
333                         <listitem>krb5-user</listitem>
334                 </itemizedlist>
335         </para>
336         </sect3>
337
338         <sect3>
339         <title>Installing the Required Packages for Red Hat Linux</title>
340
341         <para>On Red Hat Linux, this means you should have at least: </para>
342         <para>
343                 <itemizedlist>
344                         <listitem>krb5-workstation (for kinit)</listitem>
345                         <listitem>krb5-libs (for linking with)</listitem>
346                         <listitem>krb5-devel (because you are compiling from source)</listitem>
347                 </itemizedlist>
348         </para>
349
350         <para>in addition to the standard development environment.</para>
351
352         <para>If these files are not installed on your system, you should check the installation
353         CDs to find which has them and install the files using your tool of choice. If in doubt
354         about what tool to use, refer to the Red Hat Linux documentation.</para>
355
356         </sect3>
357
358         <sect3>
359         <title>SuSE Linux Package Requirements</title>
360
361         <para>SuSE Linux installs Heimdal packages that may be required to allow you to build
362         binary packages. You should verify that the development libraries have been installed on
363         your system.
364         </para>
365
366         <para>SuSE Linux Samba RPMs support Kerberos. Please refer to the documentation for
367         your SuSE Linux system for information regading SuSE Linux specific configuration.
368         Additionally, SuSE are very active in the maintenance of Samba packages that provide
369         the maximum capabilities that are available. You should consider using SuSE provided
370         packages where they are available.
371         </para>
372
373         </sect3>
374         
375         </sect2>
376                           
377 </sect1>
378
379 <sect1>
380         <title>Starting the &smbd; and &nmbd;</title>
381
382
383         <para>
384         <indexterm><primary>inetd</primary></indexterm>
385                 You must choose to start &smbd; and &nmbd; either
386         as daemons or from <application>inetd</application>. Don't try
387         to do both!  Either you can put them in <filename>
388         inetd.conf</filename> and have them started on demand
389         by <application>inetd</application> or <application>xinetd</application>, 
390         or you can start them as
391         daemons either from the command line or in <filename>
392         /etc/rc.local</filename>. See the man pages for details
393         on the command line options. Take particular care to read
394         the bit about what user you need to have to start
395         Samba. In many cases, you must be root.</para>
396
397         <para>The main advantage of starting &smbd;
398         and &nmbd; using the recommended daemon method
399         is that they will respond slightly more quickly to an initial connection
400         request.</para>
401
402         <sect2>
403                 <title>Starting from inetd.conf</title>
404
405                 <indexterm><primary>inetd</primary></indexterm>
406                 
407                 <note>
408                 <para>The following will be different if 
409                 you use NIS, NIS+ or LDAP to distribute services maps.</para>
410                 </note>
411                 
412                 <para>Look at your <filename>/etc/services</filename>. 
413                 What is defined at port 139/tcp? If nothing is defined, 
414                 then add a line like this:</para>
415
416                 <para><programlisting>netbios-ssn     139/tcp</programlisting></para>
417
418                 <para>Similarly for 137/udp, you should have an entry like:</para>
419
420                 <para><programlisting>netbios-ns        137/udp</programlisting></para>
421
422                 <para>Next, edit your <filename>/etc/inetd.conf</filename> 
423                 and add two lines like this:</para>
424
425                 <para><programlisting>
426                 netbios-ssn stream tcp nowait root /usr/local/samba/bin/smbd smbd 
427                 netbios-ns dgram udp wait root /usr/local/samba/bin/nmbd nmbd 
428                 </programlisting></para>
429
430                 <para>The exact syntax of <filename>/etc/inetd.conf</filename> 
431                 varies between UNIXes. Look at the other entries in inetd.conf 
432                 for a guide. </para>
433
434         <para>
435                 <indexterm><primary>xinetd</primary></indexterm>
436                 Some distributions use xinetd instead of inetd. Consult the 
437                 xinetd manual for configuration information.</para>
438
439                 <note><para>Some UNIXes already have entries like netbios_ns 
440                 (note the underscore) in <filename>/etc/services</filename>. 
441                 You must edit <filename>/etc/services</filename> or
442                 <filename>/etc/inetd.conf</filename> to make them consistent.
443                 </para></note>
444
445                 <note><para>
446                 <indexterm><primary>ifconfig</primary></indexterm>
447                                 On many systems you may need to use the 
448                 <smbconfoption><name>interfaces</name></smbconfoption> option in &smb.conf; to specify the IP
449                 address and netmask of your interfaces. Run 
450                 <application>ifconfig</application> 
451                 as root if you do not know what the broadcast is for your
452                 net. &nmbd; tries to determine it at run 
453                 time, but fails on some UNIXes. 
454                 </para></note>
455
456                 <warning><para>Many UNIXes only accept around five 
457                 parameters on the command line in <filename>inetd.conf</filename>. 
458                 This means you shouldn't use spaces between the options and 
459                 arguments, or you should use a script and start the script 
460                 from <command>inetd</command>.</para></warning>
461
462                 <para>Restart <application>inetd</application>, perhaps just send 
463                         it a HUP. </para>
464
465                 <screen>
466                         &rootprompt;<userinput>killall -HUP inetd</userinput>
467                 </screen>
468                 
469         </sect2>
470         
471         <sect2>
472                 <title>Alternative: Starting &smbd; as a Daemon</title>
473
474                 
475                 <para>
476                 <indexterm><primary>daemon</primary></indexterm>
477                         To start the server as a daemon, you should create 
478                 a script something like this one, perhaps calling 
479                 it <filename>startsmb</filename>.</para>
480
481                 <para><programlisting>
482                 #!/bin/sh
483                 /usr/local/samba/bin/smbd -D 
484                 /usr/local/samba/bin/nmbd -D 
485                 </programlisting></para>
486
487                 <para>Make it executable with <command>chmod 
488                 +x startsmb</command></para>
489
490                 <para>You can then run <command>startsmb</command> by 
491                 hand or execute it from <filename>/etc/rc.local</filename>.
492                 </para>
493
494                 <para>To kill it, send a kill signal to the processes 
495                         &nmbd; and &smbd;.</para>
496
497                 <note><para>If you use the SVR4 style init system, 
498                 you may like to look at the <filename>examples/svr4-startup</filename>
499                 script to make Samba fit into that system.</para></note>
500         </sect2>
501 </sect1>
502
503 </chapter>