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'>
7 <chapter id="compiling">
13 <pubdate> 22 May 2001 </pubdate>
14 <pubdate> 18 March 2003 </pubdate>
17 <title>How to Compile Samba</title>
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>.
26 <title>Access Samba Source Code via Subversion</title>
30 <title>Introduction</title>
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.
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.
49 <title>Subversion Access to samba.org</title>
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:
59 <title>Access via SVNweb</title>
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.
72 <ulink noescape="1" url="http://svnweb.samba.org/">http://svnweb.samba.org/</ulink>
77 <title>Access via Subversion</title>
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.
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>.
94 To gain access via anonymous Subversion, use the following steps.
98 <title>Retrieving Samba using Subversion</title>
102 Install a recent copy of Subversion. All you really need is a
103 copy of the Subversion client binary.
113 <userinput>svn co svn://svnanon.samba.org/samba/trunk samba</userinput>.
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.
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:
131 <userinput>svn co svn://svnanon.samba.org/samba/branches/SAMBA_3_0 samba_3</userinput>.
137 Whenever you want to merge in the latest code changes, use
138 the following command from within the Samba directory:
142 <userinput>svn update</userinput>
153 <title>Accessing the Samba Sources via rsync and ftp</title>
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.
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.
175 <title>Verifying Samba's PGP Signature</title>
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.
187 With that said, go ahead and download the following files:
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>
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:
203 &prompt;<userinput>gpg --import samba-pubkey.asc</userinput>
207 and verify the Samba source code integrity with:
211 &prompt;<userinput>gzip -d samba-3.0.0.tar.gz</userinput>
212 &prompt;<userinput>gpg --verify samba-3.0.0.tar.asc</userinput>
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:
222 gpg: BAD signature from <quote>Samba Distribution Verification Key</quote>
228 <title>Building the Binaries</title>
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>
238 <para><screen>&rootprompt;<userinput>./configure --help
239 </userinput></screen></para>
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>
245 <para>Executing</para>
249 <indexterm><primary>make</primary></indexterm>
250 <screen>&rootprompt;<userinput>make</userinput></screen></para>
252 <para>will create the binaries. Once it is successfully
253 compiled you can use</para>
255 <para><screen>&rootprompt;<userinput>make install</userinput></screen></para>
257 <para>to install the binaries and manual pages. You can
258 separately install the binaries and/or man pages using</para>
260 <para><screen>&rootprompt;<userinput>make installbin
261 </userinput></screen></para>
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>
273 <para><screen>&rootprompt;<userinput>make revert
274 </userinput></screen></para>
276 <para>if you find this version a disaster!</para>
279 <title>Compiling Samba with Active Directory Support</title>
281 <para>In order to compile Samba with ADS support, you need to have installed
282 on your system:</para>
285 <listitem><para>The MIT or Heimdal Kerberos development libraries
286 (either install from the sources or use a package).</para></listitem>
288 <listitem><para>The OpenLDAP development libraries.</para></listitem>
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
300 <para><programlisting>
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>
310 <title>Installing the Required Packages for Debian</title>
312 <para>On Debian, you need to install the following packages:</para>
315 <listitem>libkrb5-dev</listitem>
316 <listitem>krb5-user</listitem>
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>
327 <listitem>krb5-workstation (for kinit)</listitem>
328 <listitem>krb5-libs (for linking with)</listitem>
329 <listitem>krb5-devel (because you are compiling from source)</listitem>
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>
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
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.
363 <title>Starting the &smbd; and &nmbd;</title>
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
386 <title>Starting from inetd.conf</title>
388 <indexterm><primary>inetd</primary></indexterm>
391 <para>The following will be different if
392 you use NIS, NIS+ or LDAP to distribute services maps.</para>
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
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.
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.
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
449 &rootprompt;<userinput>killall -HUP inetd</userinput>
455 <title>Alternative: Starting &smbd; as a Daemon</title>
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>
467 /usr/local/samba/bin/smbd -D
468 /usr/local/samba/bin/nmbd -D
469 </programlisting></para>
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>.
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>