summaryrefslogtreecommitdiff
path: root/games/crafty/Makefile
blob: 66b3d17b75875e2256e9081ee977063a32b35f6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# $NetBSD: Makefile,v 1.22 2003/03/29 12:41:02 jmmv Exp $

DISTNAME=		crafty-18.15
WRKSRC=			${WRKDIR}
CATEGORIES=		games
MASTER_SITES=		ftp://ftp.cis.uab.edu/pub/hyatt/v18/ \
			ftp://ftp.cis.uab.edu/pub/hyatt/ \
			ftp://ftp.cis.uab.edu/pub/hyatt/common/
DISTFILES=		${CRAFTY_DISTFILES}
DISTFILES+=		${CRAFTY_STARTPGN} ${CRAFTY_DOCFILES}

MAINTAINER=		jlam@netbsd.org
COMMENT=		chess engine

USE_BUILDLINK2=		YES

DIST_SUBDIR=		${DISTNAME}
CRAFTY_DISTFILES=	${DISTNAME}${EXTRACT_SUFX}
CRAFTY_STARTPGN=	start.pgn
CRAFTY_DOCFILES=	read.me crafty.faq
EXTRACT_ONLY=		${CRAFTY_DISTFILES}

.include "../../mk/bsd.prefs.mk"

.if !empty(MACHINE_PLATFORM:MNetBSD-*-i386)
.  if ${OBJECT_FMT} == "ELF"
ALL_TARGET=		netbsd-i386-elf
.  else
ALL_TARGET=		netbsd-i386
.  endif
.elif !empty(MACHINE_PLATFORM:MNetBSD-*-sparc)
ALL_TARGET=		netbsd-sparc
# higher levels of optimization cause crafty to immediately segfault
CFLAGS:=		${CFLAGS:C/-O[0-9]*/-O1/}
.elif !empty(MACHINE_PLATFORM:MNetBSD-*-*)
ALL_TARGET=		netbsd
.elif !empty(MACHINE_PLATFORM:MSunOS-*-*)
ALL_TARGET=		solaris-gcc
.else
ALL_TARGET=		generic
.endif

CRAFTY_OPTS=		-DBOOKDIR=\\\"${BOOKDIR}\\\"
CRAFTY_OPTS+=		-DTBDIR=\\\"${TBDIR}\\\"
MAKE_ENV+=		opt="${CRAFTY_OPTS}"

BOOKDIR=		${PREFIX}/lib/crafty
TBDIR=			${PREFIX}/share/egtb
DOCDIR=			${PREFIX}/share/doc/crafty

CRAFTYRC=		${WRKDIR}/.craftyrc

post-extract:
	${CP} ${DISTDIR}/${DIST_SUBDIR}/${CRAFTY_STARTPGN} ${WRKDIR}
	${MV} ${WRKSRC}/Sparc.s ${WRKSRC}/Sparc.S

post-patch:
	cd ${WRKSRC}; for file in Makefile; do				\
		${SED}	-e "s| -O3||g" -e "s| -m486||g"			\
			$${file} >> $${file}.fixed;			\
		${MV} $${file}.fixed $${file};				\
	done

post-build:
	${RM} -f ${CRAFTYRC}
	${ECHO} "books create ${CRAFTY_STARTPGN} 60" > ${CRAFTYRC}
	${ECHO} "quit" >> ${CRAFTYRC}
	cd ${WRKSRC} && ${WRKSRC}/crafty bookpath=.

do-install:
	${INSTALL_PROGRAM} ${WRKSRC}/crafty ${PREFIX}/bin
	${INSTALL_DATA_DIR} ${BOOKDIR}
	${INSTALL_DATA} ${WRKDIR}/books.bin ${BOOKDIR}
	${INSTALL_DATA_DIR} ${DOCDIR}
	for file in ${CRAFTY_DOCFILES}; do \
		${INSTALL_DATA} ${DISTDIR}/${DIST_SUBDIR}/$${file} ${DOCDIR}; \
	done

.include "../../mk/bsd.pkg.mk"