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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
#!/bin/sh
#
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# A shell script used to configure the host-specific parts of the NDK
# build system. This will create out/host/config-host.make based on
# your host system and additionnal command-line options.
#
# check that this script is run from the top-level NDK directory
if [ ! -f build/core/ndk-common.sh ] ; then
echo "Please run this script from the top-level NDK directory as in:"
echo " cd \$NDKROOT"
echo " build/host-setup.sh"
exit 1
fi
# include common function and variable definitions
. `dirname $0`/core/ndk-common.sh
OUT_DIR=out
HOST_CONFIG=$OUT_DIR/host/config.mk
## Build configuration file support
## you must define $config_mk before calling this function
##
create_config_mk ()
{
# create the directory if needed
local config_dir
config_mk=${config_mk:-$HOST_CONFIG}
config_dir=`dirname $config_mk`
mkdir -p $config_dir 2> $TMPL
if [ $? != 0 ] ; then
echo "Can't create directory for host config file: $config_dir"
exit 1
fi
# re-create the start of the configuration file
log "Generate : $config_mk"
echo "# This file was autogenerated by $PROGNAME. Do not edit !" > $config_mk
}
add_config ()
{
echo "$1" >> $config_mk
}
# assume $1 points to a GNU Make executable, and extract version number
# to verify its a least what we need
check_gnu_make_version ()
{
if [ -n "$GNU_MAKE" ] ; then
return
fi
log2 " looking for GNU Make as '$1'"
local executable=`which $1`
if [ -z "$executable" ] ; then
log2 " Not available."
return
fi
# I'd love to do the version extraction with awk, but I'm unsure it is
# part of the default Cygwin install, so don't bring the dependency
# and rely on dumb tools instead.
#
local version major minor
version=`$executable --version | grep "GNU Make"`
if [ -z "$version" ] ; then
log2 " Not a GNU Make executable."
return
fi
version=`echo $version | sed -e 's/^GNU Make \([0-9\.]*\).*$/\1/g'`
log2 " Found version $version"
major=`echo $version | sed -e 's/\([0-9]*\)\..*/\1/g'`
minor=`echo $version | sed -e 's/[0-9]*\.\(.*\)/\1/g'`
if [ "$major" -lt "3" ] ; then
log2 " Major version too small ($major.$minor < 3.81)."
return
fi
if [ "$major" -eq "3" -a $minor -lt 80 ] ; then
log2 " Minor version too small ($major.$minor < 3.81)."
return
fi
GNU_MAKE=$1
GNU_MAKE_VERSION=$version
}
# check that $1 points to an awk executable that has a working
# match() function. This really means Nawk or GNU Awk, which should
# be installed on all modern distributions, but hey, you never know...
check_awk ()
{
if [ -n "$AWK" ] ; then
return
fi
log2 " looking for nawk/gawk as '$1'"
local executable=`which $1`
if [ -z "$executable" ] ; then
log2 " Not available."
return
fi
local result
result=`echo "" | $executable -f build/check-awk.awk`
if [ "$result" = "Pass" ] ; then
AWK="$1"
fi
log2 " Check $result"
}
bad_toolchain()
{
tc=$1 # Toolchain
ht=$2 # Host Tag
echo ""
echo "ERROR: Toolchain compiler not found"
echo "It seems you do not have the correct $tc toolchain binaries."
echo "This may be the result of incorrect unzipping of the NDK archive."
echo "Please go to the official Android NDK web site and download the"
echo "appropriate NDK package for your platform ($ht)."
echo "See http://developer.android.com/sdk/index.html"
echo ""
echo "ABORTING."
echo ""
}
OPTION_HELP=no
OPTION_NO_MAKE_CHECK=no
OPTION_NO_AWK_CHECK=no
for opt do
optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
case "$opt" in
--help|-h|-\?) OPTION_HELP=yes
;;
--no-make-check) OPTION_NO_MAKE_CHECK=yes
;;
--no-awk-check) OPTION_NO_AWK_CHECK=yes
;;
--verbose)
if [ "$VERBOSE" = "yes" ] ; then
VERBOSE2=yes
else
VERBOSE=yes
fi
;;
*)
echo "unknown option '$opt', use --help"
exit 1
esac
done
if [ $OPTION_HELP = yes ] ; then
echo "Usage: build/host-setup.sh [options]"
echo ""
echo "This script is used to check your host development environment"
echo "to ensure that the Android NDK will work correctly with it."
echo ""
echo "Options: [defaults in brackets after descriptions]"
echo ""
echo " --help Print this help message"
echo " --verbose Enable verbose mode"
echo " --no-make-check Ignore GNU Make version check"
echo " --no-awk-check Ignore Nawk/Gawk check"
echo ""
exit 1
fi
echo "Checking host development environment."
echo "NDK Root : $ANDROID_NDK_ROOT"
## Check for GNU Make with a proper version number
##
if [ "$OPTION_NO_MAKE_CHECK" = "no" ] ; then
GNU_MAKE=
check_gnu_make_version make
check_gnu_make_version gmake
if [ -z "$GNU_MAKE" ] ; then
echo "ERROR: Could not find a valid GNU Make executable."
echo " Please ensure GNU Make 3.81 or later is installed."
echo " Use the --no-make-check option to ignore this message."
exit 1
fi
echo "GNU Make : $GNU_MAKE (version $GNU_MAKE_VERSION)"
else
echo "GNU Make : Check ignored through user option."
fi
## Check for nawk or gawk, straight awk doesn't have the 'match'
## function we need in the build system.
##
if [ "$OPTION_NO_AWK_CHECK" = "no" ] ; then
AWK=
check_awk awk
check_awk gawk
check_awk nawk
if [ -z "$AWK" ] ; then
echo "ERROR: Could not find a valid Nawk or Gawk executable."
echo " Please ensure that either one of them is installed."
echo " Use the --no-awk-check option to ignore this message."
exit 1
fi
echo "Awk : $AWK"
else
echo "Awk : Check ignored through user option."
fi
## Check the host platform tag that will be used to locate prebuilt
## toolchain binaries. And create configuration file.
##
force_32bit_binaries
echo "Platform : $HOST_TAG"
create_config_mk
add_config "HOST_OS := $HOST_OS"
add_config "HOST_ARCH := $HOST_ARCH"
add_config "HOST_TAG := $HOST_TAG"
add_config "HOST_AWK := $AWK"
## Determine which toolchains are installed and verify their integrity.
## Otherwise, instruct the user to download them from the web site
TOOLCHAINS=`ls build/prebuilt/$HOST_TAG`
if [ -z "$TOOLCHAINS" ]; then
bad_toolchain NONE_FOUND $HOST_TAG
exit 1
fi
for tc in $TOOLCHAINS; do
echo "Toolchain : Checking for $tc prebuilt binaries"
PREBUILT_BIN=build/prebuilt/$HOST_TAG/$tc/bin
log2 "Toolchain : Cross-compiler in <NDK>/$PREBUILT_BIN ?"
COMPILER_PATTERN=$ANDROID_NDK_ROOT/$PREBUILT_BIN/*-gcc$HOST_EXE
COMPILERS=`ls $COMPILER_PATTERN 2> /dev/null`
if [ -z $COMPILERS ] ; then
bad_toolchain $tc $HOST_TAG
exit 1
fi
done
echo ""
echo "Host setup complete. Please read docs/OVERVIEW.TXT if you don't know what to do."
echo ""
|