1.1 --- a/configure Thu Apr 02 22:28:10 2009 +0000
1.2 +++ b/configure Sun May 03 09:50:16 2009 +0000
1.3 @@ -1,62 +1,10 @@
1.4 #!/bin/sh
1.5
1.6 +myname="${0##*/}"
1.7 +
1.8 VERSION=$( cat .version )
1.9 DATE=$( date +%Y%m%d )
1.10
1.11 -# All absolutely required tools, one per line to ease diff.
1.12 -# See function 'has_or_abort, below, for syntax
1.13 -# - Hopefully, if gcc is present, then all associated tools will be
1.14 -# - awk must be GNU awk
1.15 -# - makeinfo for building docs, even if discarded later on
1.16 -# - others obvious... :-/
1.17 -#
1.18 -# Format of a pattern to check for, one per line:
1.19 -# pattern := var_name : tool_pattern OR tool_pattern
1.20 -# tool_pattern := tool_test OR tool_pattern || tool_test
1.21 -# tool_test := tool=regexp OR tool
1.22 -# tool := basename of the tool OR absolute pathname to the tool
1.23 -# regexp := valid grep(1) extended regular expression, $( tool --version)
1.24 -# will be matched against this regexp.
1.25 -#
1.26 -# In case a pattern list is given (eg foo || bar || buz), then tests are performed
1.27 -# from left to right, stopping at the first matching test (like the shell
1.28 -# would parse 'foo || bar || buz' ).
1.29 -#
1.30 -# Examples:
1.31 -# bash:bash=^GNU bash, version 3\.
1.32 -# - if ${bash} is set and non-null, does nothing
1.33 -# - else ensures that bash exists in the PATH, and that $( bash --version )
1.34 -# matches the regexp '^GNU bash, version 3\.'
1.35 -# - if so, then sets bash="$( which bash )"
1.36 -# autoconf=(GNU Autoconf) || autoconf2.50
1.37 -# - does not look at an existing variable
1.38 -# - ensures that:
1.39 -# - 'autoconf' is to be found in the PATH, and that $( autoconf --version )
1.40 -# matches the regexp '(GNU Autoconf)' (which btw is the signature of
1.41 -# autoconf >= 2.50),
1.42 -# OR that:
1.43 -# - 'autoconf2.50' is to be found in the PATH
1.44 -#
1.45 -TOOLS_TO_CHECK='
1.46 -bash:bash=^GNU bash, version [34]\.
1.47 -cut
1.48 -xargs
1.49 -install:install=GNU coreutils
1.50 -make:make=^GNU Make
1.51 -gcc
1.52 -awk:awk=^GNU Awk || gawk=^GNU Awk
1.53 -bison
1.54 -flex
1.55 -makeinfo
1.56 -automake=\(GNU automake\) (1\.[[:digit:]]{2,}\.|[2-9][[:digit:]]*\.)
1.57 -libtool=\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)
1.58 -curl || wget
1.59 -patch
1.60 -tar
1.61 -gzip
1.62 -bzip2
1.63 -'
1.64 -
1.65 PREFIX_DEFAULT=/usr/local
1.66
1.67 BINDIR_set=
1.68 @@ -64,101 +12,16 @@
1.69 DOCDIR_set=
1.70 MANDIR_set=
1.71 LOCAL_set=
1.72 +FORCE=
1.73
1.74 do_quit=
1.75
1.76 # Simply print the error message, and exit. Obvious, he?
1.77 do_error() {
1.78 - echo "${@}"
1.79 + echo "${myname}: ${@}"
1.80 exit 1
1.81 }
1.82
1.83 -# A small function to test for existence of various tools
1.84 -# Usage: has_or_abort test_pattern (see top of file, TOOLS_TO_CHECK, for
1.85 -# complete pattern format)
1.86 -has_or_abort() {
1.87 - local save_IFS
1.88 - local var_name
1.89 - local var_value
1.90 - local tool_pattern
1.91 - local field
1.92 -
1.93 - var_name="$( echo "${1}" |"${sed}" -r -e 's/^(([^=:]+):.+|[^:=]+=.+|[^:=]+)$/\2/;' )"
1.94 - field="${var_name:+2}"
1.95 - field="${field:-1}"
1.96 - tool_pattern="$( echo "${1}" |cut -d : -f ${field}- |"${sed}" -r -e 's/ *\|\| */\n/g;' )"
1.97 -
1.98 - save_IFS="${IFS}"
1.99 - # Set IFS to \n only
1.100 - IFS='
1.101 -'
1.102 - for item in ${tool_pattern}; do
1.103 - case "${item}" in
1.104 - *=*)
1.105 - tool="${item%%=*}"
1.106 - regexp="${item#*=}"
1.107 - ;;
1.108 - *) tool="${item}"
1.109 - regexp=
1.110 - ;;
1.111 - esac
1.112 -
1.113 - printf "Checking for '${tool}'... "
1.114 - if [ -n "${var_name}" ]; then
1.115 - eval var_value='"${'"${var_name}"'}"'
1.116 - if [ -n "${var_value}" ]; then
1.117 - echo "${var_value} (cached)"
1.118 - return 0
1.119 - fi
1.120 - fi
1.121 - where=$( which "${tool}" 2>/dev/null )
1.122 - if [ -z "${where}" ]; then
1.123 - echo "not found"
1.124 - where=
1.125 - continue
1.126 - elif [ -n "${regexp}" ]; then
1.127 - tool_version=$( ${tool} --version 2>&1 )
1.128 - str=$( echo "${tool_version}" |"${grep}" -E "${regexp}" |head -n 1 )
1.129 - if [ -z "${str}" ]; then
1.130 - echo "not found"
1.131 - where=""
1.132 - continue
1.133 - fi
1.134 - fi
1.135 - break
1.136 - done
1.137 - if [ -z "${where}" ]; then
1.138 - for item in ${tool_pattern}; do
1.139 - case "${item}" in
1.140 - *=*)
1.141 - tool="${item%%=*}"
1.142 - regexp="${item#*=}"
1.143 - ;;
1.144 - *) tool="${item}"
1.145 - regexp=
1.146 - ;;
1.147 - esac
1.148 - printf " could not find '${tool}'"
1.149 - [ -n "${regexp}" ] && printf " matching regexp '${regexp}'"
1.150 - echo
1.151 - done
1.152 - echo "Either you are missing entirely the needed tool,"
1.153 - echo "or the version you have is too old."
1.154 - if [ -n "${var_name}" ]; then
1.155 - echo "You can give the path to this tool using: --with-${var_name}=PATH"
1.156 - fi
1.157 - # FORCE can be set in the environment
1.158 - [ -z "${FORCE}" ] && do_error "Bailing out..."
1.159 - else
1.160 - echo "${where}"
1.161 - if [ -n "${var_name}" ]; then
1.162 - eval ${var_name}='"'"${where}"'"'
1.163 - fi
1.164 - fi
1.165 - IFS="${save_IFS}"
1.166 - return 0
1.167 -}
1.168 -
1.169 # Given an option string and the following argument,
1.170 # echoes the value of the option.
1.171 # If --var=val => echoes val and returns 0, meaning second arg was not consumed
1.172 @@ -203,6 +66,130 @@
1.173 eval ${var_name}="\$( get_optval "$1" "$2" )"
1.174 }
1.175
1.176 +# var_list is a list of variables, each one holding a path to a
1.177 +# tool, either detected by ./configure, or specified by the user.
1.178 +var_list=""
1.179 +
1.180 +# This function adds a variable name to the above list of variable names.
1.181 +# $1: the name of the variable to add to the list
1.182 +add_to_var_list() {
1.183 + var_list="${var_list} ${1}"
1.184 +}
1.185 +
1.186 +# A function to test for required tools/headers/libraries
1.187 +# $*: [prog|inc|lib]=<name[ name...]>
1.188 +# the name(s) of tool(s) to test for
1.189 +# mandatory
1.190 +# eg: prog=bash prog="curl wget"
1.191 +# $*: var=<var_name>
1.192 +# the name of the variable to test and set
1.193 +# optional
1.194 +# eg: var=bash if ${bash} is set and non-null, use that,
1.195 +# else check for bash and set bash=$(which bash)
1.196 +# $*: ver=<regexp>
1.197 +# for each 'prog', test if $(prog --version) matches 'regexp'
1.198 +# optional
1.199 +# eg: ver='^GNU bash, version [34]\.'
1.200 +# $*: err=<error_message>
1.201 +# the error message to print if tool is missing
1.202 +# optional, defaults to: '${prog}: none found'
1.203 +# eg: err="'bash' 3.x or above was not found"
1.204 +has_or_abort() {
1.205 + local prog inc lib
1.206 + local var ver err
1.207 + local val
1.208 + local item
1.209 + local where
1.210 + local version
1.211 + local status
1.212 +
1.213 + for item in "${@}"; do
1.214 + case "${item}" in
1.215 + prog=*|inc=*|lib=*|var=*|ver=*|err=*)
1.216 + eval ${item%%=*}="'${item#*=}'"
1.217 + ;;
1.218 + *) do_error "has_or_abort: incorrect parameters: '$@'";;
1.219 + esac
1.220 + done
1.221 +
1.222 + case "${prog}:${inc}:${lib}" in
1.223 + ?*::)
1.224 + for item in ${prog}; do
1.225 + printf "Checking for '${item}'... "
1.226 + if [ -n "${var}" ]; then
1.227 + eval val="\${${var}}"
1.228 + if [ -n "${val}" ]; then
1.229 + printf "${val} (cached)\n"
1.230 + return 0
1.231 + fi
1.232 + fi
1.233 + where="$( which "${item}" 2>/dev/null )"
1.234 + if [ -z "${where}" ]; then
1.235 + printf "no\n"
1.236 + continue
1.237 + elif [ -n "${ver}" ]; then
1.238 + version=$( ${where} --version 2>&1 )
1.239 + str=$( echo "${version}" |grep -E "${ver}" |head -n 1 )
1.240 + if [ -z "${str}" ]; then
1.241 + printf "no\n"
1.242 + unset where
1.243 + continue
1.244 + fi
1.245 + fi
1.246 + status="${where}"
1.247 + break
1.248 + done
1.249 + ;;
1.250 + :?*:)
1.251 + for item in ${inc}; do
1.252 + printf "Checking for '${item}'... "
1.253 + if printf "#include \"${item}\"" |gcc -x c -c - -o /dev/null >/dev/null 2>&1; then
1.254 + where="${item}"
1.255 + status=yes
1.256 + break;
1.257 + fi
1.258 + printf "no\n"
1.259 + done
1.260 + ;;
1.261 + ::?*)
1.262 + for item in ${lib}; do
1.263 + printf "Checking for '${item}'... "
1.264 + where="$( gcc -print-file-name="${item}" )"
1.265 + if [ "${where}" != "${item}" ]; then
1.266 + where="$( readlink -e "${where}" )"
1.267 + status=yes
1.268 + break;
1.269 + fi
1.270 + printf "no\n"
1.271 + done
1.272 + ;;
1.273 + esac
1.274 + if [ -z "${status}" ]; then
1.275 + printf "\n${err:-${prog}${inc}${lib}: none found}\n\n"
1.276 + printf "Either you are missing entirely the needed tool,\n"
1.277 + printf "or the version you have is too old.\n"
1.278 + if [ -n "${var}" ]; then
1.279 + printf "You can give the path to this tool using: --with-${var}=PATH\n"
1.280 + fi
1.281 + # FORCE can be set in the environment
1.282 + [ -z "${FORCE}" ] && do_error "Bailing out..."
1.283 + printf "\n"
1.284 + printf "<* *>\n"
1.285 + printf "<* FORCE in action: *>\n"
1.286 + printf "<* Continuing despite missing pre-requisite *>\n"
1.287 + printf "<* Prepare for breakage *>\n"
1.288 + printf "<* *>\n"
1.289 + printf "\n"
1.290 + else
1.291 + printf "${status}"
1.292 + if [ -n "${var}" ]; then
1.293 + eval ${var}='"'"${where}"'"'
1.294 + add_to_var_list "${var}"
1.295 + fi
1.296 + printf "\n"
1.297 + fi
1.298 +}
1.299 +
1.300 do_help() {
1.301 cat <<__EOF__
1.302 \`configure' configures crosstool-NG-${VERSION} to adapt to many kind of systems.
1.303 @@ -213,6 +200,8 @@
1.304
1.305 Configuration:
1.306 -h, --help display this help and exit
1.307 + --force force configure to continue, even in case
1.308 + some pre-requisites are missing
1.309
1.310 Installation directories:
1.311 --prefix=PREFIX install files in PREFIX [${PREFIX_DEFAULT}]
1.312 @@ -233,10 +222,9 @@
1.313
1.314 Optional Features:
1.315 --with-install=PATH Specify the full PATH to GNU install
1.316 - --with-make=PATH Specify the full PATH to GNU make
1.317 + --with-make=PATH Specify the full PATH to GNU make >= 3.80
1.318 --with-grep=PATH Specify the full PATH to GNU grep
1.319 --with-sed=PATH Specify the full PATH to GNU sed
1.320 - --with-awk=PATH Specify the full PATH to GNU awk
1.321 --with-bash=PATH Specify the full PATH to bash >= 3.0
1.322 __EOF__
1.323 }
1.324 @@ -246,13 +234,14 @@
1.325
1.326 while [ $# -ne 0 ]; do
1.327 case "$1" in
1.328 - --local) LOCAL_set=1; shift;;
1.329 + --local) LOCAL_set="y"; shift;;
1.330 --prefix*) set_prefix "$1" "$2" && shift || shift 2;;
1.331 --bindir*) set_bindir "$1" "$2" && shift || shift 2;;
1.332 --libdir*) set_libdir "$1" "$2" && shift || shift 2;;
1.333 --docdir*) set_docdir "$1" "$2" && shift || shift 2;;
1.334 --mandir*) set_mandir "$1" "$2" && shift || shift 2;;
1.335 --with-*) set_tool "$1" "$2" && shift || shift 2;;
1.336 + --force) FORCE=1; shift;;
1.337 --help|-h) do_help; exit 0;;
1.338 *) echo "Unrecognised option: '${1}'"; do_help; exit 1;;
1.339 esac
1.340 @@ -262,7 +251,7 @@
1.341 [ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
1.342
1.343 # Special case when installing locally
1.344 -if [ "${LOCAL_set}" = "1" ]; then
1.345 +if [ "${LOCAL_set}" = "y" ]; then
1.346 set_prefix "" "$( pwd )"
1.347 set_bindir "" "$( pwd )"
1.348 set_libdir "" "$( pwd )"
1.349 @@ -298,6 +287,7 @@
1.350 echo "You can give the path to this tool using: --with-grep=PATH"
1.351 do_error "Bailing out..."
1.352 fi
1.353 +add_to_var_list grep
1.354
1.355 printf "Checking for 'sed'... "
1.356 if [ -n "${sed}" ]; then
1.357 @@ -325,24 +315,53 @@
1.358 echo "You can give the path to this tool using: --with-sed=PATH"
1.359 do_error "Bailing out..."
1.360 fi
1.361 +add_to_var_list sed
1.362
1.363 -# Check the existence of absolutely required tools
1.364 -save_IFS="${IFS}"
1.365 -IFS='
1.366 -'
1.367 -for tool in ${TOOLS_TO_CHECK}; do
1.368 - has_or_abort "${tool}"
1.369 -done
1.370 -IFS="${save_IFS}"
1.371 +# The regular list of tools we can now easily check for
1.372 +has_or_abort prog=bash \
1.373 + var=bash \
1.374 + ver='^GNU bash, version [34]\.' \
1.375 + err="'bash' 3.x or above was not found"
1.376 +has_or_abort prog=cut
1.377 +has_or_abort prog=install var=install
1.378 +has_or_abort prog=make \
1.379 + var=make \
1.380 + ver='^GNU Make (3.[89][[:digit:]]|[4-9])' \
1.381 + err="GNU 'make' 3.80 or above was not found"
1.382 +has_or_abort prog=gcc
1.383 +has_or_abort prog=awk
1.384 +has_or_abort prog=bison
1.385 +has_or_abort prog=flex
1.386 +has_or_abort prog=makeinfo
1.387 +has_or_abort prog=automake \
1.388 + ver='\(GNU automake\) (1\.[[:digit:]]{2,}\.|[2-9][[:digit:]]*\.)' \
1.389 + err="'automake' 1.10 or above was not found"
1.390 +has_or_abort prog=libtool \
1.391 + ver='\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)' \
1.392 + err="'libtool' 1.5.26 or above was not found"
1.393 +has_or_abort prog="curl wget"
1.394 +has_or_abort prog=patch
1.395 +has_or_abort prog=tar
1.396 +has_or_abort prog=gzip
1.397 +has_or_abort prog=bzip2
1.398 +has_or_abort prog=lzma
1.399 +has_or_abort prog=readlink
1.400 +
1.401 +has_or_abort inc="ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h" \
1.402 + err="'ncurses' headers files were not found"
1.403 +
1.404 +has_or_abort lib="$( echo lib{ncursesw,ncurses,curses}.{so,a,dylib} )" \
1.405 + err="'ncurses' library was not found"
1.406
1.407 #---------------------------------------------------------------------
1.408 # Compute the version string
1.409
1.410 # If this version is a svn snapshot, try to get the revision number
1.411 # If we can't get the revision number, use date
1.412 -printf "Computing version string... "
1.413 case "${VERSION}" in
1.414 *+svn|svn)
1.415 + has_or_abort prog=svnversion
1.416 + printf "Computing version string... "
1.417 REVISION="$( LC_ALL=C svnversion )"
1.418 case "${REVISION}" in
1.419 exported)
1.420 @@ -389,11 +408,6 @@
1.421 # That's all, folks!
1.422
1.423 printf "Building up Makefile... "
1.424 -var_list="grep
1.425 - sed
1.426 - $( printf "${TOOLS_TO_CHECK}" \
1.427 - |"${sed}" -r -e 's/^(([^=:]+):.+|[^:=]+=.+|[^:=]+)$/\2/;'
1.428 - )"
1.429 var_sed="$( for var_name in ${var_list}; do
1.430 eval echo 's,@@${var_name}@@,${'"${var_name}"'},g'
1.431 done
1.432 @@ -419,5 +433,7 @@
1.433
1.434 Now run:
1.435 make
1.436 - make install
1.437 __EOF__
1.438 +if [ "${LOCAL_set}" != "y" ]; then
1.439 + printf " make install\n"
1.440 +fi