1 <chapter id="compiling">
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>
21 <indexterm><primary>CVS</primary></indexterm>
24 <title>Introduction</title>
27 Samba is developed in an open environment. Developers use CVS
28 (Concurrent Versioning System) to "checkin" (also known as
29 "commit") new source code. Samba's various CVS branches can
30 be accessed via anonymous CVS using the instructions
31 detailed in this chapter.
35 This chapter is a modified version of the instructions found at
36 <ulink noescape="1" url="http://samba.org/samba/cvs.html">http://samba.org/samba/cvs.html</ulink>
42 <title>CVS Access to samba.org</title>
45 The machine samba.org runs a publicly accessible CVS
46 repository for access to the source code of several packages,
47 including samba, rsync, distcc, ccache and jitterbug. There are two main ways
48 of accessing the CVS server on this host.
52 <title>Access via CVSweb</title>
54 <indexterm><primary>CVS</primary><secondary>web</secondary></indexterm>
57 You can access the source code via your
58 favourite WWW browser. This allows you to access the contents of
59 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 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 'How to get cvs' link. CVS is free software under
87 the GNU GPL (as is Samba). Note that there are several graphical CVS clients
88 which provide a graphical interface to the sometimes mundane CVS commands.
89 Links to theses clients are also available from the Cyclic website.
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 samba 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 "Development" 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>
174 <indexterm><primary>rsync</primary></indexterm>
175 <indexterm><primary>ftp</primary></indexterm>
178 pserver.samba.org 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. rsync access is most convenient
187 for an initial install.
192 <title>Verifying Samba's PGP signature</title>
195 In these days of insecurity, it's strongly recommended that you verify the PGP
196 signature for any source file before installing it. Even if you're not
197 downloading from a mirror site, verifying PGP signatures should be a
203 With that said, go ahead and download the following files:
207 &prompt;<userinput>wget http://us1.samba.org/samba/ftp/samba-2.2.8a.tar.asc</userinput>
208 &prompt;<userinput>wget http://us1.samba.org/samba/ftp/samba-pubkey.asc</userinput>
213 <indexterm><primary>GPG</primary></indexterm>
214 The first file is the PGP signature for the Samba source file; the other is the Samba public
215 PGP key itself. Import the public PGP key with:
219 &prompt;<userinput>gpg --import samba-pubkey.asc</userinput>
223 And verify the Samba source code integrity with:
227 &prompt;<userinput>gzip -d samba-2.2.8a.tar.gz</userinput>
228 &prompt;<userinput>gpg --verify samba-2.2.8a.tar.asc</userinput>
232 If you receive a message like, "Good signature from Samba Distribution
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:
240 gpg: BAD signature from "Samba Distribution Verification Key"
247 <title>Building the Binaries</title>
249 <indexterm><primary>configure</primary></indexterm>
252 To do this, first run the program <userinput>./configure
253 </userinput> in the source directory. This should automatically
254 configure Samba for your operating system. If you have unusual
255 needs then you may wish to run</para>
257 <para><screen>&rootprompt;<userinput>./configure --help
258 </userinput></screen></para>
260 <para>first to see what special options you can enable.
261 Then executing</para>
263 <indexterm><primary>make</primary></indexterm>
265 <para><screen>&rootprompt;<userinput>make</userinput></screen></para>
267 <para>will create the binaries. Once it's successfully
268 compiled you can use </para>
270 <para><screen>&rootprompt;<userinput>make install</userinput></screen></para>
272 <para>to install the binaries and manual pages. You can
273 separately install the binaries and/or man pages using</para>
275 <para><screen>&rootprompt;<userinput>make installbin
276 </userinput></screen></para>
280 <para><screen>&rootprompt;<userinput>make installman
281 </userinput></screen></para>
283 <para>Note that if you are upgrading for a previous version
284 of Samba you might like to know that the old versions of
285 the binaries will be renamed with a ".old" extension. You
286 can go back to the previous version with</para>
288 <para><screen>&rootprompt;<userinput>make revert
289 </userinput></screen></para>
291 <para>if you find this version a disaster!</para>
294 <title>Compiling samba with Active Directory support</title>
296 <para>In order to compile samba with ADS support, you need to have installed
297 on your system:</para>
300 <listitem><para>the MIT kerberos development libraries
301 (either install from the sources or use a package). The
302 Heimdal libraries will not work.</para></listitem>
304 <listitem><para>the OpenLDAP development libraries.</para></listitem>
308 <para>If your kerberos libraries are in a non-standard location then
309 remember to add the configure option
310 <option>--with-krb5=<replaceable>DIR</replaceable></option>.</para>
312 <para>After you run configure make sure that
313 <filename>include/config.h</filename> it generates contains lines like
316 <para><programlisting>
319 </programlisting></para>
321 <para>If it doesn't then configure did not find your krb5 libraries or
322 your ldap libraries. Look in <filename>config.log</filename> to figure
323 out why and fix it.</para>
326 <title>Installing the required packages for Debian</title>
328 <para>On Debian you need to install the following packages:</para>
331 <listitem><para>libkrb5-dev</para></listitem>
332 <listitem><para>krb5-user</para></listitem>
338 <title>Installing the required packages for RedHat</title>
340 <para>On RedHat this means you should have at least: </para>
343 <listitem><para>krb5-workstation (for kinit)</para></listitem>
344 <listitem><para>krb5-libs (for linking with)</para></listitem>
345 <listitem><para>krb5-devel (because you are compiling from source)</para></listitem>
349 <para>in addition to the standard development environment.</para>
351 <para>Note that these are not standard on a RedHat install, and you may need
352 to get them off CD2.</para>
361 <title>Starting the &smbd; and &nmbd;</title>
363 <indexterm><primary>inetd</primary></indexterm>
365 <para>You must choose to start &smbd; and &nmbd; either
366 as daemons or from <application>inetd</application>. Don't try
367 to do both! Either you can put them in <filename>
368 inetd.conf</filename> and have them started on demand
369 by <application>inetd</application> or <application>xinetd</application>,
370 or you can start them as
371 daemons either from the command line or in <filename>
372 /etc/rc.local</filename>. See the man pages for details
373 on the command line options. Take particular care to read
374 the bit about what user you need to be in order to start
375 Samba. In many cases you must be root.</para>
377 <para>The main advantage of starting &smbd;
378 and &nmbd; using the recommended daemon method
379 is that they will respond slightly more quickly to an initial connection
383 <title>Starting from inetd.conf</title>
385 <indexterm><primary>inetd</primary></indexterm>
388 <para>The following will be different if
389 you use NIS, NIS+ or LDAP to distribute services maps.</para>
392 <para>Look at your <filename>/etc/services</filename>.
393 What is defined at port 139/tcp. If nothing is defined
394 then add a line like this:</para>
396 <para><programlisting>netbios-ssn 139/tcp</programlisting></para>
398 <para>similarly for 137/udp you should have an entry like:</para>
400 <para><programlisting>netbios-ns 137/udp</programlisting></para>
402 <para>Next edit your <filename>/etc/inetd.conf</filename>
403 and add two lines something like this:</para>
405 <para><programlisting>
406 netbios-ssn stream tcp nowait root /usr/local/samba/bin/smbd smbd
407 netbios-ns dgram udp wait root /usr/local/samba/bin/nmbd nmbd
408 </programlisting></para>
410 <para>The exact syntax of <filename>/etc/inetd.conf</filename>
411 varies between unixes. Look at the other entries in inetd.conf
414 <indexterm><primary>xinetd</primary></indexterm>
415 <para>Some distributions use xinetd instead of inetd. Consult the
416 xinetd manual for configuration information.</para>
418 <note><para>Some unixes already have entries like netbios_ns
419 (note the underscore) in <filename>/etc/services</filename>.
420 You must either edit <filename>/etc/services</filename> or
421 <filename>/etc/inetd.conf</filename> to make them consistent.
424 <indexterm><primary>ifconfig</primary></indexterm>
425 <note><para>On many systems you may need to use the
426 <smbconfoption><name>interfaces</name></smbconfoption> option in &smb.conf; to specify the IP
427 address and netmask of your interfaces. Run
428 <application>ifconfig</application>
429 as root if you don't know what the broadcast is for your
430 net. &nmbd; tries to determine it at run
431 time, but fails on some unixes.
434 <warning><para>Many unixes only accept around 5
435 parameters on the command line in <filename>inetd.conf</filename>.
436 This means you shouldn't use spaces between the options and
437 arguments, or you should use a script, and start the script
438 from <command>inetd</command>.</para></warning>
440 <para>Restart <application>inetd</application>, perhaps just send
444 &rootprompt;<userinput>killall -HUP inetd</userinput>
450 <title>Alternative: starting it as a daemon</title>
452 <indexterm><primary>daemon</primary></indexterm>
454 <para>To start the server as a daemon you should create
455 a script something like this one, perhaps calling
456 it <filename>startsmb</filename>.</para>
458 <para><programlisting>
460 /usr/local/samba/bin/smbd -D
461 /usr/local/samba/bin/nmbd -D
462 </programlisting></para>
464 <para>then make it executable with <command>chmod
465 +x startsmb</command></para>
467 <para>You can then run <command>startsmb</command> by
468 hand or execute it from <filename>/etc/rc.local</filename>
471 <para>To kill it send a kill signal to the processes
472 &nmbd; and &smbd;.</para>
474 <note><para>If you use the SVR4 style init system then
475 you may like to look at the <filename>examples/svr4-startup</filename>
476 script to make Samba fit into that system.</para></note>