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