#!/bin/bash if [ $# -ne 1 ] ;then echo "Usage:$0 all|clean" && exit fi root_path=$(pwd) uname=$(uname -s) if [ "$uname" == "Darwin" ] ;then platform="macosx" else platform="linux" fi function build() { cd $root_path/$1 real_path=$(pwd) echo "开始编译:$1" if [ "$1" == "lua-snapshot" ] ;then make $2 elif [ "$1" == "jmutil" ] ;then make $2 elif [ "$1" == "luafilesystem" ] ;then make $2 else make all fi } function install() { echo "cd $root_path/$1 && make install" cd $root_path/$1 && make install } function clean() { echo "cd $root_path/$1 && make clean" cd $root_path/$1 && make clean } dir=$(ls -l ./ |awk '/^d/ {print $NF}') for i in $dir do if [ "$1" == "all" ] ;then build $i $platform install $i echo "" else clean $i echo "" fi done