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 # - makeinfo for building docs, even if discarded later on
10 # - others obvious... :-/
12 # Format of a pattern to check for, one per line:
13 # pattern := var_name : tool_pattern OR tool_pattern
14 # tool_pattern := tool_test OR tool_pattern || tool_test
15 # tool_test := tool=regexp OR tool
16 # tool := basename of the tool OR absolute pathname to the tool
17 # regexp := valid grep(1) extended regular expression, $( tool --version)
18 # will be matched against this regexp.
20 # In case a pattern list is given (eg foo || bar || buz), then tests are performed
21 # from left to right, stopping at the first matching test (like the shell
22 # would parse 'foo || bar || buz' ).
25 # bash:bash=^GNU bash, version 3\.
26 # - if ${bash} is set and non-null, does nothing
27 # - else ensures that bash exists in the PATH, and that $( bash --version )
28 # matches the regexp '^GNU bash, version 3\.'
29 # - if so, then sets bash="$( which bash )"
30 # autoconf=(GNU Autoconf) || autoconf2.50
31 # - does not look at an existing variable
33 # - 'autoconf' is to be found in the PATH, and that $( autoconf --version )
34 # matches the regexp '(GNU Autoconf)' (which btw is the signature of
37 # - 'autoconf2.50' is to be found in the PATH
40 bash:bash=^GNU bash, version [34]\.
43 install:install=GNU coreutils
50 automake=\(GNU automake\) (1\.[[:digit:]]{2,}\.|[2-9][[:digit:]]*\.)
51 libtool=\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)
59 PREFIX_DEFAULT=/usr/local
69 # Simply print the error message, and exit. Obvious, he?
75 # A small function to test for existence of various tools
76 # Usage: has_or_abort test_pattern (see top of file, TOOLS_TO_CHECK, for
77 # complete pattern format)
85 var_name="$( echo "${1}" |"${sed}" -r -e 's/^(([^=:]+):.+|[^:=]+=.+|[^:=]+)$/\2/;' )"
86 field="${var_name:+2}"
88 tool_pattern="$( echo "${1}" |cut -d : -f ${field}- |"${sed}" -r -e 's/ *\|\| */\n/g;' )"
94 for item in ${tool_pattern}; do
105 printf "Checking for '${tool}'... "
106 if [ -n "${var_name}" ]; then
107 eval var_value='"${'"${var_name}"'}"'
108 if [ -n "${var_value}" ]; then
109 echo "${var_value} (cached)"
113 where=$( which "${tool}" 2>/dev/null )
114 if [ -z "${where}" ]; then
118 elif [ -n "${regexp}" ]; then
119 tool_version=$( ${tool} --version 2>&1 )
120 str=$( echo "${tool_version}" |"${grep}" -E "${regexp}" |head -n 1 )
121 if [ -z "${str}" ]; then
129 if [ -z "${where}" ]; then
130 for item in ${tool_pattern}; do
140 printf " could not find '${tool}'"
141 [ -n "${regexp}" ] && printf " matching regexp '${regexp}'"
144 echo "Either you are missing entirely the needed tool,"
145 echo "or the version you have is too old."
146 if [ -n "${var_name}" ]; then
147 echo "You can give the path to this tool using: --with-${var_name}=PATH"
149 # FORCE can be set in the environment
150 [ -z "${FORCE}" ] && do_error "Bailing out..."
153 if [ -n "${var_name}" ]; then
154 eval ${var_name}='"'"${where}"'"'
161 # Given an option string and the following argument,
162 # echoes the value of the option.
163 # If --var=val => echoes val and returns 0, meaning second arg was not consumed
164 # If --var val => echoes val and returns non null, meaning second arg was used
178 # The set_xxx functions will set the corresponding configuration variable
179 # They return 0 if second arg was not consumed, and non-zero if it was consumed.
181 PREFIX="$( get_optval "$1" "$2" )"
185 BINDIR="$( get_optval "$1" "$2" )"
189 LIBDIR="$( get_optval "$1" "$2" )"
193 DOCDIR="$( get_optval "$1" "$2" )"
197 MANDIR="$( get_optval "$1" "$2" )"
200 local var_name="${1%%=*}"
201 var_name="${var_name#--with-}"
202 eval ${var_name}="\$( get_optval "$1" "$2" )"
207 \`configure' configures crosstool-NG-${VERSION} to adapt to many kind of systems.
209 USAGE: ./configure [OPTION]...
211 Defaults for the options are specified in brackets.
214 -h, --help display this help and exit
216 Installation directories:
217 --prefix=PREFIX install files in PREFIX [${PREFIX_DEFAULT}]
218 --local don't install, and use current directory
220 By default, \`make install' will install all the files in
221 \`${PREFIX_DEFAULT}/bin', \`${PREFIX_DEFAULT}/lib' etc. You can specify
222 an installation prefix other than \`${PREFIX_DEFAULT}' using \`--prefix',
223 for instance \`--prefix=\${HOME}'.
225 For better control, use the options below.
227 Fine tuning of the installation directories:
228 --bindir=DIR user executables [PREFIX/bin]
229 --libdir=DIR object code libraries [PREFIX/lib]
230 --docdir=DIR info documentation [PREFIX/share/doc]
231 --mandir=DIR man documentation [PREFIX/share/man]
234 --with-install=PATH Specify the full PATH to GNU install
235 --with-make=PATH Specify the full PATH to GNU make
236 --with-grep=PATH Specify the full PATH to GNU grep
237 --with-sed=PATH Specify the full PATH to GNU sed
238 --with-awk=PATH Specify the full PATH to GNU awk
239 --with-bash=PATH Specify the full PATH to bash >= 3.0
243 #---------------------------------------------------------------------
246 while [ $# -ne 0 ]; do
248 --local) LOCAL_set="y"; shift;;
249 --prefix*) set_prefix "$1" "$2" && shift || shift 2;;
250 --bindir*) set_bindir "$1" "$2" && shift || shift 2;;
251 --libdir*) set_libdir "$1" "$2" && shift || shift 2;;
252 --docdir*) set_docdir "$1" "$2" && shift || shift 2;;
253 --mandir*) set_mandir "$1" "$2" && shift || shift 2;;
254 --with-*) set_tool "$1" "$2" && shift || shift 2;;
255 --help|-h) do_help; exit 0;;
256 *) echo "Unrecognised option: '${1}'"; do_help; exit 1;;
261 [ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
263 # Special case when installing locally
264 if [ "${LOCAL_set}" = "y" ]; then
265 set_prefix "" "$( pwd )"
266 set_bindir "" "$( pwd )"
267 set_libdir "" "$( pwd )"
268 set_docdir "" "$( pwd )/docs"
269 set_mandir "" "$( pwd )/docs"
272 #---------------------------------------------------------------------
273 # Some sanity checks, now
275 # We check for grep and sed manually, because they are used in has_or_abort
276 printf "Checking for 'grep'... "
277 if [ -n "${grep}" ]; then
278 echo "${grep} (cached)"
280 grep="$( which grep 2>/dev/null )"
281 if [ -z "${grep}" ]; then
285 printf "Checking whether '${grep}' supports -E... "
286 if echo 'foo' |"${grep}" -E 'foo' >/dev/null 2>&1; then
294 if [ -z "${grep}" ]; then
295 echo "Either you are missing entirely the needed tool,"
296 echo "or the version you have is too old."
297 echo "You can give the path to this tool using: --with-grep=PATH"
298 do_error "Bailing out..."
301 printf "Checking for 'sed'... "
302 if [ -n "${sed}" ]; then
303 echo "${sed} (cached)"
305 sed="$( which sed 2>/dev/null )"
306 if [ -z "${sed}" ]; then
310 printf "Checking whether '${sed}' supports -i and -e... "
311 touch .ct-ng.sed.test
312 if "${sed}" -r -i -e 's/foo/bar/' .ct-ng.sed.test >/dev/null 2>&1; then
318 rm -f .ct-ng.sed.test
321 if [ -z "${sed}" ]; then
322 echo "Either you are missing entirely the needed tool,"
323 echo "or the version you have is too old."
324 echo "You can give the path to this tool using: --with-sed=PATH"
325 do_error "Bailing out..."
328 # Check the existence of absolutely required tools
332 for tool in ${TOOLS_TO_CHECK}; do
333 has_or_abort "${tool}"
337 #---------------------------------------------------------------------
338 # Compute the version string
340 # If this version is a svn snapshot, try to get the revision number
341 # If we can't get the revision number, use date
342 printf "Computing version string... "
345 REVISION="$( LC_ALL=C svnversion )"
346 case "${REVISION}" in
348 VERSION="${VERSION}_unknown@$( date +%Y%m%d.%H%M%S )";;
350 URL="$( LC_ALL=C svn info 2>/dev/null \
354 ROOT="$( LC_ALL=C svn info 2>/dev/null \
355 |"${grep}" '^Repository Root: ' \
358 VERSION="${VERSION}${URL#${ROOT}}@${REVISION}"
361 # Arrange to have no / in the directory name, no need to create an
362 # arbitrarily deep directory structure
363 VERSION="$( echo "${VERSION}" |"${sed}" -r -e 's|/+|_|g;' )"
368 #---------------------------------------------------------------------
369 # Compute and check install paths
371 # Now we have the version string, we can build up the paths
372 [ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin"
373 [ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib/ct-ng-${VERSION}"
374 [ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc/ct-ng-${VERSION}"
375 [ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man/man1"
377 # Check that install PATHs are absolute
378 for p in BIN LIB DOC MAN; do
380 eval v='"${'"${var}"'}"'
383 *) do_error "'${var}' is not an absolute path: '${v}'"
387 #---------------------------------------------------------------------
390 printf "Building up Makefile... "
393 $( printf "${TOOLS_TO_CHECK}" \
394 |"${sed}" -r -e 's/^(([^=:]+):.+|[^:=]+=.+|[^:=]+)$/\2/;'
396 var_sed="$( for var_name in ${var_list}; do
397 eval echo 's,@@${var_name}@@,${'"${var_name}"'},g'
400 "${sed}" -r -e "s,@@BINDIR@@,${BINDIR},g
401 s,@@LIBDIR@@,${LIBDIR},g
402 s,@@DOCDIR@@,${DOCDIR},g
403 s,@@MANDIR@@,${MANDIR},g
404 s,@@VERSION@@,${VERSION},g
407 s,@@LOCAL@@,${LOCAL_set},g" Makefile.in >Makefile
412 crosstool-NG configured as follows:
422 if [ "${LOCAL_set}" != "y" ]; then
423 printf " make install\n"