fix bootstrap on osx
[folly.git] / folly / build / bootstrap-osx-homebrew.sh
1 #!/bin/bash -x
2 # The only prerequisite should be homebrew. If something doesn't work out of
3 # the box with just homebrew, let's fix it.
4
5 # fail fast
6 set -e
7
8 BASE_DIR="$(cd "$(dirname -- "$0")"/.. ; pwd)"  # folly/folly
9 cd "$BASE_DIR"
10
11 # brew install alias
12 brew_install() {
13     brew install $@ || brew upgrade $@
14 }
15
16 # install deps
17 install_deps() {
18         # folly deps
19         dependencies=(autoconf automake libtool pkg-config double-conversion glog gflags boost libevent xz snappy lz4 jemalloc openssl)
20
21         # fetch deps
22         for dependency in ${dependencies[@]}; do
23                 brew_install ${dependency}
24         done
25 }
26
27 # set env flags
28 export_flags() {
29         # fetch opt dirs
30         OPT_GFLAGS=$(brew --prefix gflags)
31         OPT_OPENSSL=$(brew --prefix openssl)
32
33         # export LDFLAGS
34         export LDFLAGS=-L${OPT_OPENSSL}/lib
35         export CPPFLAGS=-I${OPT_OPENSSL}/include
36         export GFLAGS_LIBS=-L${OPT_GFLAGS}/lib
37         export GFLAGS_CFLAGS=-I${OPT_GFLAGS}/include
38 }
39
40 # now the fun part
41 install_deps
42 export_flags
43 autoreconf -ivf
44 ./configure --disable-silent-rules --disable-dependency-tracking
45
46 # fetch googletest, if doesn't exist
47 pushd test
48 GTEST_VER=1.7.0
49 GTEST_DIR=gtest-${GTEST_VER}
50 if [ ! -d ${GTEST_DIR} ]; then
51         mkdir ${GTEST_DIR}
52     curl -SL \
53         https://github.com/google/googletest/archive/release-${GTEST_VER}.tar.gz | \
54         tar -xvzf - --strip-components=1 -C ${GTEST_DIR}
55 fi
56 popd
57
58 # make, test, install
59 make
60 make install