AmatCoder / mednaffe

A front-end (GUI) for mednafen emulator
GNU General Public License v3.0
429 stars 35 forks source link

Support compilation under FreeBSD #64

Closed PaddyMac closed 6 years ago

PaddyMac commented 7 years ago

Mednafen itself runs under FreeBSD, so it would be nice to have Mednaffe working under FreeBSD too.

AmatCoder commented 7 years ago

Hmm, doesn't it compile? Some time ago somebody reported me that Mednaffe works under NetBSD.

Please, can you tell me what is the error message which you are getting?

PaddyMac commented 7 years ago

input.c:30:11: fatal error: 'linux/joystick.h' file not found

include <linux/joystick.h>

      ^~~~~~~~~~~~~~~~~~

1 error generated.

I tried changing linux/joystick.h to sys/joystick.h, but then that resulted in the following errors.

input.c:176:19: error: variable has incomplete type 'struct js_event' struct js_event e; ^ input.c:176:10: note: forward declaration of 'struct js_event' struct js_event e; ^ input.c:201:18: error: use of undeclared identifier 'JS_EVENT_BUTTON' if ((e.type == JS_EVENT_BUTTON) || ^ input.c:202:18: error: use of undeclared identifier 'JS_EVENT_AXIS' ((e.type == JS_EVENT_AXIS) && ^ input.c:211:17: error: use of undeclared identifier 'JS_EVENT_BUTTON' if (e.type == JS_EVENT_BUTTON) { ^ input.c:218:17: error: use of undeclared identifier 'JS_EVENT_AXIS' if (e.type == JS_EVENT_AXIS) { ^ 5 errors generated.

AmatCoder commented 7 years ago

Ah, yes, I forgot that...Joystick implementation is Linux only :( Surely, the guy that reported that Mednaffe works under NetBSD used a version below 0.7.

The problem is that Mednafen emulator does not use the joystick device driver in *BSD OS'es but SDL functions so this will be harder than expected (apart from adding a new dependency).

PaddyMac commented 7 years ago

I tried the December 26, 2013 revision of Mednaffe, and it compiled with no problems. Of course, it complained that "You need 0.9.3x-WIP version" instead of the 0.9.45.1 version of Mednafen I have installed. It was worth a try.

AmatCoder commented 7 years ago

Now (since commit eac83de) compilation under *BSD should work but (obviously) joysticks are not supported, only keyboard.

Please test it.

PaddyMac commented 7 years ago

I checked out the git master, and I still got an error after running "./configure && gmake"

joystick_linux.c:27:10: fatal error: 'linux/joystick.h' file not found

include <linux/joystick.h>

     ^~~~~~~~~~~~~~~~~~

1 error generated.

However, I successfully compiled it manually based on the comment in mednaffe.c: "clang -g -std=c99 -Wall -DGTK2_ENABLED -o mednaffe about.c active.c command.c gui.c prefs.c list.c toggles.c bios.c log.c input.c md5.c resource.c mednaffe.c $(pkg-config --cflags --libs gtk+-2.0 gmodule-export-2.0)" (I just omitted joystick_linux.c from the command line).

So maybe there's an issue with the build system. Or maybe it's some kind of issue on my end. I did get an error about conflicting automake versions telling me to run aclocal. I ran aclocal then automake without any arguments, and the error went away, but maybe it didn't really resolve the issue. Below is the error in full.

$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/local/bin/gmkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking for gcc... no checking for cc... cc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ISO C89... none needed checking whether cc understands -c and -o together... yes checking for style of include used by make... GNU checking dependency style of cc... gcc3 checking for pkg-config... yes checking for pkg-config... /usr/local/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for GTK... yes configure: selecting GTK 2.x automatically checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating share/Makefile config.status: creating src/Makefile config.status: creating config.h config.status: executing depfiles commands $ gmake (CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /usr/home/patrick/work/git-sources/mednaffe-working/mednaffe/missing autoheader) rm -f stamp-h1 touch config.h.in cd . && /bin/sh ./config.status config.h config.status: creating config.h config.status: config.h is unchanged gmake all-recursive gmake[1]: Entering directory '/usr/home/patrick/work/git-sources/mednaffe-working/mednaffe' Making all in src gmake[2]: Entering directory '/usr/home/patrick/work/git-sources/mednaffe-working/mednaffe/src' cd .. && /bin/sh /usr/home/patrick/work/git-sources/mednaffe-working/mednaffe/missing automake-1.15 --foreign src/Makefile configure.ac:6: error: version mismatch. This is Automake 1.15.1, configure.ac:6: but the definition used by this AM_INIT_AUTOMAKE configure.ac:6: comes from Automake 1.15. You should recreate configure.ac:6: aclocal.m4 with aclocal and run automake again. WARNING: 'automake-1.15' is probably too old. You should only need it if you modified 'Makefile.am' or 'configure.ac' or m4 files included by 'configure.ac'. The 'automake' program is part of the GNU Automake package: http://www.gnu.org/software/automake It also requires GNU Autoconf, GNU m4 and Perl in order to run: http://www.gnu.org/software/autoconf http://www.gnu.org/software/m4/ http://www.perl.org/ gmake[2]: [Makefile:267: Makefile.in] Error 63 gmake[2]: Leaving directory '/usr/home/patrick/work/git-sources/mednaffe-working/mednaffe/src' gmake[1]: [Makefile:410: all-recursive] Error 1 gmake[1]: Leaving directory '/usr/home/patrick/work/git-sources/mednaffe-working/mednaffe' gmake: *** [Makefile:330: all] Error 2

PaddyMac commented 7 years ago

Just a quick follow-up. I had to remove every reference to joystick_linux.c or joystick_linux.h from src/Makefile.{in,am} and then run autoreconf because it seemed pretty hard coded into the build system. I guess that's a hacky way to do it, but I'm not familiar enough with the inner workings of autotools to do it more elegantly. But after that, it compiled without issue using the normal ./configure && gmake.

AmatCoder commented 7 years ago

Thanks for testing. I believe that I fixed the build sytem in commit ce3b962.

PaddyMac commented 7 years ago

It sort of works. Here's the output:

$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/local/bin/gmkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes configure: error: cannot run /bin/sh ./config.sub

$ autoreconf configure.ac:9: error: required file './config.guess' not found configure.ac:9: 'automake --add-missing' can install 'config.guess' configure.ac:9: error: required file './config.sub' not found configure.ac:9: 'automake --add-missing' can install 'config.sub' autoreconf-2.69: automake failed with exit status: 1

$ automake --add-missing configure.ac:9: installing './config.guess' configure.ac:9: installing './config.sub'

Then after that, "./configure && gmake" worked as expected. I then tried again from scratch, and the only thing that was actually required was "automake --add-missing" to get "./configure && gmake" to work.

AmatCoder commented 7 years ago

Yes, my fault. I forgot to upload those files. I fixed in commit d7ebca0. That was my bad habit of doing "git add -u" ;)

Thanks for reporting.

PaddyMac commented 7 years ago

I tested the new commit, and it compiles with no difficulties.

AmatCoder commented 6 years ago

Fixed with latest release. Joysticks still can not be configured with mednaffe on *BSD as stated above.