# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI=3 export CBUILD=${CBUILD:-${CHOST}} export CTARGET=${CTARGET:-${CHOST}} if [[ ${CTARGET} == ${CHOST} ]] ; then if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then export CTARGET=${CATEGORY/cross-} fi fi inherit eutils flag-o-matic versionator MY_PV=$(replace_all_version_separators '-') MY_P=${PN}-${MY_PV}-release DESCRIPTION="Implementation of pthreads for Win32" HOMEPAGE="http://sourceware.org/pthreads-win32" SRC_URI="ftp://sourceware.org/pub/pthreads-win32/${MY_P}.tar.gz" LICENSE="LGPL-2.1" SLOT="0" KEYWORDS="~amd64" IUSE="" RESTRICT="strip" DEPEND="" RDEPEND="${DEPEND}" S="${WORKDIR}/${MY_P}" test-flag-LD() { local flags="$1" [[ -z ${flags} ]] && \ return 1 local PROG=$(tc-getCC) local tmpfile=$(mktemp tmp.test-flag-LD.XXXXXX) echo 'int main(void){}' \ | ${PROG} ${flags} -o "${tmpfile}" -xc - \ > /dev/null 2&>1 local ret=$? rm -f "${tmpfile}" > /dev/null 2&>1 return $ret } test-flags-LD() { test-flags-PROG "LD" "$@"; } strip-unsupported-flags() { export CFLAGS=$(test-flags-CC ${CFLAGS}) export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS}) export FFLAGS=$(test-flags-F77 ${FFLAGS}) export FCFLAGS=$(test-flags-FC ${FCFLAGS}) export LDFLAGS=$(test-flags-LD ${LDFLAGS}) } pkg_setup() { if [[ ${CBUILD} == ${CHOST} ]] && [[ ${CHOST} == ${CTARGET} ]] ; then die "Invalid configuration; do not emerge this directly" fi } src_prepare() { filter-flags -fstack-protector CHOST=${CTARGET} strip-unsupported-flags sed -i GNUmakefile \ -e '/^OPT/s/-O3 -finline-functions//' \ -e "/^CFLAGS/s/\$/ ${CFLAGS}/" \ -e "/^CFLAGS/a\ LFLAGS = ${LDFLAGS} -lwsock32" \ || die } src_compile() { emake CROSS=${CTARGET}- GC || die } src_install() { insinto /usr/${CTARGET}/usr/lib doins libpthreadGC2.a || die insinto /usr/${CTARGET}/usr/bin doins pthreadGC2.dll || die insinto /usr/${CTARGET}/usr/include doins {pthread,sched,semaphore}.h || die }