scripts/build/companion_libs/120-ppl.sh
author Yann Diorcet <diorcet.yann@gmail.com>
Fri Nov 16 15:25:57 2012 +0100 (2012-11-16)
changeset 3119 1c56c03b7ed5
parent 3115 1c68438f44f7
child 3135 3829050af02a
permissions -rw-r--r--
scripts: add BUILD/HOST extra cflags/ldflags

On some hosts, and for certain toolchains (eg. toolchain targetting
the upcoming Darwin), it may be necessary to pass arbitrary CFLAGS
and/or LDFLAGS when building the components.

And necessary infrastructure:
- EXTRA_{CFLAGS,LDFLAGS}_FOR_{BUILD,HOST} as config options
- pass those extra flags to components

Fix-up a slight typo in elf2flt at the same time (misnamed cflags).

Signed-off-by: Yann Diorcet <diorcet.yann@gmail.com>
Message-Id: <d24043276c9243a35421.1353077450@macbook-smorlat.local>
Patchwork-Id: 199645
     1 # This file adds the functions to build the PPL library
     2 # Copyright 2009 Yann E. MORIN
     3 # Licensed under the GPL v2. See COPYING in the root of this package
     4 
     5 do_ppl_get() { :; }
     6 do_ppl_extract() { :; }
     7 do_ppl_for_build() { :; }
     8 do_ppl_for_host() { :; }
     9 
    10 # Overide functions depending on configuration
    11 if [ "${CT_PPL}" = "y" ]; then
    12 
    13 # Download PPL
    14 do_ppl_get() {
    15     CT_GetFile "ppl-${CT_PPL_VERSION}"                                      \
    16         http://www.cs.unipr.it/ppl/Download/ftp/releases/${CT_PPL_VERSION}  \
    17         ftp://ftp.cs.unipr.it/pub/ppl/releases/${CT_PPL_VERSION}            \
    18         ftp://gcc.gnu.org/pub/gcc/infrastructure
    19 }
    20 
    21 # Extract PPL
    22 do_ppl_extract() {
    23     CT_Extract "ppl-${CT_PPL_VERSION}"
    24     CT_Patch "ppl" "${CT_PPL_VERSION}"
    25 }
    26 
    27 # Build PPL for running on build
    28 # - always build statically
    29 # - we do not have build-specific CFLAGS
    30 # - install in build-tools prefix
    31 do_ppl_for_build() {
    32     local -a ppl_opts
    33 
    34     case "${CT_TOOLCHAIN_TYPE}" in
    35         native|cross)   return 0;;
    36     esac
    37 
    38     CT_DoStep INFO "Installing PPL for build"
    39     CT_mkdir_pushd "${CT_BUILD_DIR}/build-ppl-build-${CT_BUILD}"
    40 
    41     ppl_opts+=( "host=${CT_BUILD}" )
    42     ppl_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
    43     ppl_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
    44     ppl_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
    45     do_ppl_backend "${ppl_opts[@]}"
    46 
    47     CT_Popd
    48     CT_EndStep
    49 }
    50 
    51 # Build PPL for running on host
    52 do_ppl_for_host() {
    53     local -a ppl_opts
    54 
    55     CT_DoStep INFO "Installing PPL for host"
    56     CT_mkdir_pushd "${CT_BUILD_DIR}/build-ppl-host-${CT_HOST}"
    57 
    58     ppl_opts+=( "host=${CT_HOST}" )
    59     ppl_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
    60     ppl_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    61     ppl_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    62     do_ppl_backend "${ppl_opts[@]}"
    63 
    64     CT_Popd
    65     CT_EndStep
    66 }
    67 
    68 # Build PPL
    69 #     Parameter     : description               : type      : default
    70 #     host          : machine to run on         : tuple     : (none)
    71 #     prefix        : prefix to install into    : dir       : (none)
    72 #     cflags        : cflags to use             : string    : (empty)
    73 #     ldflags       : ldflags to use            : string    : (empty)
    74 do_ppl_backend() {
    75     local host
    76     local prefix
    77     local cflags
    78     local ldflags
    79     local arg
    80 
    81     for arg in "$@"; do
    82         eval "${arg// /\\ }"
    83     done
    84 
    85     CT_DoLog EXTRA "Configuring PPL"
    86 
    87     CT_DoExecLog CFG                                \
    88     CFLAGS="${cflags}"                              \
    89     CXXFLAGS="${cflags}"                            \
    90     LDFLAGS="${ldflags}"                            \
    91     "${CT_SRC_DIR}/ppl-${CT_PPL_VERSION}/configure" \
    92         --build=${CT_BUILD}                         \
    93         --host=${host}                              \
    94         --prefix="${prefix}"                        \
    95         --with-libgmp-prefix="${prefix}"            \
    96         --with-libgmpxx-prefix="${prefix}"          \
    97         --with-gmp-prefix="${prefix}"               \
    98         --enable-watchdog                           \
    99         --disable-debugging                         \
   100         --disable-assertions                        \
   101         --disable-ppl_lcdd                          \
   102         --disable-ppl_lpsol                         \
   103         --disable-shared                            \
   104         --enable-interfaces='c c++'                 \
   105         --enable-static
   106 
   107     # Maybe-options:
   108     # --enable-optimization=speed  or sspeed (yes, with 2 's')
   109 
   110     CT_DoLog EXTRA "Building PPL"
   111     CT_DoExecLog ALL make ${JOBSFLAGS}
   112 
   113     if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
   114         CT_DoLog EXTRA "Checking PPL"
   115         CT_DoExecLog ALL make ${JOBSFLAGS} -s check
   116     fi
   117 
   118     CT_DoLog EXTRA "Installing PPL"
   119     CT_DoExecLog ALL make install
   120 
   121     # Remove spuriously installed file
   122     CT_DoExecLog ALL rm -f "${prefix}/bin/ppl-config"
   123 }
   124 
   125 fi # CT_PPL