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