# Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/eclass/dvb.eclass,v 1.16 2005/06/16 09:44:33 zzam Exp $ # # Matthias Schwarzott # # Changelog # # 17.08.2004 Path to driver can be set in /etc/make.conf (DVB_DRIVER_INCLUDE) MS # 18.08.2004 Detect if Kernel 2.6.7 or greater and set Path magically MS # 19.08.2004 Detect Path to header-files automatic MS # 20.08.2004 Added more files to check for __user MS # 21.08.2004 Added more pathes to check for dvb-driver MS # 24.09.2004 Better tests for need to patch driver / cosmetic changes MS # 21.01.2005 Changed grep for API-Version MS # 18.04.2005 Search for includes in pkg_setup (like linux-info.eclass) MS # 16.05.2005 make vdr_opts less verbose MS # ECLASS=dvb INHERITED="$INHERITED $ECLASS" EXPORT_FUNCTIONS pkg_setup test -z ${DVB_TEST_API_VERSION} || DVB_TEST_API_VERSION=1 # No dependency for linux26-headers #if [ "${KV:0:3}" == "2.6" ]; then # KV_patch=$(echo ${KV} | cut -f 3 -d . | cut -f 1 -d -) # # if [ "${KV_patch}" -gt 7 ]; then # DEPEND="sys-kernel/linux26-headers" # fi #fi # # function to implement a "local" use variable called VDR_OPTS # vdr_opts() { local x for x in ${VDR_OPTS} do if [ "${x}" = "${1}" ] then #einfo "Option ${1} found in VDR_OPTS" return 0 fi done #ewarn "No optional ${1} in VDR_OPTS" #echo return 1 } # best be called from pkg_setup dvb_find_driver_include() { # Only continue if first call test -z "${DVB_DRIVER_INCLUDE_DONE}" || return local local_path="${DVB_DRIVER_INCLUDE}" local versfile local found=0 # Search for driver-headers in any of these locations for DVB_DRIVER_INCLUDE in ${local_path} /usr/include/linuxtv-dvb-cvs/ /usr/include/linuxtv-dvb/ /usr/include/ /usr/src/linux/include/; do local versfile="${DVB_DRIVER_INCLUDE}/linux/dvb/version.h" test -f "${versfile}" || continue # Read Version of DVB-API DVB_API_VERSION=$(cat ${versfile} | awk '/DVB_API_VERSION / { print $3 }') DVB_API_VERSION_MINOR=$(cat ${versfile} | awk '/DVB_API_VERSION_MINOR/ { print $3 }') [ "$DVB_TEST_API_VERSION" == "1" ] && [ "${DVB_API_VERSION}" -ne "3" ] && continue found=1 break done # No accaptable headers found if [ "$found" == "0" ]; then ewarn "No Header for the DVB-Driver found!" einfo einfo "You need to install either" einfo " + >=linuxtv-dvb-cvs-0.0.2" einfo " + a Kernel with DVB-Support (2.6.x)" einfo " + linux26-headers" die fi local version_txt=${DVB_API_VERSION} test -z ${DVB_API_VERSION_MINOR} || version_txt=${version_txt}.${DVB_API_VERSION_MINOR} einfo "Found DVB-Driver Includes:" einfo " ${DVB_DRIVER_INCLUDE} (API ${version_txt})" # Test if headers need to be patched pushd . >/dev/null cd ${DVB_DRIVER_INCLUDE} dvb_check_user_patch popd >/dev/null DVB_DRIVER_INCLUDE_DONE="1" } dvb_check_user_patch() { # Testing Headers for __user without included linux/compiler.h local headers="linux/dvb/*.h" grep -q __user ${headers} || return if grep -q linux/compiler.h ${headers}; then # This is good (no need to patch) # if compiler.h has apropriate define (it has in >=linux26-headers-2.6.8.1) if grep -q __user /usr/include/linux/compiler.h; then return fi fi # Only get here if headers need to be patched einfo "Workaround for older kernel-headers or strange driver-snapshot" mkdir -p ${T}/dvb-includes/linux/dvb local f for f in ${headers}; do sed -e 's:__user::' < ${f} > ${T}/dvb-includes/${f} done DVB_DRIVER_INCLUDE=${T}/dvb-includes } dvb_patch_makefile() { # dvb_find_driver_include already called from pkg_setup test -z "$SILENT" && einfo Patching Makefile for new path to dvb-driver local f="${1}" test -z "${f}" && f="${S}/Makefile" sed -i ${f} \ -e "s:^DVBDIR.*$:DVBDIR = ${DVB_DRIVER_INCLUDE}:" \ -e 's:\$(DVBDIR)/include:$(DVBDIR):' } dvb_patch_all_makefiles() { einfo "Patching Makefiles for new path to dvb-driver" local f for f in $(find -name Makefile); do SILENT=1 dvb_patch_makefile "${f}" done } dvb_pkg_setup() { dvb_find_driver_include }