configure
author "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
Wed Jun 08 15:47:43 2011 +0200 (2011-06-08)
changeset 2508 9e2761e59a75
parent 2507 a5856225d851
child 2509 45a4393fa357
permissions -rwxr-xr-x
debug/cross-gdb: check host dependencies

Cross-gdb depends on expat and python. If either is missing, cross-gdb will
build successfully, but lacking some features.

Especially, if expat is missing, cross-gdb will be unable to parse the target
description, which may lead to runtime malfunctions and the following GDB
warning:
"Can not parse XML target description; XML support was disabled at compile time"

Hence, expat should be considered mandatory.

On the other hand, the features missing without python are not critical, so
python should not be considered mandatory.

This patch does the following:
- At configure time, warn the user if either expat or python is missing.
- In menuconfig, disable the static build options regarding cross-gdb if no
static version of expat is available, and disable cross-gdb if expat is
missing.

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