aboutsummaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap')
-rwxr-xr-xbootstrap33
1 files changed, 28 insertions, 5 deletions
diff --git a/bootstrap b/bootstrap
index 6ddb872..6ac5499 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,13 +1,16 @@
#!/bin/sh
+usage="Usage: $0 [--help] [--cxx <compiler>] [--cxxflags <flags>] [<host>]"
+
cxx=g++
cxxflags=
libbutl=
+host=
while test $# -ne 0; do
case $1 in
--help)
- echo "Usage: $0 [--help] [--cxx <compiler>] [--cxxflags <flags>]" 1>&2
+ echo "$usage" 1>&2
echo "See the INSTALL file for details." 1>&2
exit 0
;;
@@ -15,6 +18,7 @@ while test $# -ne 0; do
shift
if test $# -eq 0; then
echo "error: c++ compiler executable expected after --cxx" 1>&2
+ echo "$usage" 1>&2
exit 1
fi
cxx=$1
@@ -24,6 +28,7 @@ while test $# -ne 0; do
shift
if test $# -eq 0; then
echo "error: c++ compiler flags expected after --cxxflags" 1>&2
+ echo "$usage" 1>&2
exit 1
fi
cxxflags=$1
@@ -33,6 +38,7 @@ while test $# -ne 0; do
shift
if test $# -eq 0; then
echo "error: libbutl path expected after --libbutl" 1>&2
+ echo "$usage" 1>&2
exit 1
fi
if test ! -d "$1"; then
@@ -43,12 +49,27 @@ while test $# -ne 0; do
shift
;;
*)
- echo "error: unknown option $1" 1>&2
- exit 1
+ host=$1
+ shift
;;
esac
done
+if test -z "$host"; then
+ if ! host=`./config.guess`; then
+ echo "error: unable to guess host triplet" 1>&2
+ exit 1
+ fi
+else
+ if ! chost=`./config.sub $host`; then
+ echo "error: unable to canonicalize host triplet '$host'" 1>&2
+ exit 1
+ fi
+ host=$chost
+fi
+
+echo "using $host as build2 host" 1>&2
+
# See if there is libbutl or libbutl-* in the current directory and
# one directory up.
#
@@ -79,6 +100,8 @@ if test -z "$libbutl"; then
exit 1
fi
+cppflags='-DBUILD2_HOST_TRIPLET="'$host'"'
+
src="build2/*.cxx"
src="$src build2/config/*.cxx"
src="$src build2/dist/*.cxx"
@@ -89,5 +112,5 @@ src="$src build2/test/*.cxx"
src="$src build2/install/*.cxx"
src="$src $libbutl/butl/*.cxx"
-echo $cxx -std=c++1y $cxxflags -I$libbutl -I. -o build2/b-boot $src 1>&2
-exec $cxx -std=c++1y $cxxflags -I$libbutl -I. -o build2/b-boot $src
+echo $cxx -std=c++1y -I$libbutl -I. $cppflags $cxxflags -o build2/b-boot $src 1>&2
+exec $cxx -std=c++1y -I$libbutl -I. $cppflags $cxxflags -o build2/b-boot $src