Name Date Size

..11-Feb-20204 KiB

.gitignoreH A D11-Feb-202012

cmake/Modules/H11-Feb-20204 KiB

CMakeLists.txtH A D11-Feb-20204.2 KiB

deps/H11-Feb-20204 KiB

GNUmakefileH A D11-Feb-20201.1 KiB

MakefileH A D11-Feb-20203 KiB

memcached-wrapper.inH A D11-Feb-2020807

moxi-wrapper.inH A D11-Feb-2020108

README.markdownH A D11-Feb-202018.1 KiB

win32/H11-Feb-20204 KiB

README.markdown

1# tlm - Top-level Makefile
2
3What's this, then? The tlm project contains the make information for
4building Couchbase on multiple platforms.
5
6**Table of Contents**
7
8- [Content](#user-content-content)
9- [How to build](#user-content-how-to-build)
10	- [Simple](#user-content-simple-build)
11	- [Customize your builds](#user-content-customize-your-builds)
12- [Microsoft Windows 2008R2](#user-content-microsoft-windows-2008r2)
13	- [Configuration](#user-content-configuration)
14		- [git](#user-content-git)
15	- [How to build](#user-content-how-to-build-1)
16- [MacOSX](#user-content-macosx)
17- [Ubuntu 14.04](#user-content-ubuntu-1404)
18- [Fedora 21](#user-content-fedora-21)
19- [OpenSUSE](#opensuse)
20- [SmartOS containers](#user-content-smartos)
21	- [SmartOS](#user-content-smartos-container)
22	- [CentOS 7](#user-content-centos-7)
23	- [Ubuntu](#user-content-ubuntu)
24	- [Debian 7](#user-content-debian7)
25- [Static Analysis](#user-content-static-analysis)
26
27## Content
28
29The file named `CMakeLists.txt` contains the full build description
30for Couchbase. It should be copied to the top of your source directory
31(this happens automatically when you are using repo).
32
33The `cmake` directory contains macros used by cmake to configure a
34build of Couchbase.
35
36`Makefile` is a convenience file that repo will put in the root of
37your source directory. It invokes `cmake` with a specific set of
38options. "All" flavors of make should be able to parse this makefile,
39and its defaults are set to match building on Microsoft Windows.
40
41`GNUmakefile` is another convenience file that repo will put in the
42root of your source directory. GNU make will favor this file over
43`Makefile` and this file just overrides the defaults specified in
44`Makefile`.
45
46## How to build
47
48Couchbase utilizes [CMake][cmake_link] in order to provide build
49support for a wide range of platforms. CMake isn't a build system
50like GNU Autotools, but a tool that generates build information for
51external systems like: Visual Studio projects, XCode projects and
52Makefiles to name a few. Their good support for Microsoft Windows and
53Makefiles is the primary reason why we decided to move away from GNU
54Autotools. CMake isn't a magic pill that solves all our problems; it
55comes with its own list of challenges.
56
57It is recommended to perform "out of source builds", which means that
58the build artifacts is stored _outside_ the source directory.
59
60### Simple build
61
62If you just want to build Couchbase and without any special
63configuration, you may use the Makefile we've supplied for your
64convenience:
65
66    trond@ok > mkdir source
67    trond@ok > mkdir build
68    trond@ok > cd source
69    trond@ok source> repo init -u git://github.com/couchbase/manifest -m branch-master.xml
70    trond@ok source> repo sync
71    trond@ok source> make
72
73This would install the build software in a subdirectory named
74`install`. To change this you may run:
75
76    trond@ok source> make PREFIX=/opt/couchbase
77
78### Customize your builds
79
80CMake offers a wide range of customizations, and this chapter won't
81try to cover all of them. There is plenty of documentation available
82on the [webpage](http://www.cmake.org/cmake/help/documentation.html).
83
84There is no point of trying to keep a list of all tunables in this
85document. To find the tunables you have two options: look in
86`cmake/Modules/*.cmake` or you may look in the cache file generated
87during a normal build (see `build/CMakeCache.txt`)
88
89There are two ways to customize your own builds. You can do it all by
90yourself by invoking cmake yourself:
91
92    trond@ok > mkdir source
93    trond@ok > mkdir build
94    trond@ok > cd source
95    trond@ok source> repo init -u git://github.com/couchbase/manifest -m branch-master.xml
96    trond@ok source> repo sync
97    trond@ok source> cd ../build
98    trond@ok build> cmake -D CMAKE_INSTALL_PREFIX=/opt/couchbase -D CMAKE_BUILD_TYPE=Debug -D DTRACE_FOUND:BOOL=True -D DTRACE:FILEPATH=/usr/sbin/dtrace CMAKE_PREFIX_PATH="/opt/r14b04;/opt/couchbase"
99    trond@ok build> gmake all install
100
101Or pass extra options to the convenience Makefile provided:
102
103    trond@ok > mkdir source
104    trond@ok > mkdir build
105    trond@ok > cd source
106    trond@ok source> repo init -u git://github.com/couchbase/manifest -m branch-master.xml
107    trond@ok source> repo sync
108    trond@ok source> make PREFIX=/opt/couchbase CMAKE_PREFIX_PATH="/opt/r14b04;/opt/couchbase" EXTRA_CMAKE_OPTIONS='-D DTRACE_FOUND:BOOL=True -D DTRACE:FILEPATH=/usr/sbin/dtrace'
109
110Use `CMAKE_PREFIX_PATH` to specify a "list" of directories to search
111for tools/libraries if they are stored in "non-standard"
112locations. Ex:
113
114    CMAKE_PREFIX_PATH="/opt/r14b04;/opt/couchbase;/opt/local"
115
116## Microsoft Windows 2008R2
117
118The following steps is needed to build Couchbase on Microsoft Windows 2008R2
119
120* Install OS, activate and run Windows Update and install all updates
121* Install Google Chrome (optional, but makes your life easier)
122* Install [Visual Studio 2013 Professional][win_visual_studio_link]
123* Install all updates from microsoft update
124* Install [GIT][win_git_link] and select the option to add GIT to path
125* Install [Python 2.7][win_python_link] and add c:\python27 to path (manually)
126* Install [7-ZIP][win_7zip_link] and add the installation to path (manually)
127* Install [CMake][win_cmake_link] and add to path
128* Install [GO][win_go_link] and add to path
129* Download and install [2008 runtime extensions][win_2008_runtime_ext_link]
130
131### Configuration
132
133#### git
134
135Repo will complain if git isn't properly configured. Setting name and
136email should be sufficient, but you also may at least want to set the
137two additional settings suggested:
138
139    C:\> git config --global user.email trond.norbye@gmail.com
140    C:\> git config --global user.name "Trond Norbye"
141    C:\> git config --global color.ui false
142    C:\> git config --global core.autocrlf true
143
144### How to build
145
146Before you may start to build on Microsoft Windows you have to set up
147the environment. The script `environment.bat` is located in the `win32`
148directory.
149
150Open cmd.com and type in the following (assuming c:\compile\couchbase
151is the directory holding your source):
152
153    C:\> set source_root=c:\compile\couchbase
154    C:\> set target_arch=amd64
155    C:\> environment
156
157You may now follow the build description outlined in [How to
158build](#user-content-how-to-build). Please note that the make utility
159on windows is named `nmake`.
160
161## MacOSX
162
163Multiple versions of Mac OSX may work, but this list is verified with
164Mavericks.
165
166* Install XCode 5.1
167* Install [Homebrew][homebrew_link]
168
169Install the following packages from homebrew:
170
171    trond@ok> brew install cmake git icu4c libevent snappy go
172
173Ensure that your `PATH` variable includes `/usr/local/opt/icu4c/bin`:
174
175    trond@ok> export PATH=$PATH:/usr/local/bin:/usr/local/opt/icu4c/bin
176
177You should be all set to start compile the server as described above.
178
179## Ubuntu 14.04
180
181The steps below may work on other versions of Ubuntu as well, but this
182procedure is verified with a clean installation of Ununtu 14.04.1
183
184    sudo su -
185    wget https://storage.googleapis.com/git-repo-downloads/repo
186    chmod a+x repo
187    mv repo /usr/local/bin
188    apt-get install -y git gcc g++ ccache cmake libssl-dev libicu-dev \
189                       erlang mercurial
190    cd /usr/local
191    hg clone -u release https://code.google.com/p/go
192    cd go/src
193    ./all.bash
194    cd ../../bin
195    ln -s ../go/bin/go
196    ln -s ../go/bin/gofmt
197
198## Fedora 21
199
200The steps below may work on other versions of Fedora as well, but this
201procedure is verified with a clean installation of Fedora 21
202
203    sudo su -
204    wget https://storage.googleapis.com/git-repo-downloads/repo
205    chmod a+x repo
206    mv repo /usr/local/bin
207    yum install -y gcc gcc-c++ git cmake ccache redhat-lsb-core \
208                   erlang mercurial openssl-devel libicu-devel
209    cd /usr/local
210    hg clone -u release https://code.google.com/p/go
211    cd go/src
212    ./all.bash
213    cd ../../bin
214    ln -s ../go/bin/go
215    ln -s ../go/bin/gofmt
216
217## OpenSUSE
218
219I tested this on a clean install of OpenSUSE 13.2 by choosing the
220defaults during the installer except choosing gnome desktop and enable
221ssh access.
222
223    sudo zypper install gcc gcc-c++ autoconf automake ncurses-devel \
224                        git go ccache libopenssl-devel cmake
225
226Open a new terminal to ensure you get an updated environment (the
227package install modifies some of the environement variables)
228
229    curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
230    chmod a+x ~/bin/repo
231    sudo mkdir /opt/couchbase
232    sudo chown `whoami` /opt/couchbase
233    mkdir -p compile/couchbase
234    cd compile/couchbase
235    repo init -u git://github.com/couchbase/manifest -m sherlock.xml -g default,build
236    repo sync
237    repo start opensuse --all
238    mkdir cbdeps && cd cbdeps
239    ../cbbuild/cbdeps/build-all-sherlock.sh
240    export CB_DOWNLOAD_DEPS_CACHE=`pwd`/output
241    export CB_DOWNLOAD_DEPS_MANIFEST=`pwd`/output/manifest.cmake
242    unset GOBIN
243    cd ..
244    gmake PREFIX=/opt/couchbase
245
246You should be able to start the server by running
247
248    /opt/couchbase/bin/couchbase-server start
249
250## SmartOS
251
252The following chapters describes how to configure and build under
253various containers hosted by SmartOS. [Joyent][joyent_link] provides a
254variety of datasets for various operating systems (CentOS, Fedora,
255FreeBSD, Debian, SmartOS, ...). This section is not intended to cover
256all of these, but covers a set of configurations known to work.
257
258### SmartOS container
259
260The following descrtiption use the standard64 (14.2.1) image imported by:
261
262    root@smartos~> imgadm import 3f57ffe8-47da-11e4-aa8b-dfb50a06586a
263
264The KVM may be created with the following attributes (store in `smartos.json`):
265
266    {
267      "alias" : "compilesrv",
268      "autoboot": true,
269      "brand": "joyent",
270      "dns_domain" : "norbye.org",
271      "resolvers" : [ "8.8.4.4" ],
272      "image_uuid" : "3f57ffe8-47da-11e4-aa8b-dfb50a06586a",
273      "hostname" : "compilesrv",
274      "filesystems" : [
275       {
276          "type" : "lofs",
277          "source" : "/zones/home",
278          "target" : "/home",
279          "options" : "nodevices"
280        }
281      ],
282      "max_physical_memory": 4096,
283      "nics": [
284         {
285          "nic_tag": "admin",
286          "ip": "10.0.0.207",
287          "netmask": "255.255.255.0",
288          "gateway": "10.0.0.1"
289        }
290      ]
291    }
292
293Create the KVM with:
294
295    root@smartos~> vmadm create -f smartos.json
296
297Log into the newly created zone and install the following packages:
298
299    root@compilesrv~> pkgin update
300    root@compilesrv~> pkgin -y in py27-expat-2.7.7 icu-53.1 erlang-16.1.2nb3 go-1.3
301
302[Install Google repo][google_repo_link] and you should be all set to
303start building the code as described above.
304
305### CentOS 7
306
307The following descrtiption use the Centos-7 image imported by:
308
309    root@smartos~> imgadm import 553da8ba-499e-11e4-8bee-5f8dadc234ce
310
311The KVM may be created with the following attributes (store in `centos.json`):
312
313    {
314      "alias": "centos-7",
315      "brand": "kvm",
316      "resolvers": [
317        "10.0.0.1",
318        "8.8.4.4"
319      ],
320      "default-gateway": "10.0.0.1",
321      "hostname":"centos",
322      "ram": "6144",
323      "vcpus": "2",
324      "nics": [
325        {
326          "nic_tag": "admin",
327          "ip": "10.0.0.201",
328          "netmask": "255.255.255.0",
329          "gateway": "10.0.0.1",
330          "model": "virtio",
331          "primary": true
332        }
333      ],
334      "disks": [
335        {
336          "image_uuid": "553da8ba-499e-11e4-8bee-5f8dadc234ce",
337          "boot": true,
338          "model": "virtio",
339          "image_size": 10240
340        },
341       {
342          "model": "virtio",
343          "size": 10240
344        }
345      ],
346    "customer_metadata": {
347        "root_authorized_keys": "<my ssh key>"
348      }
349    }
350
351Create the KVM with:
352
353    root@smartos~> vmadm create -f centos.json
354
355You should now be able to ssh into the machine and run `yum update` and
356install all of the updates ;-)
357
358Install as much as possible of the precompiled dependencies with:
359
360    yum install -y gcc gcc-c++ make redhat-lsb git openssl-devel
361
362A newer version of cmake, go and repo is needed so we have to compile
363it from source with:
364
365    wget http://www.cmake.org/files/v3.2/cmake-3.2.1.tar.gz
366    tar xfz cmake-3.2.1.tar.gz
367    cd cmake-3.2.1
368    ./bootstrap && make && make install
369    cd /usr/local
370    git clone https://go.googlesource.com/go
371    cd go
372    git checkout -b go1.4.2 go1.4.2
373    cd src
374    ./all.bash
375    cd ../../bin
376    ln -s ../go/bin/go
377    ln -s ../go/bin/gofmt
378    curl https://storage.googleapis.com/git-repo-downloads/repo > repo
379    chmod a+x repo
380
381And you should be all set to start building the code as described above.
382
383### Ubuntu
384
385The following descrtiption use the Ubuntu 14.04 image imported by:
386
387    root@smartos~> imgadm import c864f104-624c-43d2-835e-b49a39709b6b
388
389The KVM may be created with the following attributes (store in `ubuntu.json`):
390
391    {
392      "alias": "ubuntu-1404",
393      "brand": "kvm",
394      "resolvers": [
395        "10.0.0.1",
396        "8.8.4.4"
397      ],
398      "default-gateway": "10.0.0.1",
399      "hostname":"ubuntu",
400      "ram": "6144",
401      "vcpus": "2",
402      "nics": [
403        {
404          "nic_tag": "admin",
405          "ip": "10.0.0.203",
406          "netmask": "255.255.255.0",
407          "gateway": "10.0.0.1",
408          "model": "virtio",
409          "primary": true
410        }
411      ],
412      "disks": [
413        {
414          "image_uuid": "c864f104-624c-43d2-835e-b49a39709b6b",
415          "boot": true,
416          "model": "virtio",
417          "image_size": 10240
418        },
419       {
420          "model": "virtio",
421          "size": 20480
422        }
423      ],
424    "customer_metadata": {
425        "root_authorized_keys": "<my ssh key>"
426      }
427    }
428
429Create the KVM with:
430
431    root@smartos~> vmadm create -f ubuntu.json
432
433You should now be able to ssh into the machine and run `aptitude` and
434install all of the updates ;-)
435
436Install as much as possible of the precompiled dependencies with:
437
438    apt-get update --fix-missing
439    apt-get install -y git gcc g++ make ccache lsb-release libssl-dev cmake
440
441A newer version of go and repo is needed so we have to compile
442it from source with:
443
444    cd /usr/local
445    git clone https://go.googlesource.com/go
446    cd go
447    git checkout -b go1.4.2 go1.4.2
448    cd src
449    ./all.bash
450    cd ../../bin
451    ln -s ../go/bin/go
452    ln -s ../go/bin/gofmt
453    curl https://storage.googleapis.com/git-repo-downloads/repo > repo
454    chmod a+x repo
455
456And you should be all set to start building the code as described above.
457
458### Debian7
459
460The following descrtiption use the Debian image imported by:
461
462    root@smartos~> imgadm import 5f41692e-a70d-11e4-8c2d-afc6735144dc
463
464The KVM may be created with the following attributes (store in `debian7.json`):
465
466    {
467      "alias": "debian-7",
468      "brand": "kvm",
469      "resolvers": [
470        "10.0.0.1",
471        "8.8.4.4"
472      ],
473      "default-gateway": "10.0.0.1",
474      "hostname":"debian",
475      "ram": "6144",
476      "vcpus": "2",
477      "nics": [
478        {
479          "nic_tag": "admin",
480          "ip": "10.0.0.200",
481          "netmask": "255.255.255.0",
482          "gateway": "10.0.0.1",
483          "model": "virtio",
484          "primary": true
485        }
486      ],
487      "disks": [
488        {
489          "image_uuid": "5f41692e-a70d-11e4-8c2d-afc6735144dc",
490          "boot": true,
491          "model": "virtio",
492          "image_size": 10240
493        }
494      ],
495      "customer_metadata": {
496        "root_authorized_keys": "ssh-rsa <my-personal-public-key>"
497      }
498    }
499
500Create the KVM with:
501
502    root@smartos~> vmadm create -f debian7.json
503
504You should now be able to ssh into the machine and run `aptitude` and
505install all of the updates ;-)
506
507Install as much as possible of the precompiled dependencies with:
508
509    apt-get update --fix-missing
510    apt-get install -y git gcc g++ make ccache lsb-release libssl-dev
511
512A newer version of cmake, go and repo is needed so we have to compile
513it from source with:
514
515    wget http://www.cmake.org/files/v3.2/cmake-3.2.1.tar.gz
516    tar xfz cmake-3.2.1.tar.gz
517    cd cmake-3.2.1
518    ./bootstrap && make && make install
519    cd /usr/local
520    git clone https://go.googlesource.com/go
521    cd go
522    git checkout -b go1.4.2 go1.4.2
523    cd src
524    ./all.bash
525    cd ../../bin
526    ln -s ../go/bin/go
527    ln -s ../go/bin/gofmt
528    curl https://storage.googleapis.com/git-repo-downloads/repo > repo
529    chmod a+x repo
530
531And you should be all set to start building the code as described above.
532
533## Static Analysis
534
535There are pre-canned build rules to allow you to run the
536[Clang Static Analyzer][clang_static_analyzer_link] against the Couchbase
537codebase.
538
539So far this has only been tested on OS X, using Clang shipping as part
540of OS X Developer Tools. It *should* be possible to also run on other
541platforms which Clang/LLVM is available, however this isn't tested.
542
543### Prerequisites
544
545* Install `clang` (from OS X Developer Tools). If you can build from source you should already have this :)
546* Download and extract clang Static Analyzer tools
547  (from [clang-analyzer.llvm.org][clang_static_analyzer_link]).
548  Note that while the actual analyzer functionality is built into
549  clang, this is needed for `scan-build` and `scan-view` tools to
550  invoke and display the analyser results.
551
552### Running
553
554*  Add `scan-build` and `scan-view` to your path:
555
556        export PATH=$PATH:/path/to/checker-276
557
558*  Run `make analyzer` at the top-level to configure clang-analyser as the 'compiler':
559
560        make analyzer
561
562*  At the end you will see a message similar to the following - Invoke the specified command to browse the found bugs:
563
564
565        scan-build: 31 bugs found.
566        scan-build: Run 'scan-view /source/build-analyzer/analyser-results/2014-06-05-173247-52416-1' to examine bug reports.
567
568
569
570[win_visual_studio_link]: http://hub.internal.couchbase.com/confluence/download/attachments/7242678/en_visual_studio_professional_2013_x86_web_installer_3175305.exe?version=1&modificationDate=1389383332000
571[win_git_link]: http://git-scm.com/download/win
572[win_python_link]: http://www.python.org/download/releases/2.7/
573[win_7zip_link]: http://downloads.sourceforge.net/sevenzip/7z920-x64.msi
574[win_cmake_link]: http://www.cmake.org/cmake/resources/software.html
575[win_go_link]: https://code.google.com/p/go/downloads/list
576[win_2008_runtime_ext_link]: http://www.microsoft.com/en-us/download/confirmation.aspx?id=15336
577[google_repo_link]: http://source.android.com/source/downloading.html#installing-repo
578[homebrew_link]: http://brew.sh/
579[cmake_link]: http://www.cmake.org/cmake/
580[clang_static_analyzer_link]: http://clang-analyzer.llvm.org
581