configure
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Aug 17 23:05:01 2011 +0200 (2011-08-17)
changeset 2621 00853d565edf
parent 2619 628192dbf847
child 2622 bc9f7c29311e
permissions -rwxr-xr-x
configure: handle --program-prefix

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