Fix some old license headers
[folly.git] / README.md
1 Folly: Facebook Open-source Library
2 -----------------------------------
3
4 ### What is `folly`?
5
6 Folly (acronymed loosely after Facebook Open Source Library) is a
7 library of C++11 components designed with practicality and efficiency
8 in mind. **Folly contains a variety of core library components used extensively
9 at Facebook**. In particular, it's often a dependency of Facebook's other
10 open source C++ efforts and place where those projects can share code.
11
12 It complements (as opposed to competing against) offerings
13 such as Boost and of course `std`. In fact, we embark on defining our
14 own component only when something we need is either not available, or
15 does not meet the needed performance profile. We endeavor to remove
16 things from folly if or when `std` or Boost obsoletes them.
17
18 Performance concerns permeate much of Folly, sometimes leading to
19 designs that are more idiosyncratic than they would otherwise be (see
20 e.g. `PackedSyncPtr.h`, `SmallLocks.h`). Good performance at large
21 scale is a unifying theme in all of Folly.
22
23 ### Logical Design
24
25 Folly is a collection of relatively independent components, some as
26 simple as a few symbols. There is no restriction on internal
27 dependencies, meaning that a given folly module may use any other
28 folly components.
29
30 All symbols are defined in the top-level namespace `folly`, except of
31 course macros. Macro names are ALL_UPPERCASE and should be prefixed
32 with `FOLLY_`. Namespace `folly` defines other internal namespaces
33 such as `internal` or `detail`. User code should not depend on symbols
34 in those namespaces.
35
36 Folly has an `experimental` directory as well. This designation connotes
37 primarily that we feel the API may change heavily over time. This code,
38 typically, is still in heavy use and is well tested.
39
40 ### Physical Design
41
42 At the top level Folly uses the classic "stuttering" scheme
43 `folly/folly` used by Boost and others. The first directory serves as
44 an installation root of the library (with possible versioning a la
45 `folly-1.0/`), and the second is to distinguish the library when
46 including files, e.g. `#include <folly/FBString.h>`.
47
48 The directory structure is flat (mimicking the namespace structure),
49 i.e. we don't have an elaborate directory hierarchy (it is possible
50 this will change in future versions). The subdirectory `experimental`
51 contains files that are used inside folly and possibly at Facebook but
52 not considered stable enough for client use. Your code should not use
53 files in `folly/experimental` lest it may break when you update Folly.
54
55 The `folly/folly/test` subdirectory includes the unittests for all
56 components, usually named `ComponentXyzTest.cpp` for each
57 `ComponentXyz.*`. The `folly/folly/docs` directory contains
58 documentation.
59
60 ### What's in it?
61
62 Because of folly's fairly flat structure, the best way to see what's in it
63 is to look at the headers in [top level `folly/` directory](https://github.com/facebook/folly/tree/master/folly). You can also
64 check the [`docs` folder](folly/docs) for documentation, starting with the
65 [overview](folly/docs/Overview.md).
66
67 Folly is published on Github at https://github.com/facebook/folly
68
69 ### Build Notes
70
71 #### Dependencies
72
73 folly requires gcc 4.9+ and a version of boost compiled with C++14 support.
74
75 Please download googletest from
76 https://github.com/google/googletest/archive/release-1.8.0.tar.gz and unpack it into the
77 folly/test subdirectory as `gtest`:
78
79     (cd folly/test && \
80      rm -rf gtest && \
81      wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz && \
82      tar zxf release-1.8.0.tar.gz && \
83      rm -f release-1.8.0.tar.gz && \
84      mv googletest-release-1.8.0 gtest)
85
86 #### Ubuntu 12.04
87
88 This release is old, requiring many upgrades. However, since Travis CI runs
89 on 12.04, `folly/build/deps_ubuntu_12.04.sh` is provided, and upgrades all
90 the required packages.
91
92 #### Ubuntu 13.10
93
94 The following packages are required (feel free to cut and paste the apt-get
95 command below):
96
97 ```
98 sudo apt-get install \
99     g++ \
100     automake \
101     autoconf \
102     autoconf-archive \
103     libtool \
104     libboost-all-dev \
105     libevent-dev \
106     libdouble-conversion-dev \
107     libgoogle-glog-dev \
108     libgflags-dev \
109     liblz4-dev \
110     liblzma-dev \
111     libsnappy-dev \
112     make \
113     zlib1g-dev \
114     binutils-dev \
115     libjemalloc-dev \
116     libssl-dev \
117     pkg-config
118 ```
119
120 If advanced debugging functionality is required
121
122 ```
123 sudo apt-get install \
124     libunwind8-dev \
125     libelf-dev \
126     libdwarf-dev
127 ```
128
129 #### Ubuntu 14.04 LTS
130
131 The packages listed above for Ubuntu 13.10 are required, as well as:
132
133 ```
134 sudo apt-get install \
135     libiberty-dev
136 ```
137
138 The above packages are sufficient for Ubuntu 13.10 and Ubuntu 14.04.
139
140 In the folly directory, run
141 ```
142   autoreconf -ivf
143   ./configure
144   make
145   make check
146   sudo make install
147 ```
148
149 #### OS X (Homebrew)
150
151 folly is available as a Formula and releases may be built via `brew install folly`.
152
153 You may also use `folly/build/bootstrap-osx-homebrew.sh` to build against `master`:
154
155 ```
156   cd folly
157   ./build/bootstrap-osx-homebrew.sh
158 ```
159
160 #### OS X (MacPorts)
161
162 Install the required packages from MacPorts:
163
164 ```
165   sudo port install \
166     autoconf \
167     automake \
168     boost \
169     gflags \
170     git \
171     google-glog \
172     libevent \
173     libtool \
174     lz4 \
175     lzma \
176     scons \
177     snappy \
178     zlib
179 ```
180
181 Download and install double-conversion:
182
183 ```
184   git clone https://github.com/google/double-conversion.git
185   cd double-conversion
186   cmake -DBUILD_SHARED_LIBS=ON .
187   make
188   sudo make install
189 ```
190
191 Download and install folly with the parameters listed below:
192
193 ```
194   git clone https://github.com/facebook/folly.git
195   cd folly/folly
196   autoreconf -ivf
197   ./configure CPPFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib"
198   make
199   sudo make install
200 ```
201
202 #### Other Linux distributions
203
204 - double-conversion (https://github.com/google/double-conversion)
205
206   Download and build double-conversion.
207   You may need to tell configure where to find it.
208
209   [double-conversion/] `ln -s src double-conversion`
210
211   [folly/] `./configure LDFLAGS=-L$DOUBLE_CONVERSION_HOME/ CPPFLAGS=-I$DOUBLE_CONVERSION_HOME/`
212
213   [folly/] `LD_LIBRARY_PATH=$DOUBLE_CONVERSION_HOME/ make`
214
215 - additional platform specific dependencies:
216
217   Fedora 21 64-bit
218     - gcc
219     - gcc-c++
220     - autoconf
221     - autoconf-archive
222     - automake
223     - boost-devel
224     - libtool
225     - lz4-devel
226     - lzma-devel
227     - snappy-devel
228     - zlib-devel
229     - glog-devel
230     - gflags-devel
231     - scons
232     - double-conversion-devel
233     - openssl-devel
234     - libevent-devel
235
236   Optional
237     - libdwarf-dev
238     - libelf-dev
239     - libunwind8-dev