From: Henrik Gramner Date: Wed, 12 Aug 2015 20:23:31 +0000 (+0200) Subject: Use a relative $SRCPATH for out-of-tree builds X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7edaf4b966aaee098ff301436f8d2b33a6fe5983;p=libx264 Use a relative $SRCPATH for out-of-tree builds Fixes out-of-tree MSVS builds on Cygwin. --- diff --git a/configure b/configure index 70aa07f2..e96973a5 100755 --- a/configure +++ b/configure @@ -305,9 +305,22 @@ configure_system_override() { rm -f x264_config.h config.h config.mak config.log x264.pc x264.def conftest* -SRCPATH="$(cd $(dirname $0); pwd)" -[ "$SRCPATH" = "$(pwd)" ] && SRCPATH=. -[ -n "$(echo $SRCPATH | grep ' ')" ] && die "Out of tree builds are impossible with whitespace in source path." +# Construct a path to the specified directory relative to the working directory +relative_path() { + local base="${PWD%/}" + local path="$(cd "$1" >/dev/null; printf '%s/.' "${PWD%/}")" + local up='' + + while [[ $path != "$base/"* ]]; do + base="${base%/*}" + up="../$up" + done + + dirname "$up${path#"$base/"}" +} + +SRCPATH="$(relative_path "$(dirname "$0")")" +echo "$SRCPATH" | grep -q ' ' && die "Out of tree builds are impossible with whitespace in source path." [ -e "$SRCPATH/config.h" -o -e "$SRCPATH/x264_config.h" ] && die "Out of tree builds are impossible with config.h/x264_config.h in source dir." prefix='/usr/local'