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