Difference between revisions of "Build Samba from Source"

(Step 1: Download Samba)
Line 61: Line 61:
  
 
Refer to the [[#Updating via git|Updating via git]] instructions on how to manage the source tree with <tt>git</tt>.
 
Refer to the [[#Updating via git|Updating via git]] instructions on how to manage the source tree with <tt>git</tt>.
 +
 +
== Step 2: Compile Samba ==
 +
 +
To build Samba, run the following command in your <tt>samba-master</tt> directory:
 +
 +
  $ cd samba-master
 +
  $ ./configure --enable-debug --enable-selftest
 +
  $ make
 +
 +
The above command will setup Samba to install in <tt>/usr/local/samba</tt>. If you want Samba to install in a different directory, then you should use the <tt>--prefix</tt> option to <tt>configure</tt>.
 +
 +
The reason we recommend using <tt>--enable-debug --enable-selftest</tt> for Samba is that it will include extra debug information that will help us diagnose problems in case of failures, and will also allow you to run our selftest <tt>make test</tt> to validate that Samba can behave correctly on your platform.  Both of these are however, entirely '''optional'''.
 +
 +
'''Profiling with google-perftools'''
 +
 +
If you want to enable profiling support, change the configure command above to the following:
 +
  $ LDFLAGS="-ltcmalloc -lprofiler" ./configure.developer
 +
:''(This also works for CFLAGS)''
 +
 +
== Step 3: Install Samba ==
 +
 +
To install Samba, run the following command in your <tt>samba-master</tt> directory:
 +
 +
  $ make install
 +
 +
Note that this must be run as a user who has permission to write to the install directory, which defaults to <tt>/usr/local/samba</tt>. See [[#Step 2: Compile Samba4|Step 2: Compile Samba ]] for instructions on how to change the install directory.

Revision as of 02:38, 21 January 2013

Samba OS Requirements

Because of the constantly changing and ever expanding nature of Linux, the OS Requirements for Samba 4 have been moved from Step 2, to Samba_4/OS_Requirements. This not only includes the required packages for a successful Samba AD DC deployment, but also the required file system features. Please consider that page as a prerequisite to a successful Samba AD DC setup.

Step 1: Download Samba

Currently, there are three methods to download the current Samba sources, either as a tarball of the latest stable release, or a development version via git or rsync. If you hope to work with the team on a development version to resolve issues you may hit via code changes, we recommend using the git method for downloading Samba, as it makes getting updates easier, and also allows you to integrate test patches from Samba developers more easily in case of problems.

In the following examples we will assume that your top-level source is named samba-master. If you downloaded a tarball this will instead be based on the name of the tarball downloaded (e.g. samba-4.0.0 for the tarball samba-4.0.0.tar.gz). Also note that in the master branch the Samba 4 code in our current git tree is now located in the top level directory.

Downloading a tarball

If you wish to use a released version of Samba 4.0, you can download the latest Samba 4.0 tarball from the Samba website

Downloading via git

Git allows you to download the source tree via either the git or httpprotocols. In general, the git protocol is the preferred choice since it compresses the data being transferred. To download the source tree via git, run the following command:

$ git clone git://git.samba.org/samba.git samba-master

Alternatively, if you prefer to use the http protocol, run the following command:

$ git clone http://gitweb.samba.org/samba.git samba-master

Either command will create a directory called samba-master in the current directory.

Updating via git

If you already have downloaded the source tree via git and want to update the tree to the latest version, run the following command in your samba-master directory:

$ git pull

If you get an error like this:

fatal: Unable to create '[...]/samba_master/.git/index.lock': File exists.

Run the command below to reset your tree.

If you are having trouble compiling the source, it may be due to stale files. You can reset your git tree to correct these errors. To reset your git tree, run the following command in your samba-master directory:

$ git clean -x -f -d

Downloading via rsync

If git is not available to you, rsync is the next best choice. To download the source tree via rsync, run the following command:

$ rsync -avz samba.org::ftp/unpacked/samba_4_0_test/ samba-master

This command will create a directory called samba-master in the current directory, containing a checked out git repository. If you plan on using git to manage the tree, you will need to run the following commands in your samba-master directory:

$ cd samba-master/
$ rm .git/refs/tags/*
$ rm -r .git/refs/remotes/
$ git config remote.origin.url git://git.samba.org/samba.git
$ git config --add remote.origin.fetch +refs/tags/*:refs/tags/* (this line is optional)
$ git fetch

Note you can ignore this error from git fetch:

error: refs/heads/master does not point to a valid object!

Refer to the Updating via git instructions on how to manage the source tree with git.

Step 2: Compile Samba

To build Samba, run the following command in your samba-master directory:

 $ cd samba-master
 $ ./configure --enable-debug --enable-selftest
 $ make

The above command will setup Samba to install in /usr/local/samba. If you want Samba to install in a different directory, then you should use the --prefix option to configure.

The reason we recommend using --enable-debug --enable-selftest for Samba is that it will include extra debug information that will help us diagnose problems in case of failures, and will also allow you to run our selftest make test to validate that Samba can behave correctly on your platform. Both of these are however, entirely optional.

Profiling with google-perftools

If you want to enable profiling support, change the configure command above to the following:

 $ LDFLAGS="-ltcmalloc -lprofiler" ./configure.developer
(This also works for CFLAGS)

Step 3: Install Samba

To install Samba, run the following command in your samba-master directory:

 $ make install

Note that this must be run as a user who has permission to write to the install directory, which defaults to /usr/local/samba. See Step 2: Compile Samba for instructions on how to change the install directory.