complibs: allow either static or shared build
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Apr 11 00:47:23 2010 +0200 (2010-04-11)
changeset 1892af092b4bf65c
parent 1891 2f0de10c058d
child 1893 f5dab3c43abf
complibs: allow either static or shared build
config/companion_libs.in
scripts/build/cc/gcc.sh
scripts/build/companion_libs/cloog.sh
scripts/build/companion_libs/gmp.sh
scripts/build/companion_libs/libelf.sh
scripts/build/companion_libs/mpc.sh
scripts/build/companion_libs/mpfr.sh
scripts/build/companion_libs/ppl.sh
     1.1 --- a/config/companion_libs.in	Sat Apr 10 23:43:08 2010 +0200
     1.2 +++ b/config/companion_libs.in	Sun Apr 11 00:47:23 2010 +0200
     1.3 @@ -17,7 +17,6 @@
     1.4  config GMP
     1.5      bool
     1.6      select COMPLIBS
     1.7 -    select WRAPPER_NEEDED
     1.8      help
     1.9        gcc 4.3.0 and above requires GMP to build some frontends, and some
    1.10        other components can use them as well.
    1.11 @@ -35,7 +34,6 @@
    1.12      bool
    1.13      select GMP
    1.14      select COMPLIBS
    1.15 -    select WRAPPER_NEEDED
    1.16      help
    1.17        gcc 4.3.0 and above requires MPFR to build some frontends, and some
    1.18        other components can use them as well.
    1.19 @@ -54,7 +52,6 @@
    1.20      select GMP
    1.21      select MPFR
    1.22      select COMPLIBS
    1.23 -    select WRAPPER_NEEDED
    1.24      help
    1.25        gcc-4.4.0 and above requires PPL to build some parts of the optimiser
    1.26        (the GRAPHITE loop optimisation, to be precise).
    1.27 @@ -69,7 +66,6 @@
    1.28      select MPFR
    1.29      select PPL
    1.30      select COMPLIBS
    1.31 -    select WRAPPER_NEEDED
    1.32      help
    1.33        gcc-4.4.0 and above requires CLooG/PPL to build some parts of the
    1.34        optimiser (the GRAPHITE loop optimisation, to be precise).
    1.35 @@ -85,7 +81,6 @@
    1.36      select PPL
    1.37      select CLOOG
    1.38      select COMPLIBS
    1.39 -    select WRAPPER_NEEDED
    1.40      help
    1.41        gcc-4.4.0 and above can also optionally use MPC to enable additional
    1.42        optimisations on complex numbers. Although MPC is optional,
    1.43 @@ -98,7 +93,6 @@
    1.44  config LIBELF
    1.45      bool
    1.46      select COMPLIBS
    1.47 -    select WRAPPER_NEEDED
    1.48      help
    1.49        gcc-4.5.0 and above can also use libelf to enable some optimisation
    1.50        (LTO, Link-Time Optimisation, to be precise).  Although libelf is
    1.51 @@ -170,14 +164,14 @@
    1.52  config FOO
    1.53      bool
    1.54  
    1.55 +if COMPLIBS
    1.56 +
    1.57  comment "Companion libraries common options"
    1.58 -    depends on COMPLIBS || WRAPPER_NEEDED
    1.59  
    1.60  config COMPLIBS_CHECK
    1.61      bool
    1.62 -    prompt "|  Check the companion libraries builds (!!! READ HELP!!!)"
    1.63 +    prompt "Check the companion libraries builds (!!! READ HELP!!!)"
    1.64      default n
    1.65 -    depends on COMPLIBS
    1.66      help
    1.67        It is highly recommended to check the newly built companion libraries.
    1.68        Unfortunately, this is a very intensive task, and takes a loooong time.
    1.69 @@ -192,6 +186,19 @@
    1.70        building PPL on my machine takes roughly 1'40", while checking it takes
    1.71        about 1h40'...
    1.72  
    1.73 +config COMPLIBS_SHARED
    1.74 +    bool
    1.75 +    prompt "Build shared companion libraries"
    1.76 +    default n
    1.77 +    depends on COMPLIBS
    1.78 +    select WRAPPER_NEEDED
    1.79 +    help
    1.80 +      By default, the companion libraries will be build static. If you want to
    1.81 +      build shared libraries, then you can say 'Y' here, but a wrapper will be
    1.82 +      needed (see docs/overview.txt,section "Tools wrapper").
    1.83 +      
    1.84 +      It is highly recommended that you keep static libraries.
    1.85 +
    1.86  choice
    1.87      bool
    1.88      prompt "|  Install tools wrapper as:"
    1.89 @@ -223,4 +230,6 @@
    1.90      default "script" if TOOLS_WRAPPER_SCRIPT
    1.91      default "exec"   if TOOLS_WRAPPER_EXEC
    1.92  
    1.93 +endif # COMPLIBS
    1.94 +
    1.95  endmenu
     2.1 --- a/scripts/build/cc/gcc.sh	Sat Apr 10 23:43:08 2010 +0200
     2.2 +++ b/scripts/build/cc/gcc.sh	Sun Apr 11 00:47:23 2010 +0200
     2.3 @@ -95,6 +95,7 @@
     2.4      local lang_opt
     2.5      local tmp
     2.6      local -a extra_config
     2.7 +    local core_LDFLAGS
     2.8  
     2.9      eval $1
    2.10      eval $2
    2.11 @@ -162,10 +163,17 @@
    2.12  
    2.13      CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
    2.14  
    2.15 +    # When companion libraries are build static (eg !shared),
    2.16 +    # the libstdc++ is not pulled automatically, although it
    2.17 +    # is needed. Shoe-horn it in our LDFLAGS
    2.18 +    if [ -z "${CT_COMPLIBS_SHARED}" ]; then
    2.19 +        core_LDFLAGS='-lstdc++'
    2.20 +    fi
    2.21 +
    2.22      # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
    2.23      CC_FOR_BUILD="${CT_BUILD}-gcc"                  \
    2.24      CFLAGS="${CT_CFLAGS_FOR_HOST}"                  \
    2.25 -    LDFLAGS="-lstdc++"                              \
    2.26 +    LDFLAGS="${core_LDFLAGS}"                       \
    2.27      CT_DoExecLog ALL                                \
    2.28      "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/configure"  \
    2.29          --build=${CT_BUILD}                         \
    2.30 @@ -257,6 +265,7 @@
    2.31  do_cc() {
    2.32      local -a extra_config
    2.33      local tmp
    2.34 +    local final_LDFLAGS
    2.35  
    2.36      # If building for bare metal, nothing to be done here, the static core conpiler is enough!
    2.37      [ "${CT_BARE_METAL}" = "y" ] && return 0
    2.38 @@ -325,13 +334,20 @@
    2.39  
    2.40      CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
    2.41  
    2.42 +    # When companion libraries are build static (eg !shared),
    2.43 +    # the libstdc++ is not pulled automatically, although it
    2.44 +    # is needed. Shoe-horn it in our LDFLAGS
    2.45 +    if [ -z "${CT_COMPLIBS_SHARED}" ]; then
    2.46 +        final_LDFLAGS='-lstdc++'
    2.47 +    fi
    2.48 +
    2.49      # --enable-symvers=gnu really only needed for sh4 to work around a
    2.50      # detection problem only matters for gcc-3.2.x and later, I think.
    2.51      # --disable-nls to work around crash bug on ppc405, but also because
    2.52      # embedded systems don't really need message catalogs...
    2.53      CC_FOR_BUILD="${CT_BUILD}-gcc"                  \
    2.54      CFLAGS="${CT_CFLAGS_FOR_HOST}"                  \
    2.55 -    LDFLAGS="-lstdc++"                              \
    2.56 +    LDFLAGS="${final_LDFLAGS}"                      \
    2.57      CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"         \
    2.58      CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"       \
    2.59      LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}"       \
     3.1 --- a/scripts/build/companion_libs/cloog.sh	Sat Apr 10 23:43:08 2010 +0200
     3.2 +++ b/scripts/build/companion_libs/cloog.sh	Sun Apr 11 00:47:23 2010 +0200
     3.3 @@ -35,6 +35,8 @@
     3.4  
     3.5  do_cloog() {
     3.6      local _t
     3.7 +    local cloog_LDFLAGS
     3.8 +    local -a cloog_opts
     3.9  
    3.10      # Version 0.15.3 has a dirname 'cloog-ppl' (with no version in it!)
    3.11      # while versions 0.15.4 onward do have the version in the dirname.
    3.12 @@ -49,8 +51,16 @@
    3.13      CT_DoStep INFO "Installing CLooG/ppl"
    3.14  
    3.15      CT_DoLog EXTRA "Configuring CLooG/ppl"
    3.16 +
    3.17 +    if [ "${CT_COMPLIBS_SHARED}" = "y" ]; then
    3.18 +        cloog_opts+=( --enable-shared --disable-static )
    3.19 +    else
    3.20 +        cloog_opts+=( --disable-shared --enable-static )
    3.21 +        cloog_LDFLAGS='-lstdc++'
    3.22 +    fi
    3.23 +
    3.24      CFLAGS="${CT_CFLAGS_FOR_HOST}"              \
    3.25 -    LDFLAGS='-lstdc++'                          \
    3.26 +    LDFLAGS="${cloog_LDFLAGS}"                  \
    3.27      CT_DoExecLog ALL                            \
    3.28      "${CT_SRC_DIR}/cloog-ppl${_t}/configure"    \
    3.29          --build=${CT_BUILD}                     \
    3.30 @@ -58,9 +68,8 @@
    3.31          --prefix="${CT_PREFIX_DIR}"             \
    3.32          --with-gmp="${CT_PREFIX_DIR}"           \
    3.33          --with-ppl="${CT_PREFIX_DIR}"           \
    3.34 -        --disable-shared                        \
    3.35 -        --enable-static                         \
    3.36 -        --with-bits=gmp
    3.37 +        --with-bits=gmp                         \
    3.38 +        "${cloog_opts[@]}"
    3.39  
    3.40      CT_DoLog EXTRA "Building CLooG/ppl"
    3.41      CT_DoExecLog ALL make ${PARALLELMFLAGS}
     4.1 --- a/scripts/build/companion_libs/gmp.sh	Sat Apr 10 23:43:08 2010 +0200
     4.2 +++ b/scripts/build/companion_libs/gmp.sh	Sun Apr 11 00:47:23 2010 +0200
     4.3 @@ -24,6 +24,7 @@
     4.4  if [ "${CT_GMP}" = "y" ]; then
     4.5  
     4.6  do_gmp() {
     4.7 +    local -a gmp_opts
     4.8  
     4.9      mkdir -p "${CT_BUILD_DIR}/build-gmp"
    4.10      cd "${CT_BUILD_DIR}/build-gmp"
    4.11 @@ -32,17 +33,22 @@
    4.12  
    4.13      CT_DoLog EXTRA "Configuring GMP"
    4.14  
    4.15 +    if [ "${CT_COMPLIBS_SHARED}" = "y" ]; then
    4.16 +        gmp_opts+=( --enable-shared --disable-static )
    4.17 +    else
    4.18 +        gmp_opts+=( --disable-shared --enable-static )
    4.19 +    fi
    4.20 +
    4.21      CFLAGS="${CT_CFLAGS_FOR_HOST} -fexceptions"     \
    4.22      CT_DoExecLog ALL                                \
    4.23      "${CT_SRC_DIR}/gmp-${CT_GMP_VERSION}/configure" \
    4.24          --build=${CT_BUILD}                         \
    4.25          --host=${CT_HOST}                           \
    4.26          --prefix="${CT_PREFIX_DIR}"                 \
    4.27 -        --disable-shared                            \
    4.28 -        --enable-static                             \
    4.29          --enable-fft                                \
    4.30          --enable-mpbsd                              \
    4.31 -        --enable-cxx
    4.32 +        --enable-cxx                                \
    4.33 +        "${gmp_opts[@]}"
    4.34  
    4.35      CT_DoLog EXTRA "Building GMP"
    4.36      CT_DoExecLog ALL make ${PARALLELMFLAGS}
     5.1 --- a/scripts/build/companion_libs/libelf.sh	Sat Apr 10 23:43:08 2010 +0200
     5.2 +++ b/scripts/build/companion_libs/libelf.sh	Sun Apr 11 00:47:23 2010 +0200
     5.3 @@ -24,12 +24,21 @@
     5.4  # Uncomment when we need it for gcc-4.5
     5.5  # WARNING! This function is absolutely UNTESTED yet!
     5.6  do_libelf() {
     5.7 -    : # Remove this line!
     5.8 +    : # Remove this line! and uncomment the following lines
     5.9 +#    local -a libelf_opts
    5.10 +#
    5.11  #    CT_DoStep INFO "Installing libelf"
    5.12  #    mkdir -p "${CT_BUILD_DIR}/build-libelf"
    5.13  #    CT_Pushd "${CT_BUILD_DIR}/build-libelf"
    5.14  #
    5.15  #    CT_DoLog EXTRA "Configuring libelf"
    5.16 +#
    5.17 +#    if [ "${CT_COMPLIBS_SHARED}" = "y" ]; then
    5.18 +#        libelf_opts+=( --enable-shared --disable-static )
    5.19 +#    else
    5.20 +#        libelf_opts+=( --disable-shared --enable-static )
    5.21 +#    fi
    5.22 +#
    5.23  #    CC="${CT_TARGET}-gcc"                                   \
    5.24  #    CT_DoExecLog ALL                                        \
    5.25  #    "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure"   \
    5.26 @@ -39,9 +48,8 @@
    5.27  #        --prefix="${CT_PREFIX_DIR}"                         \
    5.28  #        --enable-compat                                     \
    5.29  #        --enable-elf64                                      \
    5.30 -#        --enable-static                                     \
    5.31 -#        --enable-shared                                     \
    5.32 -#        --enable-extended-format
    5.33 +#        --enable-extended-format                            \
    5.34 +#        "${libelf_opts[@]}"
    5.35  #
    5.36  #    CT_DoLog EXTRA "Building libelf"
    5.37  #    CT_DoExecLog ALL make
     6.1 --- a/scripts/build/companion_libs/mpc.sh	Sat Apr 10 23:43:08 2010 +0200
     6.2 +++ b/scripts/build/companion_libs/mpc.sh	Sun Apr 11 00:47:23 2010 +0200
     6.3 @@ -23,12 +23,21 @@
     6.4  }
     6.5  
     6.6  do_mpc() {
     6.7 +    local -a mpc_opts
     6.8 +
     6.9      mkdir -p "${CT_BUILD_DIR}/build-mpc"
    6.10      cd "${CT_BUILD_DIR}/build-mpc"
    6.11  
    6.12      CT_DoStep INFO "Installing MPC"
    6.13  
    6.14      CT_DoLog EXTRA "Configuring MPC"
    6.15 +
    6.16 +    if [ "${CT_COMPLIBS_SHARED}" = "y" ]; then
    6.17 +        mpc_opts+=( --enable-shared --disable-static )
    6.18 +    else
    6.19 +        mpc_opts+=( --disable-shared --enable-static )
    6.20 +    fi
    6.21 +
    6.22      CFLAGS="${CT_CFLAGS_FOR_HOST}"                  \
    6.23      CT_DoExecLog ALL                                \
    6.24      "${CT_SRC_DIR}/mpc-${CT_MPC_VERSION}/configure" \
    6.25 @@ -37,8 +46,7 @@
    6.26          --prefix="${CT_PREFIX_DIR}"                 \
    6.27          --with-gmp="${CT_PREFIX_DIR}"               \
    6.28          --with-mpfr="${CT_PREFIX_DIR}"              \
    6.29 -        --disable-shared                            \
    6.30 -        --enable-static
    6.31 +        "${mpc_opts[@]}"
    6.32  
    6.33      CT_DoLog EXTRA "Building MPC"
    6.34      CT_DoExecLog ALL make ${PARALLELMFLAGS}
     7.1 --- a/scripts/build/companion_libs/mpfr.sh	Sat Apr 10 23:43:08 2010 +0200
     7.2 +++ b/scripts/build/companion_libs/mpfr.sh	Sun Apr 11 00:47:23 2010 +0200
     7.3 @@ -67,20 +67,27 @@
     7.4  if [ "${CT_MPFR}" = "y" ]; then
     7.5  
     7.6  do_mpfr() {
     7.7 +    local -a mpfr_opts
     7.8 +
     7.9      mkdir -p "${CT_BUILD_DIR}/build-mpfr"
    7.10      cd "${CT_BUILD_DIR}/build-mpfr"
    7.11  
    7.12      CT_DoStep INFO "Installing MPFR"
    7.13  
    7.14 -    mpfr_opt=
    7.15      # Under Cygwin, we can't build a thread-safe library
    7.16      case "${CT_HOST}" in
    7.17 -        *cygwin*)   mpfr_opt="--disable-thread-safe";;
    7.18 -        *mingw*)    mpfr_opt="--disable-thread-safe";;
    7.19 -        *darwin*)   mpfr_opt="--disable-thread-safe";;
    7.20 -        *)          mpfr_opt="--enable-thread-safe";;
    7.21 +        *cygwin*)   mpfr_opts+=( --disable-thread-safe );;
    7.22 +        *mingw*)    mpfr_opts+=( --disable-thread-safe );;
    7.23 +        *darwin*)   mpfr_opts+=( --disable-thread-safe );;
    7.24 +        *)          mpfr_opts+=( --enable-thread-safe  );;
    7.25      esac
    7.26  
    7.27 +    if [ "${CT_COMPLIBS_SHARED}" = "y" ]; then
    7.28 +        mpfr_opts+=( --enable-shared --disable-static )
    7.29 +    else
    7.30 +        mpfr_opts+=( --disable-shared --enable-static )
    7.31 +    fi
    7.32 +
    7.33      CT_DoLog EXTRA "Configuring MPFR"
    7.34      CC="${CT_HOST}-gcc"                                 \
    7.35      CFLAGS="${CT_CFLAGS_FOR_HOST}"                      \
    7.36 @@ -89,10 +96,8 @@
    7.37          --build=${CT_BUILD}                             \
    7.38          --host=${CT_HOST}                               \
    7.39          --prefix="${CT_PREFIX_DIR}"                     \
    7.40 -        ${mpfr_opt}                                     \
    7.41 -        --disable-shared                                \
    7.42 -        --enable-static                                 \
    7.43 -        --with-gmp="${CT_PREFIX_DIR}"
    7.44 +        --with-gmp="${CT_PREFIX_DIR}"                   \
    7.45 +        "${mpfr_opts[@]}"
    7.46  
    7.47      CT_DoLog EXTRA "Building MPFR"
    7.48      CT_DoExecLog ALL make ${PARALLELMFLAGS}
     8.1 --- a/scripts/build/companion_libs/ppl.sh	Sat Apr 10 23:43:08 2010 +0200
     8.2 +++ b/scripts/build/companion_libs/ppl.sh	Sun Apr 11 00:47:23 2010 +0200
     8.3 @@ -25,12 +25,21 @@
     8.4  }
     8.5  
     8.6  do_ppl() {
     8.7 +    local -a ppl_opts
     8.8 +
     8.9      mkdir -p "${CT_BUILD_DIR}/build-ppl"
    8.10      cd "${CT_BUILD_DIR}/build-ppl"
    8.11  
    8.12      CT_DoStep INFO "Installing PPL"
    8.13  
    8.14      CT_DoLog EXTRA "Configuring PPL"
    8.15 +
    8.16 +    if [ "${CT_COMPLIBS_SHARED}" = "y" ]; then
    8.17 +        ppl_opts+=( --enable-shared --disable-static )
    8.18 +    else
    8.19 +        ppl_opts+=( --disable-shared --enable-static )
    8.20 +    fi
    8.21 +
    8.22      CFLAGS="${CT_CFLAGS_FOR_HOST}"                  \
    8.23      CXXFLAGS="${CT_CFLAGS_FOR_HOST}"                \
    8.24      CT_DoExecLog ALL                                \
    8.25 @@ -40,12 +49,11 @@
    8.26          --prefix="${CT_PREFIX_DIR}"                 \
    8.27          --with-libgmp-prefix="${CT_PREFIX_DIR}"     \
    8.28          --with-libgmpxx-prefix="${CT_PREFIX_DIR}"   \
    8.29 -        --disable-shared                            \
    8.30 -        --enable-static                             \
    8.31          --disable-debugging                         \
    8.32          --disable-assertions                        \
    8.33          --disable-ppl_lcdd                          \
    8.34 -        --disable-ppl_lpsol
    8.35 +        --disable-ppl_lpsol                         \
    8.36 +        "${ppl_opts[@]}"
    8.37  
    8.38      # Maybe-options:
    8.39      # --enable-interfaces=...