From 96389ef83b42b7fa41ddf6abc33eccd724e105bf Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 4 Feb 2011 22:47:37 +0100 Subject: [PATCH] Some testing fixes for OSX. --- Makefile | 16 ++++++++++++++-- osx-glue.m | 12 ++++++++++++ ssnes.c | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 osx-glue.m diff --git a/Makefile b/Makefile index e9df198f97..8017f33a6c 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/osx-glue.m b/osx-glue.m new file mode 100644 index 0000000000..d2f470db13 --- /dev/null +++ b/osx-glue.m @@ -0,0 +1,12 @@ +#import +static NSAutoreleasePool * pool; +void init_ns_pool() +{ + pool = [[NSAutoreleasePool alloc] init]; +} + +void deinit_ns_pool() +{ + [pool release]; +} + diff --git a/ssnes.c b/ssnes.c index f259e760e6..f174ac381c 100644 --- a/ssnes.c +++ b/ssnes.c @@ -35,6 +35,12 @@ #include #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; }