All pastes #374798 Raw Edit

Mine

public shellscript v1 · immutable
#374798 ·published 2007-02-27 20:40 UTC
rendered paste body
#!/bin/bashfunction updatedirs(){    # initialise variables    local devhome=${DEVHOME-$HOME}    local srchome=${SRCHOME-$devhome/src}    local objhome=${OBJHOME-$devhome/obj}    # the other ones    export srcdir=$PWD    export objdir=$PWD    # find out if we're in src or obj    case "$PWD" in        $srchome*)            # we're in a srcdir - try to find the objdir            objdir=${PWD/#$srchome/$objhome}            ;;        $objhome*)            # we're in an objdir - try to find the srcdir            srcdir=${PWD/#$objhome/$srchome}            ;;    esac    if [ \! -d "$srcdir" ]; then        srcdir=$PWD    fi    if [ \! -d "$objdir" ]; then        objdir=$PWD    fi}function 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