Skip to content

Commit

Permalink
Fix OSX build and package
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Jul 24, 2014
1 parent 41a91ee commit 154184f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ else()
ADD_DEFINITIONS(-O2)
endif()
if(CLANG)
add_definitiions(-std=c99)
add_definitions(-std=c99)
else()
# Probably GCC...
add_definitions(-freg-struct-return -std=gnu99)
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ elseif(APPLE)
set(MACOSX_BUNDLE_ICON_FILE cdogs-icon.icns)
set_source_files_properties(../build/macosx/SDLMain.m
PROPERTIES LANGUAGE C)
set(EXTRA_LIBRARIES "${EXTRA_LIBRARIES} -framework Carbon -framework IOKit")
endif()
add_executable(cdogs-sdl MACOSX_BUNDLE ${CDOGS_SDL_SOURCES} ${CDOGS_SDL_HEADERS} ${CDOGS_SDL_EXTRA})
if(APPLE)
Expand Down
6 changes: 3 additions & 3 deletions src/cdogs/physfs/physfs_platforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@
# define PHYSFS_PLATFORM_MACOSX
# define PHYSFS_PLATFORM_POSIX
# endif
# define _GNU_SOURCE
#elif defined(macintosh)
# error Classic Mac OS support was dropped from PhysicsFS 2.0. Move to OS X.
#elif defined(unix) || defined(__unix__)
# define PHYSFS_PLATFORM_UNIX
# define PHYSFS_PLATFORM_POSIX
# define _POSIX_C_SOURCE 200809L
# define _GNU_SOURCE
#else
# error Unknown platform.
#endif

#define _POSIX_C_SOURCE 200809L
#define _GNU_SOURCE

#endif /* include-once blocker. */

9 changes: 9 additions & 0 deletions src/cdogs/physfs/platform/macosx.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,32 @@ static CFAllocatorRef cfallocator = NULL;

CFStringRef cfallocDesc(const void *info)
{
(void)info;
return(CFStringCreateWithCString(cfallocator, "PhysicsFS",
kCFStringEncodingASCII));
} /* cfallocDesc */


static void *cfallocMalloc(CFIndex allocSize, CFOptionFlags hint, void *info)
{
(void)hint;
(void)info;
return allocator.Malloc(allocSize);
} /* cfallocMalloc */


static void cfallocFree(void *ptr, void *info)
{
(void)info;
allocator.Free(ptr);
} /* cfallocFree */


static void *cfallocRealloc(void *ptr, CFIndex newsize,
CFOptionFlags hint, void *info)
{
(void)hint;
(void)info;
if ((ptr == NULL) || (newsize <= 0))
return NULL; /* ADC docs say you should always return NULL here. */
return allocator.Realloc(ptr, newsize);
Expand Down Expand Up @@ -230,6 +236,8 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
char *cstr = NULL;
int rc = 0;

(void)argv0;

BAIL_IF_MACRO(GetProcessBundleLocation(&psn, &fsref) != noErr, NULL, NULL);
cfurl = CFURLCreateFromFSRef(cfallocator, &fsref);
BAIL_IF_MACRO(cfurl == NULL, NULL, NULL);
Expand Down Expand Up @@ -367,6 +375,7 @@ static void macosxAllocatorFree(void *ptr)

int __PHYSFS_platformSetDefaultAllocator(PHYSFS_Allocator *a)
{
(void)a;
allocator.Init = macosxAllocatorInit;
allocator.Deinit = macosxAllocatorDeinit;
allocator.Malloc = macosxAllocatorMalloc;
Expand Down

0 comments on commit 154184f

Please sign in to comment.