Name Date Size

..11-Feb-20204 KiB

.gitignoreH A D11-Feb-202012

cmake/Modules/H11-Feb-20204 KiB

CMakeLists.txtH A D11-Feb-20201.4 KiB

deps/H11-Feb-20204 KiB

GNUmakefileH A D11-Feb-20201.4 KiB

MakefileH A D11-Feb-20202.3 KiB

memcached-wrapper.inH A D11-Feb-2020807

moxi-wrapper.inH A D11-Feb-2020108

README.markdownH A D11-Feb-202016.1 KiB

winbuild.batH A D11-Feb-20201.9 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- [SmartOS containers](#user-content-smartos)
18	- [CentOS 6](#user-content-centos-6)
19	- [Ubuntu](#user-content-ubuntu)
20	- [Debian 7](#user-content-debian7)
21- [Static Analysis](#user-content-static-analysis)
22
23## Content
24
25The file named `CMakeLists.txt` contains the full build description
26for Couchbase. It should be copied to the top of your source directory
27(this happens automatically when you are using repo).
28
29The `cmake` directory contains macros used by cmake to configure a
30build of Couchbase.
31
32`Makefile` is a convenience file that repo will put in the root of
33your source directory. It invokes `cmake` with a specific set of
34options. "All" flavors of make should be able to parse this makefile,
35and its defaults are set to match building on Microsoft Windows.
36
37`GNUmakefile` is another convenience file that repo will put in the
38root of your source directory. GNU make will favor this file over
39`Makefile` and this file just overrides the defaults specified in
40`Makefile`.
41
42## How to build
43
44Couchbase utilizes [CMake][cmake_link] in order to provide build
45support for a wide range of platforms. CMake isn't a build system
46like GNU Autotools, but a tool that generates build information for
47external systems like: Visual Studio projects, XCode projects and
48Makefiles to name a few. Their good support for Microsoft Windows and
49Makefiles is the primary reason why we decided to move away from GNU
50Autotools. CMake isn't a magic pill that solves all our problems; it
51comes with its own list of challenges.
52
53It is recommended to perform "out of source builds", which means that
54the build artifacts is stored _outside_ the source directory.
55
56### Simple build
57
58If you just want to build Couchbase and without any special
59configuration, you may use the Makefile we've supplied for your
60convenience:
61
62    trond@ok > mkdir source
63    trond@ok > mkdir build
64    trond@ok > cd source
65    trond@ok source> repo init -u git://github.com/couchbase/manifest -m branch-master.xml
66    trond@ok source> repo sync
67    trond@ok source> make
68
69This would install the build software in a subdirectory named
70`install`. To change this you may run:
71
72    trond@ok source> make PREFIX=/opt/couchbase
73
74### Customize your builds
75
76CMake offers a wide range of customizations, and this chapter won't
77try to cover all of them. There is plenty of documentation available
78on the [webpage](http://www.cmake.org/cmake/help/documentation.html).
79
80There is no point of trying to keep a list of all tunables in this
81document. To find the tunables you have two options: look in
82`cmake/Modules/*.cmake` or you may look in the cache file generated
83during a normal build (see `build/CMakeCache.txt`)
84
85There are two ways to customize your own builds. You can do it all by
86yourself by invoking cmake yourself:
87
88    trond@ok > mkdir source
89    trond@ok > mkdir build
90    trond@ok > cd source
91    trond@ok source> repo init -u git://github.com/couchbase/manifest -m branch-master.xml
92    trond@ok source> repo sync
93    trond@ok source> cd ../build
94    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"
95    trond@ok build> gmake all install
96
97Or pass extra options to the convenience Makefile provided:
98
99    trond@ok > mkdir source
100    trond@ok > mkdir build
101    trond@ok > cd source
102    trond@ok source> repo init -u git://github.com/couchbase/manifest -m branch-master.xml
103    trond@ok source> repo sync
104    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'
105
106Use `CMAKE_PREFIX_PATH` to specify a "list" of directories to search
107for tools/libraries if they are stored in "non-standard"
108locations. Ex:
109
110    CMAKE_PREFIX_PATH="/opt/r14b04;/opt/couchbase;/opt/local"
111
112## Microsoft Windows 2008R2
113
114The following steps is needed to build Couchbase on Microsoft Windows 2008R2
115
116* Install OS, activate and run Windows Update and install all updates
117* Install Google Chrome (optional, but makes your life easier)
118* Install [Visual Studio 2013 Professional][win_visual_studio_link]
119* Install all updates from microsoft update
120* Install [GIT][win_git_link] and select the option to add GIT to path
121* Install [Python 2.7][win_python_link] and add c:\python27 to path (manually)
122* Install [7-ZIP][win_7zip_link] and add the installation to path (manually)
123* Install [CMake][win_cmake_link] and add to path
124* Install [GO][win_go_link] and add to path
125* Download and install [2008 runtime extensions][win_2008_runtime_ext_link]
126* Create a directory named `c:\tools` and add it to your path.. Copy `environment.bat` and `repo.exe` from the google drive folder into this directory (@todo figure out where to store them)
127* Copy the directory depot from google drive to `c:\` (endind up as: `c:\depot`)
128
129### Configuration
130
131#### git
132
133Repo will complain if git isn't properly configured. Setting name and
134email should be sufficient, but you also may at least want to set the
135two additional settings suggested:
136
137    C:\> git config --global user.email trond.norbye@gmail.com
138    C:\> git config --global user.name "Trond Norbye"
139    C:\> git config --global color.ui false
140    C:\> git config --global core.autocrlf true
141
142### How to build
143
144Before you may start to build on Microsoft Windows you have to set up
145the environment.
146
147Open cmd.com and type in the following (assuming c:\compile\couchbase
148is the directory holding your source):
149
150    C:\> set source_root=c:\compile\couchbase
151    C:\> set target_platform=amd64
152    C:\> environment
153
154You may now follow the build description outlined in [How to
155build](#user-content-how-to-build). Please note that the make utility
156on windows is named `nmake`.
157
158## MacOSX
159
160Multiple versions of Mac OSX may work, but this list is verified with
161Mavericks.
162
163* Install XCode 5.1
164* Install [Homebrew][homebrew_link]
165
166Install the following packages from homebrew:
167
168    trond@ok> brew install cmake erlang git icu4c libevent snappy v8
169
170Ensure that your `PATH` variable includes `/usr/local/opt/icu4c/bin`:
171
172    trond@ok> export PATH=$PATH:/usr/local/bin:/usr/local/opt/icu4c/bin
173
174You should be all set to start compile the server as described above.
175
176## SmartOS
177
178The following chapters describes how to configure and build under
179various containers hosted by SmartOS. [Joyent][joyent_link] provides a
180variety of datasets for various operating systems (CentOS, Fedora,
181FreeBSD, Debian, SmartOS, ...). This section is not intended to cover
182all of these, but covers a set of configurations known to work.
183
184### CentOS 6
185
186The following descrtiption use the Centos-6 image imported by:
187
188    root@smartos~> imgadm import df81f45e-8f9f-11e3-a819-93fab527c81e
189
190The KVM may be created with the following attributes (store in `centos.json`):
191
192    {
193      "alias": "centos-6",
194      "brand": "kvm",
195      "resolvers": [
196        "10.0.0.1",
197        "8.8.4.4"
198      ],
199      "default-gateway": "10.0.0.1",
200      "hostname": "centos",
201      "ram": "2048",
202      "vcpus": "2",
203      "nics": [
204        {
205          "nic_tag": "admin",
206          "ip": "10.0.0.201",
207          "netmask": "255.255.255.0",
208          "gateway": "10.0.0.1",
209          "model": "virtio",
210          "primary": true
211        }
212      ],
213      "disks": [
214        {
215          "image_uuid": "325dbc5e-2b90-11e3-8a3e-bfdcb1582a8d",
216          "boot": true,
217          "model": "virtio",
218          "image_size": 10240
219        }
220      ],
221      "customer_metadata": {
222        "root_authorized_keys": "ssh-rsa <my-personal-public-key>"
223      }
224    }
225
226Create the KVM with:
227
228    root@smartos~> vmadm create -f centos.json
229
230You should now be able to ssh into the machine and run `yum update` and
231install all of the updates ;-)
232
233Install as much as possible of the precompiled dependencies with:
234
235    root@centos~> yum install -y libevent-devel libicu-devel \
236                                 snappy-devel gcc gcc-c++ libcurl-devel \
237                                 make ncurses-devel openssl-devel svn \
238                                 expat-devel perl-ExtUtils-CBuilder \
239                                 perl-ExtUtils-MakeMaker tcl gettext
240
241Unfortunately the YUM repository don't include all (and new enough)
242versions of all we need, so you need to install the following from
243source:
244
245    wget http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
246    wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz
247    wget https://gperftools.googlecode.com/files/gperftools-2.1.tar.gz
248    wget -Ov1.9.2.tar.gz https://github.com/git/git/archive/v1.9.2.tar.gz
249    wget --no-check-certificate -Ov8.tar.gz \
250         https://github.com/v8/v8/archive/3.19.0.tar.gz
251    wget http://www.erlang.org/download/otp_src_R16B03.tar.gz
252
253    gtar xfz cmake-2.8.12.1.tar.gz
254    gtar xfz libunwind-1.1.tar.gz
255    gtar xfz gperftools-2.1.tar.gz
256    gtar xfz v1.9.2.tar.gz
257    gtar xfz v8.tar.gz
258    gtar xfz otp_src_R16B03.tar.gz
259
260    cd git-1.9.2
261    gmake prefix=/usr install
262    cd ../cmake-2.8.12.1
263    ./bootstrap && gmake all install
264    cd ../libunwind-1.1
265    ./configure && gmake all install
266    cd ../gperftools-2.1
267    ./configure && gmake all install
268    cd ../v8-3.19.0
269    gmake dependencies
270    gmake x64 library=shared -j 4
271    cp out/x64.release/lib.target/libv8.so /usr/local/lib
272    cp include/* /usr/local/include/
273    cd ../otp_src_R16B03
274    CFLAGS="-DOPENSSL_NO_EC=1" ./configure && gmake all install
275    cd ..
276
277[Install Google repo][google_repo_link] and you should be all set to
278start building the code as described above.
279
280### Ubuntu
281
282The following descrtiption use the Ubuntu image imported by:
283
284    root@smartos~> imgadm import d2ba0f30-bbe8-11e2-a9a2-6bc116856d85
285
286The KVM may be created with the following attributes (store in `ubuntu.json`):
287
288    {
289      "alias": "ubuntu",
290      "brand": "kvm",
291      "resolvers": [
292        "10.0.0.1",
293        "8.8.4.4"
294      ],
295      "default-gateway": "10.0.0.1",
296      "hostname":"ubuntu",
297      "ram": "2048",
298      "vcpus": "2",
299      "nics": [
300        {
301          "nic_tag": "admin",
302          "ip": "10.0.0.202",
303          "netmask": "255.255.255.0",
304          "gateway": "10.0.0.1",
305          "model": "virtio",
306          "primary": true
307       }
308      ],
309      "disks": [
310        {
311          "image_uuid": "d2ba0f30-bbe8-11e2-a9a2-6bc116856d85",
312          "boot": true,
313          "model": "virtio",
314          "image_size": 16384
315        }
316      ],
317      "customer_metadata": {
318        "root_authorized_keys": "ssh-rsa <my-personal-public-key>"
319      }
320    }
321
322Create the KVM with:
323
324    root@smartos~> vmadm create -f ubuntu.json
325
326You should now be able to ssh into the machine and run `aptitude` and
327install all of the updates ;-)
328
329Install as much as possible of the precompiled dependencies with:
330
331    root@ubuntu~> apt-get install -y git automake autoconf libtool clang \
332                                     clang++ libevent-dev libicu-dev \
333                                     libsnappy-dev libunwind7-dev erlang \
334                                     libv8-dev make ccache libcurl4-openssl-dev
335
336A newer version of cmake and google perftools is needed so we have to compile them from source with:
337
338    wget http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
339    tar xfz cmake-2.8.12.1.tar.gz
340    cd cmake-2.8.12.1
341    ./bootstrap && make && make install
342    cd ..
343    wget https://gperftools.googlecode.com/files/gperftools-2.1.tar.gz
344    tar xfz gperftools-2.1.tar.gz
345    cd gperftools-2.1
346    ./configure && make && make install
347
348[Install Google repo][google_repo_link] and you should be all set to
349start building the code as described above.
350
351### Debian7
352
353The following descrtiption use the Debian image imported by:
354
355    root@smartos~> imgadm import b9c27838-1730-11e4-adbd-43d91422294f
356
357The KVM may be created with the following attributes (store in `debian7.json`):
358
359    {
360      "alias": "debian-7",
361      "brand": "kvm",
362      "resolvers": [
363        "10.0.0.1",
364        "8.8.4.4"
365      ],
366      "default-gateway": "10.0.0.1",
367      "hostname":"debian",
368      "ram": "1027",
369      "vcpus": "2",
370      "nics": [
371        {
372          "nic_tag": "admin",
373          "ip": "10.0.0.204",
374          "netmask": "255.255.255.0",
375          "gateway": "10.0.0.1",
376          "model": "virtio",
377          "primary": true
378        }
379      ],
380      "disks": [
381        {
382          "image_uuid": "b9c27838-1730-11e4-adbd-43d91422294f",
383          "boot": true,
384          "model": "virtio",
385          "image_size": 10240
386        }
387      ],
388      "customer_metadata": {
389        "root_authorized_keys": "ssh-rsa <my-personal-public-key>"
390      }
391    }
392
393Create the KVM with:
394
395    root@smartos~> vmadm create -f debian7.json
396
397You should now be able to ssh into the machine and run `aptitude` and
398install all of the updates ;-)
399
400Install as much as possible of the precompiled dependencies with:
401
402    root@debian~> apt-get install -y git automake autoconf libtool clang \
403                                     libevent-dev libicu-dev \
404                                     libsnappy-dev libunwind7-dev erlang \
405                                     libv8-dev make ccache libcurl4-openssl-dev
406
407
408A newer version of cmake and google perftools is needed so we have to
409compile them from source with:
410
411    wget http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
412    tar xfz cmake-2.8.12.1.tar.gz
413    cd cmake-2.8.12.1
414    ./bootstrap && make && make install
415    cd ..
416    wget https://gperftools.googlecode.com/files/gperftools-2.1.tar.gz
417    tar xfz gperftools-2.1.tar.gz
418    cd gperftools-2.1
419    ./configure && make && make install
420
421[Install Google repo][google_repo_link] and you should be all set to
422start building the code as described above.
423
424## Static Analysis
425
426There are pre-canned build rules to allow you to run the
427[Clang Static Analyzer][clang_static_analyzer_link] against the Couchbase
428codebase.
429
430So far this has only been tested on OS X, using Clang shipping as part
431of OS X Developer Tools. It *should* be possible to also run on other
432platforms which Clang/LLVM is available, however this isn't tested.
433
434### Prerequisites
435
436* Install `clang` (from OS X Developer Tools). If you can build from source you should already have this :)
437* Download and extract clang Static Analyzer tools
438  (from [clang-analyzer.llvm.org][clang_static_analyzer_link]).
439  Note that while the actual analyzer functionality is built into
440  clang, this is needed for `scan-build` and `scan-view` tools to
441  invoke and display the analyser results.
442
443### Running
444
445*  Add `scan-build` and `scan-view` to your path:
446
447        export PATH=$PATH:/path/to/checker-276
448
449*  Run `make analyzer` at the top-level to configure clang-analyser as the 'compiler':
450
451        make analyzer
452
453*  At the end you will see a message similar to the following - Invoke the specified command to browse the found bugs:
454
455
456        scan-build: 31 bugs found.
457        scan-build: Run 'scan-view /source/build-analyzer/analyser-results/2014-06-05-173247-52416-1' to examine bug reports.
458
459
460
461[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
462[win_git_link]: http://git-scm.com/download/win
463[win_python_link]: http://www.python.org/download/releases/2.7/
464[win_7zip_link]: http://downloads.sourceforge.net/sevenzip/7z920-x64.msi
465[win_cmake_link]: http://www.cmake.org/cmake/resources/software.html
466[win_go_link]: https://code.google.com/p/go/downloads/list
467[win_2008_runtime_ext_link]: http://www.microsoft.com/en-us/download/confirmation.aspx?id=15336
468[google_repo_link]: http://source.android.com/source/downloading.html#installing-repo
469[homebrew_link]: http://brew.sh/
470[cmake_link]: http://www.cmake.org/cmake/
471[clang_static_analyzer_link]: http://clang-analyzer.llvm.org
472