Add some hardening to protect against unknown/future exploits.
[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.0 or greater, which uses UTF-8.  Don't try 2.8, it
36 won't work.
37
38 You need to download wxWidgets from http://www.wxwidgets.org/downloads/
39 and build it yourself.  See the build instructions and configure parameters
40 below.
41
42 Requires miniupnpc for UPnP port mapping.  It can be downloaded from
43 http://miniupnp.tuxfamily.org/files/.  UPnP support is compiled in and
44 turned off by default.  Set USE_UPNP to a different value to control this:
45 USE_UPNP=   no UPnP support, miniupnp not required;
46 USE_UPNP=0  (the default) UPnP support turned off by default at runtime;
47 USE_UPNP=1  UPnP support turned on by default at runtime.
48
49 Licenses of statically linked libraries:
50 wxWidgets      LGPL 2.1 with very liberal exceptions
51 Berkeley DB    New BSD license with additional requirement that linked software must be free open source
52 Boost          MIT-like license
53 miniupnpc      New (3-clause) BSD license
54
55 Versions used in this release:
56 GCC          4.3.3
57 OpenSSL      0.9.8g
58 wxWidgets    2.9.2
59 Berkeley DB  4.8.30.NC
60 Boost        1.37
61 miniupnpc    1.6
62
63
64 Notes
65 -----
66 The UI layout is edited with wxFormBuilder.  The project file is
67 uiproject.fbp.  It generates uibase.cpp and uibase.h, which define base
68 classes that do the rote work of constructing all the UI elements.
69
70 The release is built with GCC and then "strip bitcoin" to strip the debug
71 symbols, which reduces the executable size by about 90%.
72
73
74 wxWidgets
75 ---------
76 cd /usr/local
77 tar -xzvf wxWidgets-2.9.2.tar.gz
78 cd wxWidgets-2.9.2
79 mkdir buildgtk
80 cd buildgtk
81 ../configure --with-gtk --enable-debug --disable-shared --enable-monolithic --without-libpng --disable-svg
82 make
83 sudo su
84 make install
85 ldconfig
86
87
88 miniupnpc
89 ---------
90 tar -xzvf miniupnpc-1.6.tar.gz
91 cd miniupnpc-1.6
92 make
93 sudo su
94 make install
95
96
97 Berkeley DB
98 -----------
99 You need Berkeley DB 4.8.  If you have to build Berkeley DB yourself:
100 ../dist/configure --enable-cxx
101 make
102
103
104 Boost
105 -----
106 If you need to build Boost yourself:
107 sudo su
108 ./bootstrap.sh
109 ./bjam install
110
111
112 Security
113 --------
114 To help make your bitcoin installation more secure by making certain attacks impossible to
115 exploit even if a vulnerability is found, you can take the following measures:
116
117 * Position Independent Executable
118     Build position independent code to take advantage of Address Space Layout Randomization
119     offered by some kernels. An attacker who is able to cause execution of code at an arbitrary
120     memory location is thwarted if he doesn't know where anything useful is located.
121     The stack and heap are randomly located by default but this allows the code section to be
122     randomly located as well.
123
124     On an Amd64 processor where a library was not compiled with -fPIC, this will cause an error
125     such as: "relocation R_X86_64_32 against `......' can not be used when making a shared object;"
126
127     To build with PIE, use:
128     make -f makefile.unix ... -e PIE=1
129
130     To test that you have built PIE executable, install scanelf, part of paxutils, and use:
131     scanelf -e ./bitcoin
132
133     The output should contain:
134      TYPE
135     ET_DYN
136
137 * Non-executable Stack
138     If the stack is executable then trivial stack based buffer overflow exploits are possible if
139     vulnerable buffers are found. By default, bitcoin should be built with a non-executable stack
140     but if one of the libraries it uses asks for an executable stack or someone makes a mistake
141     and uses a compiler extension which requires an executable stack, it will silently build an
142     executable without the non-executable stack protection.
143
144     To verify that the stack is non-executable after compiling use:
145     scanelf -e ./bitcoin
146
147     the output should contain:
148     STK/REL/PTL
149     RW- R-- RW-
150
151     The STK RW- means that the stack is readable and writeable but not executable.