author | Olivier Brunel
<jjk@jjacky.com> 2023-07-07 06:57:27 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-07-07 17:07:37 UTC |
parent | fa32ddeeb1345b93ca31ebfca8e04161af8cc02f |
blddeps | +50 | -9 |
diff --git a/blddeps b/blddeps index 652abad..df0e2c5 100755 --- a/blddeps +++ b/blddeps @@ -2,6 +2,21 @@ . "$(dirname $0)"/libcomain +usage() +{ + local r=$1 + shift + + cat <<EOF +usage: $0 ACTION + + build [-n] Build dependencies in deps/ + + help Show this help screen and exit +EOF + exit $r +} + getdep() { local dep=$2 @@ -25,18 +40,44 @@ getdep() done } +mbrun() +{ + if test $dryrun -eq 0; then + run "$@" + else + echo "dry-run: $@" + fi +} + loadoptions loaddeps -foreach deps $nb_deps getdep | tac | while read -r name library arg; do - if test -e "deps/$name/$library.a" || test -e "deps/$name/$library.so"; then - echo $name already built. - continue - fi - echo Building $name - cd deps/$name - ./configure $arg && make - cd ../.. +if test $# -eq 0; then usage 0; fi + +dryrun=0 +build=0 +for arg ; do + case "$arg" in + build) build=1 ;; + + -n|--dry-run) dryrun=1 ;; + -h|--help|help) usage 0 ;; + *) dief 1 "unknown action '$arg'" ;; + esac done +if test $build -eq 1; then + foreach deps $nb_deps getdep | tac | while read -r name library arg; do + if test -e "deps/$name/$library.a" || test -e "deps/$name/$library.so"; then + echo :: $name already built. + continue + fi + echo :: Building $name + mbrun cd deps/$name + mbrun ./configure $arg + if test $? -eq 0; then mbrun make; fi + mbrun cd ../.. + done +fi + echo "done."