All pastes #374741 Raw Edit

Something

public shellscript v1 · immutable
#374741 ·published 2007-02-27 20:14 UTC
rendered paste body
#!/bin/bashfunction findMakefile() {    file="$2"    command cd "$1"    while ! test -f "./$file"; do        command cd .. 2>/dev/null        test "$PWD" == "/" && return    done    echo "$PWD"}function run() {    # Check if it's cmake; if so, don't try to colorise the output    test -d "$objdir/CMakeFiles" && progress=false    INSIDE_SPECIAL_MAKE=true    export INSIDE_SPECIAL_MAKE    if $progress; then        if type -p pmake >/dev/null; then            exec pmake "$@"        else            echo >&2 "Warning: cannot locate pmake!"        fi    fi    exec $MAKE "$@"}[ "$MAKE" == "$0" ] && unset MAKEMAKE=${MAKE-/usr/bin/make}export MAKE# Don't recursetest -n "$INSIDE_SPECIAL_MAKE" && \    exec $MAKE "$@"# safety checktest -f $HOME/.bash_functions && . $HOME/.bash_functionstest "`type -t updatedirs`" == function || $MAKE "$@"progress=truefile=Makefiledir=.args=()# parse argswhile test $# -gt 0 ; do    case "${1}" in        -f*)            file="${1#-f}"            shift            test -z "$file" && {                file="${1}"                shift            }            args=("${args[@]}" -f "$file")            ;;        -C*)            dir="${1#-C}"            shift            test -z "$dir" && {                dir="${1}"                shift            }            ;;        VERBOSE=1)            progress=false            args=("${args[@]}" "$1")            shift            ;;        *)            args=("${args[@]}" "$1")            shift            ;;    esacdoneobjdir=$(findMakefile "$dir" "$file")if [ -z "$objdir" ]; then    # See if updatedirs can do something...    objdir=$(command cd "$dir"; updatedirs; findMakefile "$objdir" "$file")firun -C "$objdir" "${args[@]}"exit 255# Old code:# Check if $dir existsif ! test -d "$dir"; then    # Doesn't exist. Let make complain    run -C "$dir" "${args[@]}"fi# Check if $dir is a source or object dirif test -f "$dir/file"; then    # It's an object dir, since there's a Makefile there    run -C "$dir" "${args[@]}"fi