+# Copyright © 2011, 2015 Nick Bowler
+# License GPLv3+: GNU General Public License version 3 or later.
+# There is NO WARRANTY, to the extent permitted by law.
+
+EAPI=5
+
+inherit games
+
+MY_P=${PN}_${PV}-1
+
+DESCRIPTION="Crack into virtual computer systems"
+HOMEPAGE="http://www.uplink.co.uk"
+SRC_URI="amd64? ( ${MY_P}_amd64.tar.gz )
+ x86? ( ${MY_P}_i386.tar.gz )"
+RESTRICT="fetch"
+
+LICENSE="uplink"
+KEYWORDS="~amd64 ~x86"
+SLOT="0"
+
+DEPEND="dev-util/patchelf"
+RDEPEND="media-libs/libsdl[opengl]
+ media-libs/sdl-mixer[mikmod]
+ media-libs/freetype:2
+ media-libs/tiff:3"
+
+src_unpack() {
+ local root
+
+ unpack $A
+
+ use amd64 && root=uplink-x64
+ use x86 && root=uplink-x86
+ test -n "$root" || die "unsupported architecture"
+
+ mv "$root" "$P" || die
+}
+
+src_compile() {
+ local useless_libs="libjpeg.so.62 libmikmod.so.2 libz.so.1"
+ local exe
+
+ use amd64 && exe=uplink.bin.x86_64
+ use x86 && exe=uplink.bin.x86
+ test -n "$exe" || die "unsupported architecture"
+
+ for lib in $useless_libs; do
+ patchelf --remove-needed "$lib" "$exe" || die
+ done
+}
+
+src_install() {
+ local dir=$GAMES_PREFIX_OPT/$PN
+ local exe
+
+ insinto "$dir"
+ doins *.dat
+
+ use amd64 && exe=uplink.bin.x86_64
+ use x86 && exe=uplink.bin.x86
+ test -n "$exe" || die "unsupported architecture"
+
+ exeinto "$dir"
+ doexe "$exe"
+
+ doicon uplink.png
+ make_desktop_entry "$PN" Uplink uplink
+ games_make_wrapper "$PN" "$dir/$exe"
+
+ dodoc *.txt
+
+ prepgamesdirs
+}