1 <chapter id="compiling">
4 <author><surname>Someone; Jerry perhaps?</surname></author>
6 <pubdate> 22 May 2001 </pubdate>
7 <pubdate> 18 March 2003 </pubdate>
10 <title>How to compile SAMBA</title>
13 You can obtain the samba source from the
14 <ulink url="http://samba.org/">samba website</ulink>. To obtain a development version,
15 you can download samba from CVS or using rsync.
19 <title>Access Samba source code via CVS</title>
22 <title>Introduction</title>
25 Samba is developed in an open environment. Developers use CVS
26 (Concurrent Versioning System) to "checkin" (also known as
27 "commit") new source code. Samba's various CVS branches can
28 be accessed via anonymous CVS using the instructions
29 detailed in this chapter.
33 This chapter is a modified version of the instructions found at
34 <ulink url="http://samba.org/samba/cvs.html">http://samba.org/samba/cvs.html</ulink>
40 <title>CVS Access to samba.org</title>
43 The machine samba.org runs a publicly accessible CVS
44 repository for access to the source code of several packages,
45 including samba, rsync, distcc, ccache and jitterbug. There are two main ways
46 of accessing the CVS server on this host.
50 <title>Access via CVSweb</title>
53 You can access the source code via your
54 favourite WWW browser. This allows you to access the contents of
55 individual files in the repository and also to look at the revision
56 history and commit logs of individual files. You can also ask for a diff
57 listing between any two versions on the repository.
62 url="http://samba.org/cgi-bin/cvsweb">http://samba.org/cgi-bin/cvsweb</ulink>
67 <title>Access via cvs</title>
70 You can also access the source code via a
71 normal cvs client. This gives you much more control over what you can
72 do with the repository and allows you to checkout whole source trees
73 and keep them up to date via normal cvs commands. This is the
74 preferred method of access if you are a developer and not
75 just a casual browser.
79 To download the latest cvs source code, point your
81 <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 the Cyclic website.
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
96 <title>Retrieving samba using CVS</title>
100 Install a recent copy of cvs. All you really need is a
101 copy of the cvs client binary.
111 <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot login</userinput>
118 When it asks you for a password type <userinput>cvs</userinput>.
128 <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot co samba</userinput>
132 This will create a directory called samba containing the
133 latest samba source code (i.e. the HEAD tagged cvs branch). This
134 currently corresponds to the 3.0 development tree.
138 CVS branches other then HEAD can be obtained by using the
139 <option>-r</option> and defining a tag name. A list of branch tag names
140 can be found on the "Development" page of the samba web site. A common
141 request is to obtain the latest 3.0 release code. This could be done by
142 using the following command:
146 <userinput>cvs -d :pserver:cvs@samba.org:/cvsroot co -r SAMBA_3_0 samba</userinput>
152 Whenever you want to merge in the latest code changes use
153 the following command from within the samba directory:
157 <userinput>cvs update -d -P</userinput>
168 <title>Accessing the samba sources via rsync and ftp</title>
171 pserver.samba.org also exports unpacked copies of most parts of the CVS
172 tree at <ulink url="ftp://pserver.samba.org/pub/unpacked">ftp://pserver.samba.org/pub/unpacked</ulink> and also via anonymous rsync at
173 <ulink url="rsync://pserver.samba.org/ftp/unpacked/">rsync://pserver.samba.org/ftp/unpacked/</ulink>. I recommend using rsync rather than ftp.
174 See <ulink url="http://rsync.samba.org/">the rsync homepage</ulink> for more info on rsync.
178 The disadvantage of the unpacked trees is that they do not support automatic
179 merging of local changes like CVS does. rsync access is most convenient
180 for an initial install.
185 <title>Verifying Samba's PGP signature</title>
188 In these days of insecurity, it's strongly recommended that you verify the PGP
189 signature for any source file before installing it. Even if you're not
190 downloading from a mirror site, verifying PGP signatures should be a
196 With that said, go ahead and download the following files:
200 <prompt>$ </prompt><userinput> wget http://us1.samba.org/samba/ftp/samba-2.2.8a.tar.asc</userinput>
201 <prompt>$ </prompt><userinput> wget http://us1.samba.org/samba/ftp/samba-pubkey.asc</userinput>
205 The first file is the PGP signature for the Samba source file; the other is the Samba public
206 PGP key itself. Import the public PGP key with:
210 <prompt>$ </prompt><userinput>gpg --import samba-pubkey.asc</userinput>
214 And verify the Samba source code integrity with:
218 <prompt>$ </prompt><userinput>gzip -d samba-2.2.8a.tar.gz</userinput>
219 <prompt>$ </prompt><userinput>gpg --verify samba-2.2.8a.tar.asc</userinput>
223 If you receive a message like, "Good signature from Samba Distribution
225 then all is well. The warnings about trust relationships can be ignored. An
226 example of what you would not want to see would be:
230 gpg: BAD signature from "Samba Distribution Verification Key"
236 <title>Building the Binaries</title>
238 <para>To do this, first run the program <userinput>./configure
239 </userinput> in the source directory. This should automatically
240 configure Samba for your operating system. If you have unusual
241 needs then you may wish to run</para>
243 <para>&rootprompt;<userinput>./configure --help
246 <para>first to see what special options you can enable.
247 Then executing</para>
249 <para>&rootprompt;<userinput>make</userinput></para>
251 <para>will create the binaries. Once it's successfully
252 compiled you can use </para>
254 <para>&rootprompt;<userinput>make install</userinput></para>
256 <para>to install the binaries and manual pages. You can
257 separately install the binaries and/or man pages using</para>
259 <para>&rootprompt;<userinput>make installbin
264 <para>&rootprompt;<userinput>make installman
267 <para>Note that if you are upgrading for a previous version
268 of Samba you might like to know that the old versions of
269 the binaries will be renamed with a ".old" extension. You
270 can go back to the previous version with</para>
272 <para>&rootprompt;<userinput>make revert
275 <para>if you find this version a disaster!</para>
278 <title>Compiling samba with Active Directory support</title>
280 <para>In order to compile samba with ADS support, you need to have installed
281 on your system:</para>
284 <listitem><para>the MIT kerberos development libraries
285 (either install from the sources or use a package). The
286 Heimdal libraries will not work.</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 contains lines like
300 <para><programlisting>
303 </programlisting></para>
305 <para>If it doesn't then 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 <member>libkrb5-dev</member>
316 <member>krb5-user</member>
322 <title>Installing the required packages for RedHat</title>
324 <para>On RedHat this means you should have at least: </para>
327 <member>krb5-workstation (for kinit)</member>
328 <member>krb5-libs (for linking with)</member>
329 <member>krb5-devel (because you are compiling from source)</member>
333 <para>in addition to the standard development environment.</para>
335 <para>Note that these are not standard on a RedHat install, and you may need
336 to get them off CD2.</para>
345 <title>Starting the &smbd; and &nmbd;</title>
347 <para>You must choose to start &smbd; and &nmbd; either
348 as daemons or from <application>inetd</application>. Don't try
349 to do both! Either you can put them in <filename>
350 inetd.conf</filename> and have them started on demand
351 by <application>inetd</application>, or you can start them as
352 daemons either from the command line or in <filename>
353 /etc/rc.local</filename>. See the man pages for details
354 on the command line options. Take particular care to read
355 the bit about what user you need to be in order to start
356 Samba. In many cases you must be root.</para>
358 <para>The main advantage of starting &smbd;
359 and &nmbd; using the recommended daemon method
360 is that they will respond slightly more quickly to an initial connection
364 <title>Starting from inetd.conf</title>
367 <para>The following will be different if
368 you use NIS, NIS+ or LDAP to distribute services maps.</para>
371 <para>Look at your <filename>/etc/services</filename>.
372 What is defined at port 139/tcp. If nothing is defined
373 then add a line like this:</para>
375 <para><programlisting>netbios-ssn 139/tcp</programlisting></para>
377 <para>similarly for 137/udp you should have an entry like:</para>
379 <para><programlisting>netbios-ns 137/udp</programlisting></para>
381 <para>Next edit your <filename>/etc/inetd.conf</filename>
382 and add two lines something like this:</para>
384 <para><programlisting>
385 netbios-ssn stream tcp nowait root /usr/local/samba/bin/smbd smbd
386 netbios-ns dgram udp wait root /usr/local/samba/bin/nmbd nmbd
387 </programlisting></para>
389 <para>The exact syntax of <filename>/etc/inetd.conf</filename>
390 varies between unixes. Look at the other entries in inetd.conf
393 <note><para>Some unixes already have entries like netbios_ns
394 (note the underscore) in <filename>/etc/services</filename>.
395 You must either edit <filename>/etc/services</filename> or
396 <filename>/etc/inetd.conf</filename> to make them consistent.
399 <note><para>On many systems you may need to use the
400 <parameter>interfaces</parameter> option in &smb.conf; to specify the IP
401 address and netmask of your interfaces. Run
402 <application>ifconfig</application>
403 as root if you don't know what the broadcast is for your
404 net. &nmbd; tries to determine it at run
405 time, but fails on some unixes.
408 <warning><para>Many unixes only accept around 5
409 parameters on the command line in <filename>inetd.conf</filename>.
410 This means you shouldn't use spaces between the options and
411 arguments, or you should use a script, and start the script
412 from <command>inetd</command>.</para></warning>
414 <para>Restart <application>inetd</application>, perhaps just send
415 it a HUP. If you have installed an earlier version of &nmbd; then
416 you may need to kill &nmbd; as well.</para>
420 <title>Alternative: starting it as a daemon</title>
422 <para>To start the server as a daemon you should create
423 a script something like this one, perhaps calling
424 it <filename>startsmb</filename>.</para>
426 <para><programlisting>
428 /usr/local/samba/bin/smbd -D
429 /usr/local/samba/bin/nmbd -D
430 </programlisting></para>
432 <para>then make it executable with <command>chmod
433 +x startsmb</command></para>
435 <para>You can then run <command>startsmb</command> by
436 hand or execute it from <filename>/etc/rc.local</filename>
439 <para>To kill it send a kill signal to the processes
440 &nmbd; and &smbd;.</para>
442 <note><para>If you use the SVR4 style init system then
443 you may like to look at the <filename>examples/svr4-startup</filename>
444 script to make Samba fit into that system.</para></note>
449 <title>Common Errors</title>
452 I'm using gcc 3 and I've compiled Samba-3 from the CVS and the
453 binaries are very large files (40 Mb and 20 Mb). I've the same result with
454 <option>--enable-shared</option> ?
459 The dwarf format used by GCC 3 for storing debugging symbols is very inefficient.
460 Strip the binaries, don't compile with -g or compile with -gstabs.