aboutsummaryrefslogtreecommitdiff
path: root/bootstrap
blob: 6ac5499388920660e39474d6c75f0b5d7f5309d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/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" 1>&2
      echo "See the INSTALL file for details." 1>&2
      exit 0
      ;;
    --cxx)
      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
      shift
      ;;
    --cxxflags)
      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
      shift
      ;;
    --libbutl)
      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
	echo "error: libbutl directory '$1' does not exist" 1>&2
	exit 1
      fi
      libbutl=$1
      shift
      ;;
    *)
      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.
#
if test -z "$libbutl"; then
  if test -d libbutl; then
    libbutl=libbutl
  else
    libbutl=`echo libbutl-*/`
    if test ! -d "$libbutl"; then
      libbutl=
    fi
  fi
fi

if test -z "$libbutl"; then
  if test -d ../libbutl; then
    libbutl=../libbutl
  else
    libbutl=`echo ../libbutl-*/`
    if test ! -d "$libbutl"; then
      libbutl=
    fi
  fi
fi

if test -z "$libbutl"; then
  echo "error: unable to find libbutl, use --libbutl to specify its location" 1>&2
  exit 1
fi

cppflags='-DBUILD2_HOST_TRIPLET="'$host'"'

src="build2/*.cxx"
src="$src build2/config/*.cxx"
src="$src build2/dist/*.cxx"
src="$src build2/bin/*.cxx"
src="$src build2/cxx/*.cxx"
src="$src build2/cli/*.cxx"
src="$src build2/test/*.cxx"
src="$src build2/install/*.cxx"
src="$src $libbutl/butl/*.cxx"

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