3 VERSION=$( cat .version )
6 # All absolutely required tools, one per line to ease diff.
7 # See function 'has_or_abort, below, for syntax
8 # - Hopefully, if gcc is present, then all associated tools will be
9 # - awk must be GNU awk
10 # - makeinfo for building docs, even if discarded later on
11 # - others obvious... :-/
13 # Format of a pattern to check for, one per line:
14 # pattern := var_name : tool_pattern OR tool_pattern
15 # tool_pattern := tool_test OR tool_pattern || tool_test
16 # tool_test := tool=regexp OR tool
17 # tool := basename of the tool OR absolute pathname to the tool
18 # regexp := valid grep(1) extended regular expression, $( tool --version)
19 # will be matched against this regexp.
21 # In case a pattern list is given (eg foo || bar || buz), then tests are performed
22 # from left to right, stopping at the first matching test (like the shell
23 # would parse 'foo || bar || buz' ).
26 # bash:bash=^GNU bash, version 3\.
27 # - if ${bash} is set and non-null, does nothing
28 # - else ensures that bash exists in the PATH, and that $( bash --version )
29 # matches the regexp '^GNU bash, version 3\.'
30 # - if so, then sets bash="$( which bash )"
31 # autoconf=(GNU Autoconf) || autoconf2.50
32 # - does not look at an existing variable
34 # - 'autoconf' is to be found in the PATH, and that $( autoconf --version )
35 # matches the regexp '(GNU Autoconf)' (which btw is the signature of
38 # - 'autoconf2.50' is to be found in the PATH
41 bash:bash=^GNU bash, version [34]\.
44 install:install=GNU coreutils
47 awk:awk=^GNU Awk || gawk=^GNU Awk
51 automake=\(GNU automake\) (1\.[[:digit:]]{2,}\.|[2-9][[:digit:]]*\.)
52 libtool=\(GNU libtool\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)
60 PREFIX_DEFAULT=/usr/local
70 # Simply print the error message, and exit. Obvious, he?
76 # A small function to test for existence of various tools
77 # Usage: has_or_abort test_pattern (see top of file, TOOLS_TO_CHECK, for
78 # complete pattern format)
86 var_name="$( echo "${1}" |"${sed}" -r -e 's/^(([^=:]+):.+|[^:=]+=.+|[^:=]+)$/\2/;' )"
87 field="${var_name:+2}"
89 tool_pattern="$( echo "${1}" |cut -d : -f ${field}- |"${sed}" -r -e 's/ *\|\| */\n/g;' )"
95 for item in ${tool_pattern}; do
106 printf "Checking for '${tool}'... "
107 if [ -n "${var_name}" ]; then
108 eval var_value='"${'"${var_name}"'}"'
109 if [ -n "${var_value}" ]; then
110 echo "${var_value} (cached)"
114 where=$( which "${tool}" 2>/dev/null )
115 if [ -z "${where}" ]; then
119 elif [ -n "${regexp}" ]; then
120 tool_version=$( ${tool} --version 2>&1 )
121 str=$( echo "${tool_version}" |"${grep}" -E "${regexp}" |head -n 1 )
122 if [ -z "${str}" ]; then
130 if [ -z "${where}" ]; then
131 for item in ${tool_pattern}; do
141 printf " could not find '${tool}'"
142 [ -n "${regexp}" ] && printf " matching regexp '${regexp}'"
145 echo "Either you are missing entirely the needed tool,"
146 echo "or the version you have is tool old."
147 if [ -n "${var_name}" ]; then
148 echo "You can give the path to this tool using: --with-${var_name}=PATH"
150 # FORCE can be set in the environment
151 [ -z "${FORCE}" ] && do_error "Bailing out..."
154 if [ -n "${var_name}" ]; then
155 eval ${var_name}='"'"${where}"'"'
162 # Given an option string and the following argument,
163 # echoes the value of the option.
164 # If --var=val => echoes val and returns 0, meaning second arg was not consumed
165 # If --var val => echoes val and returns non null, meaning second arg was used
179 # The set_xxx functions will set the corresponding configuration variable
180 # They return 0 if second arg was not consumed, and non-zero if it was consumed.
182 PREFIX="$( get_optval "$1" "$2" )"
186 BINDIR="$( get_optval "$1" "$2" )"
190 LIBDIR="$( get_optval "$1" "$2" )"
194 DOCDIR="$( get_optval "$1" "$2" )"
198 MANDIR="$( get_optval "$1" "$2" )"
201 local var_name="${1%%=*}"
202 var_name="${var_name#--with-}"
203 eval ${var_name}="\$( get_optval "$1" "$2" )"
208 \`configure' configures crosstool-NG-${VERSION} to adapt to many kind of systems.
210 USAGE: ./configure [OPTION]...
212 Defaults for the options are specified in brackets.
215 -h, --help display this help and exit
217 Installation directories:
218 --prefix=PREFIX install files in PREFIX [${PREFIX_DEFAULT}]
219 --local don't install, and use current directory
221 By default, \`make install' will install all the files in
222 \`${PREFIX_DEFAULT}/bin', \`${PREFIX_DEFAULT}/lib' etc. You can specify
223 an installation prefix other than \`${PREFIX_DEFAULT}' using \`--prefix',
224 for instance \`--prefix=\${HOME}'.
226 For better control, use the options below.
228 Fine tuning of the installation directories:
229 --bindir=DIR user executables [PREFIX/bin]
230 --libdir=DIR object code libraries [PREFIX/lib]
231 --docdir=DIR info documentation [PREFIX/share/doc]
232 --mandir=DIR man documentation [PREFIX/share/man]
235 --with-install=PATH Specify the full PATH to GNU install
236 --with-make=PATH Specify the full PATH to GNU make
237 --with-grep=PATH Specify the full PATH to GNU grep
238 --with-sed=PATH Specify the full PATH to GNU sed
239 --with-awk=PATH Specify the full PATH to GNU awk
240 --with-bash=PATH Specify the full PATH to bash >= 3.0
244 #---------------------------------------------------------------------
247 while [ $# -ne 0 ]; do
249 --local) LOCAL_set=1; shift;;
250 --prefix*) set_prefix "$1" "$2" && shift || shift 2;;
251 --bindir*) set_bindir "$1" "$2" && shift || shift 2;;
252 --libdir*) set_libdir "$1" "$2" && shift || shift 2;;
253 --docdir*) set_docdir "$1" "$2" && shift || shift 2;;
254 --mandir*) set_mandir "$1" "$2" && shift || shift 2;;
255 --with-*) set_tool "$1" "$2" && shift || shift 2;;
256 --help|-h) do_help; exit 0;;
257 *) echo "Unrecognised option: '${1}'"; do_help; exit 1;;
262 [ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
264 # Special case when installing locally
265 if [ "${LOCAL_set}" = "1" ]; then
266 set_prefix "" "$( pwd )"
267 set_bindir "" "$( pwd )"
268 set_libdir "" "$( pwd )"
269 set_docdir "" "$( pwd )/docs"
270 set_mandir "" "$( pwd )/docs"
273 #---------------------------------------------------------------------
274 # Some sanity checks, now
276 # We check for grep and sed manually, because they are used in has_or_abort
277 printf "Checking for 'grep'... "
278 if [ -n "${grep}" ]; then
279 echo "${grep} (cached)"
281 grep="$( which grep 2>/dev/null )"
282 if [ -z "${grep}" ]; then
286 printf "Checking whether '${grep}' supports -E... "
287 if echo 'foo' |"${grep}" -E 'foo' >/dev/null 2>&1; then
295 if [ -z "${grep}" ]; then
296 echo "Either you are missing entirely the needed tool,"
297 echo "or the version you have is tool old."
298 echo "You can give the path to this tool using: --with-grep=PATH"
299 do_error "Bailing out..."
302 printf "Checking for 'sed'... "
303 if [ -n "${sed}" ]; then
304 echo "${sed} (cached)"
306 sed="$( which sed 2>/dev/null )"
307 if [ -z "${sed}" ]; then
311 printf "Checking wether '${sed}' supports -i and -e... "
312 touch .ct-ng.sed.test
313 if "${sed}" -r -i -e 's/foo/bar/' .ct-ng.sed.test >/dev/null 2>&1; then
319 rm -f .ct-ng.sed.test
322 if [ -z "${sed}" ]; then
323 echo "Either you are missing entirely the needed tool,"
324 echo "or the version you have is tool old."
325 echo "You can give the path to this tool using: --with-sed=PATH"
326 do_error "Bailing out..."
329 # Check the existence of absolutely required tools
333 for tool in ${TOOLS_TO_CHECK}; do
334 has_or_abort "${tool}"
338 #---------------------------------------------------------------------
339 # Compute the version string
341 # If this version is a svn snapshot, try to get the revision number
342 # If we can't get the revision number, use date
343 printf "Computing version string... "
346 REVISION="$( LC_ALL=C svnversion )"
347 case "${REVISION}" in
349 VERSION="${VERSION}_unknown@$( date +%Y%m%d.%H%M%S )";;
351 URL="$( LC_ALL=C svn info 2>/dev/null \
355 ROOT="$( LC_ALL=C svn info 2>/dev/null \
356 |"${grep}" '^Repository Root: ' \
359 VERSION="${VERSION}${URL#${ROOT}}@${REVISION}"
362 # Arrange to have no / in the directory name, no need to create an
363 # arbitrarily deep directory structure
364 VERSION="$( echo "${VERSION}" |"${sed}" -r -e 's|/+|_|g;' )"
369 #---------------------------------------------------------------------
370 # Compute and check install paths
372 # Now we have the version string, we can build up the paths
373 [ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin"
374 [ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib/ct-ng-${VERSION}"
375 [ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc/ct-ng-${VERSION}"
376 [ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man/man1"
378 # Check that install PATHs are absolute
379 for p in BIN LIB DOC MAN; do
381 eval v='"${'"${var}"'}"'
384 *) do_error "'${var}' is not an absolute path: '${v}'"
388 #---------------------------------------------------------------------
391 printf "Building up Makefile... "
394 $( printf "${TOOLS_TO_CHECK}" \
395 |"${sed}" -r -e 's/^(([^=:]+):.+|[^:=]+=.+|[^:=]+)$/\2/;'
397 var_sed="$( for var_name in ${var_list}; do
398 eval echo 's,@@${var_name}@@,${'"${var_name}"'},g'
401 "${sed}" -r -e "s,@@BINDIR@@,${BINDIR},g
402 s,@@LIBDIR@@,${LIBDIR},g
403 s,@@DOCDIR@@,${DOCDIR},g
404 s,@@MANDIR@@,${MANDIR},g
405 s,@@VERSION@@,${VERSION},g
408 s,@@LOCAL@@,${LOCAL_set},g" Makefile.in >Makefile
413 crosstool-NG configured as follows: