- oot)
- echo "Out of tree build"
- BUILD_PATH=$WORKSPACE/oot
- mkdir -p $BUILD_PATH
- cd $BUILD_PATH
- MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS
- ;;
-
- dist)
- echo "Distribution out of tree build"
- BUILD_PATH=`mktemp -d`
-
- # Initial configure and generate tarball
- MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" ./configure $CONF_OPTS
- $MAKE dist
-
- mkdir -p $BUILD_PATH
- cp *.tar.* $BUILD_PATH/
- cd $BUILD_PATH
-
- # Ignore level 1 of tar
- $TAR xvf *.tar.* --strip 1
-
- MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
- ;;
-
- *)
- BUILD_PATH=$WORKSPACE
- echo "Standard tree build"
- MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS
- ;;
+oot)
+ echo "Out of tree build"
+
+ # Create and enter a temporary build directory
+ builddir=$(mktemp -d)
+ cd "$builddir"
+
+ "$SRCDIR/configure" "${CONF_OPTS[@]}"
+ ;;
+
+dist)
+ echo "Distribution in-tree build"
+
+ # Run configure and generate the tar file
+ # in the source directory
+ ./configure
+ $MAKE dist
+
+ # Create and enter a temporary build directory
+ builddir=$(mktemp -d)
+ cd "$builddir"
+
+ # Extract the distribution tar in the build directory,
+ # ignore the first directory level
+ $TAR xvf "$SRCDIR"/*.tar.* --strip 1
+
+ # Build in extracted source tree
+ ./configure "${CONF_OPTS[@]}"
+ ;;
+
+oot-dist)
+ echo "Distribution out of tree build"
+
+ # Create and enter a temporary build directory
+ builddir=$(mktemp -d)
+ cd "$builddir"
+
+ # Run configure out of tree and generate the tar file
+ "$SRCDIR/configure"
+ $MAKE dist
+
+ dist_srcdir="$(mktemp -d)"
+ cd "$dist_srcdir"
+
+ # Extract the distribution tar in the new source directory,
+ # ignore the first directory level
+ $TAR xvf "$builddir"/*.tar.* --strip 1
+
+ # Create and enter a second temporary build directory
+ builddir="$(mktemp -d)"
+ cd "$builddir"
+
+ # Run configure from the extracted distribution tar,
+ # out of the source tree
+ "$dist_srcdir/configure" "${CONF_OPTS[@]}"
+ ;;
+
+*)
+ echo "Standard in-tree build"
+ ./configure "${CONF_OPTS[@]}"
+ ;;