function runMake () { run gmake -w -j $(detectNumCPUs) $@ } function configure () { if [[ ! -f configure.ac && ! -f configure.in ]]; then echo "ERROR: Neither configure.ac nor configure.in exists in the current directory." >&2 return 1 fi if [[ ! -f configure ]]; then run autoreconf -v -i -f fi if [[ ! -f "_build/Makefile" ]]; then run mkdir -p _build run pushd _build run ../configure "${configArgs[@]}" run popd fi } function build () { configure runMake -C "_build" $buildTarget } function doc () { configure runMake -C "_build/$docDirectory" $docTarget } function check () { build runMake -C "_build" check "$@" } function clean () { run rm -rf "_build" } function dist () { configure runMake -C "_build" dist } function install () { build runMake -C "_build" install "$0" } 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. If no COMMAND is given, it defaults to "build". Commands: build run "$0 configure" then make(1). check [ARG] run "$0 build" then "make check [ARG]". configure run autoreconf(1) and "./configure" if necessary. clean run "rm -rf _build" dist run "make dist" doc similar to "$0 build" but only build the documentation. install [ARG] run "$0 build" then "make install [ARG]". 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" ;; "configure") cmd="configure";; "doc" ) cmd="doc" ;; "check" ) cmd="check" ;; "clean" ) cmd="clean" ;; "dist" ) cmd="dist" ;; "install" ) cmd="install" ;; *) cmd="usage" ;; esac if (( $# > 0 )); then shift fi "$cmd" "$@" } main "$@"