From e45f9238e149b87ef189438d5942529418677299 Mon Sep 17 00:00:00 2001 From: Bertrand Jacquin Date: Mon, 13 Mar 2006 16:29:58 +0100 Subject: add new java things --- eclass/gcc-java.eclass | 338 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 239 insertions(+), 99 deletions(-) (limited to 'eclass/gcc-java.eclass') diff --git a/eclass/gcc-java.eclass b/eclass/gcc-java.eclass index 55b9dca6..47b96be5 100644 --- a/eclass/gcc-java.eclass +++ b/eclass/gcc-java.eclass @@ -4,14 +4,17 @@ ECLASS=gcc-java -ETYPE="gcc-compiler" -GCC_LANG="java" +# +# ECLASS CONFIG +# -# get the version parsing functions. -inherit versionator gnuconfig libtool +inherit flag-o-matic gnuconfig libtool toolchain-funcs versionator -EXPORT_FUNCTIONS src_unpack src_compile src_test src_install +EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install +gcc-java_pkg_setup() { + gcj_pkg_setup +} gcc-java_src_unpack() { gcj_src_unpack } @@ -25,7 +28,8 @@ gcc-java_src_install() { gcj_src_install } -IUSE="nogtk cairo" +IUSE="n32 n64 nls nogtk cairo" +RESTRICT="nostrip" RDEPEND="virtual/libc >=sys-libs/zlib-1.1.4 @@ -39,6 +43,9 @@ DEPEND="${RDEPEND} >=sys-apps/texinfo-4.2-r4 >=sys-devel/bison-1.875 >=sys-devel/binutils-2.16.1" +# +# GCJ VARIABLES +# export CTARGET=${CTARGET:-${CHOST}} if [[ ${CTARGET} = ${CHOST} ]] ; then @@ -74,7 +81,9 @@ GCC_VAR_TYPE=${GCC_VAR_TYPE:-versioned} GCC_LIB_COMPAT_ONLY="false" GCC_TARGET_NO_MULTILIB=${GCC_TARGET_NO_MULTILIB:-false} -#---->> S + SRC_URI essentials <<---- +# +# SOURCE PATH & FILES +# # This function sets the source directory depending on whether we're using # a prerelease, snapshot, or release tarball. To use it, just set S with: @@ -155,60 +164,22 @@ get_gcc_src_uri() { S=$(gcc_get_s_dir) SRC_URI=$(get_gcc_src_uri) -#create_vanilla_specs_file() { -# pushd ${WORKDIR}/build/gcc > /dev/null -# einfo "Creating a vanilla gcc specs file" -# ./xgcc -dumpspecs > ${WORKDIR}/build/vanilla.specs -# popd > /dev/null -#} - -#guess_patch_type_in_dir() { -# [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \ -# && EPATCH_SUFFIX="patch.bz2" \ -# || EPATCH_SUFFIX="patch" -#} - -gcj_src_unpack() { - local release_version="Gentoo ${PVR}" - - gcc_quick_unpack - - cd ${S:=$(gcc_get_s_dir)} - - version_string="${version_string} (${release_version})" - einfo "patching gcc version: ${version_string}" - gcc_version_patch "${version_string}" +# +# SETUP +# - # Misdesign in libstdc++ (Redhat) - if [[ ${GCCMAJOR} -ge 3 ]] && [[ -e ${S}/libstdc++-v3/config/cpu/i486/atomicity.h ]] ; then - cp -pPR "${S}"/libstdc++-v3/config/cpu/i{4,3}86/atomicity.h +gcj_pkg_setup() { + if [ "${CHOST}" != "${CTARGET}" ]; then + eerror "cross-compile unsupported!" + die fi - # Fixup libtool to correctly generate .la files with portage - cd "${S}" - elibtoolize --portage --shallow --no-uclibc - - gnuconfig_update - - # update configure files - einfo "Fixing misc issues in configure files" - for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do - ebegin " Updating ${f/${S}\/}" - patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \ - || die "Please file a bug about this" - eend $? - done - - ./contrib/gcc_update --touch &> /dev/null - + unset GCC_SPECS } -gcj_src_test() { - cd "${WORKDIR}"/build - make check || ewarn "check failed and that sucks :(" -} - - +# +# UNPACK +# # gcc_quick_unpack will unpack the gcc tarball and patches in a way that is # consistant with the behavior of get_gcc_src_uri. The only patch it applies @@ -241,21 +212,6 @@ gcc_quick_unpack() { popd > /dev/null } - -# Try to apply some stub patches so that gcc won't error out when -# passed parameters like -fstack-protector but no ssp is found -do_gcc_stub() { - local v stub_patch="" - for v in ${GCC_RELEASE_VER} ${GCC_BRANCH_VER} ; do - stub_patch=${GCC_FILESDIR}/stubs/gcc-${v}-$1-stub.patch - if [[ -e ${stub_patch} ]] ; then - EPATCH_SINGLE_MSG="Applying stub patch for $1 ..." \ - epatch "${stub_patch}" - return 0 - fi - done -} - # This function allows us to gentoo-ize gcc's version number and bugzilla # URL without needing to use patches. gcc_version_patch() { @@ -265,55 +221,243 @@ gcc_version_patch() { -e 's~http:\/\/gcc\.gnu\.org\/bugs\.html~http:\/\/bugs\.gentoo\.org\/~' ${S}/gcc/version.c || die "failed to update version.c with Gentoo branding." } -fix_libtool_libdir_paths() { - local dirpath - for archive in $* ; do - dirpath=$(dirname ${archive} | sed -e "s:^${D}::") - sed -i ${archive} -e "s:^libdir.*:libdir=\'${dirpath}\':" +gcj_src_unpack() { + local release_version="Gentoo ${PVR}" + + gcc_quick_unpack + + cd ${S:=$(gcc_get_s_dir)} + + version_string="${version_string} (${release_version})" + einfo "patching gcc version: ${version_string}" + gcc_version_patch "${version_string}" + + # Misdesign in libstdc++ (Redhat) + if [[ ${GCCMAJOR} -ge 3 ]] && [[ -e ${S}/libstdc++-v3/config/cpu/i486/atomicity.h ]] ; then + cp -pPR "${S}"/libstdc++-v3/config/cpu/i{4,3}86/atomicity.h + fi + + # Fixup libtool to correctly generate .la files with portage + cd "${S}" + elibtoolize --portage --shallow --no-uclibc + + gnuconfig_update + + # update configure files + einfo "Fixing misc issues in configure files" + for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do + ebegin " Updating ${f/${S}\/}" + patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \ + || die "Please file a bug about this" + eend $? done + + ./contrib/gcc_update --touch &> /dev/null } -gcj_src_compile() { - local conf - - # GCC must be built from an alternate (tmp) directory +# +# TEST +# - mkdir -p ${WORKDIR}/build - pushd ${WORKDIR}/build >/dev/null +gcj_src_test() { + cd "${WORKDIR}"/build + make check || ewarn "check failed and that sucks :(" +} + +# +# COMPILE +# + +# This is mostly a stub function to be overwritten in an ebuild +gcc_do_filter_flags() { + strip-flags + + # In general gcc does not like optimization, and add -O2 where + # it is safe. This is especially true for gcc 3.3 + 3.4 + replace-flags -O? -O2 + + # ... sure, why not? + strip-unsupported-flags + + # dont want to funk ourselves + filter-flags '-mabi*' -m31 -m32 -m64 + + case ${GCC_BRANCH_VER} in + 3.4|4.*) + case $(tc-arch) in + x86|amd64) filter-flags '-mcpu=*';; + esac + ;; + esac + + # Compile problems with these (bug #6641 among others)... + #filter-flags "-fno-exceptions -fomit-frame-pointer -fforce-addr" + + # CFLAGS logic (verified with 3.4.3): + # CFLAGS: + # This conflicts when creating a crosscompiler, so set to a sane + # default in this case: + # used in ./configure and elsewhere for the native compiler + # used by gcc when creating libiberty.a + # used by xgcc when creating libstdc++ (and probably others)! + # this behavior should be removed... + # + # CXXFLAGS: + # used by xgcc when creating libstdc++ + # + # STAGE1_CFLAGS (not used in creating a crosscompile gcc): + # used by ${CHOST}-gcc for building stage1 compiler + # + # BOOT_CFLAGS (not used in creating a crosscompile gcc): + # used by xgcc for building stage2/3 compiler + + export GCJFLAGS=${GCJFLAGS:-${CFLAGS}} +} + +is_uclibc() { + [[ ${GCCMAJOR} -lt 3 ]] && return 1 + [[ ${CTARGET} == *-uclibc ]] +} + +# Other than the variables described for gcc_setup_variables, the following +# will alter tha behavior of gcc_do_configure: +# +# CTARGET +# CBUILD +# Enable building for a target that differs from CHOST +# +# GCC_TARGET_NO_MULTILIB +# Disable multilib. Useful when building single library targets. +# +# GCC_LANG +# Enable support for ${GCC_LANG} languages. defaults to just "c" +# +# Travis Tilley (04 Sep 2004) +# +gcc_do_configure() { + local confgcc # global configure defaults from toolchain.eclass - conf="--with-system-zlib \ + confgcc="--with-system-zlib \ --disable-checking \ --disable-werror \ - --disable-libunwind-exceptions \ - --enable-nls --without-included-gettext" + --disable-libunwind-exceptions" + + [[ ${CTARGET} == *-softfloat-* ]] && confgcc="${confgcc} --with-float=soft" + + # Native Language Support + if use nls ; then + confgcc="${confgcc} --enable-nls --without-included-gettext" + else + confgcc="${confgcc} --disable-nls" + fi + + case $(tc-arch) in + # Add --with-abi flags to set default MIPS ABI + mips) + local mips_abi="" + use n64 && mips_abi="--with-abi=64" + use n32 && mips_abi="--with-abi=n32" + [[ -n ${mips_abi} ]] && confgcc="${confgcc} ${mips_abi}" + ;; + # Enable sjlj exceptions for backward compatibility on hppa + hppa) + [[ ${GCC_PV:0:1} == "3" ]] && \ + confgcc="${confgcc} --enable-sjlj-exceptions" + ;; + esac + + confgcc="${confgcc} --enable-shared --enable-threads=posix" + + # __cxa_atexit is "essential for fully standards-compliant handling of + # destructors", but apparently requires glibc. + # --enable-sjlj-exceptions : currently the unwind stuff seems to work + # for statically linked apps but not dynamic + # so use setjmp/longjmp exceptions by default + if is_uclibc ; then + confgcc="${confgcc} --disable-__cxa_atexit --enable-target-optspace" + else + confgcc="${confgcc} --enable-__cxa_atexit" + fi + [[ ${CTARGET} == *-gnu* ]] && confgcc="${confgcc} --enable-clocale=gnu" + [[ ${CTARGET} == *-uclibc* ]] && confgcc="${confgcc} --enable-clocale=uclibc" # our build specific configuration - conf="--prefix=/opt/${PN}-${GCC_BRANCH_VER} \ - --with-languages=c++,java \ + confgcc="--prefix=${GCJ_HOME} \ + --with-gxx-include-dir=${GCJ_HOME}/include \ + --enable-languages=c,c++,java \ $(use_enable !nogtk java-awt gtk) \ $(use_enable cairo gtk-cairo) \ + --disable-altivec \ --disable-gtktest \ --disable-glibtest \ --disable-libarttest \ --disable-multilib \ --disable-maintainer-mode \ --disable-libada \ - --enable-threads=posix \ - ${conf}" + --disable-libmudflap \ + --disable-libssp \ + --disable-static \ + ${confgcc}" echo - einfo "Configuring GCC with: ${conf//--/\n\t--} ${@} ${EXTRA_ECONF}" + einfo "Configuring GCJ with: ${confgcc//--/\n\t--} ${@} ${EXTRA_ECONF}" echo + # and now to do the actual configuration + addwrite /dev/zero + "${S}"/configure ${confgcc} $@ ${EXTRA_ECONF} \ + || die "failed to run configure" +} - ${S}/configure ${conf} || die "configure failed!" +gcj_src_compile() { + gcc_do_filter_flags - make || die "make failed!" + # Build in a separate build tree + mkdir -p ${WORKDIR}/build + pushd ${WORKDIR}/build >/dev/null + + gcc_do_configure + + if [[ $(tc-arch) == "x86" || $(tc-arch) == "amd64" || $(tc-arch) == "ppc64" ]] + then + GCC_MAKE_TARGET=profiledbootstrap + else + GCC_MAKE_TARGET=bootstrap-lean + fi + + # the gcc docs state that parallel make isnt supported for the + # profiledbootstrap target, as collisions in profile collecting may occur. + [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] && export MAKEOPTS="${MAKEOPTS} -j1" + + touch ${S}/gcc/c-gperf.h + + emake \ + BOOT_CFLAGS="$(get_abi_CFLAGS) ${CFLAGS}" \ + LDFLAGS="-Wl,-O1" \ + LIBPATH="${GCJ_HOME}/lib" \ + STAGE1_CFLAGS="-O" \ + ${GCC_MAKE_TARGET} \ + || die "emake failed with ${GCC_MAKE_TARGET}" popd >/dev/null } +# +# INSTALL +# + +do_cleanup() { + # delete binaries + rm ${D}${GCJ_HOME}/bin/{addr2name.awk,c++,cpp,g++,gcc*,gcov,${CHOST}-*} + + # copy headers - have them in one place for apps + cp -a ${D}${GCJ_HOME}/lib/gcc/${CHOST}/${PV/_/-}/include/* \ + ${D}${GCJ_HOME}/include/ + cp -a ${D}${GCJ_HOME}/include/${CHOST}/bits/* \ + ${D}${GCJ_HOME}/include/bits/ +} + gcj_src_install() { einfo "Installing GCJ ..." pushd ${WORKDIR}/build >/dev/null @@ -325,16 +469,12 @@ gcj_src_install() { # This one comes with binutils find "${D}" -name libiberty.a -exec rm -f {} \; + # conflicts with gcc? + do_cleanup + # Now do the fun stripping stuff env RESTRICT="" STRIP=${CHOST}-strip prepstrip "${D}${BINPATH}" "${D}${LIBEXECPATH}" env RESTRICT="" STRIP=${CTARGET}-strip prepstrip "${D}${LIBPATH}" - # create env file - mkdir -p "${D}"/etc/env.d/ - sed -e "s:@P@:${PN}-${GCC_BRANCH_VER}:g" \ - < ${FILESDIR}/gcj.env \ - > "${D}"etc/env.d/99gcj \ - || die "build of env file failed!" - popd >/dev/null } -- cgit v1.2.3