configure
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Aug 21 23:11:26 2011 +0200 (2011-08-21)
changeset 2623 e8e30025fcc5
parent 2622 bc9f7c29311e
child 2625 b1be254591e7
permissions -rwxr-xr-x
configure: recognise and handle --program-transform-name

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     1 #!/bin/sh
     2 
     3 myname="${0##*/}"
     4 
     5 VERSION=$( cat .version )
     6 DATE=$( date +%Y%m%d )
     7 
     8 PREFIX_DEFAULT=/usr/local
     9 
    10 BINDIR_set=
    11 LIBDIR_set=
    12 DOCDIR_set=
    13 MANDIR_set=
    14 PROG_PFX=
    15 PROG_SFX=
    16 PROG_SED=
    17 LOCAL_set=
    18 FORCE=
    19 
    20 do_quit=
    21 
    22 # Simply print the error message, and exit. Obvious, he?
    23 do_error() {
    24     printf "${myname}: ${@}\n"
    25     exit 1
    26 }
    27 
    28 # Given an option string and the following argument,
    29 # echoes the value of the option.
    30 # If --var=val => echoes val and returns 0, meaning second arg was not consumed
    31 # If --var val => echoes val and returns non null, meaning second arg was used
    32 get_optval(){
    33     case "$1" in
    34         --*=?*)
    35             printf "${1#*=}"
    36             return 0
    37             ;;
    38         *)
    39             printf "${2}"
    40             return 1
    41             ;;
    42     esac
    43 }
    44 
    45 # The set_xxx functions will set the corresponding configuration variable
    46 # They return 0 if second arg was not consumed, and non-zero if it was consumed.
    47 set_prefix() {
    48     PREFIX="$( get_optval "$1" "$2" )"
    49 }
    50 set_bindir() {
    51     BINDIR_set=1
    52     BINDIR="$( get_optval "$1" "$2" )"
    53 }
    54 set_libdir() {
    55     LIBDIR_set=1
    56     LIBDIR="$( get_optval "$1" "$2" )"
    57 }
    58 set_docdir() {
    59     DOCDIR_set=1
    60     DOCDIR="$( get_optval "$1" "$2" )"
    61 }
    62 set_mandir() {
    63     MANDIR_set=1
    64     MANDIR="$( get_optval "$1" "$2" )"
    65 }
    66 set_program_prefix() {
    67     PROG_PFX="$( get_optval "$1" "$2" )"
    68 }
    69 set_program_suffix() {
    70     PROG_SFX="$( get_optval "$1" "$2" )"
    71 }
    72 set_program_transform_name() {
    73     PROG_SED="$( get_optval "$1" "$2" )"
    74 }
    75 set_tool() {
    76     local var_name="${1%%=*}"
    77     var_name="${var_name#--with-}"
    78     eval ${var_name}="\$( get_optval "$1" "$2" )"
    79 }
    80 
    81 # var_list is a list of variables, each one holding a path to a
    82 # tool, either detected by ./configure, or specified by the user.
    83 var_list=""
    84 kconfig_list=""
    85 
    86 # This function adds a variable name to the above list of variable names.
    87 # $1: the name of the variable to add to the list
    88 add_to_var_list() {
    89     local v
    90     for v in ${var_list}; do
    91         [ "${v}" = "${1}" ] && return 0
    92     done
    93     var_list="${var_list} ${1}"
    94 }
    95 add_to_kconfig_list() {
    96     local k
    97     for k in ${kconfig_list}; do
    98         [ "${k}" = "${1}" ] && return 0
    99     done
   100     kconfig_list="${kconfig_list} ${1}"
   101 }
   102 
   103 # A function to test for required tools/headers/libraries
   104 # Return 0 (true) if found, !0 (false) if not found
   105 #
   106 # $*: [prog|inc|lib]=<name[ name...]>
   107 #     the name(s) of tool(s) to test for
   108 #     mandatory
   109 #       eg: prog=bash   prog="curl wget"
   110 # $*: var=<var_name>
   111 #     the name of the variable to test and set
   112 #     optional
   113 #       eg: var=bash    if ${bash} is set and non-null, use that,
   114 #                       else check for bash and set bash=$(which bash)
   115 # $*: ver=<regexp>
   116 #     for each 'prog', test if $(prog --version) matches 'regexp'
   117 #     optional
   118 #       eg: ver='^GNU bash, version [34]\.'
   119 # $*: lib_exts=<extension[ extension...]>
   120 #     the list of allowed library extension
   121 #     mandatory
   122 #       eg: lib_exts="so dylib"     lib_exts="so dylib a"
   123 # $*: err=<error_message>
   124 #     the error message to print if tool is missing
   125 #     optional, defaults to: '${prog}: none found'
   126 #       eg: err="'bash' 3.x or above was not found"
   127 #     Note: err may be printed by caller, not us
   128 # $*: kconfig=<var_name>
   129 #     the name of a variable to pass down to kconfig if
   130 #     the prog/inc/lib was found
   131 #     optional, defaults to none
   132 #       eg: kconfig=has_libncurses
   133 # $*: skip=[y|n|]
   134 #     if set to 'y', skip the test, but still register the
   135 #     kconfig and var variables; if 'n' or empty, do the
   136 #     test.
   137 #     optional, default to 'n'
   138 #       eg: skip="${static_link_ko}"
   139 check_for() {
   140     local lib_exts
   141     local skip
   142     local val
   143     local item
   144     local where
   145     local status
   146     local ext
   147 
   148     # Note: prog/inc/lib and var/kconfig/ver/err are set here,
   149     # but declared by the caller (because it needs it)
   150     for item in "${@}"; do
   151         case "${item}" in
   152             prog=*|inc=*|lib=*|var=*|ver=*|err=*|kconfig=*|lib_exts=*|skip=*)
   153                 eval ${item%%=*}=\"${item#*=}\"
   154                 ;;
   155             *)  do_error "check_for: incorrect parameters: '${item}'";;
   156         esac
   157     done
   158 
   159     case "${prog}:${inc}:${lib}" in
   160         ?*:?*:|?*::?*|:?*:?*|?*:?*:?*)
   161             if [ -n "${var}" ]; then
   162                 do_error "check_for: the use of var is not compatible with passing several of [prog|inc|lib] at once"
   163             fi
   164             ;;
   165         ::) do_error "check_for: [prog|inc|lib] is mandatory";;
   166     esac
   167 
   168     if [ -n "${var}" ]; then
   169         add_to_var_list "${var}"
   170     fi
   171     if [ -n "${kconfig}" ]; then
   172         add_to_kconfig_list "${kconfig}"
   173     fi
   174 
   175     if [ "${skip}" = "y" ]; then
   176         return 0
   177     fi
   178 
   179     if [ -n "${prog}" ]; then
   180         for item in ${prog}; do
   181             printf "Checking for '${item}'... "
   182             if [ -n "${var}" ]; then
   183                 eval val="\${${var}}"
   184                 if [ -n "${val}" ]; then
   185                     status="${val} (cached)\n"
   186                     break
   187                 fi
   188             fi
   189             where="$( which "${item}" 2>/dev/null )"
   190             if [ -z "${where}" ]; then
   191                 printf "no\n"
   192                 continue
   193             elif [ -n "${ver}" ]; then
   194                 str=$( LC_ALL=C "${where}" --version 2>&1   \
   195                        |grep -E "${ver}"                    \
   196                        |head -n 1
   197                      )
   198                 if [ -z "${str}" ]; then
   199                     printf "no\n"
   200                     unset where
   201                     continue
   202                 fi
   203             fi
   204             status="${where}"
   205             break
   206         done
   207         if [ -z "${status}" ]; then
   208             return 1
   209         fi
   210         printf "${status}\n"
   211         unset status
   212     fi
   213 
   214     if [ -n "${inc}" ]; then
   215         for item in ${inc}; do
   216             printf "Checking for '${item}'... "
   217             if printf "#include \"${item}\"" |gcc -x c -c - -o /dev/null >/dev/null 2>&1; then
   218                 where="${item}"
   219                 status=yes
   220                 break;
   221             fi
   222             printf "no\n"
   223         done
   224         if [ -z "${status}" ]; then
   225             return 1
   226         fi
   227         printf "${status}\n"
   228         unset status
   229     fi
   230 
   231     if [ -n "${lib}" ]; then
   232         if [ -z "${lib_exts}" ]; then
   233             do_error "check_for: no library extension specified for '${lib}'"
   234         fi
   235         for item in ${lib}; do
   236             for ext in ${lib_exts}; do
   237                 printf "Checking for '${item}.${ext}'... "
   238                 where="$( gcc -print-file-name="${item}.${ext}" )"
   239                 if [ "${where}" != "${item}.${ext}" ]; then
   240                     where="$( readlink "${where}" )"
   241                     status=yes
   242                     break 2;
   243                 fi
   244                 printf "no\n"
   245             done
   246         done
   247         if [ -z "${status}" ]; then
   248             return 1
   249         fi
   250         printf "${status}\n"
   251         unset status
   252     fi
   253 
   254     if [ -n "${var}" ]; then
   255         eval ${var}='"'"${where}"'"'
   256     fi
   257     if [ -n "${kconfig}" ]; then
   258         eval ${kconfig}=y
   259     fi
   260 }
   261 
   262 # This function checks for a tool, and aborts if not found
   263 # See check_for(), above, for how to call has_or_abort
   264 has_or_abort() {
   265     # We declare these 6 variables here, although they are
   266     # set in check_for(), called below
   267     local prog inc lib
   268     local var ver err kconfig
   269 
   270     if ! check_for "$@"; then
   271         printf " * A mandatory dependency is missing, or version mis-match:\n"
   272         printf " * - ${err:-${prog}${inc}${lib}: none found}\n"
   273         if [ -n "${var}" ]; then
   274             printf " * --> You can give the path to this tool using: --with-${var}=PATH\n"
   275         fi
   276         printf "\n"
   277         # Bail out if --force is not specified
   278         [ -z "${FORCE}" ] && do_error "Bailing out..."
   279         printf "<*                                          *>\n"
   280         printf "<*            FORCE in action:              *>\n"
   281         printf "<* Continuing despite missing pre-requisite *>\n"
   282         printf "<*          Prepare for breakage            *>\n"
   283         printf "<*                                          *>\n"
   284         printf "\n"
   285     fi
   286 }
   287 
   288 # This function checks for a tool, and warns if not found
   289 # See check_for(), above, for how to call has_or_abort
   290 # Note: if err is not set, then no error message is printed
   291 has_or_warn() {
   292     # We declare these 6 variables here, although they are
   293     # set in check_for(), called below
   294     local prog inc lib
   295     local var ver err kconfig
   296 
   297     if ! check_for "$@"; then
   298         printf " * An optional dependency is missing, some features will be disabled"
   299         printf "${err:+:\n * - ${err}}\n"
   300         if [ -n "${var}" ]; then
   301             printf " * --> You can give the path to this tool using: --with-${var}=PATH\n"
   302         fi
   303     fi
   304 }
   305 
   306 do_help() {
   307     cat <<__EOF__
   308 \`configure' configures crosstool-NG-${VERSION} to adapt to many kind of systems.
   309 
   310 USAGE: ./configure [OPTION]...
   311 
   312 Defaults for the options are specified in brackets.
   313 
   314 Configuration:
   315   -h, --help              display this help and exit
   316       --force             force configure to continue, even in case
   317                           some pre-requisites are missing
   318 
   319 Installation directories:
   320   --prefix=PREFIX         install files in PREFIX [${PREFIX_DEFAULT}]
   321   --local                 don't install, and use current directory
   322 
   323 By default, \`make install' will install all the files in
   324 \`${PREFIX_DEFAULT}/bin', \`${PREFIX_DEFAULT}/lib' etc.  You can specify
   325 an installation prefix other than \`${PREFIX_DEFAULT}' using \`--prefix',
   326 for instance \`--prefix=\${HOME}'.
   327 
   328 For better control, use the options below.
   329 Note: options marked as \`ignored' are recognised, but not acted upon, as
   330 they make no sense for crosstool-NG, or they are not implemented yet.
   331 
   332 Fine tuning of the installation directories:
   333   --bindir=DIR            user executables [PREFIX/bin]
   334   --libdir=DIR            object code libraries [PREFIX/lib]
   335   --docdir=DIR            info documentation [PREFIX/share/doc]
   336   --mandir=DIR            man documentation [PREFIX/share/man]
   337   --infodir=DIR           info documentation [DATAROOTDIR/info] (ignored)
   338   --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
   339                           (ignored)
   340   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc] (ignored)
   341   --localstatedir=DIR     modifiable single-machine data [PREFIX/var] (ignored)
   342 
   343 Program names:
   344   --program-prefix=PREFIX            prepend PREFIX to installed program names
   345   --program-suffix=SUFFIX            append SUFFIX to installed program names
   346   --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
   347 
   348 System types:
   349   --build=BUILD     configure for building on BUILD [guessed] (ignored)
   350   --host=HOST       cross-compile to build programs to run on HOST [BUILD]
   351                     (ignored)
   352 
   353 Optional Features:
   354   --enable-shared[=PKGS]  build shared libraries [default=yes] (ignored)
   355   --enable-static[=PKGS]  build static libraries [default=yes] (ignored)
   356 
   357 Optional Packages:
   358   --with-install=PATH     Specify the full PATH to GNU install
   359   --with-make=PATH        Specify the full PATH to GNU make >= 3.80
   360   --with-grep=PATH        Specify the full PATH to GNU grep
   361   --with-sed=PATH         Specify the full PATH to GNU sed
   362   --with-bash=PATH        Specify the full PATH to bash >= 3.0
   363 __EOF__
   364 }
   365 
   366 #---------------------------------------------------------------------
   367 # Set user's options
   368 
   369 while [ $# -ne 0 ]; do
   370     case "$1" in
   371         --local)    LOCAL_set="y"; shift;;
   372         --prefix*)  set_prefix "$1" "$2" && shift || shift 2;;
   373         --bindir*)  set_bindir "$1" "$2" && shift || shift 2;;
   374         --libdir*)  set_libdir "$1" "$2" && shift || shift 2;;
   375         --docdir*)  set_docdir "$1" "$2" && shift || shift 2;;
   376         --mandir*)  set_mandir "$1" "$2" && shift || shift 2;;
   377         --with-*)   set_tool   "$1" "$2" && shift || shift 2;;
   378         --program-prefix=*|--program-prefix)
   379                     set_program_prefix "$1" "$2" && shift || shift 2
   380                     ;;
   381         --program-suffix=*|--program-suffix)
   382                     set_program_suffix "$1" "$2" && shift || shift 2
   383                     ;;
   384         --program-transform-name=*|--program-transform-name)
   385                     set_program_transform_name "$1" "$2" && shift || shift 2
   386                     ;;
   387         --force)    FORCE=1; shift;;
   388         --help|-h)  do_help; exit 0;;
   389         # Skip, auto-stuff compatibility
   390         --build=*|--host=*|--infodir=*|--datadir=*|--sysconfdir=*|--localstatedir=*) shift;;
   391         --build|--host|--infodir|--datadir|--sysconfdir|--localstatedir)             shift 2;;
   392         --enable-shared|--disable-shared|--enable-static|--disable-static)           shift;;
   393         *)          printf "Unrecognised option: '${1}'\n"; do_help; exit 1;;
   394     esac
   395 done
   396 
   397 # Use defaults
   398 [ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
   399 
   400 # Special case when installing locally
   401 if [ "${LOCAL_set}" = "y" ]; then
   402     set_prefix "" "$( pwd )"
   403     set_bindir "" "$( pwd )"
   404     set_libdir "" "$( pwd )"
   405     set_docdir "" "$( pwd )/docs"
   406     set_mandir "" "$( pwd )/docs"
   407     set_program_prefix "" ""
   408     set_program_suffix "" ""
   409     set_program_transform_name "" ""
   410 fi
   411 
   412 #---------------------------------------------------------------------
   413 # Some sanity checks, now
   414 
   415 # We check for grep and sed manually, because they are used in check_for()
   416 printf "Checking for 'grep'... "
   417 if [ -n "${grep}" ]; then
   418     printf "${grep} (cached)\n"
   419 else
   420     grep="$( which grep 2>/dev/null )"
   421     if [ -z "${grep}" ]; then
   422         printf "not found\n"
   423     else
   424         printf "${grep}\n"
   425         printf "Checking whether '${grep}' supports -E... "
   426         if echo 'foo' |"${grep}" -E 'foo' >/dev/null 2>&1; then
   427             printf "yes\n"
   428         else
   429             printf "no\n"
   430             grep=
   431         fi
   432     fi
   433 fi
   434 if [ -z "${grep}" ]; then
   435     printf "Either you are missing entirely the needed tool,\n"
   436     printf "or the version you have is too old.\n"
   437     printf "You can give the path to this tool using: --with-grep=PATH\n"
   438     do_error "Bailing out..."
   439 fi
   440 add_to_var_list grep
   441 
   442 printf "Checking for 'sed'... "
   443 if [ -n "${sed}" ]; then
   444     printf "${sed} (cached)\n"
   445 else
   446     sed="$( which sed 2>/dev/null )"
   447     if [ -z "${sed}" ]; then
   448         printf "not found\n"
   449     else
   450         printf "${sed}\n"
   451         printf "Checking whether '${sed}' supports -i and -e... "
   452         touch .ct-ng.sed.test
   453         if "${sed}" -r -i -e 's/foo/bar/' .ct-ng.sed.test >/dev/null 2>&1; then
   454             printf "yes\n"
   455         else
   456             printf "no\n"
   457             sed=
   458         fi
   459         rm -f .ct-ng.sed.test
   460     fi
   461 fi
   462 if [ -z "${sed}" ]; then
   463     printf "Either you are missing entirely the needed tool,\n"
   464     printf "or the version you have is too old.\n"
   465     printf "You can give the path to this tool using: --with-sed=PATH\n"
   466     do_error "Bailing out..."
   467 fi
   468 add_to_var_list sed
   469 
   470 # The regular list of tools we can now easily check for
   471 has_or_abort prog=bash                              \
   472              var=bash                               \
   473              ver='^GNU bash, version (3\.[1-9]|4)'  \
   474              err="'bash' 3.1 or above was not found"
   475 has_or_abort prog=cut
   476 has_or_abort prog=install var=install
   477 has_or_abort prog=make                                  \
   478              var=make                                   \
   479              ver='^GNU Make (3.[89][[:digit:]]|[4-9])'  \
   480              err="GNU 'make' 3.80 or above was not found"
   481 has_or_abort prog=gcc
   482 has_or_abort prog="awk gawk" ver='^GNU Awk' err="GNU 'awk' was not found"
   483 has_or_abort prog=bison
   484 has_or_abort prog=flex
   485 has_or_abort prog=makeinfo
   486 has_or_abort prog=automake                                                      \
   487              ver='\(GNU automake\) (1\.[[:digit:]]{2,}|[2-9][[:digit:]]*\.)'    \
   488              err="'automake' 1.10 or above was not found"
   489 has_or_abort prog=libtool                                                                           \
   490              var=libtool                                                                            \
   491              ver='\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)'   \
   492              err="'libtool' 1.5.26 or above was not found"
   493 has_or_abort prog=stat
   494 has_or_abort prog="curl wget"
   495 has_or_abort prog=patch
   496 has_or_abort prog=tar
   497 has_or_abort prog=gzip
   498 has_or_abort prog=bzip2
   499 has_or_warn  prog=xz                                        \
   500              kconfig=has_xzutils                            \
   501              err="xz-comoressed tarballs will not be used"
   502 has_or_abort prog=readlink
   503 has_or_abort prog=objcopy var=objcopy
   504 has_or_abort prog=objdump var=objdump
   505 has_or_abort prog=readelf var=readelf
   506 has_or_abort prog=patch var=patch
   507 has_or_warn  prog=cvs                                                   \
   508              kconfig=has_cvs                                            \
   509              err="it will not be possible to use newlib cvs snapshots"
   510 has_or_warn  prog=svn                               \
   511              kconfig=has_svn                        \
   512              err="subversion is required to download eglibc"
   513 
   514 # Host system checks
   515 
   516 printf "Checking for host system... "
   517 host="$( uname -s )"
   518 printf "%s\n" "${host}"
   519 case "${host}" in
   520     Linux)  ;;
   521     Cygwin) ;;
   522     *)
   523         printf " * Runing under %s is not fully tested\n" "${host}"
   524         printf " * You may encounter some weird behavior\n"
   525         ;;
   526 esac
   527 
   528 printf "Checking if static linking is possible... "
   529 static_link_ok=""
   530 case "${host}" in
   531     Darwin) ;;
   532     *)  tmp=.static.tmp
   533         if gcc -xc - -static -o "${tmp}" >/dev/null 2>&1 <<-_EOF_
   534 				int main() { return 0; }
   535 			_EOF_
   536         then
   537             static_link_ok="y"
   538         fi
   539         rm -f "${tmp}"
   540         ;;
   541 esac
   542 if [ "${static_link_ok}" = "y" ]; then
   543     static_link_ko=""
   544     printf "yes\n"
   545 else
   546     static_link_ko="y"
   547     printf "no\n"
   548     printf " * An optional host feature is missing, some features will be disabled:\n"
   549     printf " * - It will not be possible to statically link toolchain's binaries\n"
   550 fi
   551 add_to_kconfig_list static_link_ok
   552 
   553 # Library checks
   554 libs_exts="so dylib"
   555 if [ "${static_link_ok}" = "y" ]; then
   556     libs_exts="${libs_exts} a"
   557 fi
   558 
   559 ncurses_hdrs="ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h"
   560 ncurses_libs="libncursesw libncurses libcurses"
   561 has_or_abort lib="${ncurses_libs}"                                          \
   562              lib_exts="${libs_exts}"                                        \
   563              inc="${ncurses_hdrs}"                                          \
   564              err="The 'ncurses' library is needed fo the menuconfig frontend"
   565 
   566 has_or_abort lib="libstdc++"            \
   567              lib_exts="${libs_exts}"    \
   568              err="The 'libstdc++' library is needed to build gcc"
   569 
   570 # Yes, we may be checking twice for libstdc++.a
   571 # The first is because we need one instance of libstdc++ (shared or static)
   572 # because it is needed for PPL; the second is because the static version is
   573 # required for static-linking, and if missing, the option is removed.
   574 has_or_warn  lib="libstdc++"                \
   575              lib_exts="a"                   \
   576              err="static 'libstdc++' is needed to statically link the toolchain's executables" \
   577              kconfig=has_static_libstdcxx   \
   578              skip="${static_link_ko}"
   579 
   580 has_or_warn  inc="expat.h"              \
   581              lib="libexpat"             \
   582              lib_exts="${libs_exts}"    \
   583              err="The 'expat' header file and library are needed to link cross-gdb's executables" \
   584              kconfig=has_expat
   585 
   586 # Yes, we may be checking twice for libexpat.a
   587 # The first is because we need one instance of libexpat (shared or static)
   588 # because it is needed for cross-gdb; the second is because the static version
   589 # is required for static-linking, and if missing, the option is removed.
   590 has_or_warn  lib="libexpat"             \
   591              lib_exts="a"               \
   592              err="static 'expat' is needed to statically link cross-gdb's executables" \
   593              kconfig=has_static_expat   \
   594              skip="${static_link_ko}"
   595 
   596 for v in 7 6 5 4; do
   597     python_incs="${python_incs} python2.${v}/Python.h"
   598     python_libs="${python_libs} libpython2.${v}"
   599 done
   600 has_or_warn  inc="${python_incs}"       \
   601              lib="${python_libs}"       \
   602              lib_exts="${libs_exts}"    \
   603              err="The 'python' header file and library are needed for some features of cross-gdb"
   604 
   605 #---------------------------------------------------------------------
   606 # Compute the version string
   607 
   608 # If this version is n hg clone, try to get the revision number
   609 # If we can't get the revision number, use date
   610 printf "\nComputing version string... "
   611 case "${VERSION}" in
   612     *+hg|hg)
   613         REVISION="$( hg id -n 2>/dev/null || true )"
   614         case "${REVISION}" in
   615             "")
   616                 VERSION="${VERSION}_unknown@$( date +%Y%m%d.%H%M%S )";;
   617             *)
   618                 VERSION="${VERSION}_$( hg id -b )@${REVISION%%+}_$( hg id -i )"
   619                 ;;
   620         esac
   621         # Arrange to have no / in the directory name, no need to create an
   622         # arbitrarily deep directory structure
   623         VERSION="$( printf "${VERSION}\n" |"${sed}" -r -e 's|/+|_|g;' )"
   624         ;;
   625 esac
   626 printf "${VERSION}\n"
   627 
   628 #---------------------------------------------------------------------
   629 # Compute and check install paths
   630 
   631 # Now we have the version string, we can build up the paths
   632 [ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin"
   633 [ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib"
   634 [ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc"
   635 [ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man"
   636 
   637 # Install support files in our own sub-dir, so as not to mangle (system)
   638 # files and dirs, but only if not --local
   639 if [ -z "${LOCAL_set}" ]; then
   640     LIBDIR="${LIBDIR}/ct-ng-${VERSION}"
   641     DOCDIR="${DOCDIR}/ct-ng-${VERSION}"
   642 fi
   643 
   644 # Check that install PATHs are absolute
   645 for p in BIN LIB DOC MAN; do
   646     var="${p}DIR"
   647     eval v='"${'"${var}"'}"'
   648     case "${v}" in
   649         /*) ;;
   650         *)  do_error "'${var}' is not an absolute path: '${v}'";;
   651     esac
   652 done
   653 case "${PROG_PFX}" in
   654     */*)    do_error "program prefix '${PROG_PFX}' contains a '/'";;
   655 esac
   656 case "${PROG_SFX}" in
   657     */*)    do_error "program suffix '${PROG_SFX}' contains a '/'";;
   658 esac
   659 
   660 #---------------------------------------------------------------------
   661 # That's all, folks!
   662 
   663 printf "Building up Makefile... "
   664 var_sed="$( for var_name in ${var_list}; do
   665                 eval echo 's,@@${var_name}@@,${'"${var_name}"'},g'
   666             done
   667           )"
   668 kconfig_sed="s/@@KCONFIG@@/$( for k_name in ${kconfig_list}; do
   669                                   eval printf \"${k_name}=\${${k_name}} \"
   670                               done
   671                             )/"
   672 "${sed}" -r -e "s,@@BINDIR@@,${BINDIR},g"       \
   673             -e "s,@@LIBDIR@@,${LIBDIR},g"       \
   674             -e "s,@@DOCDIR@@,${DOCDIR},g"       \
   675             -e "s,@@MANDIR@@,${MANDIR},g"       \
   676             -e "s,@@PROG_PFX@@,${PROG_PFX},g"   \
   677             -e "s,@@PROG_SFX@@,${PROG_SFX},g"   \
   678             -e "s,@@PROG_SED@@,${PROG_SED},g"   \
   679             -e "s,@@VERSION@@,${VERSION},g"     \
   680             -e "s,@@DATE@@,${DATE},g"           \
   681             -e "s,@@LOCAL@@,${LOCAL_set},g"     \
   682             -e "${var_sed}"                     \
   683             -e "${kconfig_sed}"                 \
   684          Makefile.in                            \
   685          >Makefile
   686 echo "done"
   687 
   688 cat <<__EOF__
   689 
   690 crosstool-NG configured as follows:
   691   PREFIX='${PREFIX}'
   692   BINDIR='${BINDIR}'
   693   LIBDIR='${LIBDIR}'
   694   DOCDIR='${DOCDIR}'
   695   MANDIR='${MANDIR}'
   696   PROG_PFX='${PROG_PFX}'
   697   PROG_SFX='${PROG_SFX}'
   698   PROG_SED='${PROG_SED}'
   699 
   700 Now run:
   701   make
   702 __EOF__
   703 if [ "${LOCAL_set}" != "y" ]; then
   704     printf "  make install\n"
   705 fi