1 <chapter id="compiling">
7 <pubdate> 22 May 2001 </pubdate>
8 <pubdate> 18 March 2003 </pubdate>
11 <title>How to Compile Samba</title>
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>.
20 <title>Access Samba Source Code via CVS</title>
24 <title>Introduction</title>
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.
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>
43 <title>CVS Access to samba.org</title>
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:
53 <title>Access via CVSweb</title>
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.
66 <ulink noescape="1" url="http://samba.org/cgi-bin/CVSweb">http://samba.org/cgi-bin/CVSweb</ulink>
71 <title>Access via CVS</title>
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.
83 To download the latest CVS source code, point your
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.
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.
100 <title>Retrieving Samba using CVS</title>
104 Install a recent copy of CVS. All you really need is a
105 copy of the CVS client binary.
115 <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot login</userinput>
122 When it asks you for a password, type <userinput>cvs</userinput>.
132 <userinput>cvs -d :pserver:CVS@samba.org:/cvsroot co samba</userinput>.
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.
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:
150 <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot co -r SAMBA_3_0 samba</userinput>.
156 Whenever you want to merge in the latest code changes, use
157 the following command from within the Samba directory:
161 <userinput>cvs update -d -P</userinput>
172 <title>Accessing the Samba Sources via rsync and ftp</title>
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.
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.
192 <title>Verifying Samba's PGP Signature</title>
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.
204 With that said, go ahead and download the following files:
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>
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:
220 &prompt;<userinput>gpg --import samba-pubkey.asc</userinput>
224 and verify the Samba source code integrity with:
228 &prompt;<userinput>gzip -d samba-2.2.8a.tar.gz</userinput>
229 &prompt;<userinput>gpg --verify samba-2.2.8a.tar.asc</userinput>
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:
239 gpg: BAD signature from <quote>Samba Distribution Verification Key</quote>
245 <title>Building the Binaries</title>
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>
255 <para><screen>&rootprompt;<userinput>./configure --help
256 </userinput></screen></para>
258 <para>first to see what special options you can enable. Now execute <userinput>./configure</userinput> with any arguments it might need:</para>
260 <para><screen>&rootprompt;<userinput>./configure <replaceable>[... arguments ...]</replaceable></userinput></screen></para>
262 <para>Executing</para>
266 <indexterm><primary>make</primary></indexterm>
267 <screen>&rootprompt;<userinput>make</userinput></screen></para>
269 <para>will create the binaries. Once it is successfully
270 compiled you can use</para>
272 <para><screen>&rootprompt;<userinput>make install</userinput></screen></para>
274 <para>to install the binaries and manual pages. You can
275 separately install the binaries and/or man pages using</para>
277 <para><screen>&rootprompt;<userinput>make installbin
278 </userinput></screen></para>
282 <para><screen>&rootprompt;<userinput>make installman
283 </userinput></screen></para>
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>
290 <para><screen>&rootprompt;<userinput>make revert
291 </userinput></screen></para>
293 <para>if you find this version a disaster!</para>
296 <title>Compiling Samba with Active Directory Support</title>
298 <para>In order to compile Samba with ADS support, you need to have installed
299 on your system:</para>
302 <listitem><para>The MIT or Heimdal kerberos development libraries
303 (either install from the sources or use a package).</para></listitem>
305 <listitem><para>The OpenLDAP development libraries.</para></listitem>
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>
313 <para>After you run configure, make sure that
314 <filename>include/config.h</filename> it generates contain lines like
317 <para><programlisting>
320 </programlisting></para>
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>
327 <title>Installing the Required Packages for Debian</title>
329 <para>On Debian, you need to install the following packages:</para>
332 <listitem>libkrb5-dev</listitem>
333 <listitem>krb5-user</listitem>
339 <title>Installing the Required Packages for Red Hat Linux</title>
341 <para>On Red Hat Linux, this means you should have at least: </para>
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>
350 <para>in addition to the standard development environment.</para>
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>
359 <title>SuSE Linux Package Requirements</title>
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
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.
380 <title>Starting the &smbd; and &nmbd;</title>
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>
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
403 <title>Starting from inetd.conf</title>
405 <indexterm><primary>inetd</primary></indexterm>
408 <para>The following will be different if
409 you use NIS, NIS+ or LDAP to distribute services maps.</para>
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>
416 <para><programlisting>netbios-ssn 139/tcp</programlisting></para>
418 <para>Similarly for 137/udp, you should have an entry like:</para>
420 <para><programlisting>netbios-ns 137/udp</programlisting></para>
422 <para>Next, edit your <filename>/etc/inetd.conf</filename>
423 and add two lines like this:</para>
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>
430 <para>The exact syntax of <filename>/etc/inetd.conf</filename>
431 varies between UNIXes. Look at the other entries in inetd.conf
435 <indexterm><primary>xinetd</primary></indexterm>
436 Some distributions use xinetd instead of inetd. Consult the
437 xinetd manual for configuration information.</para>
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.
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.
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>
462 <para>Restart <application>inetd</application>, perhaps just send
466 &rootprompt;<userinput>killall -HUP inetd</userinput>
472 <title>Alternative: Starting &smbd; as a Daemon</title>
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>
481 <para><programlisting>
483 /usr/local/samba/bin/smbd -D
484 /usr/local/samba/bin/nmbd -D
485 </programlisting></para>
487 <para>Make it executable with <command>chmod
488 +x startsmb</command></para>
490 <para>You can then run <command>startsmb</command> by
491 hand or execute it from <filename>/etc/rc.local</filename>.
494 <para>To kill it, send a kill signal to the processes
495 &nmbd; and &smbd;.</para>
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>