3 Star 3 Fork 2

happyfish100 / faststore

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
make.sh 4.46 KB
一键复制 编辑 原始数据 按行查看 历史
ENABLE_STATIC_LIB=0
ENABLE_SHARED_LIB=1
TARGET_PREFIX=$DESTDIR/usr
TARGET_CONF_PATH=$DESTDIR/etc/fdir
DEBUG_FLAG=0
export CC=gcc
#CFLAGS='-Wall -DFS_DUMP_SLICE_FOR_DEBUG=32'
CFLAGS='-Wall'
GCC_VERSION=$(gcc -dM -E - < /dev/null | grep -w __GNUC__ | awk '{print $NF;}')
if [ -n "$GCC_VERSION" ] && [ $GCC_VERSION -ge 7 ]; then
CFLAGS="$CFLAGS -Wformat-truncation=0 -Wformat-overflow=0"
fi
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE"
if [ "$DEBUG_FLAG" = "1" ]; then
CFLAGS="$CFLAGS -g -DDEBUG_FLAG"
else
CFLAGS="$CFLAGS -g -O3"
fi
if [ -f /usr/include/fastcommon/_os_define.h ]; then
OS_BITS=$(grep -F OS_BITS /usr/include/fastcommon/_os_define.h | awk '{print $NF;}')
elif [ -f /usr/local/include/fastcommon/_os_define.h ]; then
OS_BITS=$(grep -F OS_BITS /usr/local/include/fastcommon/_os_define.h | awk '{print $NF;}')
else
OS_BITS=64
fi
uname=$(uname)
if [ "$OS_BITS" -eq 64 ]; then
if [ $uname = 'Linux' ]; then
osname=$(cat /etc/os-release | grep -w NAME | awk -F '=' '{print $2;}' | \
awk -F '"' '{if (NF==3) {print $2} else {print $1}}' | awk '{print $1}')
if [ $osname = 'Ubuntu' -o $osname = 'Debian' ]; then
LIB_VERSION=lib
else
LIB_VERSION=lib64
fi
else
LIB_VERSION=lib
fi
else
LIB_VERSION=lib
fi
LIBS=''
if [ "$uname" = "Linux" ]; then
if [ "$OS_BITS" -eq 64 ]; then
LIBS="$LIBS -L/usr/lib64"
else
LIBS="$LIBS -L/usr/lib"
fi
LIBS="$LIBS -laio"
CFLAGS="$CFLAGS"
elif [ "$uname" = "FreeBSD" ] || [ "$uname" = "Darwin" ]; then
LIBS="$LIBS -L/usr/lib"
CFLAGS="$CFLAGS"
if [ "$uname" = "Darwin" ]; then
CFLAGS="$CFLAGS -DDARWIN"
TARGET_PREFIX=$TARGET_PREFIX/local
fi
elif [ "$uname" = "SunOS" ]; then
LIBS="$LIBS -L/usr/lib"
CFLAGS="$CFLAGS -D_THREAD_SAFE"
LIBS="$LIBS -lsocket -lnsl -lresolv"
elif [ "$uname" = "AIX" ]; then
LIBS="$LIBS -L/usr/lib"
CFLAGS="$CFLAGS -D_THREAD_SAFE"
elif [ "$uname" = "HP-UX" ]; then
LIBS="$LIBS -L/usr/lib"
CFLAGS="$CFLAGS"
fi
have_pthread=0
if [ -f /usr/lib/libpthread.so ] || [ -f /usr/local/lib/libpthread.so ] || [ -f /lib64/libpthread.so ] || [ -f /usr/lib64/libpthread.so ] || [ -f /usr/lib/libpthread.a ] || [ -f /usr/local/lib/libpthread.a ] || [ -f /lib64/libpthread.a ] || [ -f /usr/lib64/libpthread.a ]; then
LIBS="$LIBS -lpthread"
have_pthread=1
elif [ "$uname" = "HP-UX" ]; then
lib_path="/usr/lib/hpux$OS_BITS"
if [ -f $lib_path/libpthread.so ]; then
LIBS="-L$lib_path -lpthread"
have_pthread=1
fi
elif [ "$uname" = "FreeBSD" ]; then
if [ -f /usr/lib/libc_r.so ]; then
line=$(nm -D /usr/lib/libc_r.so | grep -F pthread_create | grep -w T)
if [ $? -eq 0 ]; then
LIBS="$LIBS -lc_r"
have_pthread=1
fi
elif [ -f /lib64/libc_r.so ]; then
line=$(nm -D /lib64/libc_r.so | grep -F pthread_create | grep -w T)
if [ $? -eq 0 ]; then
LIBS="$LIBS -lc_r"
have_pthread=1
fi
elif [ -f /usr/lib64/libc_r.so ]; then
line=$(nm -D /usr/lib64/libc_r.so | grep -F pthread_create | grep -w T)
if [ $? -eq 0 ]; then
LIBS="$LIBS -lc_r"
have_pthread=1
fi
fi
fi
if [ $have_pthread -eq 0 ] && [ "$uname" != "Darwin" ]; then
/sbin/ldconfig -p | grep -F libpthread.so > /dev/null
if [ $? -eq 0 ]; then
LIBS="$LIBS -lpthread"
else
echo -E 'Require pthread lib, please check!'
exit 2
fi
fi
sed_replace()
{
sed_cmd=$1
filename=$2
if [ "$uname" = "FreeBSD" ] || [ "$uname" = "Darwin" ]; then
sed -i "" "$sed_cmd" $filename
else
sed -i "$sed_cmd" $filename
fi
}
replace_makefile()
{
cp Makefile.in Makefile
sed_replace "s#\\\$(CFLAGS)#$CFLAGS#g" Makefile
sed_replace "s#\\\$(LIBS)#$LIBS#g" Makefile
sed_replace "s#\\\$(TARGET_PREFIX)#$TARGET_PREFIX#g" Makefile
sed_replace "s#\\\$(LIB_VERSION)#$LIB_VERSION#g" Makefile
sed_replace "s#\\\$(TARGET_CONF_PATH)#$TARGET_CONF_PATH#g" Makefile
sed_replace "s#\\\$(ENABLE_STATIC_LIB)#$ENABLE_STATIC_LIB#g" Makefile
sed_replace "s#\\\$(ENABLE_SHARED_LIB)#$ENABLE_SHARED_LIB#g" Makefile
}
cwd=$(pwd)
cd src/include/faststore/
for subdir in api client; do
link=$(readlink $subdir)
if [ $? -ne 0 ] || [ "$link" != "../../$subdir" -a "$link" != "../../$subdir/" ]; then
ln -sf ../../$subdir/ $subdir
fi
done
cd $cwd/src/server
replace_makefile
make $1 $2
cd ../client
replace_makefile
make $1 $2
cd tools
replace_makefile
make $1 $2
cd ..
if [ -z $DESTDIR ]; then
cd tests || exit
replace_makefile
make $1 $2
cd ..
fi
cd ../api
replace_makefile
make $1 $2
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/fastdfs100/faststore.git
git@gitee.com:fastdfs100/faststore.git
fastdfs100
faststore
faststore
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891