学习笔记 linux 编译文件用shell脚本实现

来源:互联网 发布:慈云蚕丝被 知乎 编辑:程序博客网 时间:2021/03/07 20:01

根据自己程序,修改一下如下代码即可 


#!/bin/sh

cd $(dirname $0)
echo Current working dir
pwd
if [ $# == 1 ]
then
 echo "..."
else
 echo "Invalid parameter count."
 exit
fi


if [ "$1" = "-r" ]
then
 echo "Build for release."
 mkdir release
 SOUT="-o release/globalquote"
 SOPExt="-O2"
elif [ "$1" = "-d" ]
then
 echo "Build for debug."
 mkdir debug
 SOUT="-o debug/globalquote"
 SOPExt="-O0"
else
 echo "Unknown paramer : $1."
 exit
fi

SDIR="../.."
SDEFINE="-D_LINUX_SYS -DENABLE_LOG4CXX -DLINUX"
SFILEEXT="$SDIR/md5/ssmd5.cpp"
SFILE="$SFILEEXT Main.cpp Config.cpp frame/FrameUtil.cpp 
SINCLUDE=" -I$SDIR -I. -I.. -I$SDIR/md5   -I$SDIR/loginlib/include 
SOPTION="-Wl,-rpath,. -g $SOPExt"
#SOUT="-o libTestPush.so"
SLIBINCLUDE="-L$SDIR/logger -L$SDIR/backcom/lib   -L$SDIR/common/library 

SLIB="-lcommon -liconv -llog4cxx -ldozlib -lz $SDIR/coredumper/lib/libcoredumper.a"

SBUILD="g++ $SFILE $SDEFINE $SINCLUDE $SOPTION $SOUT $SLIBINCLUDE $SLIB"

echo $SBUILD
echo Start to building...
$SBUILD

echo Finish.


例如:文件名为mk.sh   编译命令为sh mk.sh -d(或-r)


0 0
原创粉丝点击