Fix build when using system installed lz4 library instead of third-party
[hiphop-php.git] / configure_generic.sh
blob1ef6536ac3bfb0d487393a959c65b356c6bc5e72
1 #########################################
2 # #
3 # Generic Dependency Installer Script #
4 # #
5 #########################################
7 # Current Script details
8 SCRIPT="$(readlink -f $0)"
9 SCRIPT_DIR="$(dirname $SCRIPT)"
10 PWD=$(readlink -f `pwd`)
12 # Make sure the script is run from its proper path.
13 # OR Since we know the path, why don't we do it ourselves ?
14 if [ $PWD != $SCRIPT_DIR ]
15 then
16 echo "Run the script from the hiphop-php directory like:"
17 echo "cd $SCRIPT_DIR && ./$SCRIPT"
18 exit 1
21 # Identify the Distro
22 OS_TYPE=$(uname)
23 if [ "x$OS_TYPE" = "xLinux" ];then
24 DISTRO_NAME=$(head -1 /etc/issue)
25 if grep -i fedora /etc/issue >/dev/null 2>&1; then
26 DISTRO=fedora
27 elif grep -i ubuntu /etc/issue >/dev/null 2>&1;then
28 DISTRO=ubuntu
29 else
30 DISTRO=unknown
32 else
33 echo "Linux is the only supported Operating system right now."
34 echo "Please submit a PR when this script is enhanced to support"
35 echo "other operating systems"
36 echo ""
37 echo "Project URL: https://github.com/facebook/hhvm"
38 echo ""
39 echo " - Thank You."
40 exit 1
43 echo "Date/Time : $(date)"
44 echo "Current Distro : $DISTRO_NAME"
46 # Determine the CPUs irrespective of Travis Mode
47 CPUS=`cat /proc/cpuinfo | grep -E '^processor' | tail -1 | cut -d : -f 2`
48 CPUS=`expr ${CPUS} + 1`
50 # For travis
51 if [ "x${TRAVIS}" != "x" ]; then
52 # Collect some stats for use in tuning build later on
53 free
54 echo "Travis Mode : YES"
55 echo "# CPUs : ${CPUS}"
56 echo ""
57 else
58 echo "Travis Mode : NO"
59 echo "# CPUs : ${CPUS}"
60 echo ""
63 # Place to save all the binaries/libraries/headers from the ext packages
64 export CMAKE_PREFIX_PATH=`/bin/pwd`/..
66 case $DISTRO in
67 fedora)
68 # install the actual dependencies
69 sudo yum groupinstall "Fedora Packager" -y
70 sudo yum install -y git wget make autoconf binutils-devel \
71 boost-devel bzip2-devel chrpath cmake cyrus-sasl elfutils-libelf-devel \
72 expat-devel fontconfig-devel freetype-devel gcc-c++ gd-devel glibc-devel \
73 glog-devel jemalloc-devel keyutils-libs krb5-devel libaio-devel libcap-devel \
74 libc-client libc-client-devel libcom_err-devel libdwarf-devel libedit-devel \
75 libicu-devel libjpeg-turbo libjpeg-turbo-devel libmcrypt-devel libmemcached-devel \
76 libpng-devel libselinux-devel libsepol-devel libstdc++-devel libtool \
77 libunwind-devel libvpx-devel libX11-devel libXau-devel libxcb-devel libxml2-devel \
78 libxml++-devel libXpm-devel mysql-devel ncurses-devel oniguruma-devel openldap-devel \
79 openssl-devel pam-devel pcre-devel readline-devel tbb-devel unixODBC-devel \
80 uw-imap-devel zlib zlib-devel \
81 ImageMagick-devel libxslt-devel &
83 # For patched stuff.
84 git clone git://github.com/libevent/libevent.git --quiet &
85 git clone git://github.com/bagder/curl.git --quiet &
87 ubuntu)
88 # install python-software-properties before trying to add a PPA
89 sudo apt-get -y update
90 sudo apt-get install -y python-software-properties
92 # install apt-fast to speed up later dependency installation
93 sudo add-apt-repository -y ppa:apt-fast/stable
94 sudo add-apt-repository -y ppa:boost-latest/ppa
95 sudo apt-get -y update
96 sudo apt-get -y install apt-fast
98 # install the actual dependencies
99 sudo apt-fast -y update
100 sudo apt-fast -y install git-core cmake g++ boost1.55 libmysqlclient-dev \
101 libxml2-dev libmcrypt-dev libicu-dev openssl build-essential binutils-dev \
102 libcap-dev libgd2-xpm-dev zlib1g-dev libtbb-dev libonig-dev libpcre3-dev \
103 wget memcached libreadline-dev libncurses-dev libmemcached-dev libbz2-dev \
104 libc-client2007e-dev php5-mcrypt php5-imagick libgoogle-perftools-dev \
105 libcloog-ppl0 libelf-dev libdwarf-dev libunwind7-dev subversion \
106 autoconf libtool libcurl4-openssl-dev \
107 libmagickwand-dev libxslt1-dev &
109 git clone git://github.com/libevent/libevent.git --quiet &
110 git clone git://github.com/bagder/curl.git --quiet &
111 svn checkout http://google-glog.googlecode.com/svn/trunk/ google-glog --quiet &
112 wget -nc http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2 --quiet &
115 echo "Unknown distribution. Please update packages in this section."
116 exit 1
118 esac
120 # init submodules
121 git submodule update --init --recursive
123 # wait until all background processes finished
124 FAIL=0
126 for job in `jobs -p`
128 echo "waiting for background job $job"
129 wait $job || let "FAIL+=1"
130 done
132 if [ "$FAIL" == "0" ];
133 then
134 echo "all downloads finished"
135 else
136 echo "$FAIL errors while downloading!"
137 exit 100
140 if [[ "x$DISTRO" == "xubuntu" ]];then
141 # Leave this install till after the main parallel package install above
142 # since it adds a non-12.04 package repo and we don't want to
143 # pull EVERYTHING in, just the newer gcc compiler (and toolchain)
144 GCC_VER=4.8
145 sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
146 sudo apt-get -y update
147 sudo apt-get -y install gcc-${GCC_VER} g++-${GCC_VER}
148 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VER} 60 \
149 --slave /usr/bin/g++ g++ /usr/bin/g++-${GCC_VER}
150 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 40 \
151 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
152 sudo update-alternatives --set gcc /usr/bin/gcc-${GCC_VER}
155 # libevent
156 cd libevent
157 git checkout release-1.4.14b-stable
158 cat ../third-party/libevent-1.4.14.fb-changes.diff | patch -p1
159 ./autogen.sh
160 ./configure --prefix=$CMAKE_PREFIX_PATH
161 make -j $CPUS
162 make install
163 cd ..
165 # curl
166 cd curl
167 ./buildconf
168 ./configure --prefix=$CMAKE_PREFIX_PATH
169 make -j $CPUS
170 make install
171 cd ..
173 if [[ "x$DISTRO" == "xubuntu" ]];then
174 # glog
175 cd google-glog
176 ./configure --prefix=$CMAKE_PREFIX_PATH
177 make -j $CPUS
178 make install
179 cd ..
181 # jemaloc
182 tar xjvf jemalloc-3.6.0.tar.bz2
183 cd jemalloc-3.6.0
184 ./configure --prefix=$CMAKE_PREFIX_PATH
185 make -j $CPUS
186 make install
187 cd ..
189 # cleanup
190 rm -rf google-glog jemalloc-3.6.0.tar.bz2 jemalloc-3.6.0
193 # cleanup
194 rm -rf libevent curl
196 # hphp
197 cmake "$@" .
199 # all set
200 echo "-------------------------------------------------------------------------"
201 echo "Done. Now run:"
202 echo " CMAKE_PREFIX_PATH=\`pwd\`/.. make"