comp-libs: make libelf a companion library
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Feb 17 23:41:17 2010 +0100 (2010-02-17)
changeset 181135cf5e2f110a
parent 1810 e44f67656c5f
child 1812 9c3bfbb46b19
comp-libs: make libelf a companion library

When gcc-4.5 is out, it will require libelf. So better make it a
companion library now rather than postponing the ineluctable.
config/companion_libs.in
config/companion_libs/libelf.in
config/debug/ltrace.in
config/tools/libelf.in
scripts/build/companion_libs/libelf.sh
scripts/build/tools/100-libelf.sh
scripts/crosstool-NG.sh.in
steps.mk
     1.1 --- a/config/companion_libs.in	Wed Feb 17 23:50:49 2010 +0100
     1.2 +++ b/config/companion_libs.in	Wed Feb 17 23:41:17 2010 +0100
     1.3 @@ -100,6 +100,20 @@
     1.4        can say 'Y' here, although it is unknown yet if any other component
     1.5        can use it.
     1.6  
     1.7 +config LIBELF
     1.8 +    bool
     1.9 +#    prompt "libelf"
    1.10 +    select COMPLIBS
    1.11 +    select WRAPPER_NEEDED
    1.12 +    help
    1.13 +      gcc-4.5.0 and above can also use libelf to enable some optimisation
    1.14 +      (LTO, Link-Time Optimisation, to be precise).  Although libelf is
    1.15 +      optional, crosstool-NG requires it and uses it to build gcc >= 4.5.0.
    1.16 +      
    1.17 +      This will be automatically selected if you choose gcc>=4.5.0, but you
    1.18 +      can say 'Y' here, although it is unknown yet if any other component
    1.19 +      can use it.
    1.20 +
    1.21  config GMP_TARGET
    1.22      bool
    1.23  
    1.24 @@ -125,6 +139,9 @@
    1.25      select PPL_TARGET
    1.26      select CLOOG_TARGET
    1.27  
    1.28 +config LIBELF_TARGET
    1.29 +    bool
    1.30 +
    1.31  if GMP || GMP_TARGET
    1.32  comment "GMP version needed to build for target"
    1.33      depends on !GMP
    1.34 @@ -150,6 +167,11 @@
    1.35      depends on !MPC
    1.36  source config/companion_libs/mpc.in
    1.37  endif
    1.38 +if LIBELF || LIBELF_TARGET
    1.39 +comment "libelf version needed to build for target"
    1.40 +    depends on !LIBELF
    1.41 +source config/companion_libs/libelf.in
    1.42 +endif
    1.43  
    1.44  config FOO
    1.45      bool
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/config/companion_libs/libelf.in	Wed Feb 17 23:41:17 2010 +0100
     2.3 @@ -0,0 +1,30 @@
     2.4 +# libelf config file
     2.5 +
     2.6 +choice
     2.7 +    bool
     2.8 +    prompt "libelf version"
     2.9 +# Don't remove next line
    2.10 +# CT_INSERT_VERSION_BELOW
    2.11 +
    2.12 +config LIBELF_V_0_8_12
    2.13 +    bool
    2.14 +    prompt "0.8.12"
    2.15 +
    2.16 +config LIBELF_V_0_8_11
    2.17 +    bool
    2.18 +    prompt "0.8.11"
    2.19 +
    2.20 +config LIBELF_V_0_8_10
    2.21 +    bool
    2.22 +    prompt "0.8.10 (OBSOLETE)"
    2.23 +    depends on OBSOLETE
    2.24 +
    2.25 +endchoice
    2.26 +
    2.27 +config LIBELF_VERSION
    2.28 +    string
    2.29 +# Don't remove next line
    2.30 +# CT_INSERT_VERSION_STRING_BELOW
    2.31 +    default "0.8.12" if LIBELF_V_0_8_12
    2.32 +    default "0.8.11" if LIBELF_V_0_8_11
    2.33 +    default "0.8.10" if LIBELF_V_0_8_10
     3.1 --- a/config/debug/ltrace.in	Wed Feb 17 23:50:49 2010 +0100
     3.2 +++ b/config/debug/ltrace.in	Wed Feb 17 23:41:17 2010 +0100
     3.3 @@ -1,7 +1,7 @@
     3.4  # ltrace
     3.5  
     3.6  config DEBUG_ltrace
     3.7 -    select TOOL_libelf
     3.8 +    select LIBELF_TARGET
     3.9      help
    3.10        ltrace is a program that simply runs the specified command until it exits.
    3.11        It intercepts and records the dynamic library calls which are called by
     4.1 --- a/config/tools/libelf.in	Wed Feb 17 23:50:49 2010 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,35 +0,0 @@
     4.4 -# libelf config file
     4.5 -
     4.6 -config TOOL_libelf
     4.7 -    help
     4.8 -      libelf lets you read, modify or create ELF files in an
     4.9 -      architecture-independent way.
    4.10 -
    4.11 -choice
    4.12 -    bool
    4.13 -    prompt "libelf version"
    4.14 -# Don't remove next line
    4.15 -# CT_INSERT_VERSION_BELOW
    4.16 -
    4.17 -config LIBELF_V_0_8_12
    4.18 -    bool
    4.19 -    prompt "0.8.12"
    4.20 -
    4.21 -config LIBELF_V_0_8_11
    4.22 -    bool
    4.23 -    prompt "0.8.11"
    4.24 -
    4.25 -config LIBELF_V_0_8_10
    4.26 -    bool
    4.27 -    prompt "0.8.10 (OBSOLETE)"
    4.28 -    depends on OBSOLETE
    4.29 -
    4.30 -endchoice
    4.31 -
    4.32 -config LIBELF_VERSION
    4.33 -    string
    4.34 -# Don't remove next line
    4.35 -# CT_INSERT_VERSION_STRING_BELOW
    4.36 -    default "0.8.12" if LIBELF_V_0_8_12
    4.37 -    default "0.8.11" if LIBELF_V_0_8_11
    4.38 -    default "0.8.10" if LIBELF_V_0_8_10
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/scripts/build/companion_libs/libelf.sh	Wed Feb 17 23:41:17 2010 +0100
     5.3 @@ -0,0 +1,91 @@
     5.4 +# Build script for libelf
     5.5 +
     5.6 +do_libelf_get() { :; }
     5.7 +do_libelf_extract() { :; }
     5.8 +do_libelf() { :; }
     5.9 +do_libelf_target() { :; }
    5.10 +
    5.11 +if [ "${CT_LIBELF}" = "y" -o "${CT_LIBELF_TARGET}" = "y" ]; then
    5.12 +
    5.13 +do_libelf_get() {
    5.14 +    # The server hosting libelf will return an "HTTP 300 : Multiple Choices"
    5.15 +    # error code if we try to download a file that does not exists there.
    5.16 +    # So we have to request the file with an explicit extension.
    5.17 +    CT_GetFile "libelf-${CT_LIBELF_VERSION}" .tar.gz http://www.mr511.de/software/
    5.18 +}
    5.19 +
    5.20 +do_libelf_extract() {
    5.21 +    CT_Extract "libelf-${CT_LIBELF_VERSION}"
    5.22 +    CT_Patch "libelf-${CT_LIBELF_VERSION}"
    5.23 +}
    5.24 +
    5.25 +if [ "${CT_LIBELF}" = "y" ]; then
    5.26 +
    5.27 +# Uncomment when we need it for gcc-4.5
    5.28 +# WARNING! This function is absolutely UNTESTED yet!
    5.29 +do_libelf() {
    5.30 +    : # Remove this line!
    5.31 +#    CT_DoStep INFO "Installing libelf"
    5.32 +#    mkdir -p "${CT_BUILD_DIR}/build-libelf"
    5.33 +#    CT_Pushd "${CT_BUILD_DIR}/build-libelf"
    5.34 +#
    5.35 +#    CT_DoLog EXTRA "Configuring libelf"
    5.36 +#    CC="${CT_TARGET}-gcc"                                   \
    5.37 +#    CT_DoExecLog ALL                                        \
    5.38 +#    "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure"   \
    5.39 +#        --build=${CT_BUILD}                                 \
    5.40 +#        --host=${CT_HOST}                                   \
    5.41 +#        --target=${CT_TARGET}                               \
    5.42 +#        --prefix="${CT_PREFIX_DIR}"                         \
    5.43 +#        --enable-compat                                     \
    5.44 +#        --enable-elf64                                      \
    5.45 +#        --enable-static                                     \
    5.46 +#        --enable-shared                                     \
    5.47 +#        --enable-extended-format
    5.48 +#
    5.49 +#    CT_DoLog EXTRA "Building libelf"
    5.50 +#    CT_DoExecLog ALL make
    5.51 +#
    5.52 +#    CT_DoLog EXTRA "Installing libelf"
    5.53 +#    CT_DoExecLog ALL make instroot="${CT_SYSROOT_DIR}" install
    5.54 +#
    5.55 +#    CT_Popd
    5.56 +#    CT_EndStep
    5.57 +}
    5.58 +
    5.59 +fi # CT_LIBELF
    5.60 +
    5.61 +if [ "${CT_LIBELF_TARGET}" = "y" ]; then
    5.62 +
    5.63 +do_libelf_target() {
    5.64 +    CT_DoStep INFO "Installing libelf for the target"
    5.65 +    mkdir -p "${CT_BUILD_DIR}/build-libelf"
    5.66 +    CT_Pushd "${CT_BUILD_DIR}/build-libelf"
    5.67 +
    5.68 +    CT_DoLog EXTRA "Configuring libelf"
    5.69 +    CC="${CT_TARGET}-gcc"                                   \
    5.70 +    CT_DoExecLog ALL                                        \
    5.71 +    "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure"   \
    5.72 +        --build=${CT_BUILD}                                 \
    5.73 +        --host=${CT_TARGET}                                 \
    5.74 +        --target=${CT_TARGET}                               \
    5.75 +        --prefix=/usr                                       \
    5.76 +        --enable-compat                                     \
    5.77 +        --enable-elf64                                      \
    5.78 +        --enable-shared                                     \
    5.79 +        --enable-extended-format                            \
    5.80 +        --enable-static
    5.81 +
    5.82 +    CT_DoLog EXTRA "Building libelf"
    5.83 +    CT_DoExecLog ALL make
    5.84 +
    5.85 +    CT_DoLog EXTRA "Installing libelf"
    5.86 +    CT_DoExecLog ALL make instroot="${CT_SYSROOT_DIR}" install
    5.87 +
    5.88 +    CT_Popd
    5.89 +    CT_EndStep
    5.90 +}
    5.91 +
    5.92 +fi # CT_LIBELF_TARGET
    5.93 +
    5.94 +fi # CT_LIBELF || CT_LIBELF_TARGET
     6.1 --- a/scripts/build/tools/100-libelf.sh	Wed Feb 17 23:50:49 2010 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,43 +0,0 @@
     6.4 -# Build script for libelf
     6.5 -
     6.6 -do_tools_libelf_get() {
     6.7 -    # The server hosting libelf will return an "HTTP 300 : Multiple Choices"
     6.8 -    # error code if we try to download a file that does not exists there.
     6.9 -    # So we have to request the file with an explicit extension.
    6.10 -    CT_GetFile "libelf-${CT_LIBELF_VERSION}" .tar.gz http://www.mr511.de/software/
    6.11 -}
    6.12 -
    6.13 -do_tools_libelf_extract() {
    6.14 -    CT_Extract "libelf-${CT_LIBELF_VERSION}"
    6.15 -    CT_Patch "libelf-${CT_LIBELF_VERSION}"
    6.16 -}
    6.17 -
    6.18 -do_tools_libelf_build() {
    6.19 -    CT_DoStep INFO "Installing libelf"
    6.20 -    mkdir -p "${CT_BUILD_DIR}/build-libelf"
    6.21 -    CT_Pushd "${CT_BUILD_DIR}/build-libelf"
    6.22 -
    6.23 -    CT_DoLog EXTRA "Configuring libelf"
    6.24 -    CC="${CT_TARGET}-gcc"                                   \
    6.25 -    CT_DoExecLog ALL                                        \
    6.26 -    "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure"   \
    6.27 -        --build=${CT_BUILD}                                 \
    6.28 -        --host=${CT_TARGET}                                 \
    6.29 -        --target=${CT_TARGET}                               \
    6.30 -        --prefix=/usr                                       \
    6.31 -        --enable-compat                                     \
    6.32 -        --enable-elf64                                      \
    6.33 -        --enable-shared                                     \
    6.34 -        --enable-extended-format                            \
    6.35 -        --enable-static
    6.36 -
    6.37 -    CT_DoLog EXTRA "Building libelf"
    6.38 -    CT_DoExecLog ALL make
    6.39 -
    6.40 -    CT_DoLog EXTRA "Installing libelf"
    6.41 -    CT_DoExecLog ALL make instroot="${CT_SYSROOT_DIR}" install
    6.42 -
    6.43 -    CT_Popd
    6.44 -    CT_EndStep
    6.45 -}
    6.46 -
     7.1 --- a/scripts/crosstool-NG.sh.in	Wed Feb 17 23:50:49 2010 +0100
     7.2 +++ b/scripts/crosstool-NG.sh.in	Wed Feb 17 23:41:17 2010 +0100
     7.3 @@ -118,6 +118,7 @@
     7.4  . "${CT_LIB_DIR}/scripts/build/companion_libs/ppl.sh"
     7.5  . "${CT_LIB_DIR}/scripts/build/companion_libs/cloog.sh"
     7.6  . "${CT_LIB_DIR}/scripts/build/companion_libs/mpc.sh"
     7.7 +. "${CT_LIB_DIR}/scripts/build/companion_libs/libelf.sh"
     7.8  . "${CT_LIB_DIR}/scripts/build/binutils/binutils.sh"
     7.9  . "${CT_LIB_DIR}/scripts/build/binutils/elf2flt.sh"
    7.10  . "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
    7.11 @@ -500,6 +501,7 @@
    7.12          do_ppl_get
    7.13          do_cloog_get
    7.14          do_mpc_get
    7.15 +        do_libelf_get
    7.16          do_binutils_get
    7.17          do_elf2flt_get
    7.18          do_cc_get
    7.19 @@ -529,6 +531,7 @@
    7.20          do_ppl_extract
    7.21          do_cloog_extract
    7.22          do_mpc_extract
    7.23 +        do_libelf_extract
    7.24          do_binutils_extract
    7.25          do_elf2flt_extract
    7.26          do_cc_extract
     8.1 --- a/steps.mk	Wed Feb 17 23:50:49 2010 +0100
     8.2 +++ b/steps.mk	Wed Feb 17 23:41:17 2010 +0100
     8.3 @@ -23,6 +23,7 @@
     8.4              ppl                 \
     8.5              cloog               \
     8.6              mpc                 \
     8.7 +            libelf              \
     8.8              binutils            \
     8.9              elf2flt             \
    8.10              cc_core_pass_1      \
    8.11 @@ -34,6 +35,7 @@
    8.12              libc_finish         \
    8.13              gmp_target          \
    8.14              mpfr_target         \
    8.15 +            libelf_target       \
    8.16              binutils_target     \
    8.17              tools               \
    8.18              debug               \