X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=src%2Fmain.bash;h=4b7f67ecde80f89db2781521f325534bbc42339f;hb=HEAD;hp=32a49d9e0aa551e42e72311e829c74a0cde3519d;hpb=1b97c8a3b0aa01ec27c2382cfcacc2c407297b80;p=autobuild.git diff --git a/src/main.bash b/src/main.bash index 32a49d9..4b7f67e 100644 --- a/src/main.bash +++ b/src/main.bash @@ -1,5 +1,9 @@ function runMake () { - run gmake -w -j $(detectNumCPUs) $@ + run gmake -w -j $(detectNumCPUs) "$@" +} + +function autogen () { + run autoreconf -v -i -f } function configure () { @@ -9,13 +13,13 @@ function configure () { fi if [[ ! -f configure ]]; then - run autoreconf -v -i -f + autogen fi if [[ ! -f "_build/Makefile" ]]; then run mkdir -p _build run pushd _build - run ../configure "${configArgs[@]}" + run ../configure --prefix="$prefix" "${configArgs[@]}" run popd fi } @@ -44,25 +48,68 @@ function dist () { runMake -C "_build" dist } +function distcheck () { + configure + runMake -C "_build" distcheck DISTCHECK_CONFIGURE_FLAGS="${configArgs[*]}" +} + function install () { build - runMake -C "_build" install + runMake -C "_build" install "$@" +} + +function other () { + runMake -C "_build" "$@" +} + +function usage () { + cat <&2 +Usage: $0 [COMMAND] + +This is an automation script designed to work with autotools. It creates a +directory "./_build" and builds any files inside it. Its behaviour is +somewhat configurable: See "./Build.rc" for details. + +If no COMMAND is given, it defaults to "build". + +Commands: + build run "$0 configure" then make(1) + check [ARGS] run "$0 build" then "make check [ARGS]" + autogen run autoreconf(1) + configure run "$0 autogen" and "./configure" if necessary + clean run "rm -rf _build" + dist run "make dist" + distcheck run "$0 configure" then "make distcheck" + doc similar to "$0 build" but only build the documentation + help print this message + install [ARGS] run "$0 build" then "make install [ARGS]" + -- [ARGS] run "make [ARGS]" + +Please report any bugs, feature requests, and pull requests (the most +preferred!) to the maintainer presented in the preamble of the "$0" itself. +EOF + return 1 } function main () { local cmd case "$1" in - ""|"build") cmd=build ;; - "doc" ) cmd=doc ;; - "check" ) cmd=check ;; - "clean" ) cmd=clean ;; - "dist" ) cmd=dist ;; - "install" ) cmd=install;; - *) - echo "Usage: $0 [build | doc | check | clean | dist | install]" >&2 - exit 1 + ""|"build" ) cmd="build" ;; + "autogen" ) cmd="autogen" ;; + "configure") cmd="configure";; + "doc" ) cmd="doc" ;; + "check" ) cmd="check" ;; + "clean" ) cmd="clean" ;; + "dist" ) cmd="dist" ;; + "distcheck") cmd="distcheck";; + "help" ) cmd="usage" ;; + "install" ) cmd="install" ;; + "--" ) cmd="other" ;; + *) cmd="usage" ;; esac - shift + if (( $# > 0 )); then + shift + fi "$cmd" "$@" }