#!/bin/sh
# @function install TCMalloc
function InstallTCMalloc()
{
    ShowResult "[green]正在安装TCMalloc... [/green]" 1
    
    # install libunwind
    eval cd ${_PATH_COMPILATION_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval rm -rf ./libunwind-* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval tar zxvf ${_PATH_SOFTWARE_}/libunwind-* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval cd libunwind-* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval ./configure ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make ${_SYS_MAKE_EXT_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make install ${_SYS_SHOW_INSTALL_DETAILS_}
    
    ShowStatus $? 1
    
    # install gperftools (tcmalloc)
    eval cd ${_PATH_COMPILATION_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval rm -rf ./gperftools-* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval tar zxvf ${_PATH_SOFTWARE_}/gperftools-* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval cd gperftools-* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval ./configure --disable-cpu-profiler --disable-heap-profiler --disable-heap-checker --disable-debugalloc --enable-minimal ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make ${_SYS_MAKE_EXT_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make install ${_SYS_SHOW_INSTALL_DETAILS_}
    
    ShowStatus $? 1
    
    echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
    eval ldconfig ${_SYS_SHOW_INSTALL_DETAILS_}
    
    ShowStatus $?
}