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 if test $? -ne 0; then exit 1 fi make if test $? -ne 0; then exit 1 fi make install cd - # # 安装libevent # printf "\n\033[0;32;34minstalling libevent\033[m\n" tar xzf $libevent.tar.gz cd $libevent ./configure --prefix=$THIRD_PARTY_HOME/libevent if test $? -ne 0; then exit 1 fi make if test $? -ne 0; then exit 1 fi make install cd - # # 安装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 if test $? -ne 0; then exit 1 fi # 完成上述修改后,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 make if test $? -ne 0; then exit 1 fi make install cd - # 安装成功提示一下 printf "\n\033[0;32;34minstall SUCCESS\033[m\n"