Index: build_all.sh
===================================================================
--- build_all.sh	(revision 8183b3548088910ca54eb34856d948332593917c)
+++ build_all.sh	(revision 18b16433ae626911b34dc224161022372e1ae62a)
@@ -29,27 +29,7 @@
 for profile in $PROFILES; do
 	# echo "Configuring profile ${profile}"
-	if [ -f ${profile}/build.ninja ]; then
-		script -q -e /dev/null -c "ninja -C '${profile}' build.ninja" </dev/null >"${profile}/configure_output.log" 2>&1  &
-		echo "$!" >"${profile}/configure.pid"
-		continue
-	fi
 
-	# Let HelenOS config tool write out Makefile.config and config.h.
 	mkdir -p ${profile} || exit 1
-	cd ${profile} || exit 1
-	"${SOURCE_DIR}/tools/config.py" "${CONFIG_RULES}" "${CONFIG_DEFAULTS}" hands-off "${profile}" || exit 1
-	cd -
-
-
-	if [ "$profile" = 'special/abs32le' ]; then
-		cross_target='ia32'
-	else
-		cross_target=`dirname $profile`
-		if [ "$cross_target" = '.' ]; then
-			cross_target=$profile
-		fi
-	fi
-
-	script -q -e /dev/null -c "meson '${SOURCE_DIR}' '${profile}' --cross-file '${SOURCE_DIR}/meson/cross/${cross_target}'" </dev/null >"${profile}/configure_output.log" 2>&1 &
+	script -q -e /dev/null -c "cd '${profile}' && '${SOURCE_DIR}/configure.sh' '${profile}' && ninja build.ninja" </dev/null >"${profile}/configure_output.log" 2>&1  &
 	echo "$!" >"${profile}/configure.pid"
 done
@@ -79,4 +59,5 @@
 
 for profile in $PROFILES; do
+	echo
 	ninja -C ${profile} || exit 1
 done
@@ -88,5 +69,15 @@
 
 	for profile in $PROFILES; do
+		echo
 		ninja -C ${profile} image_path || exit 1
+	done
+
+	echo
+	for profile in $PROFILES; do
+		path=`cat ${profile}/image_path`
+
+		if [ ! -z "$path" ]; then
+			echo "built ${profile}/${path}"
+		fi
 	done
 else
Index: configure.sh
===================================================================
--- configure.sh	(revision 18b16433ae626911b34dc224161022372e1ae62a)
+++ configure.sh	(revision 18b16433ae626911b34dc224161022372e1ae62a)
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+# Find out the path to the script.
+SOURCE_DIR=`which -- "$0" 2>/dev/null`
+# Maybe we are running bash.
+[ -z "$SOURCE_DIR" ] && SOURCE_DIR=`which -- "$BASH_SOURCE"`
+[ -z "$SOURCE_DIR" ] && exit 1
+SOURCE_DIR=`dirname -- "$SOURCE_DIR"`
+SOURCE_DIR=`cd $SOURCE_DIR && echo $PWD`
+
+CONFIG_RULES="${SOURCE_DIR}/HelenOS.config"
+CONFIG_DEFAULTS="${SOURCE_DIR}/defaults"
+
+
+test "$#" -eq 1 && { test "$1" = "-h" || test "$1" = "--help"; }
+want_help="$?"
+
+if [ "$#" -gt 1 ] || [ "$want_help" -eq 0 ]; then
+
+	# Find all the leaf subdirectories in the defaults directory.
+	PROFILES=`find ${CONFIG_DEFAULTS} -type d -links 2 -printf "%P\n" | sort`
+
+	echo "Configures the current working directory as a HelenOS build directory."
+	echo "In-tree build is not supported, you must create a separate directory for build."
+	echo
+	echo "Usage:"
+	echo "	$0 -h|--help"
+	echo "	$0 [PROFILE]"
+	echo
+	echo "If profile is not specified, a graphical configuration utility is launched."
+	echo
+	echo "Possible profiles:"
+	printf "\t%s\n" $PROFILES
+
+	exit "$want_help"
+fi
+
+if [ "$PWD" = "$SOURCE_DIR" ]; then
+	echo "We don't support in-tree build."
+	echo "Please create a build directory, cd into it, and run this script from there."
+	echo "Or run \`$0 --help\` to see usage."
+	exit 1
+fi
+
+ninja_help() {
+	echo 'Run  `ninja config`      to adjust configuration.'
+	echo 'Run  `ninja`             to build all program and library binaries, but not bootable image.'
+	echo 'Run  `ninja image_path`  to build boot image. The file image_path will contain path to the boot image file.'
+}
+
+if [ -f build.ninja ]; then
+	echo "This build directory was already configured."
+	echo
+	ninja_help
+	exit 0
+fi
+
+# Run HelenOS config tool.
+if [ "$#" -eq 1 ]; then
+	"${SOURCE_DIR}/tools/config.py" "${CONFIG_RULES}" "${CONFIG_DEFAULTS}" hands-off "$1" || exit 1
+else
+	"${SOURCE_DIR}/tools/config.py" "${CONFIG_RULES}" "${CONFIG_DEFAULTS}" || exit 1
+fi
+
+PLATFORM=`sed -n '/^PLATFORM\b/p' Makefile.config | sed 's:[^=]*= ::'`
+MACHINE=`sed -n '/^MACHINE\b/p' Makefile.config | sed 's:[^=]*= ::'`
+
+cross_target="$PLATFORM"
+if [ "$PLATFORM" = 'abs32le' ]; then
+	cross_target='ia32'
+fi
+if [ "$MACHINE" = 'bmalta' ]; then
+	cross_target='mips32eb'
+fi
+
+meson "${SOURCE_DIR}" '.' --cross-file "${SOURCE_DIR}/meson/cross/${cross_target}" || exit 1
+
+echo
+echo "Configuration for platform $PLATFORM finished."
+echo
+ninja_help
Index: meson.build
===================================================================
--- meson.build	(revision 8183b3548088910ca54eb34856d948332593917c)
+++ meson.build	(revision 18b16433ae626911b34dc224161022372e1ae62a)
@@ -538,2 +538,5 @@
 	)
 endif
+
+
+# TODO: ninja config
