summaryrefslogtreecommitdiff
path: root/emulators/xmame/Makefile
blob: 60c4ee92ccf88341c03d33a00ea79692f407441f (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# $NetBSD: Makefile,v 1.61 2002/01/04 12:04:22 tron Exp $
#

DISTNAME=		xmame-0.56.2
CATEGORIES=		emulators games x11
MASTER_SITES=		http://roms.mame.dk/emu/ \
			http://x.mame.net/download/
EXTRACT_SUFX=		.tar.bz2

MAINTAINER=		kristerw@netbsd.org
HOMEPAGE=		http://x.mame.net/
COMMENT=		X11 emulator for old arcade machines

RESTRICTED=		"selling is not allowed"
NO_SRC_ON_CDROM=	${RESTRICTED}
NO_BIN_ON_CDROM=	${RESTRICTED}

USE_X11BASE=		YES
USE_GMAKE=		YES
MAKEFILE=		makefile.unix
TARGET=			${PKGBASE}
UNLIMIT_RESOURCES=	d

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

ROMPATH=		${PREFIX}/share/${TARGET}
SPOOLDIR=		/var/games/${TARGET}

MAKE_FLAGS+=		TARGET="${TARGET:S/x//}"
MAKE_FLAGS+=		CC="${CC}"
MAKE_FLAGS+=		LIBS="${LDFLAGS} ${LIBS}"
MAKE_FLAGS+=		CFLAGS="${CFLAGS}"
MAKE_FLAGS+=		X11INC= X11LIB=

MAME_DISP_METHOD?=	x11

# Determine which CPU-specific code to use.
.for MARCH in i386 alpha m68k
MAME_CPU.${MARCH}?=	${MARCH}
.endfor
.if !defined(MAME_CPU.${MACHINE_ARCH})
# Determine the endianness of the CPU by checking header files.
.  if !defined(MACHINE_ENDIAN)
_ENDIAN_H_FILES=	/usr/include/sys/endian.h
_ENDIAN_H_FILES+=	/usr/include/machine/endian.h
_ENDIAN_H_FILES+=	/usr/include/endian.h
_ENDIAN_H_FILES+=	/usr/include/sys/byteorder.h
_ENDIAN_H_FILES+=	/dev/null
.    for FILE in ${_ENDIAN_H_FILES}
.      if exists(${FILE})
_ENDIAN_H?=		${FILE:S/\/usr\/include\///}
.      endif
.    endfor
MACHINE_ENDIAN!=							\
	if (								\
		${ECHO} "\#include <${_ENDIAN_H}>";			\
		${ECHO} "\#ifndef BYTE_ORDER";				\
		${ECHO} "\#ifdef _BIG_ENDIAN";				\
		${ECHO} "\#define BYTE_ORDER 4321";			\
		${ECHO} "\#else";					\
		${ECHO} "\#define BYTE_ORDER 1234";			\
		${ECHO} "\#endif";					\
		${ECHO} "\#endif";					\
		${ECHO} "BYTE_ORDER";					\
	   ) | ${CC} -E - | ${GREP} "4321" >/dev/null 2>&1;		\
	then								\
		${ECHO} big;						\
	else								\
		${ECHO} little;						\
	fi
MAKEFLAGS+=	MACHINE_ENDIAN="${MACHINE_ENDIAN}"
.  endif
_MAME_CPU.big-endian=		risc
_MAME_CPU.little-endian=	risc_lsb
MAME_CPU.${MACHINE_ARCH}?=	${_MAME_CPU.${MACHINE_ENDIAN}-endian}
.endif

# Determine which operating system defaults to use.
MAME_ARCH.NetBSD?=	netbsd
MAME_ARCH.Linux?=	linux
MAME_ARCH.SunOS?=	solaris
.if !defined(MAME_ARCH.${OPSYS})
MAME_ARCH.${OPSYS}?=	generic
.endif

MAKE_FLAGS+=		DISPLAY_METHOD="${MAME_DISP_METHOD}"
MAKE_FLAGS+=		MY_CPU="${MAME_CPU.${MACHINE_ARCH}}"
MAKE_FLAGS+=		ARCH="${MAME_ARCH.${OPSYS}}"

.if exists({${X11BASE}/include/X11/extensions/xf86dga.h)
MAKE_FLAGS+=		X11_DGA=1
.endif

# If supported, add appropriate definitions to build joystick drivers.
.if exists(/usr/include/machine/joystick.h) ||				\
    exists(/usr/include/linux/joystick.h)
MAKE_FLAGS+=		JOY_I386=1
.endif
.if ${OPSYS} == "NetBSD"
.  if exists(/usr/lib/libusb.a)
MAKE_FLAGS+=		JOY_USB=1
.  endif
.endif

OWN_DIRS=		${SPOOLDIR}

post-configure:
	cd ${WRKSRC}/doc;						\
	${SED}	-e "s|@ROMPATH@|${ROMPATH}|g"				\
		-e "s|@SPOOLDIR@|${SPOOLDIR}|g"				\
		xmamerc.dist > ${TARGET}rc
.if ${MAKE_FLAGS:M*USB*} != ""
	${LN} -fs /usr/include/usb.h ${BUILDLINK_DIR}/include
	for FILE in /usr/lib/libusb*; do				\
	  ${LN} -fs $$FILE ${BUILDLINK_DIR}/lib;			\
	done
.endif

do-install:
	${INSTALL_PROGRAM} ${WRKSRC}/${TARGET}.${MAME_DISP_METHOD}	\
		${PREFIX}/bin/${TARGET}
	${INSTALL_MAN} ${WRKSRC}/doc/xmame.6				\
		${PREFIX}/man/man6/${TARGET}.6
	${INSTALL_DATA_DIR} ${ROMPATH}
	${INSTALL_DATA} ${WRKSRC}/doc/${TARGET}rc ${ROMPATH}/${TARGET}rc

.include "../../graphics/xpm/buildlink.mk"
.include "../../mk/x11.buildlink.mk"
.include "../../mk/bsd.pkg.install.mk"
.include "../../mk/bsd.pkg.mk"