Merge pull request #513 from cjdelisle/feature-hardening
[novacoin.git] / doc / build-unix.txt
1 Copyright (c) 2009-2010 Satoshi Nakamoto
2 Distributed under the MIT/X11 software license, see the accompanying
3 file license.txt or http://www.opensource.org/licenses/mit-license.php.
4 This product includes software developed by the OpenSSL Project for use in
5 the OpenSSL Toolkit (http://www.openssl.org/).  This product includes
6 cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP
7 software written by Thomas Bernard.
8
9
10 UNIX BUILD NOTES
11 ================
12
13 To Build
14 --------
15
16 cd src/
17
18 make -f makefile.unix            # Bitcoin with wxWidgets GUI
19   or
20 make -f makefile.unix bitcoind   # Headless bitcoin
21
22
23 Dependencies
24 ------------
25 sudo apt-get install build-essential
26 sudo apt-get install libgtk2.0-dev
27 sudo apt-get install libssl-dev
28 sudo apt-get install libdb4.8-dev
29 sudo apt-get install libdb4.8++-dev
30 Boost 1.40+: sudo apt-get install libboost-all-dev
31 or Boost 1.37: sudo apt-get install libboost1.37-dev
32
33 If using Boost 1.37, append -mt to the boost libraries in the makefile.
34
35 Requires wxWidgets 2.9.1 or newer.
36
37 You need to download wxWidgets from http://www.wxwidgets.org/downloads/
38 and build it yourself.  See the build instructions and configure parameters
39 below.
40
41 Requires miniupnpc for UPnP port mapping.  It can be downloaded from
42 http://miniupnp.tuxfamily.org/files/.  UPnP support is compiled in and
43 turned off by default.  Set USE_UPNP to a different value to control this:
44 USE_UPNP=   no UPnP support, miniupnp not required;
45 USE_UPNP=0  (the default) UPnP support turned off by default at runtime;
46 USE_UPNP=1  UPnP support turned on by default at runtime.
47
48 Licenses of statically linked libraries:
49 wxWidgets      LGPL 2.1 with very liberal exceptions
50 Berkeley DB    New BSD license with additional requirement that linked software must be free open source
51 Boost          MIT-like license
52 miniupnpc      New (3-clause) BSD license
53
54 Versions used in this release:
55 GCC          4.3.3
56 OpenSSL      0.9.8g
57 wxWidgets    2.9.2
58 Berkeley DB  4.8.30.NC
59 Boost        1.37
60 miniupnpc    1.6
61
62
63 Notes
64 -----
65 The UI layout is edited with wxFormBuilder.  The project file is
66 uiproject.fbp.  It generates uibase.cpp and uibase.h, which define base
67 classes that do the rote work of constructing all the UI elements.
68
69 The release is built with GCC and then "strip bitcoin" to strip the debug
70 symbols, which reduces the executable size by about 90%.
71
72
73 wxWidgets
74 ---------
75 cd /usr/local
76 tar -xzvf wxWidgets-2.9.2.tar.gz
77 cd wxWidgets-2.9.2
78 mkdir buildgtk
79 cd buildgtk
80 ../configure --with-gtk --enable-debug --disable-shared --enable-monolithic --without-libpng --disable-svg
81 make
82 sudo su
83 make install
84 ldconfig
85
86
87 miniupnpc
88 ---------
89 tar -xzvf miniupnpc-1.6.tar.gz
90 cd miniupnpc-1.6
91 make
92 sudo su
93 make install
94
95
96 Berkeley DB
97 -----------
98 You need Berkeley DB 4.8.  If you have to build Berkeley DB yourself:
99 ../dist/configure --enable-cxx
100 make
101
102
103 Boost
104 -----
105 If you need to build Boost yourself:
106 sudo su
107 ./bootstrap.sh
108 ./bjam install
109
110
111 Security
112 --------
113 To help make your bitcoin installation more secure by making certain attacks impossible to
114 exploit even if a vulnerability is found, you can take the following measures:
115
116 * Position Independent Executable
117     Build position independent code to take advantage of Address Space Layout Randomization
118     offered by some kernels. An attacker who is able to cause execution of code at an arbitrary
119     memory location is thwarted if he doesn't know where anything useful is located.
120     The stack and heap are randomly located by default but this allows the code section to be
121     randomly located as well.
122
123     On an Amd64 processor where a library was not compiled with -fPIC, this will cause an error
124     such as: "relocation R_X86_64_32 against `......' can not be used when making a shared object;"
125
126     To build with PIE, use:
127     make -f makefile.unix ... -e PIE=1
128
129     To test that you have built PIE executable, install scanelf, part of paxutils, and use:
130     scanelf -e ./bitcoin
131
132     The output should contain:
133      TYPE
134     ET_DYN
135
136 * Non-executable Stack
137     If the stack is executable then trivial stack based buffer overflow exploits are possible if
138     vulnerable buffers are found. By default, bitcoin should be built with a non-executable stack
139     but if one of the libraries it uses asks for an executable stack or someone makes a mistake
140     and uses a compiler extension which requires an executable stack, it will silently build an
141     executable without the non-executable stack protection.
142
143     To verify that the stack is non-executable after compiling use:
144     scanelf -e ./bitcoin
145
146     the output should contain:
147     STK/REL/PTL
148     RW- R-- RW-
149
150     The STK RW- means that the stack is readable and writeable but not executable.