scripts/build/cc_gcc.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Feb 24 11:00:05 2007 +0000 (2007-02-24)
changeset 1 eeea35fbf182
child 20 e238f7fbc941
permissions -rw-r--r--
Add the full crosstool-NG sources to the new repository of its own.
You might just say: 'Yeah! crosstool-NG's got its own repo!".
Unfortunately, that's because the previous repo got damaged beyond repair and I had no backup.
That means I'm putting backups in place in the afternoon.
That also means we've lost history... :-(
     1 # This file adds the function to build the final gcc C compiler
     2 # Copyright 2007 Yann E. MORIN
     3 # Licensed under the GPL v2. See COPYING in the root of this package
     4 
     5 do_cc() {
     6     CT_DoStep INFO "Installing final C compiler"
     7 
     8     mkdir -p "${CT_BUILD_DIR}/build-cc"
     9     cd "${CT_BUILD_DIR}/build-cc"
    10 
    11     CT_DoLog EXTRA "Configuring C compiler"
    12 
    13     # Enable selected languages
    14     lang_opt="c"
    15     [ "${CT_CC_LANG_CXX}" = "y"      ] && lang_opt="${lang_opt},c++"
    16     [ "${CT_CC_LANG_FORTRAN}" = "y"  ] && lang_opt="${lang_opt},fortran"
    17     [ "${CT_CC_LANG_ADA}" = "y"      ] && lang_opt="${lang_opt},ada"
    18     [ "${CT_CC_LANG_JAVA}" = "y"     ] && lang_opt="${lang_opt},java"
    19     [ "${CT_CC_LANG_OBJC}" = "y"     ] && lang_opt="${lang_opt},objc"
    20     [ "${CT_CC_LANG_OBJCXX}" = "y"   ] && lang_opt="${lang_opt},obj-c++"
    21     CT_Test "Building Fortran language is not yet supported. Will try..." "${CT_CC_LANG_FORTRAN}" = "y"
    22     CT_Test "Building ADA language is not yet supported. Will try..." "${CT_CC_LANG_ADA}" = "y"
    23     CT_Test "Building Java language is not yet supported. Will try..." "${CT_CC_LANG_JAVA}" = "y"
    24     CT_Test "Building Objective-C language is not yet supported. Will try..." "${CT_CC_LANG_OBJC}" = "y"
    25     CT_Test "Building Objective-C++ language is not yet supported. Will try..." "${CT_CC_LANG_OBJCXX}" = "y"
    26     CT_Test "Building ${CT_CC_LANG_OTHERS} language(s) is not yet supported. Will try..." -n "${CT_CC_LANG_OTHERS}"
    27     lang_opt=`echo "${lang_opt},${CT_CC_LANG_OTHERS}" |sed -r -e 's/^(.*),*$/\1/;'`
    28 
    29     extra_config="--enable-languages=${lang_opt}"
    30     [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
    31     [ "${CT_SHARED_LIBS}" = "y" ] || extra_config="${extra_config} --disable-shared"
    32     [ -n "${CT_ARCH_CPU}" ]  && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
    33     [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
    34     [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
    35     [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
    36     if [ "${CT_TARGET_MULTILIB}" = "y" ]; then
    37        extra_config="${extra_config} --enable-multilib"
    38     else
    39        extra_config="${extra_config} --disable-multilib"
    40     fi
    41 
    42     CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
    43 
    44     # --enable-symvers=gnu really only needed for sh4 to work around a
    45     # detection problem only matters for gcc-3.2.x and later, I think.
    46     # --disable-nls to work around crash bug on ppc405, but also because
    47     # embedded systems don't really need message catalogs...
    48     CFLAGS="${CT_CFLAGS_FOR_HOST}"                  \
    49     "${CT_SRC_DIR}/${CT_CC_FILE}/configure"     \
    50         ${CT_CANADIAN_OPT}                      \
    51         --target=${CT_TARGET} --host=${CT_HOST} \
    52         --prefix="${CT_PREFIX_DIR}"             \
    53         ${CC_SYSROOT_ARG}                       \
    54         ${extra_config}                         \
    55         --with-local-prefix="${CT_SYSROOT_DIR}" \
    56         --disable-nls                           \
    57         --enable-threads=posix                  \
    58         --enable-symvers=gnu                    \
    59         --enable-__cxa_atexit                   \
    60         --enable-c99                            \
    61         --enable-long-long                      \
    62         ${CT_CC_EXTRA_CONFIG}                   2>&1 |CT_DoLog DEBUG
    63 
    64     if [ ! "${CT_CANADIAN}" = "y" ]; then
    65         CT_DoLog EXTRA "Building libiberty"
    66         make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog DEBUG
    67     fi
    68 
    69 
    70     # Idea from <cort.dougan at gmail.com>:
    71     # Fix lib/lib64 confusion for GCC 3.3.3 on PowerPC64 and x86_64.
    72     # GCC 3.4.0 and up don't suffer from this confusion, and don't need this
    73     # kludge.
    74     # FIXME: we should patch gcc's source rather than uglify crosstool.sh.
    75     # FIXME: is this needed for gcc-3.3.[56]?
    76     case "${CT_CC_FILE}" in
    77       gcc-3.3.[34])
    78         case "${CT_TARGET}" in
    79           powerpc64-unknown-linux-gnu|x86_64-unknown-linux-gnu)
    80             for d in `find "${CT_SYSROOT_DIR}" -name lib -type d -empty`; do
    81               if [ -d `dirname "${d}"`/lib64 ] ; then
    82                 rm -rf "${d}"
    83                 ln -s `dirname "${d}"`/lib64 "${d}"
    84               fi
    85             done ;;
    86           *) ;;
    87         esac ;;
    88     esac
    89 
    90     CT_DoLog EXTRA "Building C compiler"
    91     make ${PARALLELMFLAGS} all 2>&1 |CT_DoLog DEBUG
    92 
    93     CT_DoLog EXTRA "Installing C compiler"
    94     make install 2>&1 |CT_DoLog DEBUG
    95 
    96     # FIXME: shouldn't people who want this just --disable-multilib in final gcc
    97     # and be done with it?
    98     # This code should probably be deleted, it was written long ago and hasn't
    99     # been tested in ages.
   100     # kludge: If the chip does not have a floating point unit
   101     # (i.e. if GLIBC_EXTRA_CONFIG contains --without-fp),
   102     # and there are shared libraries in /lib/nof, copy them to /lib
   103     # so they get used by default.
   104     # FIXME: only rs6000/powerpc seem to use nof.  See MULTILIB_DIRNAMES
   105     # in $GCC_DIR/gcc/config/$TARGET/* to see what your arch calls it.
   106     #case "${CT_LIBC_EXTRA_CONFIG}" in
   107     #    *--without-fp*)
   108     #        if test -d "${CT_SYSROOT_DIR}/lib/nof"; then
   109     #            cp -af "${CT_SYSROOT_DIR}/lib/nof/"*.so* "${CT_SYSROOT_DIR}/lib" || true
   110     #        fi
   111     #    ;;
   112     #esac
   113 
   114     CT_EndStep
   115 }