Some testing fixes for OSX.

This commit is contained in:
Themaister 2011-02-04 22:47:37 +01:00
parent af010712f3
commit 96389ef83b
3 changed files with 44 additions and 2 deletions

View File

@ -9,6 +9,14 @@ HEADERS = $(wildcard */*.h) $(wildcard *.h)
LIBS =
DEFINES = -DHAVE_CONFIG_H
ifneq ($(findstring Darwin,$(shell uname -a)),)
OSX := 1
LIBS += -framework AppKit
OBJ += osx-glue.o
else
OSX := 0
endif
ifeq ($(HAVE_SRC), 1)
LIBS += $(SRC_LIBS)
DEFINES += $(SRC_CFLAGS)
@ -36,7 +44,7 @@ ifeq ($(HAVE_ROAR), 1)
endif
ifeq ($(HAVE_AL), 1)
OBJ += audio/openal.o
ifneq ($(findstring Darwin,$(shell uname -a)),)
ifeq ($(OSX),1)
LIBS += -framework OpenAL
else
LIBS += -lopenal
@ -56,7 +64,7 @@ ifeq ($(HAVE_SDL), 1)
OBJ += gfx/gl.o input/sdl.o audio/sdl.o audio/buffer.o
DEFINES += $(SDL_CFLAGS)
LIBS += $(SDL_LIBS)
ifneq ($(findstring Darwin,$(shell uname -a)),)
ifeq ($(OSX),1)
LIBS += -framework OpenGL
else
LIBS += -lGL
@ -124,6 +132,10 @@ tools/ssnes-joyconfig: $(JOYCONFIG_OBJ)
$(Q)$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
@$(if $(Q), $(shell echo echo CC $<),)
%.o: %.m
$(Q)$(CC) -c -o $@ $<
@$(if $(Q), $(shell echo echo CC $<),)
install: $(TARGET)
mkdir -p $(DESTDIR)$(PREFIX)/bin
mkdir -p $(DESTDIR)/etc

12
osx-glue.m Normal file
View File

@ -0,0 +1,12 @@
#import <Foundation/Foundation.h>
static NSAutoreleasePool * pool;
void init_ns_pool()
{
pool = [[NSAutoreleasePool alloc] init];
}
void deinit_ns_pool()
{
[pool release];
}

18
ssnes.c
View File

@ -35,6 +35,12 @@
#include <samplerate.h>
#endif
#ifdef __APPLE__
void NSApplicationLoad(void);
void init_ns_pool(void);
void deinit_ns_pool(void);
#endif
struct global g_extern = {
.video_active = true,
.audio_active = true,
@ -945,6 +951,11 @@ static void do_state_checks(void)
int main(int argc, char *argv[])
{
#ifdef __APPLE__ // Very unix-y indeed...
NSApplicationLoad();
init_ns_pool();
#endif
parse_input(argc, argv);
parse_config();
init_dlsym();
@ -1015,6 +1026,10 @@ int main(int argc, char *argv[])
uninit_drivers();
uninit_dlsym();
#ifdef __APPLE__
deinit_ns_pool();
#endif
return 0;
error:
@ -1023,6 +1038,9 @@ error:
uninit_drivers();
uninit_dlsym();
#ifdef __APPLE__
deinit_ns_pool();
#endif
return 1;
}