# Main and minor version definition # usage: ./build.sh oem pid ---> ./build.sh hg 200 @echo off # clear oem=$1 #厂商 pid=$2 cpu=$(arch) #cpu架构 sys=$(cat /etc/issue) sys=${sys%% *} #操作系统 cp CMakeLists.txt CMakeLists.txtbkp # replace oem, pid, os and cpu ... if [ "$oem" == "hw" ]; then sed -i "s/hgtwain/hwtwain/g" CMakeLists.txt sed -i "s/DOEM_NONE/DOEM_HANWANG/g" CMakeLists.txt elif [ "$oem" == "lsc" ]; then sed -i "s/hgtwain/lsctwain/g" CMakeLists.txt sed -i "s/DOEM_NONE/DOEM_LISICHENG/g" CMakeLists.txt elif [ "$oem" == "cts" ]; then sed -i "s/hgtwain/ctstwain/g" CMakeLists.txt sed -i "s/DOEM_NONE/DOEM_CANGTIAN/g" CMakeLists.txt elif [ "$oem" == "zj" ]; then sed -i "s/hgtwain/zjtwain/g" CMakeLists.txt sed -i "s/DOEM_NONE/DOEM_ZHONGJING/g" CMakeLists.txt elif [ "$oem" == "zg" ]; then sed -i "s/hgtwain/zgtwain/g" CMakeLists.txt sed -i "s/DOEM_NONE/DOEM_ZIGUANG/g" CMakeLists.txt fi if [ "$pid" == "" ]; then pid=200 fi sed -i "s/DPRODUCT_ID=200/DPRODUCT_ID=${pid}/g" CMakeLists.txt if [ "$sys" == "UnionTech" ]; then sys="uos" elif [ "$sys" == "Kylin" ]; then sys="kylin" else echo "Other linux: "${sys}", change to 'kylin'." sys="kylin" fi sed -i "s/kylin/"${sys}"/g" CMakeLists.txt sed -i "s/x86_64/"${cpu}"/g" CMakeLists.txt origin_dir=$(pwd) echo origin path is $origin_dir if [ -f ../../build/twain/Makefile ]; then echo "" else mkdir ../../../build mkdir ../../../build/twainds fi cd ../../../build/twainds echo building path is $(pwd) rm -rf ./* cmake $origin_dir make -j4 if [ $? -ne 0 ];then err=1 echo "--------------------------------------make fail---------------------------------------" # commented, we should restore the CMakeLists.txts... else err=0 echo "--------------------------------------make succeed------------------------------------" mv ../../release/${sys}/${cpu}/lib${oem}twain.so ../../release/${sys}/${cpu}/lib${oem}twain${pid}.ds fi if [ -f ../../code_device/twain/ds/CMakeLists.txtbkp ]; then mv ../../code_device/twain/ds/CMakeLists.txtbkp ../../code_device/twain/ds/CMakeLists.txt pwd fi cd $origin_dir exit $err if [ "$3" == "" ]; then echo -------copy DS to system directory ...------- sudo cp ../../../release/${sys}/${cpu}/lib${oem}twain${pid}.ds /usr/local/lib/twain/ fi