summaryrefslogtreecommitdiff
path: root/eclass/gcc-java.eclass
diff options
context:
space:
mode:
Diffstat (limited to 'eclass/gcc-java.eclass')
-rw-r--r--eclass/gcc-java.eclass340
1 files changed, 340 insertions, 0 deletions
diff --git a/eclass/gcc-java.eclass b/eclass/gcc-java.eclass
new file mode 100644
index 00000000..55b9dca6
--- /dev/null
+++ b/eclass/gcc-java.eclass
@@ -0,0 +1,340 @@
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# Header: $
+
+ECLASS=gcc-java
+
+ETYPE="gcc-compiler"
+GCC_LANG="java"
+
+# get the version parsing functions.
+inherit versionator gnuconfig libtool
+
+EXPORT_FUNCTIONS src_unpack src_compile src_test src_install
+
+gcc-java_src_unpack() {
+ gcj_src_unpack
+}
+gcc-java_src_compile() {
+ gcj_src_compile
+}
+gcc-java_src_test() {
+ gcj_src_test
+}
+gcc-java_src_install() {
+ gcj_src_install
+}
+
+IUSE="nogtk cairo"
+
+RDEPEND="virtual/libc
+ >=sys-libs/zlib-1.1.4
+ !nogtk? ( >=x11-libs/gtk+-2.8
+ cairo? ( >=x11-libs/cairo-1.0.2 ) )
+ >=media-libs/libart_lgpl-2.1
+ >=sys-libs/ncurses-5.2-r2
+ nls? ( sys-devel/gettext )"
+
+DEPEND="${RDEPEND}
+ >=sys-apps/texinfo-4.2-r4
+ >=sys-devel/bison-1.875
+ >=sys-devel/binutils-2.16.1"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} = ${CHOST} ]] ; then
+ if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+
+GCC_RELEASE_VER=$(get_version_component_range 1-3)
+GCC_BRANCH_VER=$(get_version_component_range 1-2)
+GCCMAJOR=$(get_version_component_range 1)
+GCCMINOR=$(get_version_component_range 2)
+GCCMICRO=$(get_version_component_range 3)
+[[ ${BRANCH_UPDATE:-notset} == "notset" ]] && BRANCH_UPDATE=$(get_version_component_range 4)
+
+# According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex.
+# ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)?
+GCC_CONFIG_VER=${GCC_CONFIG_VER:-"$(replace_version_separator 3 '-')"}
+
+# Pre-release support
+if [[ ${PV} != ${PV/_pre/-} ]] ; then
+ PRERELEASE=${PV/_pre/-}
+fi
+# make _alpha and _beta ebuilds automatically use a snapshot
+if [[ ${PV} != ${PV/_alpha/} ]] ; then
+ SNAPSHOT=${GCC_BRANCH_VER}-${PV##*_alpha}
+elif [[ ${PV} != ${PV/_beta/} ]] ; then
+ SNAPSHOT=${GCC_BRANCH_VER}-${PV##*_beta}
+fi
+export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}}
+
+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 <<----
+
+# 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:
+#
+# S="$(gcc_get_s_dir)"
+
+gcc_get_s_dir() {
+ if [[ -n ${PRERELEASE} ]] ; then
+ GCC_S=${WORKDIR}/gcc-${PRERELEASE}
+ elif [[ -n ${SNAPSHOT} ]] ; then
+ GCC_S=${WORKDIR}/gcc-${SNAPSHOT}
+ else
+ GCC_S=${WORKDIR}/gcc-${GCC_RELEASE_VER}
+ fi
+
+ echo "${GCC_S}"
+}
+
+# This function handles the basics of setting the SRC_URI for a gcc ebuild.
+# To use, set SRC_URI with:
+#
+# SRC_URI="$(get_gcc_src_uri)"
+#
+# Other than the variables normally set by portage, this function's behavior
+# can be altered by setting the following:
+#
+# SNAPSHOT
+# If set, this variable signals that we should be using a snapshot
+# of gcc from ftp://sources.redhat.com/pub/gcc/snapshots/. It is
+# expected to be in the format "YYYY-MM-DD". Note that if the ebuild
+# has a _pre suffix, this variable is ignored and the prerelease
+# tarball is used instead.
+#
+# BRANCH_UPDATE
+# If set, this variable signals that we should be using the main
+# release tarball (determined by ebuild version) and applying a
+# CVS branch update patch against it. The location of this branch
+# update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}.
+# Just like with SNAPSHOT, this variable is ignored if the ebuild
+# has a _pre suffix.
+#
+# PATCH_VER
+# PATCH_GCC_VER
+# This should be set to the version of the gentoo patch tarball.
+# The resulting filename of this tarball will be:
+# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+
+gentoo_urls() {
+ local devspace="HTTP~lv/GCC/URI HTTP~eradicator/gcc/URI HTTP~vapier/dist/URI
+ HTTP~halcy0n/patches/URI"
+ devspace=${devspace//HTTP/http:\/\/dev.gentoo.org\/}
+ echo mirror://gentoo/$1 ${devspace//URI/$1}
+}
+
+get_gcc_src_uri() {
+ export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
+
+ # Set where to download gcc itself depending on whether we're using a
+ # prerelease, snapshot, or release tarball.
+ if [[ -n ${PRERELEASE} ]] ; then
+ GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2"
+ elif [[ -n ${SNAPSHOT} ]] ; then
+ GCC_SRC_URI="ftp://sources.redhat.com/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2"
+ else
+ GCC_SRC_URI="mirror://gnu/gcc/gcc-${PV}/gcc-${GCC_RELEASE_VER}.tar.bz2"
+ # we want all branch updates to be against the main release
+ [[ -n ${BRANCH_UPDATE} ]] && \
+ GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)"
+ fi
+
+ # various gentoo patches
+ [[ -n ${PATCH_VER} ]] && \
+ GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
+
+ echo "${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}"
+
+ # 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_test() {
+ cd "${WORKDIR}"/build
+ make check || ewarn "check failed and that sucks :("
+}
+
+
+
+# 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
+# itself is the branch update if present.
+#
+gcc_quick_unpack() {
+ pushd ${WORKDIR} > /dev/null
+ export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
+
+ if [[ -n ${GCC_A_FAKEIT} ]] ; then
+ unpack ${GCC_A_FAKEIT}.tar.bz2
+ mv ${GCC_A_FAKEIT} "${S}"
+ elif [[ -n ${PRERELEASE} ]] ; then
+ unpack gcc-${PRERELEASE}.tar.bz2
+ elif [[ -n ${SNAPSHOT} ]] ; then
+ unpack gcc-${SNAPSHOT}.tar.bz2
+ else
+ unpack gcc-${GCC_RELEASE_VER}.tar.bz2
+ # We want branch updates to be against a release tarball
+ if [[ -n ${BRANCH_UPDATE} ]] ; then
+ pushd ${S:-"$(gcc_get_s_dir)"} > /dev/null
+ epatch ${DISTDIR}/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
+ popd > /dev/null
+ fi
+ fi
+
+ [[ -n ${PATCH_VER} ]] && \
+ unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2
+
+ 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() {
+ [[ -z $1 ]] && die "no arguments to gcc_version_patch"
+
+ sed -i -e "s~\(const char version_string\[\] = \"\).*\(\".*\)~\1$1\2~" \
+ -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}\':"
+ done
+}
+
+gcj_src_compile() {
+ local conf
+
+ # GCC must be built from an alternate (tmp) directory
+
+ mkdir -p ${WORKDIR}/build
+ pushd ${WORKDIR}/build >/dev/null
+
+ # global configure defaults from toolchain.eclass
+ conf="--with-system-zlib \
+ --disable-checking \
+ --disable-werror \
+ --disable-libunwind-exceptions \
+ --enable-nls --without-included-gettext"
+
+ # our build specific configuration
+ conf="--prefix=/opt/${PN}-${GCC_BRANCH_VER} \
+ --with-languages=c++,java \
+ $(use_enable !nogtk java-awt gtk) \
+ $(use_enable cairo gtk-cairo) \
+ --disable-gtktest \
+ --disable-glibtest \
+ --disable-libarttest \
+ --disable-multilib \
+ --disable-maintainer-mode \
+ --disable-libada \
+ --enable-threads=posix \
+ ${conf}"
+
+ echo
+ einfo "Configuring GCC with: ${conf//--/\n\t--} ${@} ${EXTRA_ECONF}"
+ echo
+
+
+ ${S}/configure ${conf} || die "configure failed!"
+
+ make || die "make failed!"
+
+ popd >/dev/null
+}
+
+gcj_src_install() {
+ einfo "Installing GCJ ..."
+ pushd ${WORKDIR}/build >/dev/null
+
+ make DESTDIR="${D}" install || die "install failed!"
+
+ # Punt some tools which are really only useful while building gcc
+ #rm -r "${D}${LIBEXECPATH}"/install-tools
+ # This one comes with binutils
+ find "${D}" -name libiberty.a -exec rm -f {} \;
+
+ # 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
+}