# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils flag-o-matic versionator games MY_PV=$(get_version_component_range 3) DESCRIPTION="A game similar to Settlers 2" HOMEPAGE="http://www.widelands.org/" # Build 13 breaks previous naming conventions # (used to be ${PN}-build-${PV}-source.tar.bz2) SRC_URI="mirror://sourceforge/${PN}/Widelands-Build${MY_PV}-src.tar.bz2" LICENSE="GPL-2" SLOT="0" KEYWORDS="~amd64 ~ppc ~x86" IUSE="nls shrink" RDEPEND="media-libs/libsdl media-libs/sdl-image >=media-libs/sdl-mixer-1.2.6 media-libs/sdl-net >=media-libs/sdl-ttf-2.0 media-libs/sdl-gfx media-libs/libpng >=dev-libs/boost-1.33 nls? ( virtual/libintl )" DEPEND="${RDEPEND} nls? ( sys-devel/gettext ) shrink? ( media-gfx/optipng media-gfx/pngrewrite ) >=dev-util/scons-1.0" S=${WORKDIR}/${PN}-b13 src_unpack() { if use shrink; then ewarn "You have activated png shrinking. This is usually only" ewarn "done upstream. Expect it to last many hours." fi unpack ${A} # build 13 breaks standard unpacking: creates widelands-b13 # per discussions in IRC, S variable updated instead of a mv # mv "${WORKDIR}/widelands-b13" "${S}" cd "${S}" # TODO: Gentooify locale abbreviations and let user select languages #strip-linguas -u po # per comment 3 in bug #249396 scons works without patching # makefile is unsupported, perhaps even broken # rm -f $(find . -name SConscript) # when build=release, scons strips the binary, we'll do that ourselves # per discussion in IRC. Using sed inside the ebuild instead of external # patch. sed -i "s:\(env.strip=\)1:\10:g" build/scons-tools/scons_configure.py \ || die "sed no-strip failed" sed -i "s:__ppc__:__PPC__:" src/s2map.cc \ || die "sed s2map.cc failed" sed -i "s:/usr/share/games:${GAMES_DATADIR}:" src/wlapplication.cc \ || die "sed wlapplication.cc failed" sed -i "s:/l/WiLa/Setup:${GAMES_DATADIR}/${PN}:" src/config.h.default \ || die "sed config.h.default failed" # make nls use flag dependant sed -i "s:opts.AddOptions(:&\n\ BoolOption('gentoo_use_nls', '', False),:g;\ s:env\['build'\]=='release':env\['gentoo_use_nls'\]==True:g" \ SConstruct \ || die "sed SConstruct:nls failed" # we will install doc manually (hard to configure with scons) sed -i "s:instadd(env, '.*', 'doc'):#&:g" SConstruct \ || die "sed SConstruct:doc failed" # TODO: This is really ugly and redundant. Find a better solution. # TODO: Make a patch? if has ccache $FEATURES; then sed -i "s:env.Help(opts.GenerateHelpText(env)):&\n\ \renv.Append(CCACHE_DIR = os.environ['CCACHE_DIR'])\n\ \renv['CXX']='CCACHE_DIR=\"$CCACHE_DIR\" ccache g++':g"\ SConstruct \ || die "sed-inserting ccache configuration in SConstruct failed" fi # Upstream says that omit-frame-pointer breaks exceptions. Don't use it. filter-flags -fomit-frame-pointer # Upstream's optimization CXXFLAGS are inconsistent, use Gentoo's flags # instead. Do not use scons extra_compile_flags="${CXXFLAGS}" as most # of it will be overridden by the default flags cd build/scons-tools mv scons_configure.py scons_configure.py_orig local awk_cxxflags awk_cxxflags=$( for i in -fno-omit-frame-pointer ${CXXFLAGS}; do echo "print \"\t\tconf.CheckCompilerFlag('${i}', env)\"" done ) awk '/if env.optimize:$/ { a = 1 } /conf.CheckCompilerFlag/ { if (a == 1) sub(".*","#&") } /else:/ { if (a == 1) { a = 0 '"$awk_cxxflags"' print "\t\tpass" } } // { print }' \ scons_configure.py_orig > scons_configure.py \ || die "awk failed" cd ../.. } src_compile() { local gentoo_use_nls="no" use nls && gentoo_use_nls="yes" local regexp='([ \t]--jobs([=][0]*[1-9][0-9]*' regexp="${regexp}"'|[ \t]+[0]*[1-9][0-9]*))' regexp="${regexp}"'|([ \t]-j[ \t]*[0]*[1-9][0-9]*)' local parallel_switch=$( echo " ${MAKEOPTS}" | grep -oP "${regexp}" | tail -n 1 \ | sed "s:--jobs[^=][ \t]*:--jobs=:g; s:[ \t]*::g" ) [ "-j" = "${parallel_switch}" ] && parallel_switch="-j256" [ "--jobs" = "${parallel_switch}" ] && parallel_switch="-j256" [ "" = "${parallel_switch}" ] && parallel_switch="-j1" einfo "running scons with ${parallel_switch}" if use shrink; then scons ${parallel_switch} shrink \ || die "scons shrink failed" fi scons ${parallel_switch} \ build="release" \ build_id="${PVR}" \ install_prefix="${D}/usr" \ bindir="${D}${GAMES_BINDIR}" \ datadir="${D}${GAMES_DATADIR}/widelands" \ localedir="/usr/share/locale" \ gentoo_use_nls=${gentoo_use_nls} \ || die "scons build failed" } src_install() { # workaround for strange directory configuration scons localedir="${D}/usr/share/locale" install \ || die "scons install failed" newicon pics/wl-ico-48.png ${PN}.png make_desktop_entry ${PN} Widelands dodoc ChangeLog CREDITS prepgamesdirs }