天天看點

一鍵安裝thrift-0.9.0的腳本

#!/bin/sh

# 一鍵安裝thrift-0.9.0的腳本

# thrift依賴boost、openssl和libevent

# 下面的變量值可以根據實作做修改

PROJECT_HOME=$HOME/iflow # 項目源碼主目錄

# thrift及依賴的第三方庫源碼包存放目錄和安裝目錄,

# 一鍵腳本要和第三方庫源碼包放在同一個目錄下

THIRD_PARTY_HOME=$PROJECT_HOME/third-party

boost=boost_1_52_0

openssl=openssl-1.0.1c

libevent=libevent-2.0.19-stable

thrift=thrift-0.9.0

#

# 安裝boost

printf "\n\033[0;32;34minstalling boost\033[m\n"

tar xzf $boost.tar.gz

cd $boost

./bootstrap.sh

if test $? -ne 0; then

 exit 1

fi

./b2 install --prefix=$THIRD_PARTY_HOME/boost

printf "\n\033[0;32;34m./b2 install return $?\033[m\n"

cd -

# 安裝openssl

printf "\n\033[0;32;34minstalling openssl\033[m\n"

tar xzf $openssl.tar.gz

cd $openssl

./config --prefix=$THIRD_PARTY_HOME/openssl shared threads

make

make install

# 安裝libevent

printf "\n\033[0;32;34minstalling libevent\033[m\n"

tar xzf $libevent.tar.gz

cd $libevent

./configure --prefix=$THIRD_PARTY_HOME/libevent

# 安裝thrift

printf "\n\033[0;32;34minstalling thrift\033[m\n"

tar xzf $thrift.tar.gz

cd $thrift

# 按照正常的configure,使用--with-openssl,會遇到

# “Error: libcrypto required.”錯誤,這裡使用CPPFLAGS和LDFLAGS替代

./configure --prefix=$THIRD_PARTY_HOME/thrift \

            --with-boost=$THIRD_PARTY_HOME/boost \

            --with-libevent=$THIRD_PARTY_HOME/libevent \

            CPPFLAGS="-I$THIRD_PARTY_HOME/openssl/include" \

            LDFLAGS="-ldl -L$THIRD_PARTY_HOME/openssl/lib" \

            --with-qt4=no --with-c_glib=no --with-csharp=no \

            --with-java=no --with-erlang=no --with-python=no \

            --with-perl=no --with-ruby=no --with-haskell=no \

            --with-go=no --with-d=no

# 完成上述修改後,configure可以成功了,但還需要下面修改,

# 否則make時會報malloc未聲明

sed -i -e 's!#define HAVE_MALLOC 0!#define HAVE_MALLOC 1!' config.h

sed -i -e 's!#define HAVE_REALLOC 0!#define HAVE_REALLOC 1!' config.h

sed -i -e 's!#define malloc rpl_malloc!/*#define malloc rpl_malloc*/!' config.h

sed -i -e 's!#define realloc rpl_realloc!/*#define realloc rpl_realloc*/!' config.h

# 安裝成功提示一下

printf "\n\033[0;32;34minstall SUCCESS\033[m\n"

繼續閱讀