yann@182
|
1 |
#!/bin/sh
|
yann@182
|
2 |
|
yann@1311
|
3 |
myname="${0##*/}"
|
yann@1311
|
4 |
|
yann@1105
|
5 |
VERSION=$( cat .version )
|
yann@1105
|
6 |
DATE=$( date +%Y%m%d )
|
yann@182
|
7 |
|
yann@183
|
8 |
PREFIX_DEFAULT=/usr/local
|
yann@182
|
9 |
|
yann@182
|
10 |
BINDIR_set=
|
yann@182
|
11 |
LIBDIR_set=
|
yann@182
|
12 |
DOCDIR_set=
|
yann@182
|
13 |
MANDIR_set=
|
yann@2621
|
14 |
PROG_PFX=
|
yann@2622
|
15 |
PROG_SFX=
|
yann@2623
|
16 |
PROG_SED=
|
yann@285
|
17 |
LOCAL_set=
|
yann@1311
|
18 |
FORCE=
|
yann@182
|
19 |
|
yann@641
|
20 |
do_quit=
|
yann@614
|
21 |
|
yann@673
|
22 |
# Simply print the error message, and exit. Obvious, he?
|
yann@673
|
23 |
do_error() {
|
yann@1333
|
24 |
printf "${myname}: ${@}\n"
|
yann@673
|
25 |
exit 1
|
yann@673
|
26 |
}
|
yann@673
|
27 |
|
yann@641
|
28 |
# Given an option string and the following argument,
|
yann@641
|
29 |
# echoes the value of the option.
|
yann@641
|
30 |
# If --var=val => echoes val and returns 0, meaning second arg was not consumed
|
yann@641
|
31 |
# If --var val => echoes val and returns non null, meaning second arg was used
|
yann@182
|
32 |
get_optval(){
|
yann@182
|
33 |
case "$1" in
|
yann@182
|
34 |
--*=?*)
|
yann@1333
|
35 |
printf "${1#*=}"
|
yann@1105
|
36 |
return 0
|
yann@182
|
37 |
;;
|
yann@182
|
38 |
*)
|
yann@1333
|
39 |
printf "${2}"
|
yann@1105
|
40 |
return 1
|
yann@182
|
41 |
;;
|
yann@182
|
42 |
esac
|
yann@182
|
43 |
}
|
yann@182
|
44 |
|
yann@641
|
45 |
# The set_xxx functions will set the corresponding configuration variable
|
yann@641
|
46 |
# They return 0 if second arg was not consumed, and non-zero if it was consumed.
|
yann@182
|
47 |
set_prefix() {
|
yann@1105
|
48 |
PREFIX="$( get_optval "$1" "$2" )"
|
yann@182
|
49 |
}
|
yann@182
|
50 |
set_bindir() {
|
yann@376
|
51 |
BINDIR_set=1
|
yann@1105
|
52 |
BINDIR="$( get_optval "$1" "$2" )"
|
yann@182
|
53 |
}
|
yann@182
|
54 |
set_libdir() {
|
yann@376
|
55 |
LIBDIR_set=1
|
yann@1105
|
56 |
LIBDIR="$( get_optval "$1" "$2" )"
|
yann@182
|
57 |
}
|
yann@182
|
58 |
set_docdir() {
|
yann@376
|
59 |
DOCDIR_set=1
|
yann@1105
|
60 |
DOCDIR="$( get_optval "$1" "$2" )"
|
yann@182
|
61 |
}
|
yann@182
|
62 |
set_mandir() {
|
yann@376
|
63 |
MANDIR_set=1
|
yann@1105
|
64 |
MANDIR="$( get_optval "$1" "$2" )"
|
yann@182
|
65 |
}
|
yann@2621
|
66 |
set_program_prefix() {
|
yann@2621
|
67 |
PROG_PFX="$( get_optval "$1" "$2" )"
|
yann@2621
|
68 |
}
|
yann@2622
|
69 |
set_program_suffix() {
|
yann@2622
|
70 |
PROG_SFX="$( get_optval "$1" "$2" )"
|
yann@2622
|
71 |
}
|
yann@2623
|
72 |
set_program_transform_name() {
|
yann@2623
|
73 |
PROG_SED="$( get_optval "$1" "$2" )"
|
yann@2623
|
74 |
}
|
yann@1140
|
75 |
set_tool() {
|
yann@1140
|
76 |
local var_name="${1%%=*}"
|
yann@1140
|
77 |
var_name="${var_name#--with-}"
|
yann@1140
|
78 |
eval ${var_name}="\$( get_optval "$1" "$2" )"
|
yann@614
|
79 |
}
|
yann@614
|
80 |
|
yann@1311
|
81 |
# var_list is a list of variables, each one holding a path to a
|
yann@1311
|
82 |
# tool, either detected by ./configure, or specified by the user.
|
yann@1311
|
83 |
var_list=""
|
yann@2481
|
84 |
kconfig_list=""
|
yann@1311
|
85 |
|
yann@1311
|
86 |
# This function adds a variable name to the above list of variable names.
|
yann@1311
|
87 |
# $1: the name of the variable to add to the list
|
yann@1311
|
88 |
add_to_var_list() {
|
yann@2481
|
89 |
local v
|
yann@2481
|
90 |
for v in ${var_list}; do
|
yann@2481
|
91 |
[ "${v}" = "${1}" ] && return 0
|
yann@2481
|
92 |
done
|
yann@1311
|
93 |
var_list="${var_list} ${1}"
|
yann@1311
|
94 |
}
|
yann@2481
|
95 |
add_to_kconfig_list() {
|
yann@2481
|
96 |
local k
|
yann@2481
|
97 |
for k in ${kconfig_list}; do
|
yann@2481
|
98 |
[ "${k}" = "${1}" ] && return 0
|
yann@2481
|
99 |
done
|
yann@2481
|
100 |
kconfig_list="${kconfig_list} ${1}"
|
yann@2481
|
101 |
}
|
yann@1311
|
102 |
|
yann@1311
|
103 |
# A function to test for required tools/headers/libraries
|
yann@1560
|
104 |
# Return 0 (true) if found, !0 (false) if not found
|
yann@1560
|
105 |
#
|
yann@1311
|
106 |
# $*: [prog|inc|lib]=<name[ name...]>
|
yann@1311
|
107 |
# the name(s) of tool(s) to test for
|
yann@1311
|
108 |
# mandatory
|
yann@1311
|
109 |
# eg: prog=bash prog="curl wget"
|
yann@1311
|
110 |
# $*: var=<var_name>
|
yann@1311
|
111 |
# the name of the variable to test and set
|
yann@1311
|
112 |
# optional
|
yann@1311
|
113 |
# eg: var=bash if ${bash} is set and non-null, use that,
|
yann@1311
|
114 |
# else check for bash and set bash=$(which bash)
|
yann@1311
|
115 |
# $*: ver=<regexp>
|
yann@1311
|
116 |
# for each 'prog', test if $(prog --version) matches 'regexp'
|
yann@1311
|
117 |
# optional
|
yann@1311
|
118 |
# eg: ver='^GNU bash, version [34]\.'
|
yann@2527
|
119 |
# $*: lib_exts=<extension[ extension...]>
|
yann@2527
|
120 |
# the list of allowed library extension
|
yann@2527
|
121 |
# mandatory
|
yann@2527
|
122 |
# eg: lib_exts="so dylib" lib_exts="so dylib a"
|
yann@1311
|
123 |
# $*: err=<error_message>
|
yann@1311
|
124 |
# the error message to print if tool is missing
|
yann@1311
|
125 |
# optional, defaults to: '${prog}: none found'
|
yann@1311
|
126 |
# eg: err="'bash' 3.x or above was not found"
|
yann@2480
|
127 |
# Note: err may be printed by caller, not us
|
yann@2481
|
128 |
# $*: kconfig=<var_name>
|
yann@2481
|
129 |
# the name of a variable to pass down to kconfig if
|
yann@2481
|
130 |
# the prog/inc/lib was found
|
yann@2481
|
131 |
# optional, defaults to none
|
yann@2481
|
132 |
# eg: kconfig=has_libncurses
|
yann@2528
|
133 |
# $*: skip=[y|n|]
|
yann@2528
|
134 |
# if set to 'y', skip the test, but still register the
|
yann@2528
|
135 |
# kconfig and var variables; if 'n' or empty, do the
|
yann@2528
|
136 |
# test.
|
yann@2528
|
137 |
# optional, default to 'n'
|
yann@2528
|
138 |
# eg: skip="${static_link_ko}"
|
yann@1560
|
139 |
check_for() {
|
yann@2527
|
140 |
local lib_exts
|
yann@2528
|
141 |
local skip
|
yann@1311
|
142 |
local val
|
yann@1311
|
143 |
local item
|
yann@1311
|
144 |
local where
|
yann@1312
|
145 |
local status
|
yann@2527
|
146 |
local ext
|
yann@1311
|
147 |
|
yann@2481
|
148 |
# Note: prog/inc/lib and var/kconfig/ver/err are set here,
|
yann@2479
|
149 |
# but declared by the caller (because it needs it)
|
yann@1311
|
150 |
for item in "${@}"; do
|
yann@1311
|
151 |
case "${item}" in
|
yann@2528
|
152 |
prog=*|inc=*|lib=*|var=*|ver=*|err=*|kconfig=*|lib_exts=*|skip=*)
|
yann@2497
|
153 |
eval ${item%%=*}=\"${item#*=}\"
|
yann@1311
|
154 |
;;
|
yann@2527
|
155 |
*) do_error "check_for: incorrect parameters: '${item}'";;
|
yann@1311
|
156 |
esac
|
yann@1311
|
157 |
done
|
yann@1311
|
158 |
|
benoit@2507
|
159 |
case "${prog}:${inc}:${lib}" in
|
benoit@2507
|
160 |
?*:?*:|?*::?*|:?*:?*|?*:?*:?*)
|
benoit@2507
|
161 |
if [ -n "${var}" ]; then
|
benoit@2507
|
162 |
do_error "check_for: the use of var is not compatible with passing several of [prog|inc|lib] at once"
|
benoit@2507
|
163 |
fi
|
benoit@2507
|
164 |
;;
|
benoit@2507
|
165 |
::) do_error "check_for: [prog|inc|lib] is mandatory";;
|
benoit@2507
|
166 |
esac
|
benoit@2507
|
167 |
|
yann@2528
|
168 |
if [ -n "${var}" ]; then
|
yann@2528
|
169 |
add_to_var_list "${var}"
|
yann@2528
|
170 |
fi
|
yann@2481
|
171 |
if [ -n "${kconfig}" ]; then
|
yann@2481
|
172 |
add_to_kconfig_list "${kconfig}"
|
yann@2481
|
173 |
fi
|
yann@2481
|
174 |
|
yann@2528
|
175 |
if [ "${skip}" = "y" ]; then
|
yann@2528
|
176 |
return 0
|
yann@2528
|
177 |
fi
|
yann@2528
|
178 |
|
benoit@2507
|
179 |
if [ -n "${prog}" ]; then
|
benoit@2507
|
180 |
for item in ${prog}; do
|
benoit@2507
|
181 |
printf "Checking for '${item}'... "
|
benoit@2507
|
182 |
if [ -n "${var}" ]; then
|
benoit@2507
|
183 |
eval val="\${${var}}"
|
benoit@2507
|
184 |
if [ -n "${val}" ]; then
|
yann@2528
|
185 |
status="${val} (cached)\n"
|
titus@2625
|
186 |
where="${val}"
|
yann@2528
|
187 |
break
|
yann@1311
|
188 |
fi
|
benoit@2507
|
189 |
fi
|
benoit@2507
|
190 |
where="$( which "${item}" 2>/dev/null )"
|
benoit@2507
|
191 |
if [ -z "${where}" ]; then
|
benoit@2507
|
192 |
printf "no\n"
|
benoit@2507
|
193 |
continue
|
benoit@2507
|
194 |
elif [ -n "${ver}" ]; then
|
benoit@2507
|
195 |
str=$( LC_ALL=C "${where}" --version 2>&1 \
|
benoit@2507
|
196 |
|grep -E "${ver}" \
|
benoit@2507
|
197 |
|head -n 1
|
benoit@2507
|
198 |
)
|
benoit@2507
|
199 |
if [ -z "${str}" ]; then
|
yann@1312
|
200 |
printf "no\n"
|
benoit@2507
|
201 |
unset where
|
yann@1311
|
202 |
continue
|
yann@1311
|
203 |
fi
|
benoit@2507
|
204 |
fi
|
benoit@2507
|
205 |
status="${where}"
|
benoit@2507
|
206 |
break
|
benoit@2507
|
207 |
done
|
benoit@2507
|
208 |
if [ -z "${status}" ]; then
|
benoit@2507
|
209 |
return 1
|
benoit@2507
|
210 |
fi
|
benoit@2507
|
211 |
printf "${status}\n"
|
benoit@2507
|
212 |
unset status
|
yann@1560
|
213 |
fi
|
yann@1560
|
214 |
|
benoit@2507
|
215 |
if [ -n "${inc}" ]; then
|
benoit@2507
|
216 |
for item in ${inc}; do
|
benoit@2507
|
217 |
printf "Checking for '${item}'... "
|
benoit@2507
|
218 |
if printf "#include \"${item}\"" |gcc -x c -c - -o /dev/null >/dev/null 2>&1; then
|
benoit@2507
|
219 |
where="${item}"
|
benoit@2507
|
220 |
status=yes
|
benoit@2507
|
221 |
break;
|
benoit@2507
|
222 |
fi
|
benoit@2507
|
223 |
printf "no\n"
|
benoit@2507
|
224 |
done
|
benoit@2507
|
225 |
if [ -z "${status}" ]; then
|
benoit@2507
|
226 |
return 1
|
benoit@2507
|
227 |
fi
|
benoit@2507
|
228 |
printf "${status}\n"
|
benoit@2507
|
229 |
unset status
|
benoit@2507
|
230 |
fi
|
benoit@2507
|
231 |
|
benoit@2507
|
232 |
if [ -n "${lib}" ]; then
|
yann@2527
|
233 |
if [ -z "${lib_exts}" ]; then
|
yann@2527
|
234 |
do_error "check_for: no library extension specified for '${lib}'"
|
yann@2527
|
235 |
fi
|
benoit@2507
|
236 |
for item in ${lib}; do
|
yann@2527
|
237 |
for ext in ${lib_exts}; do
|
yann@2527
|
238 |
printf "Checking for '${item}.${ext}'... "
|
yann@2527
|
239 |
where="$( gcc -print-file-name="${item}.${ext}" )"
|
yann@2527
|
240 |
if [ "${where}" != "${item}.${ext}" ]; then
|
yann@2527
|
241 |
where="$( readlink "${where}" )"
|
yann@2527
|
242 |
status=yes
|
yann@2527
|
243 |
break 2;
|
yann@2527
|
244 |
fi
|
yann@2527
|
245 |
printf "no\n"
|
yann@2527
|
246 |
done
|
benoit@2507
|
247 |
done
|
benoit@2507
|
248 |
if [ -z "${status}" ]; then
|
benoit@2507
|
249 |
return 1
|
benoit@2507
|
250 |
fi
|
benoit@2507
|
251 |
printf "${status}\n"
|
benoit@2507
|
252 |
unset status
|
benoit@2507
|
253 |
fi
|
benoit@2507
|
254 |
|
yann@1560
|
255 |
if [ -n "${var}" ]; then
|
yann@1560
|
256 |
eval ${var}='"'"${where}"'"'
|
yann@1560
|
257 |
fi
|
yann@2481
|
258 |
if [ -n "${kconfig}" ]; then
|
yann@2481
|
259 |
eval ${kconfig}=y
|
yann@2481
|
260 |
fi
|
yann@1560
|
261 |
}
|
yann@1560
|
262 |
|
yann@1560
|
263 |
# This function checks for a tool, and aborts if not found
|
yann@1560
|
264 |
# See check_for(), above, for how to call has_or_abort
|
yann@1560
|
265 |
has_or_abort() {
|
yann@2479
|
266 |
# We declare these 6 variables here, although they are
|
yann@2479
|
267 |
# set in check_for(), called below
|
yann@2479
|
268 |
local prog inc lib
|
yann@2481
|
269 |
local var ver err kconfig
|
yann@2479
|
270 |
|
yann@1560
|
271 |
if ! check_for "$@"; then
|
yann@2524
|
272 |
printf " * A mandatory dependency is missing, or version mis-match:\n"
|
yann@2524
|
273 |
printf " * - ${err:-${prog}${inc}${lib}: none found}\n"
|
yann@2479
|
274 |
if [ -n "${var}" ]; then
|
yann@2498
|
275 |
printf " * --> You can give the path to this tool using: --with-${var}=PATH\n"
|
yann@2479
|
276 |
fi
|
yann@2479
|
277 |
printf "\n"
|
yann@2479
|
278 |
# Bail out if --force is not specified
|
yann@1312
|
279 |
[ -z "${FORCE}" ] && do_error "Bailing out..."
|
yann@1312
|
280 |
printf "<* *>\n"
|
yann@1312
|
281 |
printf "<* FORCE in action: *>\n"
|
yann@1312
|
282 |
printf "<* Continuing despite missing pre-requisite *>\n"
|
yann@1312
|
283 |
printf "<* Prepare for breakage *>\n"
|
yann@1312
|
284 |
printf "<* *>\n"
|
yann@1312
|
285 |
printf "\n"
|
yann@1312
|
286 |
fi
|
yann@1311
|
287 |
}
|
yann@1311
|
288 |
|
yann@2480
|
289 |
# This function checks for a tool, and warns if not found
|
yann@2480
|
290 |
# See check_for(), above, for how to call has_or_abort
|
yann@2480
|
291 |
# Note: if err is not set, then no error message is printed
|
yann@2480
|
292 |
has_or_warn() {
|
yann@2480
|
293 |
# We declare these 6 variables here, although they are
|
yann@2480
|
294 |
# set in check_for(), called below
|
yann@2480
|
295 |
local prog inc lib
|
yann@2481
|
296 |
local var ver err kconfig
|
yann@2480
|
297 |
|
yann@2480
|
298 |
if ! check_for "$@"; then
|
yann@2524
|
299 |
printf " * An optional dependency is missing, some features will be disabled"
|
yann@2524
|
300 |
printf "${err:+:\n * - ${err}}\n"
|
yann@2480
|
301 |
if [ -n "${var}" ]; then
|
yann@2498
|
302 |
printf " * --> You can give the path to this tool using: --with-${var}=PATH\n"
|
yann@2480
|
303 |
fi
|
yann@2480
|
304 |
fi
|
yann@2480
|
305 |
}
|
yann@2480
|
306 |
|
yann@183
|
307 |
do_help() {
|
yann@183
|
308 |
cat <<__EOF__
|
yann@1140
|
309 |
\`configure' configures crosstool-NG-${VERSION} to adapt to many kind of systems.
|
yann@183
|
310 |
|
yann@183
|
311 |
USAGE: ./configure [OPTION]...
|
yann@183
|
312 |
|
yann@183
|
313 |
Defaults for the options are specified in brackets.
|
yann@183
|
314 |
|
yann@183
|
315 |
Configuration:
|
yann@1105
|
316 |
-h, --help display this help and exit
|
yann@1311
|
317 |
--force force configure to continue, even in case
|
yann@1311
|
318 |
some pre-requisites are missing
|
yann@615
|
319 |
|
yann@615
|
320 |
Installation directories:
|
yann@185
|
321 |
--prefix=PREFIX install files in PREFIX [${PREFIX_DEFAULT}]
|
yann@285
|
322 |
--local don't install, and use current directory
|
yann@183
|
323 |
|
yann@183
|
324 |
By default, \`make install' will install all the files in
|
yann@183
|
325 |
\`${PREFIX_DEFAULT}/bin', \`${PREFIX_DEFAULT}/lib' etc. You can specify
|
yann@183
|
326 |
an installation prefix other than \`${PREFIX_DEFAULT}' using \`--prefix',
|
yann@183
|
327 |
for instance \`--prefix=\${HOME}'.
|
yann@183
|
328 |
|
yann@183
|
329 |
For better control, use the options below.
|
yann@2619
|
330 |
Note: options marked as \`ignored' are recognised, but not acted upon, as
|
yann@2619
|
331 |
they make no sense for crosstool-NG, or they are not implemented yet.
|
yann@183
|
332 |
|
yann@183
|
333 |
Fine tuning of the installation directories:
|
yann@683
|
334 |
--bindir=DIR user executables [PREFIX/bin]
|
yann@683
|
335 |
--libdir=DIR object code libraries [PREFIX/lib]
|
yann@683
|
336 |
--docdir=DIR info documentation [PREFIX/share/doc]
|
yann@683
|
337 |
--mandir=DIR man documentation [PREFIX/share/man]
|
yann@2619
|
338 |
--infodir=DIR info documentation [DATAROOTDIR/info] (ignored)
|
yann@2619
|
339 |
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
|
yann@2619
|
340 |
(ignored)
|
yann@2619
|
341 |
--sysconfdir=DIR read-only single-machine data [PREFIX/etc] (ignored)
|
yann@2619
|
342 |
--localstatedir=DIR modifiable single-machine data [PREFIX/var] (ignored)
|
yann@2619
|
343 |
|
yann@2619
|
344 |
Program names:
|
yann@2619
|
345 |
--program-prefix=PREFIX prepend PREFIX to installed program names
|
yann@2622
|
346 |
--program-suffix=SUFFIX append SUFFIX to installed program names
|
yann@2623
|
347 |
--program-transform-name=PROGRAM run sed PROGRAM on installed program names
|
yann@2619
|
348 |
|
yann@2619
|
349 |
System types:
|
yann@2619
|
350 |
--build=BUILD configure for building on BUILD [guessed] (ignored)
|
yann@2619
|
351 |
--host=HOST cross-compile to build programs to run on HOST [BUILD]
|
yann@2619
|
352 |
(ignored)
|
yann@614
|
353 |
|
yann@614
|
354 |
Optional Features:
|
yann@2619
|
355 |
--enable-shared[=PKGS] build shared libraries [default=yes] (ignored)
|
yann@2619
|
356 |
--enable-static[=PKGS] build static libraries [default=yes] (ignored)
|
yann@2619
|
357 |
|
yann@2619
|
358 |
Optional Packages:
|
yann@1140
|
359 |
--with-install=PATH Specify the full PATH to GNU install
|
yann@1311
|
360 |
--with-make=PATH Specify the full PATH to GNU make >= 3.80
|
yann@1140
|
361 |
--with-grep=PATH Specify the full PATH to GNU grep
|
yann@1140
|
362 |
--with-sed=PATH Specify the full PATH to GNU sed
|
yann@1140
|
363 |
--with-bash=PATH Specify the full PATH to bash >= 3.0
|
yann@183
|
364 |
__EOF__
|
yann@183
|
365 |
}
|
yann@183
|
366 |
|
yann@376
|
367 |
#---------------------------------------------------------------------
|
yann@376
|
368 |
# Set user's options
|
yann@376
|
369 |
|
yann@182
|
370 |
while [ $# -ne 0 ]; do
|
yann@182
|
371 |
case "$1" in
|
yann@1297
|
372 |
--local) LOCAL_set="y"; shift;;
|
yann@182
|
373 |
--prefix*) set_prefix "$1" "$2" && shift || shift 2;;
|
yann@182
|
374 |
--bindir*) set_bindir "$1" "$2" && shift || shift 2;;
|
yann@182
|
375 |
--libdir*) set_libdir "$1" "$2" && shift || shift 2;;
|
yann@182
|
376 |
--docdir*) set_docdir "$1" "$2" && shift || shift 2;;
|
yann@182
|
377 |
--mandir*) set_mandir "$1" "$2" && shift || shift 2;;
|
yann@1140
|
378 |
--with-*) set_tool "$1" "$2" && shift || shift 2;;
|
yann@2621
|
379 |
--program-prefix=*|--program-prefix)
|
yann@2621
|
380 |
set_program_prefix "$1" "$2" && shift || shift 2
|
yann@2621
|
381 |
;;
|
yann@2622
|
382 |
--program-suffix=*|--program-suffix)
|
yann@2622
|
383 |
set_program_suffix "$1" "$2" && shift || shift 2
|
yann@2622
|
384 |
;;
|
yann@2623
|
385 |
--program-transform-name=*|--program-transform-name)
|
yann@2623
|
386 |
set_program_transform_name "$1" "$2" && shift || shift 2
|
yann@2623
|
387 |
;;
|
yann@1311
|
388 |
--force) FORCE=1; shift;;
|
yann@183
|
389 |
--help|-h) do_help; exit 0;;
|
blueness@1739
|
390 |
# Skip, auto-stuff compatibility
|
blueness@1739
|
391 |
--build=*|--host=*|--infodir=*|--datadir=*|--sysconfdir=*|--localstatedir=*) shift;;
|
blueness@1739
|
392 |
--build|--host|--infodir|--datadir|--sysconfdir|--localstatedir) shift 2;;
|
yann@2551
|
393 |
--enable-shared|--disable-shared|--enable-static|--disable-static) shift;;
|
yann@1333
|
394 |
*) printf "Unrecognised option: '${1}'\n"; do_help; exit 1;;
|
yann@182
|
395 |
esac
|
yann@182
|
396 |
done
|
yann@182
|
397 |
|
yann@641
|
398 |
# Use defaults
|
yann@185
|
399 |
[ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
|
yann@641
|
400 |
|
yann@641
|
401 |
# Special case when installing locally
|
yann@1297
|
402 |
if [ "${LOCAL_set}" = "y" ]; then
|
yann@1105
|
403 |
set_prefix "" "$( pwd )"
|
yann@1105
|
404 |
set_bindir "" "$( pwd )"
|
yann@1105
|
405 |
set_libdir "" "$( pwd )"
|
yann@1105
|
406 |
set_docdir "" "$( pwd )/docs"
|
yann@1105
|
407 |
set_mandir "" "$( pwd )/docs"
|
yann@2621
|
408 |
set_program_prefix "" ""
|
yann@2622
|
409 |
set_program_suffix "" ""
|
yann@2623
|
410 |
set_program_transform_name "" ""
|
yann@285
|
411 |
fi
|
yann@183
|
412 |
|
yann@376
|
413 |
#---------------------------------------------------------------------
|
yann@1140
|
414 |
# Some sanity checks, now
|
yann@1106
|
415 |
|
yann@1560
|
416 |
# We check for grep and sed manually, because they are used in check_for()
|
yann@1140
|
417 |
printf "Checking for 'grep'... "
|
yann@1140
|
418 |
if [ -n "${grep}" ]; then
|
yann@1333
|
419 |
printf "${grep} (cached)\n"
|
yann@1140
|
420 |
else
|
yann@1140
|
421 |
grep="$( which grep 2>/dev/null )"
|
yann@1187
|
422 |
if [ -z "${grep}" ]; then
|
yann@1333
|
423 |
printf "not found\n"
|
yann@1187
|
424 |
else
|
yann@1333
|
425 |
printf "${grep}\n"
|
yann@1187
|
426 |
printf "Checking whether '${grep}' supports -E... "
|
yann@1187
|
427 |
if echo 'foo' |"${grep}" -E 'foo' >/dev/null 2>&1; then
|
yann@1333
|
428 |
printf "yes\n"
|
yann@1187
|
429 |
else
|
yann@1333
|
430 |
printf "no\n"
|
yann@1187
|
431 |
grep=
|
yann@1187
|
432 |
fi
|
yann@1187
|
433 |
fi
|
yann@1106
|
434 |
fi
|
yann@1187
|
435 |
if [ -z "${grep}" ]; then
|
yann@1333
|
436 |
printf "Either you are missing entirely the needed tool,\n"
|
yann@1333
|
437 |
printf "or the version you have is too old.\n"
|
yann@1333
|
438 |
printf "You can give the path to this tool using: --with-grep=PATH\n"
|
yann@1187
|
439 |
do_error "Bailing out..."
|
yann@1140
|
440 |
fi
|
yann@1311
|
441 |
add_to_var_list grep
|
yann@1140
|
442 |
|
yann@1140
|
443 |
printf "Checking for 'sed'... "
|
yann@1140
|
444 |
if [ -n "${sed}" ]; then
|
yann@1333
|
445 |
printf "${sed} (cached)\n"
|
yann@1140
|
446 |
else
|
yann@1140
|
447 |
sed="$( which sed 2>/dev/null )"
|
yann@1187
|
448 |
if [ -z "${sed}" ]; then
|
yann@1333
|
449 |
printf "not found\n"
|
yann@1187
|
450 |
else
|
yann@1333
|
451 |
printf "${sed}\n"
|
rpjday@1288
|
452 |
printf "Checking whether '${sed}' supports -i and -e... "
|
yann@1187
|
453 |
touch .ct-ng.sed.test
|
yann@1187
|
454 |
if "${sed}" -r -i -e 's/foo/bar/' .ct-ng.sed.test >/dev/null 2>&1; then
|
yann@1333
|
455 |
printf "yes\n"
|
yann@1187
|
456 |
else
|
yann@1333
|
457 |
printf "no\n"
|
yann@1187
|
458 |
sed=
|
yann@1187
|
459 |
fi
|
yann@1187
|
460 |
rm -f .ct-ng.sed.test
|
yann@1187
|
461 |
fi
|
yann@1140
|
462 |
fi
|
yann@1187
|
463 |
if [ -z "${sed}" ]; then
|
yann@1333
|
464 |
printf "Either you are missing entirely the needed tool,\n"
|
yann@1333
|
465 |
printf "or the version you have is too old.\n"
|
yann@1333
|
466 |
printf "You can give the path to this tool using: --with-sed=PATH\n"
|
yann@1187
|
467 |
do_error "Bailing out..."
|
yann@1140
|
468 |
fi
|
yann@1311
|
469 |
add_to_var_list sed
|
yann@1140
|
470 |
|
yann@1311
|
471 |
# The regular list of tools we can now easily check for
|
yann@1311
|
472 |
has_or_abort prog=bash \
|
yann@1311
|
473 |
var=bash \
|
yann@1477
|
474 |
ver='^GNU bash, version (3\.[1-9]|4)' \
|
yann@1477
|
475 |
err="'bash' 3.1 or above was not found"
|
yann@1311
|
476 |
has_or_abort prog=cut
|
yann@1311
|
477 |
has_or_abort prog=install var=install
|
yann@1311
|
478 |
has_or_abort prog=make \
|
yann@1311
|
479 |
var=make \
|
yann@1311
|
480 |
ver='^GNU Make (3.[89][[:digit:]]|[4-9])' \
|
yann@1311
|
481 |
err="GNU 'make' 3.80 or above was not found"
|
yann@1311
|
482 |
has_or_abort prog=gcc
|
yann@1431
|
483 |
has_or_abort prog="awk gawk" ver='^GNU Awk' err="GNU 'awk' was not found"
|
yann@1311
|
484 |
has_or_abort prog=bison
|
yann@1311
|
485 |
has_or_abort prog=flex
|
yann@1311
|
486 |
has_or_abort prog=makeinfo
|
yann@1311
|
487 |
has_or_abort prog=automake \
|
oron@1432
|
488 |
ver='\(GNU automake\) (1\.[[:digit:]]{2,}|[2-9][[:digit:]]*\.)' \
|
yann@1311
|
489 |
err="'automake' 1.10 or above was not found"
|
yann@1311
|
490 |
has_or_abort prog=libtool \
|
titus@1969
|
491 |
var=libtool \
|
yann@1311
|
492 |
ver='\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)' \
|
yann@1311
|
493 |
err="'libtool' 1.5.26 or above was not found"
|
titus@2626
|
494 |
has_or_abort prog=libtoolize \
|
titus@2626
|
495 |
var=libtoolize \
|
titus@2626
|
496 |
ver='\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)' \
|
titus@2626
|
497 |
err="'libtoolize' 1.5.26 or above was not found"
|
titus@1957
|
498 |
has_or_abort prog=stat
|
yann@2660
|
499 |
has_or_abort prog="curl"
|
yann@1311
|
500 |
has_or_abort prog=patch
|
yann@1311
|
501 |
has_or_abort prog=tar
|
yann@1311
|
502 |
has_or_abort prog=gzip
|
yann@1311
|
503 |
has_or_abort prog=bzip2
|
yann@2607
|
504 |
has_or_warn prog=xz \
|
yann@2607
|
505 |
kconfig=has_xzutils \
|
yann@2644
|
506 |
err="xz-compressed tarballs will not be used"
|
yann@2645
|
507 |
has_or_warn prog=lzma \
|
yann@2645
|
508 |
kconfig=has_lzma \
|
yann@2646
|
509 |
skip="${has_xzutils}" \
|
yann@2645
|
510 |
err="lzma-compressed tarballs will not be used"
|
yann@1313
|
511 |
has_or_abort prog=readlink
|
titus@1962
|
512 |
has_or_abort prog=objcopy var=objcopy
|
titus@1962
|
513 |
has_or_abort prog=objdump var=objdump
|
titus@1962
|
514 |
has_or_abort prog=readelf var=readelf
|
titus@1962
|
515 |
has_or_abort prog=patch var=patch
|
yann@2535
|
516 |
has_or_warn prog=cvs \
|
yann@2535
|
517 |
kconfig=has_cvs \
|
yann@2535
|
518 |
err="it will not be possible to use newlib cvs snapshots"
|
yann@2591
|
519 |
has_or_warn prog=svn \
|
yann@2540
|
520 |
kconfig=has_svn \
|
yann@2540
|
521 |
err="subversion is required to download eglibc"
|
yann@1311
|
522 |
|
yann@2525
|
523 |
# Host system checks
|
yann@2525
|
524 |
|
yann@2525
|
525 |
printf "Checking for host system... "
|
yann@2525
|
526 |
host="$( uname -s )"
|
yann@2525
|
527 |
printf "%s\n" "${host}"
|
yann@2525
|
528 |
case "${host}" in
|
yann@2525
|
529 |
Linux) ;;
|
yann@2525
|
530 |
Cygwin) ;;
|
yann@2525
|
531 |
*)
|
yann@2525
|
532 |
printf " * Runing under %s is not fully tested\n" "${host}"
|
yann@2525
|
533 |
printf " * You may encounter some weird behavior\n"
|
yann@2525
|
534 |
;;
|
yann@2525
|
535 |
esac
|
yann@2525
|
536 |
|
yann@2526
|
537 |
printf "Checking if static linking is possible... "
|
yann@2526
|
538 |
static_link_ok=""
|
yann@2526
|
539 |
case "${host}" in
|
yann@2526
|
540 |
Darwin) ;;
|
yann@2526
|
541 |
*) tmp=.static.tmp
|
yann@2534
|
542 |
if gcc -xc - -static -o "${tmp}" >/dev/null 2>&1 <<-_EOF_
|
yann@2526
|
543 |
int main() { return 0; }
|
yann@2526
|
544 |
_EOF_
|
yann@2526
|
545 |
then
|
yann@2526
|
546 |
static_link_ok="y"
|
yann@2526
|
547 |
fi
|
yann@2526
|
548 |
rm -f "${tmp}"
|
yann@2526
|
549 |
;;
|
yann@2526
|
550 |
esac
|
yann@2526
|
551 |
if [ "${static_link_ok}" = "y" ]; then
|
yann@2528
|
552 |
static_link_ko=""
|
yann@2526
|
553 |
printf "yes\n"
|
yann@2526
|
554 |
else
|
yann@2528
|
555 |
static_link_ko="y"
|
yann@2526
|
556 |
printf "no\n"
|
yann@2526
|
557 |
printf " * An optional host feature is missing, some features will be disabled:\n"
|
yann@2526
|
558 |
printf " * - It will not be possible to statically link toolchain's binaries\n"
|
yann@2526
|
559 |
fi
|
yann@2526
|
560 |
add_to_kconfig_list static_link_ok
|
yann@2526
|
561 |
|
yann@2526
|
562 |
# Library checks
|
yann@2528
|
563 |
libs_exts="so dylib"
|
yann@2528
|
564 |
if [ "${static_link_ok}" = "y" ]; then
|
yann@2534
|
565 |
libs_exts="${libs_exts} a"
|
yann@2528
|
566 |
fi
|
yann@2527
|
567 |
|
yann@2509
|
568 |
ncurses_hdrs="ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h"
|
yann@2527
|
569 |
ncurses_libs="libncursesw libncurses libcurses"
|
yann@2509
|
570 |
has_or_abort lib="${ncurses_libs}" \
|
yann@2527
|
571 |
lib_exts="${libs_exts}" \
|
yann@2509
|
572 |
inc="${ncurses_hdrs}" \
|
yann@2506
|
573 |
err="The 'ncurses' library is needed fo the menuconfig frontend"
|
yann@1106
|
574 |
|
yann@2527
|
575 |
has_or_abort lib="libstdc++" \
|
yann@2527
|
576 |
lib_exts="${libs_exts}" \
|
yann@2506
|
577 |
err="The 'libstdc++' library is needed to build gcc"
|
yann@2499
|
578 |
|
yann@2500
|
579 |
# Yes, we may be checking twice for libstdc++.a
|
yann@2500
|
580 |
# The first is because we need one instance of libstdc++ (shared or static)
|
yann@2500
|
581 |
# because it is needed for PPL; the second is because the static version is
|
yann@2500
|
582 |
# required for static-linking, and if missing, the option is removed.
|
yann@2528
|
583 |
has_or_warn lib="libstdc++" \
|
yann@2528
|
584 |
lib_exts="a" \
|
yann@2500
|
585 |
err="static 'libstdc++' is needed to statically link the toolchain's executables" \
|
yann@2528
|
586 |
kconfig=has_static_libstdcxx \
|
yann@2528
|
587 |
skip="${static_link_ko}"
|
yann@2500
|
588 |
|
yann@2527
|
589 |
has_or_warn inc="expat.h" \
|
yann@2527
|
590 |
lib="libexpat" \
|
yann@2527
|
591 |
lib_exts="${libs_exts}" \
|
benoit@2508
|
592 |
err="The 'expat' header file and library are needed to link cross-gdb's executables" \
|
benoit@2508
|
593 |
kconfig=has_expat
|
benoit@2508
|
594 |
|
benoit@2508
|
595 |
# Yes, we may be checking twice for libexpat.a
|
benoit@2508
|
596 |
# The first is because we need one instance of libexpat (shared or static)
|
benoit@2508
|
597 |
# because it is needed for cross-gdb; the second is because the static version
|
benoit@2508
|
598 |
# is required for static-linking, and if missing, the option is removed.
|
yann@2528
|
599 |
has_or_warn lib="libexpat" \
|
yann@2528
|
600 |
lib_exts="a" \
|
benoit@2508
|
601 |
err="static 'expat' is needed to statically link cross-gdb's executables" \
|
yann@2528
|
602 |
kconfig=has_static_expat \
|
yann@2528
|
603 |
skip="${static_link_ko}"
|
benoit@2508
|
604 |
|
benoit@2508
|
605 |
for v in 7 6 5 4; do
|
yann@2527
|
606 |
python_incs="${python_incs} python2.${v}/Python.h"
|
yann@2527
|
607 |
python_libs="${python_libs} libpython2.${v}"
|
benoit@2508
|
608 |
done
|
yann@2527
|
609 |
has_or_warn inc="${python_incs}" \
|
yann@2527
|
610 |
lib="${python_libs}" \
|
yann@2527
|
611 |
lib_exts="${libs_exts}" \
|
benoit@2508
|
612 |
err="The 'python' header file and library are needed for some features of cross-gdb"
|
benoit@2508
|
613 |
|
yann@1106
|
614 |
#---------------------------------------------------------------------
|
yann@1106
|
615 |
# Compute the version string
|
yann@376
|
616 |
|
yann@1576
|
617 |
# If this version is n hg clone, try to get the revision number
|
yann@435
|
618 |
# If we can't get the revision number, use date
|
yann@2498
|
619 |
printf "\nComputing version string... "
|
yann@435
|
620 |
case "${VERSION}" in
|
Yann@1409
|
621 |
*+hg|hg)
|
yann@1740
|
622 |
REVISION="$( hg id -n 2>/dev/null || true )"
|
yann@1105
|
623 |
case "${REVISION}" in
|
Yann@1409
|
624 |
"")
|
yann@1105
|
625 |
VERSION="${VERSION}_unknown@$( date +%Y%m%d.%H%M%S )";;
|
yann@1105
|
626 |
*)
|
yann@1430
|
627 |
VERSION="${VERSION}_$( hg id -b )@${REVISION%%+}_$( hg id -i )"
|
yann@1105
|
628 |
;;
|
yann@1105
|
629 |
esac
|
yann@1105
|
630 |
# Arrange to have no / in the directory name, no need to create an
|
yann@1105
|
631 |
# arbitrarily deep directory structure
|
yann@1333
|
632 |
VERSION="$( printf "${VERSION}\n" |"${sed}" -r -e 's|/+|_|g;' )"
|
yann@444
|
633 |
;;
|
yann@435
|
634 |
esac
|
yann@1740
|
635 |
printf "${VERSION}\n"
|
yann@435
|
636 |
|
yann@1106
|
637 |
#---------------------------------------------------------------------
|
yann@1106
|
638 |
# Compute and check install paths
|
yann@1106
|
639 |
|
yann@614
|
640 |
# Now we have the version string, we can build up the paths
|
yann@554
|
641 |
[ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin"
|
yann@1660
|
642 |
[ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib"
|
yann@1660
|
643 |
[ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc"
|
yann@2026
|
644 |
[ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man"
|
yann@554
|
645 |
|
yann@1660
|
646 |
# Install support files in our own sub-dir, so as not to mangle (system)
|
yann@1660
|
647 |
# files and dirs, but only if not --local
|
yann@1660
|
648 |
if [ -z "${LOCAL_set}" ]; then
|
yann@1660
|
649 |
LIBDIR="${LIBDIR}/ct-ng-${VERSION}"
|
yann@1660
|
650 |
DOCDIR="${DOCDIR}/ct-ng-${VERSION}"
|
yann@1660
|
651 |
fi
|
yann@1660
|
652 |
|
yann@1047
|
653 |
# Check that install PATHs are absolute
|
yann@1047
|
654 |
for p in BIN LIB DOC MAN; do
|
yann@1105
|
655 |
var="${p}DIR"
|
yann@1105
|
656 |
eval v='"${'"${var}"'}"'
|
yann@1105
|
657 |
case "${v}" in
|
yann@1105
|
658 |
/*) ;;
|
yann@2621
|
659 |
*) do_error "'${var}' is not an absolute path: '${v}'";;
|
yann@1105
|
660 |
esac
|
yann@1047
|
661 |
done
|
yann@2621
|
662 |
case "${PROG_PFX}" in
|
yann@2621
|
663 |
*/*) do_error "program prefix '${PROG_PFX}' contains a '/'";;
|
yann@2621
|
664 |
esac
|
yann@2622
|
665 |
case "${PROG_SFX}" in
|
yann@2622
|
666 |
*/*) do_error "program suffix '${PROG_SFX}' contains a '/'";;
|
yann@2622
|
667 |
esac
|
yann@1047
|
668 |
|
yann@1106
|
669 |
#---------------------------------------------------------------------
|
yann@1106
|
670 |
# That's all, folks!
|
yann@614
|
671 |
|
yann@641
|
672 |
printf "Building up Makefile... "
|
yann@1140
|
673 |
var_sed="$( for var_name in ${var_list}; do
|
yann@1140
|
674 |
eval echo 's,@@${var_name}@@,${'"${var_name}"'},g'
|
yann@2481
|
675 |
done
|
yann@1140
|
676 |
)"
|
yann@2481
|
677 |
kconfig_sed="s/@@KCONFIG@@/$( for k_name in ${kconfig_list}; do
|
yann@2481
|
678 |
eval printf \"${k_name}=\${${k_name}} \"
|
yann@2481
|
679 |
done
|
yann@2481
|
680 |
)/"
|
yann@2481
|
681 |
"${sed}" -r -e "s,@@BINDIR@@,${BINDIR},g" \
|
yann@2481
|
682 |
-e "s,@@LIBDIR@@,${LIBDIR},g" \
|
yann@2481
|
683 |
-e "s,@@DOCDIR@@,${DOCDIR},g" \
|
yann@2481
|
684 |
-e "s,@@MANDIR@@,${MANDIR},g" \
|
yann@2621
|
685 |
-e "s,@@PROG_PFX@@,${PROG_PFX},g" \
|
yann@2622
|
686 |
-e "s,@@PROG_SFX@@,${PROG_SFX},g" \
|
yann@2623
|
687 |
-e "s,@@PROG_SED@@,${PROG_SED},g" \
|
yann@2481
|
688 |
-e "s,@@VERSION@@,${VERSION},g" \
|
yann@2481
|
689 |
-e "s,@@DATE@@,${DATE},g" \
|
yann@2481
|
690 |
-e "s,@@LOCAL@@,${LOCAL_set},g" \
|
yann@2481
|
691 |
-e "${var_sed}" \
|
yann@2481
|
692 |
-e "${kconfig_sed}" \
|
yann@2481
|
693 |
Makefile.in \
|
yann@2481
|
694 |
>Makefile
|
yann@673
|
695 |
echo "done"
|
yann@185
|
696 |
|
yann@185
|
697 |
cat <<__EOF__
|
yann@673
|
698 |
|
yann@197
|
699 |
crosstool-NG configured as follows:
|
yann@554
|
700 |
PREFIX='${PREFIX}'
|
yann@554
|
701 |
BINDIR='${BINDIR}'
|
yann@554
|
702 |
LIBDIR='${LIBDIR}'
|
yann@554
|
703 |
DOCDIR='${DOCDIR}'
|
yann@554
|
704 |
MANDIR='${MANDIR}'
|
yann@2621
|
705 |
PROG_PFX='${PROG_PFX}'
|
yann@2622
|
706 |
PROG_SFX='${PROG_SFX}'
|
yann@2623
|
707 |
PROG_SED='${PROG_SED}'
|
yann@1106
|
708 |
|
yann@1106
|
709 |
Now run:
|
yann@1106
|
710 |
make
|
yann@185
|
711 |
__EOF__
|
yann@1298
|
712 |
if [ "${LOCAL_set}" != "y" ]; then
|
yann@1297
|
713 |
printf " make install\n"
|
yann@1297
|
714 |
fi
|