# Copyright 1999-2010 Gentoo Foundation# Distributed under the terms of the GNU General Public License v2# $Header: $RESTRICT="mirror strip"inherit vdr-plugin mercurial: ${EHG_REPO_URI:=http://85.17.209.13:6100/sc}DESCRIPTION="VDR plugin: softcam HG-Version"HOMEPAGE="http://vdr.bluox.org"SRC_URI=""SLOT="0"LICENSE="GPL-2"KEYWORDS="~x86 ~amd64"IUSE="firmware ffdecsa-test"DEPEND=">=media-video/vdr-1.7.8 dev-libs/openssl firmware? ( media-tv/sc-dvb-firmware )"S="${WORKDIR}/sc"PARALLEL_MODES=""pkg_setup() { vdr-plugin_pkg_setup if use ffdecsa-test; then ewarn "" ewarn "You enabled the 'ffdecsa-test' USE flag, you should know that this ebuild will perform" ewarn "the FFdecsa 'correctness and speed' tests for all the possible parallel-modes." ewarn "" ewarn "You may interrupt the build process when prompted, in order to choose the parallel-mode" ewarn "that suits you best and re-emerge with USE='-ffdecsa-test', or just let the ebuild" ewarn "continue emerging the plugin with the previously selected, or the default mode." ewarn "" fi}collect_parallel_modes() { PARALLEL_MODES="$(cat ${S}/FFdecsa/FFdecsa.c | grep '#define PARALLEL_32' | tr -s ' ' | cut -d' ' -f 2)" PARALLEL_MODES="${PARALLEL_MODES} $(cat ${S}/FFdecsa/FFdecsa.c | grep '#define PARALLEL_64' | tr -s ' ' | cut -d' ' -f 2)" PARALLEL_MODES="${PARALLEL_MODES} $(cat ${S}/FFdecsa/FFdecsa.c | grep '#define PARALLEL_128' | tr -s ' ' | cut -d' ' -f 2)"}src_unpack() { mercurial_src_unpack vdr-plugin_src_unpack all_but_unpack fix_vdr_libsi_include systems/viaccess/tps.c fix_vdr_libsi_include systems/viaccess/viaccess.c cd ${S} sed -i Makefile.system \ -e "s:^LIBDIR.*$:LIBDIR = ${S}:" # manipulating LIBDIR, otherwise it looks for inexistent ../../lib # manipulating LOCALEDIR to avoid a sandbox violation in /usr/include/vdr/locale sed -i Makefile \ -e "s:^LIBDIR.*$:LIBDIR = ${S}:" \ -e "s:LOCALEDIR =:LOCALEDIR ?=:" \ -e "s:/include/vdr/config.h:/config.h:" \ -e "s:-march=\$(CPUOPT)::" \ -e "s:\$(CSAFLAGS):\$(CXXFLAGS):" \ -e "s:ci.c:ci.h:" \ -e "s:include/vdr/i18n.h:i18n.h:" # we do not have usleep on gentoo, but sleep with float seconds arguments capability :-) sed -i FFdecsa/Makefile \ -e "s:usleep 200000:sleep 0.2:" if use ffdecsa-test; then # add single ffdecsa-test target to makefile, to be able to to perform tests in all modes epatch ${FILESDIR}/Makefile_ffdecsa-test.diff # collect all parallel-modes declared in FFdecsa source collect_parallel_modes einfo "" einfo "Found the following possible FFdecsa parallel-modes:" einfo "${PARALLEL_MODES}" einfo "" fi # create the temporary locales dir mkdir -p ${WORKDIR}/tmp-locale}src_compile() { if use ffdecsa-test; then # loop over all parallel-modes to perform the test for mymode in ${PARALLEL_MODES}; do einfo "" ebegin "Performing FFdecsa tests for ${mymode}" LOCALEDIR=$TMP_LOCALE_DIR MAKEOPTS="-j1" PARALLEL=${mymode} emake ffdecsa-test || eerror "FFdecsa test for ${mymode} failed..." eend $? done # cleanup to enforce building ffdecsa with the default or the chosen parallel mode if the user will let the ebuild finish cd ${S}/FFdecsa emake clean || eerror "Failed to clean FFdecsa test build..." cd ${S} einfo "" einfo "You may interrupt emerging the package now, scroll back and choose ONE of the settings:" einfo "" einfo "${PARALLEL_MODES}" einfo "" einfo "whichever gave the best results on your system and set it in the 'FFDECSA_PAR' variable" einfo "in your /etc/make.conf and re-emerge with USE='-ffdecsa-test'" ebeep 3 epause 5 fi # instruct the build process to use the temporary locales dir and perform just sequentially (otherwise it may fail), # and also pass the user's choice for the FFdecsa parallel-mode if it exists einfo "" if ! [ -z ${FFDECSA_PAR} ]; then PAR_MODE=${FFDECSA_PAR} einfo "Found FFdecsa parallel-mode setting FFDECSA_PAR=${FFDECSA_PAR}, will try to build with that." else einfo "Compiling FFdecsa with the default parallel-mode set in the package source." einfo "However, you may override this by setting the 'FFDECSA_PAR' variable to the desired mode." if ! use ffdecsa-test; then einfo "" einfo "For possible modes, please consult the 'PARALLEL_...' #defines in FFdecsa.c, or" einfo "emerge this package with USE='ffdecsa-test' and choose an appropriate mode listed at the" einfo "end of all tests and re-emerge one more time." fi fi einfo "" LOCALEDIR=$TMP_LOCALE_DIR MAKEOPTS="-j1" PARALLEL=${FFDECSA_PAR} emake || die "emake failed"}src_install() { vdr-plugin_src_install insinto usr/$(get_libdir)/vdr/plugins doins ${S}/libsc* diropts -gvdr -ovdr keepdir /etc/vdr/plugins/sc}