configure
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Aug 19 22:43:01 2011 +0200 (2011-08-19)
changeset 2622 bc9f7c29311e
parent 2621 00853d565edf
child 2623 e8e30025fcc5
permissions -rwxr-xr-x
configure: recognise and handle --program-suffix

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