joachim99@69: #!/bin/bash joachim99@69: joachim99@69: # this is a script around make which basicly checks joachim99@69: # if it's in srcdir or in builddir and changes to joachim99@69: # the right directory for calling /usr/bin/make joachim99@69: # (C) Stephan Kulow joachim99@69: joachim99@69: # You may need to set OBJ_REPLACEMENT variable to get it to work. joachim99@69: # In the variable use the sed syntax to switch directories, for example joachim99@69: # export OBJ_REPLACEMENT="s:/home/zack/cvs/kde:/home/zack/build:" joachim99@69: # will assure that the builds are performed under /home/zack/build joachim99@69: # directory, when the cvs is held under /home/zack/cvs/kde. joachim99@69: joachim99@69: file=Makefile joachim99@69: dir=. joachim99@69: args=() joachim99@69: jobs= joachim99@69: joachim99@69: while test $# -gt 0 ; do joachim99@69: case "${1}" in joachim99@69: -f) joachim99@69: shift joachim99@69: file="${1}" joachim99@69: shift joachim99@69: args=("${args[@]}" -f $file) joachim99@69: ;; joachim99@69: -C) joachim99@69: shift joachim99@69: dir="${1}" joachim99@69: shift ;; joachim99@69: -j) joachim99@69: shift joachim99@69: jobs="${1}" joachim99@69: shift ;; joachim99@69: -j*) joachim99@69: jobs="${1/-j/}" joachim99@69: shift ;; joachim99@69: *) joachim99@69: args=("${args[@]}" "$1") joachim99@69: shift joachim99@69: ;; joachim99@69: esac joachim99@69: done joachim99@69: joachim99@69: if test ! -f $dir/$file; then joachim99@69: if test -n "$OBJ_SUBDIR"; then joachim99@69: dir=$PWD joachim99@69: subdir=. joachim99@69: while test ! -f $dir/$OBJ_SUBDIR/$file; do joachim99@69: subdir=`basename $dir`"/$subdir" joachim99@69: dir=`dirname $dir` joachim99@69: if test "$dir" = "/"; then joachim99@69: # the case that someone puts the compile dir in / joachim99@69: # is very unlikely, so we better skip here ;) joachim99@69: echo "can't find $OBJ_SUBDIR above current dir" joachim99@69: exit 1 joachim99@69: fi joachim99@69: done joachim99@69: cd $dir/$OBJ_SUBDIR/$subdir joachim99@69: else joachim99@69: if test -n "$OBJ_REPLACEMENT"; then joachim99@69: pwd=`echo $PWD | sed -e "$OBJ_REPLACEMENT"` joachim99@69: if test ! -f $pwd/$dir/$file; then joachim99@69: echo "no objdir found. Tried $pwd" joachim99@69: exit 1 joachim99@69: fi joachim99@69: cd $pwd/$dir joachim99@69: fi joachim99@69: fi joachim99@69: else joachim99@69: cd $dir joachim99@69: fi joachim99@69: joachim99@69: echo "makeobj[0]: Entering directory \`$PWD'" joachim99@69: if test -z "$MAKE"; then joachim99@69: if head -n 1 $file | grep unsermake >/dev/null; then joachim99@69: MAKE=`type -p unsermake` joachim99@69: if test ! -x "$MAKE"; then joachim99@69: echo 'Makefile was created with unsermake, but there' joachim99@69: echo 'is no unsermake in $PATH' joachim99@69: exit 1 joachim99@69: fi joachim99@69: MAKE="$MAKE --no-real-compare VERBOSE=1" joachim99@69: if test -n "$jobs"; then args=("${args[@]}" --compile-jobs=$jobs); fi joachim99@69: else joachim99@69: MAKE=/usr/bin/make joachim99@69: if test -n "$jobs"; then args=("${args[@]}" -j $jobs); fi joachim99@69: fi joachim99@69: fi joachim99@69: joachim99@69: echo "Calling $MAKE ${args[@]}" joachim99@69: LANGUAGE=C $MAKE "${args[@]}" joachim99@69: retval=$? joachim99@69: echo "makeobj[0]: Leaving directory \`$PWD'" joachim99@69: exit $retval joachim99@69: