sys-devel/clang: x86 stable (bug #644814)
[gentoo.git] / games-simulation / pmars-sdl / pmars-sdl-0.9.2e.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5 inherit toolchain-funcs eutils games
6
7 MY_PN="${PN/-sdl/}"
8 MY_PV="${PV/e/-5}"
9 MY_P="${MY_PN}-${MY_PV}"
10
11 DESCRIPTION="Portable redcode simulator's sdl port for core war"
12 HOMEPAGE="http://corewar.co.uk/pihlaja/pmars-sdl/"
13 SRC_URI="http://corewar.co.uk/pihlaja/pmars-sdl/${MY_P}.tar.gz"
14
15 LICENSE="BSD GPL-2"
16 SLOT="0"
17 KEYWORDS="~amd64 ~x86"
18 IUSE="sdl X"
19
20 DEPEND="sdl? ( x11-libs/libX11 media-libs/libsdl[video] )
21         X? ( x11-libs/libX11 )
22         !sdl? ( !X? ( sys-libs/ncurses:0 ) )"
23 RDEPEND=${DEPEND}
24
25 S=${WORKDIR}/${MY_P}
26
27 src_prepare() {
28         epatch "${FILESDIR}"/${P}-format.patch
29 }
30
31 src_compile() {
32         CFLAGS="${CFLAGS} -DEXT94 -DPERMUTATE"
33         LFLAGS="-x"
34
35         if use sdl ; then
36                 CFLAGS="${CFLAGS} -DSDLGRAPHX `sdl-config --cflags`"
37                 LIB=`sdl-config --libs`
38         elif use X ; then
39                 CFLAGS="${CFLAGS} -DXWINGRAPHX"
40                 LIB="-L/usr/X11R6/lib -lX11"
41         else
42                 CFLAGS="${CFLAGS} -DCURSESGRAPHX"
43                 LIB="-lcurses"
44         fi
45
46         cd src
47
48         SRC="asm.c
49                  cdb.c
50                  clparse.c
51                  disasm.c
52                  eval.c
53                  global.c
54                  pmars.c
55                  sim.c
56                  pos.c
57                  str_eng.c
58                  token.c"
59
60         for x in ${SRC}; do
61                 einfo "compiling ${x}"
62                 $(tc-getCC) ${CFLAGS} ${x} -c || die
63         done
64
65         echo
66         einfo "linking with LIB: ${LIB}"
67         $(tc-getCC) ${LDFLAGS} *.o ${LIB} -o ${MY_PN} || die
68 }
69
70 src_install() {
71         dogamesbin src/${MY_PN}
72         doman doc/${MY_PN}.6
73
74         dodoc AUTHORS CONTRIB ChangeLog README doc/redcode.ref
75
76         insinto "${GAMES_DATADIR}/${MY_PN}/warriors"
77         doins warriors/*
78
79         insinto "${GAMES_DATADIR}/${MY_PN}/macros"
80         doins config/*.mac
81
82         prepgamesdirs
83 }
84
85 pkg_postinst() {
86         games_pkg_postinst
87         echo
88         ewarn "There are some macros in ${GAMES_DATADIR}/${MY_PN}/macros"
89         ewarn "which you should make accessible to pmars by typing"
90         ewarn "export PMARSHOME=${GAMES_DATADIR}/${MY_PN}/macros\n"
91 }