# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils

DESCRIPTION="webcam view tools use sdl lib." # 这是对你的软件包进行的简短说明
HOMEPAGE="http://mxhaard.free.fr" # 这个就没什么好说的了,如果你在某个站点发布你的软件,那在这里加上网站的链接就是了
#MY_PV=20060127
#SRC_URI="http://mxhaard.free.fr/spca50x/Download/Gideo-0.1.tar.gz"
SRC_URI="http://mxhaard.free.fr/spca50x/Download/${P}.tar.gz"
SLOT="0" # 通常这里写成0就可以了,这主要用于GCC,emacs这类可以多版本共存的软件包
#IUSE="linguas_zh_CN ssl applet systray doc" # 这里设置USE标记,较为复杂,这里就只加一个doc作例子了
IUSE=""
LICENSE="GPL-2" # 我们痛恨但又不可避免的软件许可
KEYWORDS="x86 amd64" #这只是个简单的脚本,所以在各种架构上都应该是可以正常运行的,不过,我们只想在x86上测试它
#并且所有起始的ebuild都应该先进行测试,所以只写上~x86
DEPEND=" media-libs/libsdl \
media-video/gspcav1"

#RDEPEND=""
#FEATURES="-sandbox ${FEATURES}"
#FEATURES="-sandbox"
RESTRICT="mirror" #for local overlay

#S="${WORKDIR}/${PN}${PV}"

src_unpack() # 这个函数用于解压源代码
{
#当前ebuild可以不用声明此函数 但为了学习而显示一些变量而用的
# ${S}是src_unpack函数起始执行的地方,由emerge系统自动创建
#cp ${FILESDIR}/unmask.gz ${S}
#FILESDIR这个变量指明了我们存放该包的路径也就是
#/usr/portage/local/myebuilds/app-portage/unmask/files
#gzip -d ${S}/unmask.gz
einfo "Start src_unpack()"
einfo "${P}"
einfo "\$\{S\}=${S}"
einfo "\$\{D\}=${D}"
einfo "\$\{FILESDIR\}=${FILESDIR}"
unpack ${A}
einfo "A = ${A}"
einfo "org S = ${S}"
einfo "WORKDIR = ${WORKDIR}"
cd "${S}"
einfo "after S = ${S}"
einfo "D = ${D}"
einfo "FEATURES=${FEATURES}"
#mv makefile Makefile
#sed -i '/^BIN/s:/local::' Makefile
#epatch "${FILESDIR}/${P}.diff" #暂时不用留着吧
#sed -i 's/CP932/CP936/g' config.h #多此一举 这个文件是configure生成的
}

#show_econf_err()
#{
# einfo "econf faile by show_econf_err()"
# if use applet; then
# einfo "try to use USE="-applet" emerge foo"
# fi
#}
#
src_compile()
{
#if !use systray; then
# econf --disable-systray || die "econf failed"
#else
# econf --enable-systray || die "econf failed"
#fi
#econf $(use_enable systray) \
# $(use_enable applet) \
# $(use_with ext-charcode) \
# $(use_with ssl) || die "econf failed"

#einfo " myconf = ${myconf}"
#econf ${myconf} || die "=================econf failed============="
econf || die "=================econf failed============="
emake || die "emake failed"
# --with-ext-charcode External character code setting(CP936(Simplified
}

# src_compile() { } #如果你需要编译什么东西,就在这个函数中完成.
src_install()
{
einfo "Start src_install()"
#dosbin unmask
# 使用dosbin将目标程序安装到/usr/sbin/目录,相应的,如果要安装到/usr/bin,可以使用dobin,这是ebuild本身提供的几个简单的安装函数,可以在man 5 ebuild中查到它们
einfo "D = ${D}"
# if has sandbox ${FEATURES} ; then
# ewarn "========== FEATURES=-sandbox emerge $PN"
# ewarn "========== sudo sh -c 'FEATURES=-sandbox emerge $PN'"
# die "============= retry it by has sandbox \${FEATURES} ==========="
# fi
# if hasq "sandbox" ${FEATURES} ; then
# ewarn "========== FEATURES=-sandbox emerge $PN"
# ewarn "========== sudo sh -c 'FEATURES=-sandbox emerge $PN'"
# ewarn "============= retry it by hasq sandbox \${FEATURES} ==========="
# #die "============= retry it ==========="
# else
# einfo "check FEATURES not sanbox"
# ewarn "============= hasq sandbox \${FEATURES} ==========="
# fi

emake DESTDIR="${D}" install || die "emake install failed" #
#dobin ${PN}
#dodoc README CHANGELOG
#推荐使用 make DESTDIR="${D}" install 方式
#GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL=1 #解决sandbox出错的题,之前要FEATURES=-sandbox emerge g2ipmsg的问题
#GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL=1 einstall || die "einstall failed"
#einstall用于对付不正常Makefile
}
#------------------ 一个使用第三方ebuild的示例---------------------------
#sudo mkdir /usr/local/myportage/net-misc/g2ipmsg/files -p
#cd /usr/local/myportage/net-misc/g2ipmsg/files
#--------------------
#add PORTDIR_OVERLAY to /etc/make.conf
#PORTDIR_OVERLAY="/usr/local/myportage"
#PORTDIR_OVERLAY="${PORTDIR_OVERLAY} /usr/portage/local/layman/gentoo-china"
#sudo sh -c "echo net-misc/g2ipmsg >> /etc/portage/package.keywords"
#sudo sh -c 'echo "net-misc/g2ipmsg ssl applet doc systray >> /etc/portage/package.use'
#不用这一步
#sudo ebuild ./g2ipmsg-0.9.5.ebuild digest
#sudo sh -c "USE=doc emerge g2ipmsg"
#cat /var/lib/portage/world | grep g2ipmsg
#---------------------------------------------
#test for ebuild
#repoman scan
#repoman full
#---------------------------------------------
#==========联系方式==========
# mailto: 3444542@163.com
# QQ: 3444542
# gmail: zlbgps@gmail.com
# irc: irc.freenode.org/#gentoo-cn GunsNRose
# blog: http://hi.baidu.com/3444542/blog
#============================