# Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils multilib libtool gnuconfig # Now, I have no mirror for GHDL. :S RESTRICT="nomirror" # GHDL 0.21 requires GCC 4.0.2 core source. GCC_PV="4.0.2" DESCRIPTION="GHDL - a complete VHDL simulator, using GCC technology" SRC_URI="ftp://gcc.gnu.org/pub/gcc/releases/gcc-${GCC_PV}/gcc-core-${GCC_PV}.tar.bz2 http://ghdl.free.fr/ghdl-${PV}.tar.bz2" HOMEPAGE="http://ghdl.free.fr/" SLOT="0" KEYWORDS="~x86 ~ppc" LICENSE="GPL-2" IUSE="multilib altivec" S="${WORKDIR}/gcc-${GCC_PV}" GHDL_BUILD="${WORKDIR}/build" # According to README of GHDL 0.21, it can build by GNAT v3.15p or GNAT GPL 2005. # So, it should use LATEST GNAT v3.15p or GNAT GPL 2005 in portage tree. # But, according to the bug #83877, it depends on GNAT v3.4*. # So, DEPEND include GNAT v3.4* by default. # Of cource, GNAT GPL 2005 is maybe O.K. GNAT_PVR="3.4*" #GNAT_GPL_PVR="3.4.5.1-r1" DEPEND=">=dev-lang/gnat-${GNAT_PVR}" #DEPEND=">=dev-lang/gnat-gpl-${GNAT_GPL_PVR}" # Any Ada95 compilers are not required for just running GHDL after it was build. # But, it means that "emerge --depclean" may remove these Ada95 compilers. # It's not useful for re-compiling from source at every GHDL version bump. # So, RDEPEND includes DEPEND by default. # Of cource, empty is maybe O.K. #RDEPEND="" RDEPEND="${DEPEND}" # When compiling GHDL, CFLAGS should be "-O", according to the README. # But, generic GCC with "-O2" as CFLAGS may be safe. #CFLAGS="-O" CFLAGS="-O2" # Bah, if emake-ing without "-j1", the build process chokes. :/ MAKEOPTS="-j1" src_unpack() { unpack ${A} einfo "Copying GHDL sources into gcc-${GCC_PV}. :)" cp -R "${WORKDIR}/${P}/vhdl" "${S}/gcc" \ || die "Copying GHDL sources faild. :(" # This patch completely delete man/info pages. :/ #einfo "patch for gcc-3.4.3..." #patch "${S}/gcc/Makefile.in" \ # "${FILESDIR}/gcc-3.4.3.patch" \ # || die "patch for gcc-3.4.3 failed. :(" # Now, I'm trying to make it with man/info pages. # Then, if these are really un-needed, I'll remove it. # This patch makes ${ADAC} = gnatgcc, # replace sed script for shared libs issuses, IMHO. einfo "patch for ${PN}-${PV}..." patch "${S}/gcc/vhdl/Makefile.in" \ "${FILESDIR}/${PN}-${PV}.patch" \ || die "patch for ${PN}-${PV} failed. :(" # Fixup libtool for .la files with portage. cd "${S}" ; elibtoolize --portage --shallow # For multilib profile arch, reference from SpanKY's ebuilds. if (has_multilib_profile || use multilib ) ; then for T_LINUX64 in `find "${S}/gcc/config" -name t-linux64` ; do einfo "sed for ${T_LINUX64} for multilib. :)" sed -i \ -e "s:\(MULTILIB_OSDIRNAMES = \).*:\1../lib64 ../lib32:" \ "${T_LINUX64}" \ || die "sed for ${T_LINUX64} failed. :(" done fi cd "${S}" ; ./contrib/gcc_update --touch &> /dev/null gnuconfig_update # Prepare the build directory mkdir -p "${GHDL_BUILD}" } src_compile() { cd "${GHDL_BUILD}" local myconf="" # Install directory layout is following generic style. # By default, program prefix is set as "${PN}" is. # GHDL must enable "vhdl" by --enable-languages option. # And, use $(get_libdir) for multilib profiles... myconf="${myconf} \ --prefix=/usr \ --program-prefix=${PN} \ --enable-languages=vhdl \ --libdir=/usr/$(get_libdir)/${PN} \ --libexecdir=/usr/$(get_libdir)/${PN} \ --datadir=/usr/share/${PN}" # These options are not included in original bugzilla's ebuild. # But if these are not included is maybe OK. myconf="${myconf} \ --bindir=/usr/bin \ --includedir=/usr/include/${PN} \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ $(use_enable altivec)" # For multilib profile. (has_multilib_profile || use multilib) || \ myconf="${myconf} --disable-multilib" # GHDL does not support cross compiling, ATM. # So, CBUILD == CHOST == CTARGET. # FIXME: # As you know, CBUILD, CHOST, CTARGET should be able to set by users/system. # But, for now, GHDL does not support cross compiling. # So, when users/system want to cross compile it, # some warnings and/or errors should happen. myconf="${myconf} --build=${CHOST} --host=${CHOST} --target=${CHOST}" einfo "Configuring GHDL..." "${S}/configure" ${myconf} || die "${PN} configure failed. :(" touch "${S}/gcc/c-gpref.h" einfo "Compiling GHDL..." S="${S}" \ emake || die "${PN} build failed. :(" } src_install() { # Remove breakable symlinks in gcc's include directory. for x in ${GHDL_BUILD}/gcc/include/* ; do if [ -L "${x}" ] then einfo "" einfo "${x} is assumed a breakable symlinks. :P" einfo "" ls "${x}" rm -f "${x}" continue fi done # Remove generated headers by fixincludes. for x in `find ${GHDL_BUILD}/build/gcc/include -name '*.h'` do if grep -q 'It has been auto-edited by fixincludes form' "${x}" then einfo "${x} is removed. :P" rm -f "${x}" fi done # Install GHDL's stuff, einfo "Install GHDL..." cd "${GHDL_BUILD}" make DESTDIR="${D}" install || die "${PN} install failed. :(" # Remove un-useful man pages, these are as its name are. :/ # But, notice, these man pages didn't conflict others, AFAIK. if [ -d "${D}/usr/share/man/man1" ] ; then einfo "" einfo "Remove ${D}/usr/share/man/man1," einfo "because of these are as its name are. :/" einfo "" rm -rf "${D}/usr/share/man/man1" fi # Prevent overwriting the files might be owned by others. # Notice, these man pages conflict others, AFAIK. if [ -d "${D}/usr/share/man/man7" ] ; then einfo "" einfo "Remove ${D}/usr/share/man/man7," einfo "because of it might be owned by others." einfo "" rm -rf "${D}/usr/share/man/man7" fi # Prevent overwriting the files might be owned by sys-devel/gcc. # Notice, these binaries conflict sys-devel/gcc, AFAIK. if [ -f "${D}/usr/bin/${CHOST}-gcc-${GCC_PV}" ] ; then einfo "" einfo "Remove ${D}/usr/bin/${CHOST}-gcc-${GCC_PV}," einfo "because of it might be ownd by sys-devel/gcc" einfo "" rm -rf "${D}/usr/bin/${CHOST}-gcc-${GCC_PV}" fi } reanalyze_libs() { local VHDL_ROOT="$1" local GHDL_BIN="$2" einfo "" einfo "Beginning re-analyze..." einfo " VHDL_ROOT=\"${VHDL_ROOT}\"" einfo " GHDL_BIN=\"${GHDL_BIN}\"" einfo "" local STD93SRCS="src/std/textio.v93 \ src/std/textio_body.v93" local STD87SRCS="src/std/textio.v87 \ src/std/textio_body.v87" local IEEE93SRCS="src/ieee/std_logic_1164.v93 \ src/ieee/std_logic_1164_body.v93 \ src/ieee/numeric_bit.v93 \ src/ieee/numeric_bit-body.v93 \ src/ieee/numeric_std.v93 \ src/ieee/numeric_std-body.v93 \ src/vital2000/timing_p.vhdl \ src/vital2000/timing_b.vhdl \ src/vital2000/prmtvs_p.vhdl \ src/vital2000/prmtvs_b.vhdl \ src/vital2000/memory_p.vhdl \ src/vital2000/memory_b.vhdl" local IEEE87SRCS="src/ieee/std_logic_1164.v87 \ src/ieee/std_logic_1164_body.v87 \ src/ieee/numeric_bit.v87 \ src/ieee/numeric_bit-body.v87 \ src/ieee/numeric_std.v87 \ src/ieee/numeric_std-body.v87 \ src/vital95/vital_timing.vhdl \ src/vital95/vital_timing_body.vhdl \ src/vital95/vital_primitives.vhdl \ src/vital95/vital_primitives_body.vhdl" local SYNSRCS="src/synopsys/std_logic_arith.vhdl \ src/synopsys/std_logic_textio.vhdl \ src/synopsys/std_logic_unsigned.vhdl \ src/synopsys/std_logic_signed.vhdl \ src/synopsys/std_logic_misc.vhdl \ src/synopsys/std_logic_misc-body.vhdl" local MENTORSRCS="src/mentor/std_logic_arith.vhdl \ src/mentor/std_logic_arith_body.vhdl" local FILE="" for FILE in ${STD93SRCS}; do einfo "Reanalys ${FILE}..." "${GHDL_BIN}" -a --bootstrap --work=std --std=93 --ieee=none \ --workdir="${VHDL_ROOT}/lib/v93/std" "${VHDL_ROOT}/${FILE}" \ || die "reanalyze for ${FILE} failed. :(" ; done for FILE in ${STD87SRCS}; do einfo "Reanalys ${FILE}..." "${GHDL_BIN}" -a --bootstrap --work=std --std=87 --ieee=none \ --workdir="${VHDL_ROOT}/lib/v87/std" "${VHDL_ROOT}/${FILE}" \ || die "reanalyze for ${FILE} failed. :(" ; done for FILE in ${IEEE93SRCS}; do einfo "Reanalys ${FILE}..." "${GHDL_BIN}" -a --bootstrap --work=ieee --ieee=none --std=93 \ -P"${VHDL_ROOT}/lib/v93/std" \ --workdir="${VHDL_ROOT}/lib/v93/ieee" "${VHDL_ROOT}/${FILE}" \ || die "reanalyze for ${FILE} failed. :(" ; done for FILE in ${IEEE87SRCS}; do einfo "Reanalys ${FILE}..." "${GHDL_BIN}" -a --bootstrap --work=ieee --std=87 --ieee=none --std=87 \ -P"${VHDL_ROOT}/lib/v87/std" \ --workdir="${VHDL_ROOT}/lib/v87/ieee" "${VHDL_ROOT}/${FILE}" \ || die "reanalyze for ${FILE} failed. :(" ; done cp "${VHDL_ROOT}/lib/v93/ieee/ieee-obj93.cf" "${VHDL_ROOT}/lib/v93/synopsys" for FILE in ${SYNSRCS}; do einfo "Reanalys ${FILE}..." "${GHDL_BIN}" -a -v --bootstrap --work=ieee --ieee=none --std=93 \ -P"${VHDL_ROOT}/lib/v93/std" \ --workdir="${VHDL_ROOT}/lib/v93/synopsys" "${VHDL_ROOT}/${FILE}" \ || die "reanalyze for ${FILE} failed. :(" ; done cp "${VHDL_ROOT}/lib/v87/ieee/ieee-obj87.cf" "${VHDL_ROOT}/lib/v87/synopsys" for FILE in ${SYNSRCS}; do einfo "Reanalys ${FILE}..." "${GHDL_BIN}" -a -v --bootstrap --work=ieee --ieee=none --std=87 \ -P"${VHDL_ROOT}/lib/v87/std" \ --workdir="${VHDL_ROOT}/lib/v87/synopsys" "${VHDL_ROOT}/${FILE}" \ || die "reanalyze for ${FILE} failed. :(" ; done cp "${VHDL_ROOT}/lib/v93/ieee/ieee-obj93.cf" "${VHDL_ROOT}/lib/v93/mentor" for FILE in ${MENTORSRCS}; do einfo "Reanalys ${FILE}..." "${GHDL_BIN}" -a -v --bootstrap --work=ieee --ieee=none --std=93 \ -P"${VHDL_ROOT}/lib/v93/std" \ --workdir="${VHDL_ROOT}/lib/v93/mentor" "${VHDL_ROOT}/${FILE}" \ || die "reanalyze for ${FILE} failed. :(" ; done } pkg_postinst() { # Reanalyze the libraries on real system. # FIXME: # As you know, if new files are generated in pkg_postinst(), # These are remained even after its package was unmerged. # So, it needs to remove these files if it was unmerged. reanalyze_libs "${ROOT}/usr/$(get_libdir)/${PN}/gcc/${CHOST}/${GCC_PV}/vhdl" "${ROOT}/usr/bin/${PN}" # Notify the user what changed. einfo "" einfo "The compiler has been installed as ${PN}." einfo "Its usage can be available by:" einfo " $ ${PN} --help && ${PN} --options-help" einfo "" }