configure
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Jan 06 22:22:02 2009 +0000 (2009-01-06)
changeset 1130 78681fe5cdd1
parent 1105 3ba2a43353df
child 1132 c232833120c1
permissions -rwxr-xr-x
Update all samples to the latest set of config options.
There might be some small issues here and there due to the split of CT_ExtractAndPatch.

/trunk/samples/x86_64-unknown-linux-gnu/crosstool.config | 14 11 3 0 ++++++++++---
/trunk/samples/sh4-unknown-linux-gnu/crosstool.config | 13 10 3 0 +++++++++---
/trunk/samples/armeb-unknown-linux-uclibc/crosstool.config | 10 7 3 0 ++++++---
/trunk/samples/arm-unknown-elf/crosstool.config | 8 4 4 0 +++---
/trunk/samples/arm-unknown-linux-gnueabi/crosstool.config | 14 11 3 0 ++++++++++---
/trunk/samples/armeb-unknown-eabi/crosstool.config | 8 4 4 0 +++---
/trunk/samples/ia64-unknown-linux-gnu/crosstool.config | 13 10 3 0 +++++++++---
/trunk/samples/x86_64-unknown-linux-uclibc/crosstool.config | 11 8 3 0 +++++++---
/trunk/samples/armeb-unknown-linux-gnueabi/crosstool.config | 14 11 3 0 ++++++++++---
/trunk/samples/powerpc-e500v2-linux-gnuspe/crosstool.config | 11 8 3 0 +++++++---
/trunk/samples/i686-nptl-linux-gnu/crosstool.config | 14 11 3 0 ++++++++++---
/trunk/samples/powerpc-unknown-linux-gnu/crosstool.config | 14 11 3 0 ++++++++++---
/trunk/samples/arm-unknown-linux-gnu/crosstool.config | 14 11 3 0 ++++++++++---
/trunk/samples/mips-unknown-linux-uclibc/crosstool.config | 10 7 3 0 ++++++---
/trunk/samples/arm-unknown-linux-uclibcgnueabi/crosstool.config | 11 8 3 0 +++++++---
/trunk/samples/arm-iphone-linux-gnueabi/crosstool.config | 5 2 3 0 ++---
/trunk/samples/armeb-unknown-linux-gnu/crosstool.config | 14 11 3 0 ++++++++++---
/trunk/samples/powerpc-unknown_nofpu-linux-gnu/crosstool.config | 14 11 3 0 ++++++++++---
/trunk/samples/powerpc-unknown-linux-uclibc/crosstool.config | 10 7 3 0 ++++++---
/trunk/samples/arm-unknown-linux-uclibc/crosstool.config | 11 8 3 0 +++++++---
/trunk/samples/i586-geode-linux-uclibc/crosstool.config | 11 8 3 0 +++++++---
/trunk/samples/powerpc-405-linux-gnu/crosstool.config | 14 11 3 0 ++++++++++---
/trunk/samples/mips-unknown-elf/crosstool.config | 8 4 4 0 +++---
/trunk/samples/armeb-unknown-linux-uclibcgnueabi/crosstool.config | 11 8 3 0 +++++++---
/trunk/samples/mipsel-unknown-linux-gnu/crosstool.config | 13 10 3 0 +++++++++---
/trunk/samples/arm-unknown-eabi/crosstool.config | 8 4 4 0 +++---
/trunk/samples/alphaev56-unknown-linux-gnu/crosstool.config | 14 11 3 0 ++++++++++---
/trunk/samples/powerpc-860-linux-gnu/crosstool.config | 13 10 3 0 +++++++++---
28 files changed, 237 insertions(+), 88 deletions(-)
     1 #!/bin/sh
     2 
     3 VERSION=$( cat .version )
     4 DATE=$( date +%Y%m%d )
     5 
     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... :-/
    12 #
    13 # Format of a pattern to check for, one per line:
    14 #   pattern := tool_test  OR  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.
    19 #
    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' ).
    23 #
    24 # Examples:
    25 #    /bin/bash=^GNU bash, version 3\.
    26 #       will ensure that /bin/bash exists, and that $( /bin/bash --version )
    27 #       matches the regexp '^GNU bash, version 3\.'
    28 #    autoconf=(GNU Autoconf) || autoconf2.50
    29 #       will ensure that:
    30 #         - 'autoconf' is to be found in the PATH, and that $( autoconf --version )
    31 #           matches the regexp '(GNU Autoconf)' (which btw is the signature of
    32 #           autoconf >= 2.50),
    33 #       OR that:
    34 #         - 'autoconf2.50' is to be found in the PATH
    35 #
    36 TOOLS_TO_CHECK='
    37 /bin/bash=^GNU bash, version 3\.
    38 cut
    39 xargs
    40 make=^GNU Make
    41 gcc
    42 gawk=^GNU Awk
    43 bison
    44 flex
    45 makeinfo
    46 automake=\(GNU automake\) (1\.[[:digit:]]{2,}\.|[2-9][[:digit:]]*\.)
    47 libtool=\(GNU libtool\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)
    48 curl || wget
    49 patch
    50 tar
    51 gzip
    52 bzip2
    53 '
    54 
    55 PREFIX_DEFAULT=/usr/local
    56 
    57 BINDIR_set=
    58 LIBDIR_set=
    59 DOCDIR_set=
    60 MANDIR_set=
    61 LOCAL_set=
    62 
    63 FORCE=0
    64 
    65 do_quit=
    66 CONTRIB_list=
    67 
    68 # Simply print the error message, and exit. Obvious, he?
    69 do_error() {
    70     echo "${@}"
    71     exit 1
    72 }
    73 
    74 # A small function to test for existence of various tools
    75 # Usage: has_or_abort test_pattern (see top of file, TOOLS_TO_CHECK, for
    76 #                                   complete pattern format)
    77 has_or_abort() {
    78     save_IFS="${IFS}"
    79     tool_pattern="$( echo "${1}" |"${sed}" -r -e 's/ *\|\| */\n/g;' )"
    80     IFS='
    81 '
    82     for item in ${tool_pattern}; do
    83         case "${item}" in
    84             *=*)
    85                 tool="${item%%=*}"
    86                 regexp="${item#*=}"
    87                 ;;
    88             *)  tool="${item}"
    89                 regexp=
    90                 ;;
    91         esac
    92         printf "Checking for '${tool}'... "
    93         where=$( which "${tool}" 2>/dev/null )
    94         if [ -z "${where}" ]; then
    95             echo "not found"
    96             where=
    97             continue
    98         elif [ -n "${regexp}" ]; then
    99             tool_version=$( ${tool} --version 2>&1 )
   100             str=$( echo "${tool_version}" |"${grep}" -E "${regexp}" |head -n 1 )
   101             if [ -z "${str}" ]; then
   102                 echo "not found"
   103                 where=""
   104                 continue
   105             fi
   106         fi
   107         echo "${where}"
   108         break
   109     done;
   110     if [ -z "${where}" ]; then
   111         for item in ${tool_pattern}; do
   112             case "${item}" in
   113                 *=*)
   114                     tool="${item%%=*}"
   115                     regexp="${item#*=}"
   116                     ;;
   117                 *)  tool="${item}"
   118                     regexp=
   119                     ;;
   120             esac
   121             echo "  could not find '${tool}' matching regexp '${regexp}'"
   122         done
   123         echo "Either you are missing entirely the needed tool,"
   124         echo "or the version you have is tool old."
   125         [ ${FORCE} -eq 0 ] && do_error "Bailing out..."
   126     fi
   127     IFS="${save_IFS}"
   128     return 0
   129 }
   130 
   131 # Given an option string and the following argument,
   132 # echoes the value of the option.
   133 # If --var=val => echoes val and returns 0, meaning second arg was not consumed
   134 # If --var val => echoes val and returns non null, meaning second arg was used
   135 get_optval(){
   136     case "$1" in
   137         --*=?*)
   138             echo "${1}" |cut -d '=' -f 2-
   139             return 0
   140             ;;
   141         *)
   142             echo "${2}"
   143             return 1
   144             ;;
   145     esac
   146 }
   147 
   148 # The set_xxx functions will set the corresponding configuration variable
   149 # They return 0 if second arg was not consumed, and non-zero if it was consumed.
   150 set_prefix() {
   151     PREFIX="$( get_optval "$1" "$2" )"
   152 }
   153 set_bindir() {
   154     BINDIR_set=1
   155     BINDIR="$( get_optval "$1" "$2" )"
   156 }
   157 set_libdir() {
   158     LIBDIR_set=1
   159     LIBDIR="$( get_optval "$1" "$2" )"
   160 }
   161 set_docdir() {
   162     DOCDIR_set=1
   163     DOCDIR="$( get_optval "$1" "$2" )"
   164 }
   165 set_mandir() {
   166     MANDIR_set=1
   167     MANDIR="$( get_optval "$1" "$2" )"
   168 }
   169 
   170 # The set_contrib function is different in that it will work like the others,
   171 # except in two cases:
   172 # If all => replaces all with the list of all available contribs
   173 # If list => just echoes the list of all available contribs, and instructs
   174 # caller to quit immediately by setting do_quit to non null.
   175 # (can't use the return code, see above).
   176 set_contrib() {
   177     opt_val="$( get_optval "$1" "$2" )"
   178     ret=$?
   179     case "${opt_val}" in
   180         all)
   181             CONTRIB_list="$( LC_ALL=C ls -1 contrib/*.patch.lzma                \
   182                                       |xargs -I {} basename {} .patch.lzma      \
   183                                       |"${sed}" -r -e ':a; /$/N; s/\n/,/; ta;'  \
   184                            )"
   185             ;;
   186         list)
   187             do_quit=1
   188             echo "Available contributions:"
   189             LC_ALL=C ls -1 contrib/*.patch.lzma             \
   190                      |xargs -I {} basename {} .patch.lzma   \
   191                      |"${sed}" -r -e 's/^/  /;'
   192             ;;
   193         *)  CONTRIB_list="${CONTRIB_list},${opt_val}";;
   194     esac
   195     return $ret
   196 }
   197 
   198 do_help() {
   199     cat <<__EOF__
   200 \`configure' configures crosstool-NG ${VERSION} to adapt to many kind of systems.
   201 
   202 USAGE: ./configure [OPTION]...
   203 
   204 Defaults for the options are specified in brackets.
   205 
   206 Configuration:
   207   -h, --help              display this help and exit
   208       --force             force ./configure to complete, even if one or more
   209                           tools were not found. Use at your own risk, only if
   210                           you know what you are doing!
   211 
   212 Installation directories:
   213   --prefix=PREFIX         install files in PREFIX [${PREFIX_DEFAULT}]
   214   --local                 don't install, and use current directory
   215 
   216 By default, \`make install' will install all the files in
   217 \`${PREFIX_DEFAULT}/bin', \`${PREFIX_DEFAULT}/lib' etc.  You can specify
   218 an installation prefix other than \`${PREFIX_DEFAULT}' using \`--prefix',
   219 for instance \`--prefix=\${HOME}'.
   220 
   221 For better control, use the options below.
   222 
   223 Fine tuning of the installation directories:
   224   --bindir=DIR            user executables [PREFIX/bin]
   225   --libdir=DIR            object code libraries [PREFIX/lib]
   226   --docdir=DIR            info documentation [PREFIX/share/doc]
   227   --mandir=DIR            man documentation [PREFIX/share/man]
   228 
   229 Optional Features:
   230   --with-contrib=XXX      Include externally contributed features found in the
   231                           contrib/ sub-directory. Set to a comma-separated list
   232                           of features. Use 'all' to use all contributions, and
   233                           'list' to see which are available.
   234 __EOF__
   235 }
   236 
   237 #---------------------------------------------------------------------
   238 # Some sanity checks, now
   239 
   240 # We check for grep and sed manually, because it is used in has_or_abort
   241 printf "Checking for 'grep'... "
   242 grep="$( which grep 2>/dev/null )"
   243 [ -z "${grep}" ] && do_error "not found"
   244 echo "${grep}"
   245 printf "Checking whether '${grep}' supports -E... "
   246 if echo 'foo' |"${grep}" -E 'foo' >/dev/null 2>&1; then
   247     echo "yes"
   248 else
   249     do_error "no"
   250 fi
   251 printf "Checking for 'sed'... "
   252 sed="$( which sed 2>/dev/null )"
   253 [ -z "${sed}" ] && do_error "not found"
   254 echo "${sed}"
   255 
   256 # Check the existence of absolutely required tools
   257 save_IFS="${IFS}"
   258 IFS='
   259 '
   260 for tool in ${TOOLS_TO_CHECK}; do
   261     has_or_abort "${tool}"
   262 done
   263 IFS="${save_IFS}"
   264 
   265 #---------------------------------------------------------------------
   266 # Set user's options
   267 
   268 while [ $# -ne 0 ]; do
   269     case "$1" in
   270         --prefix*)  set_prefix "$1" "$2" && shift || shift 2;;
   271         --bindir*)  set_bindir "$1" "$2" && shift || shift 2;;
   272         --libdir*)  set_libdir "$1" "$2" && shift || shift 2;;
   273         --docdir*)  set_docdir "$1" "$2" && shift || shift 2;;
   274         --mandir*)  set_mandir "$1" "$2" && shift || shift 2;;
   275         --local)    LOCAL_set=1; shift;;
   276         --force)    FORCE=1; shift;;
   277         --with-contrib*)
   278                     set_contrib "$1" "$2" && shift || shift 2
   279                     [ "${do_quit}" = "1" ] && exit 0
   280                     ;;
   281         --help|-h)  do_help; exit 0;;
   282         *)          do_help; exit 1;;
   283     esac
   284 done
   285 
   286 # Use defaults
   287 [ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
   288 
   289 # Special case when installing locally
   290 if [ "${LOCAL_set}" = "1" ]; then
   291     set_prefix "" "$( pwd )"
   292     set_bindir "" "$( pwd )"
   293     set_libdir "" "$( pwd )"
   294     set_docdir "" "$( pwd )/docs"
   295     set_mandir "" "$( pwd )/docs"
   296 fi
   297 
   298 #---------------------------------------------------------------------
   299 # Apply contributed code
   300 
   301 # It's safer to change all ',' to spaces rather than setting IFS
   302 CONTRIB_list="$( echo "${CONTRIB_list}"                                     \
   303                  |"${sed}" -r -e 's/,+/ /g; s/ +/ /g; s/^ //g; s/ $//g;'    \
   304                )"
   305 if [ -n "${CONTRIB_list}" ]; then
   306     has_or_abort 'lzcat'
   307     printf "Applying contributed code: "
   308     for c in ${CONTRIB_list}; do
   309         printf "${c}, "
   310         if [ ! -f "contrib/${c}.patch.lzma" ]; then
   311             do_error "Contribution '${c}' does not exist"
   312         fi
   313         lzcat "contrib/${c}.patch.lzma" |patch -p1 >/dev/null 2>&1
   314     done
   315     echo "done"
   316 fi
   317 
   318 #---------------------------------------------------------------------
   319 # Compute the version string
   320 
   321 # If this version is a svn snapshot, try to get the revision number
   322 # If we can't get the revision number, use date
   323 printf "Computing version string... "
   324 case "${VERSION}" in
   325     *+svn|svn)
   326         REVISION="$( LC_ALL=C svnversion )"
   327         case "${REVISION}" in
   328             exported)
   329                 VERSION="${VERSION}_unknown@$( date +%Y%m%d.%H%M%S )";;
   330             *)
   331                 URL="$( LC_ALL=C svn info 2>/dev/null   \
   332                                  |egrep 'URL: '         \
   333                                  |cut -d ' ' -f 2-      \
   334                       )"
   335                 ROOT="$( LC_ALL=C svn info 2>/dev/null      \
   336                          |"${grep}" '^Repository Root: '    \
   337                          |cut -d ' ' -f 3-                  \
   338                        )"
   339                 VERSION="${VERSION}${URL#${ROOT}}@${REVISION}"
   340                 ;;
   341         esac
   342         # Arrange to have no / in the directory name, no need to create an
   343         # arbitrarily deep directory structure
   344         VERSION="$( echo "${VERSION}" |"${sed}" -r -e 's|/+|_|g;' )"
   345         ;;
   346 esac
   347 echo "${VERSION}"
   348 
   349 #---------------------------------------------------------------------
   350 # Compute and check install paths
   351 
   352 # Now we have the version string, we can build up the paths
   353 [ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin"
   354 [ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib/ct-ng-${VERSION}"
   355 [ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc/ct-ng-${VERSION}"
   356 [ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man/man1"
   357 
   358 # Check that install PATHs are absolute
   359 for p in BIN LIB DOC MAN; do
   360     var="${p}DIR"
   361     eval v='"${'"${var}"'}"'
   362     case "${v}" in
   363         /*) ;;
   364         *)  do_error "'${var}' is not an absolute path: '${v}'"
   365     esac
   366 done
   367 
   368 #---------------------------------------------------------------------
   369 # That's all, folks!
   370 
   371 printf "Building up Makefile... "
   372 "${sed}" -r -e "s,@@BINDIR@@,${BINDIR},g
   373                 s,@@LIBDIR@@,${LIBDIR},g
   374                 s,@@DOCDIR@@,${DOCDIR},g
   375                 s,@@MANDIR@@,${MANDIR},g
   376                 s,@@VERSION@@,${VERSION},g
   377                 s,@@DATE@@,${DATE},g
   378                 s,@@LOCAL@@,${LOCAL_set},g"  Makefile.in >Makefile
   379 echo "done"
   380 
   381 cat <<__EOF__
   382 
   383 crosstool-NG configured as follows:
   384   PREFIX='${PREFIX}'
   385   BINDIR='${BINDIR}'
   386   LIBDIR='${LIBDIR}'
   387   DOCDIR='${DOCDIR}'
   388   MANDIR='${MANDIR}'
   389   CONTRIB='${CONTRIB_list}'
   390 
   391 Now run:
   392   make
   393   make install
   394 __EOF__