Hi,
I'm tired of dealing with scons. I'd like to switch gambatte to use a
custom makefile instead. I've been using a variant of this diff for a
few months now on my own machines.
Benefits:
- On its own, the makefile is faster than the sconstruct.
- It allows USE_CCACHE to work, which makes it even faster.
- The makefile comes from a pull request upstream. Upstream is sort of
dead but it's gotten positive response from another OS's packager and
a couple of users, so it's not a purely local effort.
This diff also enables a Qt flavor, which builds a version of the
emulator with GUI.
Any objections? ok?
Index: Makefile
===================================================================
RCS file: /cvs/ports/emulators/gambatte/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- Makefile 19 Nov 2014 10:32:48 -0000 1.10
+++ Makefile 21 Dec 2015 05:33:59 -0000
@@ -1,10 +1,18 @@
# $OpenBSD: Makefile,v 1.10 2014/11/19 10:32:48 bentley Exp $
-COMMENT = highly accurate Game Boy Color emulator
+COMMENT-main = highly accurate Game Boy Color emulator
+COMMENT-qt = highly accurate Game Boy Color emulator with GUI
REV = 571
+V = 0.5.0.${REV}
DISTNAME = gambatte_src-r${REV}
-PKGNAME = gambatte-0.5.0.${REV}
+PKGNAME = gambatte-$V
+PKGNAME-qt = gambatte-qt-$V
+REVISION-main = 0
+
+MULTI_PACKAGES = -main -qt
+
+.include <bsd.port.arch.mk>
CATEGORIES = emulators
@@ -12,37 +20,44 @@ HOMEPAGE = http://gambatte.sourceforge.
MAINTAINER = Anthony J. Bentley <[email protected]>
-# GPLv2
+# GPLv2 only
PERMIT_PACKAGE_CDROM = Yes
-WANTLIB += c m pthread stdc++ z SDL
+cWANTLIB = c m pthread stdc++ z
+WANTLIB-main = ${cWANTLIB} SDL
+WANTLIB-qt = ${cWANTLIB} GL QtCore QtGui QtOpenGL X11 Xext Xrandr Xv
ossaudio usbhid
MASTER_SITES = ${MASTER_SITE_SOURCEFORGE:=gambatte/}
-MODULES = devel/scons \
- lang/python
-LIB_DEPENDS = devel/sdl
+MODULES = lang/python
+.if ${BUILD_PACKAGES:M-qt}
+MODULES += x11/qt4
+.endif
+LIB_DEPENDS-main = devel/sdl
+
+TEST_DEPENDS = graphics/png
+
+MAKE_FILE = ${FILESDIR}/Makefile
+MAKE_FLAGS = CC="${CC}" \
+ CXX="${CXX}" \
+ LINK="${CXX}" \
+ CFLAGS="${CFLAGS} -DHAVE_USBHID_H -DUSBHID_UCR_DATA
-DUSBHID_NEW" \
+ CXXFLAGS="${CXXFLAGS} -DHAVE_STDINT_H" \
+ PYTHON="${MODPY_BIN}"
-TEST_DEPENDS = graphics/png
-
-pre-configure:
- ${SUBST_CMD} ${WRKDIST}/test/SConstruct
+do-configure:
+ cd ${WRKSRC}/gambatte_qt && qmake4 ${MAKE_FLAGS}
do-build:
- ${SETENV} ${MAKE_ENV} ${MODSCONS_BIN} -C ${WRKDIST}/libgambatte \
- ${MODSCONS_ENV} ${MODSCONS_FLAGS} ${ALL_TARGET}
- ${SETENV} ${MAKE_ENV} ${MODSCONS_BIN} -C ${WRKDIST}/gambatte_sdl \
- ${MODSCONS_ENV} ${MODSCONS_FLAGS} ${ALL_TARGET}
+ ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} -C ${WRKDIST} ${MAKE_FLAGS} \
+ -f ${MAKE_FILE} ${ALL_TARGET}
+ ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} -C ${WRKDIST}/gambatte_qt \
+ ${MAKE_FLAGS} -f Makefile ${ALL_TARGET}
do-install:
- ${INSTALL_PROGRAM} ${WRKDIST}/gambatte_sdl/gambatte_sdl ${PREFIX}/bin
- ${INSTALL_DATA} ${FILESDIR}/gambatte_sdl.6 ${PREFIX}/man/man6
-
-do-test:
- ${SETENV} ${MAKE_ENV} ${MODSCONS_BIN} -C ${WRKDIST}/test \
- ${MODSCONS_ENV} ${MODSCONS_FLAGS} ${ALL_TARGET}
- cd ${WRKDIST}/test && \
- ${MODPY_BIN} qdgbas.py hwtests/*.asm hwtests/*/*.asm \
- hwtests/*/*/*.asm hwtests/*/*/*/*.asm && ./run_tests.sh
+ ${INSTALL_DATA} ${FILESDIR}/gambatte_sdl.6 \
+ ${FILESDIR}/gambatte_qt.6 ${PREFIX}/man/man6
+ ${INSTALL_PROGRAM} ${WRKDIST}/gambatte_sdl/gambatte_sdl \
+ ${WRKDIST}/gambatte_qt/bin/gambatte_qt ${PREFIX}/bin
.include <bsd.port.mk>
Index: files/Makefile
===================================================================
RCS file: files/Makefile
diff -N files/Makefile
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ files/Makefile 21 Dec 2015 05:33:59 -0000
@@ -0,0 +1,113 @@
+# $OpenBSD$
+# https://github.com/sinamas/gambatte/pull/6
+.SUFFIXES: .c .cpp .o
+
+LIB = libgambatte/libgambatte.a
+SDL_NAME = gambatte_sdl
+SDL_TARGET = gambatte_sdl/$(SDL_NAME)
+TEST = test/testrunner
+
+PYTHON ?= python
+
+SDL_OBJECTS = \
+ gambatte_sdl/src/audiosink.o \
+ gambatte_sdl/src/blitterwrapper.o \
+ gambatte_sdl/src/gambatte_sdl.o \
+ gambatte_sdl/src/parser.o \
+ gambatte_sdl/src/sdlblitter.o \
+ gambatte_sdl/src/str_to_sdlkey.o \
+ gambatte_sdl/src/usec.o \
+ common/adaptivesleep.o \
+ common/resample/src/chainresampler.o \
+ common/resample/src/i0.o \
+ common/resample/src/kaiser50sinc.o \
+ common/resample/src/kaiser70sinc.o \
+ common/resample/src/makesinckernel.o \
+ common/resample/src/resamplerinfo.o \
+ common/resample/src/u48div.o \
+ common/rateest.o \
+ common/skipsched.o \
+ common/videolink/rgb32conv.o \
+ common/videolink/vfilterinfo.o \
+ common/videolink/vfilters/catrom2x.o \
+ common/videolink/vfilters/catrom3x.o \
+ common/videolink/vfilters/kreed2xsai.o \
+ common/videolink/vfilters/maxsthq2x.o \
+ common/videolink/vfilters/maxsthq3x.o
+
+LIB_OBJECTS = \
+ libgambatte/src/bitmap_font.o \
+ libgambatte/src/cpu.o \
+ libgambatte/src/gambatte.o \
+ libgambatte/src/initstate.o \
+ libgambatte/src/interrupter.o \
+ libgambatte/src/interruptrequester.o \
+ libgambatte/src/loadres.o \
+ libgambatte/src/memory.o \
+ libgambatte/src/sound.o \
+ libgambatte/src/state_osd_elements.o \
+ libgambatte/src/statesaver.o \
+ libgambatte/src/tima.o \
+ libgambatte/src/file/file_zip.o \
+ libgambatte/src/file/unzip/unzip.o \
+ libgambatte/src/file/unzip/ioapi.o \
+ libgambatte/src/mem/cartridge.o \
+ libgambatte/src/mem/memptrs.o \
+ libgambatte/src/mem/pakinfo.o \
+ libgambatte/src/mem/rtc.o \
+ libgambatte/src/sound/channel1.o \
+ libgambatte/src/sound/channel2.o \
+ libgambatte/src/sound/channel3.o \
+ libgambatte/src/sound/channel4.o \
+ libgambatte/src/sound/duty_unit.o \
+ libgambatte/src/sound/envelope_unit.o \
+ libgambatte/src/sound/length_counter.o \
+ libgambatte/src/video.o \
+ libgambatte/src/video/ly_counter.o \
+ libgambatte/src/video/lyc_irq.o \
+ libgambatte/src/video/next_m0_time.o \
+ libgambatte/src/video/ppu.o \
+ libgambatte/src/video/sprite_mapper.o
+
+TEST_OBJECTS = \
+ test/testrunner.o
+
+all: $(SDL_TARGET)
+
+SDL_LFLAGS != pkg-config --libs sdl
+ZLIB_LFLAGS != pkg-config --libs zlib
+$(SDL_TARGET): $(SDL_OBJECTS) $(LIB)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ -pthread $(SDL_OBJECTS) $(LIB) \
+ $(ZLIB_LFLAGS) $(SDL_LFLAGS)
+
+$(LIB): $(LIB_OBJECTS)
+ $(AR) $(ARFLAGS) $@ $(LIB_OBJECTS)
+ ranlib $@
+
+PKGCONFIG_CFLAGS != pkg-config --cflags sdl libpng zlib
+.c.o:
+ $(CC) $(CFLAGS) -c $< -o $*.o
+.cpp.o:
+ $(CXX) -Ilibgambatte/src -Ilibgambatte/include -Igambatte_sdl/src \
+ -Icommon $(CXXFLAGS) -c $< -o $*.o \
+ -DGAMBATTE_SDL_VERSION_STR=\"r571\" -DHAVE_STDINT_H \
+ $(PKGCONFIG_CFLAGS)
+
+TEST_GBS = \
+ test/hwtests/*.gb* \
+ test/hwtests/*/*.gb* \
+ test/hwtests/*/*/*.gb* \
+ test/hwtests/*/*/*/*.gb*
+
+test: $(TEST)
+ $(PYTHON) test/qdgbas.py \
+ test/hwtests/*.asm \
+ test/hwtests/*/*.asm \
+ test/hwtests/*/*/*.asm \
+ test/hwtests/*/*/*/*.asm
+ $(TEST) $(TEST_GBS)
+
+PNG_LFLAGS != pkg-config --libs libpng
+$(TEST): $(TEST_OBJECTS) $(LIB)
+ $(CXX) $(CXXFLAGS) -o $@ $(TEST_OBJECTS) $(LIB) \
+ $(PNG_LFLAGS) $(ZLIB_LFLAGS)
Index: files/gambatte_qt.6
===================================================================
RCS file: files/gambatte_qt.6
diff -N files/gambatte_qt.6
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ files/gambatte_qt.6 21 Dec 2015 05:33:59 -0000
@@ -0,0 +1,65 @@
+.\" $OpenBSD: mdoc.template,v 1.15 2014/03/31 00:09:54 dlg Exp $
+.\"
+.\" Copyright (c) 2015 Anthony J. Bentley <[email protected]>
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.Dd $Mdocdate$
+.Dt GAMBATTE_QT 6
+.Os
+.Sh NAME
+.Nm gambatte_qt
+.Nd highly accurate Game Boy Color emulator with GUI
+.Sh SYNOPSIS
+.Nm gambatte_qt
+.Op Fl Fl gba-cgb-mode
+.Op Fl Fl force-dmg-mode
+.Op Fl Fl full-screen
+.Ar romfile
+.Sh DESCRIPTION
+.Nm
+is a highly accurate Game Boy (DMG) and Game Boy Color (CGB) emulator with a
+graphical interface.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl Fl gba-cgb-mode Ns Op =0
+When emulating Game Boy Color games, identify as a Game Boy Advance,
+unlocking special features in certain games.
+This permanently enables the setting in the configuration file;
+it can be reset by passing 0.
+.It Fl Fl force-dmg-mode Ns Op =0
+When emulating Game Boy Color\(encapable games, disable color support.
+This permanently enables the setting in the configuration file;
+it can be reset by passing 0.
+.It Fl Fl full-screen Ns Op =0
+Start the emulator in full screen mode.
+.El
+.Sh ENVIRONMENT
+.Bl -tag -width Ds
+.It Ev XDG_CONFIG_HOME
+Where
+.Nm
+looks for the configuration file.
+Defaults to
+.Pa ~/.config
+if unset.
+.El
+.Sh FILES
+.Bl -tag -width Ds
+.It Pa $XDG_CONFIG_HOME/gambatte/gambatte_qt.conf
+The
+.Nm
+configuration file.
+.El
+.Sh AUTHORS
+.An Sindre Aam\(oas Aq Mt [email protected]
Index:
patches/patch-gambatte_qt_src_framework_src_SDL_Joystick_src_SDL_joystick_c
===================================================================
RCS file:
patches/patch-gambatte_qt_src_framework_src_SDL_Joystick_src_SDL_joystick_c
diff -N
patches/patch-gambatte_qt_src_framework_src_SDL_Joystick_src_SDL_joystick_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-gambatte_qt_src_framework_src_SDL_Joystick_src_SDL_joystick_c
21 Dec 2015 05:33:59 -0000
@@ -0,0 +1,13 @@
+$OpenBSD$
+https://github.com/sinamas/gambatte/pull/7
+--- gambatte_qt/src/framework/src/SDL_Joystick/src/SDL_joystick.c.orig Sun Dec
20 05:16:46 2015
++++ gambatte_qt/src/framework/src/SDL_Joystick/src/SDL_joystick.c Sun Dec
20 05:16:51 2015
+@@ -376,7 +376,7 @@ void SDL_JoystickClose(SDL_Joystick *joystick)
+ /* Remove joystick from list */
+ for ( i=0; SDL_joysticks[i]; ++i ) {
+ if ( joystick == SDL_joysticks[i] ) {
+- SDL_memcpy(&SDL_joysticks[i], &SDL_joysticks[i+1],
++ SDL_memmove(&SDL_joysticks[i], &SDL_joysticks[i+1],
+ (SDL_numjoysticks-i)*sizeof(joystick));
+ break;
+ }
Index: patches/patch-test_SConstruct
===================================================================
RCS file: patches/patch-test_SConstruct
diff -N patches/patch-test_SConstruct
--- patches/patch-test_SConstruct 19 Nov 2014 10:32:48 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,15 +0,0 @@
-$OpenBSD: patch-test_SConstruct,v 1.1 2014/11/19 10:32:48 bentley Exp $
---- test/SConstruct.orig Wed Nov 19 03:18:18 2014
-+++ test/SConstruct Wed Nov 19 03:18:41 2014
-@@ -5,9 +5,10 @@ vars = Variables()
- vars.Add('CC')
- vars.Add('CXX')
-
--env = Environment(CPPPATH = ['.', '../common', '../libgambatte/include'],
-+env = Environment(CPPPATH = ['.', '../common', '../libgambatte/include',
'${LOCALBASE}/include'],
- CFLAGS = global_cflags + global_defines,
- CXXFLAGS = global_cxxflags + global_defines,
-+ LIBPATH = '${LOCALBASE}/lib',
- LIBS = 'm',
- variables = vars)
-
Index: pkg/DESCR
===================================================================
RCS file: pkg/DESCR
diff -N pkg/DESCR
--- pkg/DESCR 8 Dec 2010 19:58:04 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,3 +0,0 @@
-Gambatte is an accuracy-focused, cross-platform Game Boy Color emulator.
-It is based on hundreds of corner case hardware tests, as well as
-previous documentation and reverse engineering efforts.
Index: pkg/DESCR-main
===================================================================
RCS file: pkg/DESCR-main
diff -N pkg/DESCR-main
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ pkg/DESCR-main 21 Dec 2015 05:33:59 -0000
@@ -0,0 +1,3 @@
+Gambatte is an accuracy-focused, cross-platform Game Boy Color emulator.
+It is based on hundreds of corner case hardware tests, as well as
+previous documentation and reverse engineering efforts.
Index: pkg/DESCR-qt
===================================================================
RCS file: pkg/DESCR-qt
diff -N pkg/DESCR-qt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ pkg/DESCR-qt 21 Dec 2015 05:33:59 -0000
@@ -0,0 +1,3 @@
+Gambatte is an accuracy-focused, cross-platform Game Boy Color emulator.
+It is based on hundreds of corner case hardware tests, as well as
+previous documentation and reverse engineering efforts.
Index: pkg/PLIST
===================================================================
RCS file: pkg/PLIST
diff -N pkg/PLIST
--- pkg/PLIST 10 Mar 2014 04:18:25 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,3 +0,0 @@
-@comment $OpenBSD: PLIST,v 1.3 2014/03/10 04:18:25 bentley Exp $
-@bin bin/gambatte_sdl
-@man man/man6/gambatte_sdl.6
Index: pkg/PLIST-main
===================================================================
RCS file: pkg/PLIST-main
diff -N pkg/PLIST-main
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ pkg/PLIST-main 21 Dec 2015 05:33:59 -0000
@@ -0,0 +1,3 @@
+@comment $OpenBSD: PLIST,v 1.3 2014/03/10 04:18:25 bentley Exp $
+@bin bin/gambatte_sdl
+@man man/man6/gambatte_sdl.6
Index: pkg/PLIST-qt
===================================================================
RCS file: pkg/PLIST-qt
diff -N pkg/PLIST-qt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ pkg/PLIST-qt 21 Dec 2015 05:33:59 -0000
@@ -0,0 +1,3 @@
+@comment $OpenBSD: PLIST,v 1.3 2014/03/10 04:18:25 bentley Exp $
+@bin bin/gambatte_qt
+@man man/man6/gambatte_qt.6