From 295cf82323f13434d19c2c4fa53d88dec8cbe221 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Thu, 16 Oct 2014 21:03:24 +0000 Subject: [PATCH] Clean up warnings and build issues when building under OS X 10.9. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4644 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/Makefile | 4 +- polymer/eduke32/Makefile.common | 84 +++++++++++++------- polymer/eduke32/build/include/glbuild.h | 10 +++ polymer/eduke32/build/include/osxbits.h | 6 +- polymer/eduke32/build/include/sdl_inc.h | 2 +- polymer/eduke32/build/src/SDLMain.m | 8 +- polymer/eduke32/build/src/osxbits.m | 21 +++-- polymer/eduke32/build/src/polymer.c | 8 ++ polymer/eduke32/build/src/sdlayer.c | 2 + polymer/eduke32/build/src/startosx.editor.m | 13 ++- polymer/eduke32/source/GameListSource.game.h | 4 +- polymer/eduke32/source/GameListSource.game.m | 16 ++-- polymer/eduke32/source/GrpFile.game.m | 2 +- polymer/eduke32/source/game.c | 1 + polymer/eduke32/source/startosx.game.m | 21 +++-- 15 files changed, 136 insertions(+), 66 deletions(-) diff --git a/polymer/eduke32/Makefile b/polymer/eduke32/Makefile index b7fb2b761..09b7a42c7 100644 --- a/polymer/eduke32/Makefile +++ b/polymer/eduke32/Makefile @@ -519,7 +519,7 @@ $(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/%.c | $(ENGINE_OBJ) $(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/%.m | $(ENGINE_OBJ) $(COMPILE_STATUS) - $(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE) + $(RECIPE_IF) $(COMPILER_OBJC) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE) $(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/%.cpp | $(ENGINE_OBJ) $(COMPILE_STATUS) @@ -579,7 +579,7 @@ $(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/util/%.c | $(DUKE3D_OBJ) $(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/%.m | $(DUKE3D_OBJ) $(COMPILE_STATUS) - $(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(DUKE3D_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE) + $(RECIPE_IF) $(COMPILER_OBJC) $(COMMONFLAGS) $(COMPILERFLAGS) $(DUKE3D_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE) $(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/%.cpp | $(DUKE3D_OBJ) $(COMPILE_STATUS) diff --git a/polymer/eduke32/Makefile.common b/polymer/eduke32/Makefile.common index 9f0d2aca3..5ac91cdee 100644 --- a/polymer/eduke32/Makefile.common +++ b/polymer/eduke32/Makefile.common @@ -33,22 +33,10 @@ ifeq ($(AS),as) override AS=nasm endif +COMPILER_OBJC=$(CC) L_CC=$(CC) L_CXX=$(CXX) -CLANG?=0 - -ifeq ($(findstring clang,$(CC)),clang) - override CLANG=1 -endif - -ifneq (0,$(CLANG)) - override CC=clang -x c - override CXX=clang -x c++ - override L_CC=clang - override L_CXX=clang -endif - CCFULLPATH=$(CC) ifeq ($(PLATFORM),WII) @@ -64,6 +52,26 @@ ifeq ($(PLATFORM),WII) STRIP=powerpc-eabi-strip endif +CLANG?=0 + +CLANG_POTENTIAL_VERSION := $(shell $(CCFULLPATH) --version) + +ifeq ($(findstring clang,$(CC)),clang) + override CLANG=1 +endif +# detect clang symlinked as gcc, as in OS X +ifeq ($(findstring clang,$(CLANG_POTENTIAL_VERSION)),clang) + override CLANG=1 +endif + +ifneq (0,$(CLANG)) + override CC=clang -x c + override CXX=clang -x c++ + override COMPILER_OBJC=clang -x objective-c + override L_CC=clang + override L_CXX=clang +endif + # GCC version, for conditional selection of flags. ifndef GCC_MAJOR GCC_MAJOR := $(shell $(CCFULLPATH) -dumpversion 2>&1 | cut -d'.' -f1) @@ -303,8 +311,14 @@ ifeq ($(PLATFORM),DARWIN) ifndef DARWINVERSION DARWINVERSION:=$(strip $(shell uname -r | cut -d . -f 1)) endif + + DARWIN9 ?= 0 + DARWIN10 ?= 0 ifeq (1,$(strip $(shell expr $(DARWINVERSION) \< 10))) - DARWIN9 ?= 1 + override DARWIN9 := 1 + endif + ifeq (1,$(strip $(shell expr $(DARWINVERSION) \< 11))) + override DARWIN10 := 1 endif # COMMONFLAGS += -fno-leading-underscore @@ -405,11 +419,9 @@ endif # See http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation # for a list of possible UBSan options. # Clang 3.2 does only supports -fsanitize=address for the AddressSanitizer -ifneq ($(PLATFORM),WINDOWS) - CLANG_DEBUG_FLAGS := -fsanitize=address -fsanitize=bounds,enum,float-cast-overflow,object-size +# CLANG_DEBUG_FLAGS := -fsanitize=address -fsanitize=bounds,enum,float-cast-overflow,object-size -fsanitize-undefined-trap-on-error # CLANG_DEBUG_FLAGS := $(CLANG_DEBUG_FLAGS),signed-integer-overflow # CLANG_DEBUG_FLAGS := $(CLANG_DEBUG_FLAGS),unsigned-integer-overflow -endif ifneq (0,$(RELEASE)) # Debugging disabled @@ -429,9 +441,9 @@ ifneq (0,$(RELEASE)) COMPILERFLAGS += -DNDEBUG else COMPILERFLAGS += -DDEBUGGINGAIDS - ifneq (0,$(CLANG)) - COMMONFLAGS += $(CLANG_DEBUG_FLAGS) - endif +# ifneq (0,$(CLANG)) +# COMMONFLAGS += $(CLANG_DEBUG_FLAGS) +# endif endif ifneq (0,$(LTO)) COMPILERFLAGS += -DUSING_LTO @@ -451,9 +463,9 @@ else COMPILERFLAGS += -DDEBUGGINGAIDS=2 endif - ifneq (0,$(CLANG)) - COMMONFLAGS += $(CLANG_DEBUG_FLAGS) - endif +# ifneq (0,$(CLANG)) +# COMMONFLAGS += $(CLANG_DEBUG_FLAGS) +# endif ifeq ($(SUBPLATFORM),LINUX) LIBS+=-rdynamic endif @@ -595,7 +607,7 @@ DLLSUFFIX=.so SDL_TARGET ?= 2 -SDL_FRAMEWORK ?= 1 +SDL_FRAMEWORK ?= 0 ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \>= 4))) L_SSP := -lssp @@ -651,15 +663,27 @@ ifeq ($(PLATFORM),DARWIN) ASFORMAT=macho$(SYSBITS) ASFLAGS+= -DUNDERSCORES - # include port and brew - LIBDIRS+= -Lplatform/Apple/lib -L/opt/local/lib -L/usr/local/lib - COMPILERFLAGS+= -Iplatform/Apple/include -I/opt/local/include -I/sw/include -I/usr/local/include + LIBDIRS+= -Lplatform/Apple/lib + COMPILERFLAGS+= -Iplatform/Apple/include + + ifneq ($(shell port --version &>/dev/null; echo $$?),127) + LIBDIRS+= -L/opt/local/lib + COMPILERFLAGS+= -I/opt/local/include + endif + ifneq ($(shell brew --version &>/dev/null; echo $$?),127) + LIBDIRS+= -L/usr/local/lib + COMPILERFLAGS+= -I/usr/local/include + endif + ifneq ($(shell fink --version &>/dev/null; echo $$?),127) + LIBDIRS+= -L/sw/lib + COMPILERFLAGS+= -I/sw/include + endif RENDERTYPE = SDL MIXERTYPE = SDL STDCPPLIB:=-lstdc++ COMPILERFLAGS += -DHAVE_INTTYPES - DLLSUFFIX=.dylib # ??? + DLLSUFFIX=.dylib GTKCOMPAT32 = 0 WITHOUT_GTK ?= 1 @@ -944,7 +968,9 @@ ifneq ($(PLATFORM),WINDOWS) ifneq ($(PLATFORM),WII) LIBS+= -ldl endif - LIBS+= -pthread + ifneq ($(PLATFORM),DARWIN) + LIBS+= -pthread + endif endif ifeq ($(PLATFORM),WINDOWS) diff --git a/polymer/eduke32/build/include/glbuild.h b/polymer/eduke32/build/include/glbuild.h index 7212a3b7a..798037b73 100644 --- a/polymer/eduke32/build/include/glbuild.h +++ b/polymer/eduke32/build/include/glbuild.h @@ -519,6 +519,12 @@ extern bglDebugMessageCallbackARBProcPtr bglDebugMessageCallbackARB; #endif // GLU +#if defined __clang__ && defined __APPLE__ +// XXX: OS X 10.9 deprecated GLUtesselator. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + typedef void (APIENTRY * bgluTessBeginContourProcPtr)(GLUtesselator* tess); extern bgluTessBeginContourProcPtr bgluTessBeginContour; typedef void (APIENTRY * bgluTessBeginPolygonProcPtr)(GLUtesselator* tess, GLvoid* data); @@ -540,6 +546,10 @@ extern bgluNewTessProcPtr bgluNewTess; typedef void (APIENTRY * bgluDeleteTessProcPtr)(GLUtesselator* tess); extern bgluDeleteTessProcPtr bgluDeleteTess; +#if defined __clang__ && defined __APPLE__ +#pragma clang diagnostic pop +#endif + typedef void (APIENTRY * bgluPerspectiveProcPtr)(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); extern bgluPerspectiveProcPtr bgluPerspective; diff --git a/polymer/eduke32/build/include/osxbits.h b/polymer/eduke32/build/include/osxbits.h index 42f35bdce..074f36dbd 100644 --- a/polymer/eduke32/build/include/osxbits.h +++ b/polymer/eduke32/build/include/osxbits.h @@ -2,7 +2,7 @@ #define __osxbits_h__ #include -int32_t osx_msgbox(char *name, char *msg); -int32_t osx_ynbox(char *name, char *msg); +int32_t osx_msgbox(const char *name, const char *msg); +int32_t osx_ynbox(const char *name, const char *msg); -#endif \ No newline at end of file +#endif diff --git a/polymer/eduke32/build/include/sdl_inc.h b/polymer/eduke32/build/include/sdl_inc.h index 54f8f1e9c..6d31144a1 100644 --- a/polymer/eduke32/build/include/sdl_inc.h +++ b/polymer/eduke32/build/include/sdl_inc.h @@ -53,7 +53,7 @@ Minimum required SDL versions: # endif # else # if (SDL_TARGET == 2) -# include +# include # else # include # endif diff --git a/polymer/eduke32/build/src/SDLMain.m b/polymer/eduke32/build/src/SDLMain.m index d284a522a..5a239cf48 100644 --- a/polymer/eduke32/build/src/SDLMain.m +++ b/polymer/eduke32/build/src/SDLMain.m @@ -5,13 +5,7 @@ Feel free to customize this file to suit your needs */ -#if defined(SDL_FRAMEWORK) -# include -#else -# include "SDL.h" -#endif - -#include "SDLMain.h" +#include "sdl_inc.h" #include /* for MAXPATHLEN */ #include diff --git a/polymer/eduke32/build/src/osxbits.m b/polymer/eduke32/build/src/osxbits.m index 0fdab83e4..a39eaeb75 100644 --- a/polymer/eduke32/build/src/osxbits.m +++ b/polymer/eduke32/build/src/osxbits.m @@ -1,3 +1,4 @@ +#include "compat.h" #include "osxbits.h" #import @@ -5,18 +6,18 @@ # define MAC_OS_VERSION_10_3 1030 #endif -int osx_msgbox(char *name, char *msg) +int osx_msgbox(const char *name, const char *msg) { - NSString *mmsg = [[NSString alloc] initWithCString: msg]; + NSString *mmsg = [[NSString alloc] initWithUTF8String:msg]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 NSAlert *alert = [[NSAlert alloc] init]; [alert addButtonWithTitle: @"OK"]; [alert setInformativeText: mmsg]; [alert setAlertStyle: NSInformationalAlertStyle]; - + [alert runModal]; - + [alert release]; #else @@ -24,12 +25,15 @@ int osx_msgbox(char *name, char *msg) #endif [mmsg release]; + + UNREFERENCED_PARAMETER(name); + return 0; } -int osx_ynbox(char *name, char *msg) +int osx_ynbox(const char *name, const char *msg) { - NSString *mmsg = [[NSString alloc] initWithCString: msg]; + NSString *mmsg = [[NSString alloc] initWithUTF8String:msg]; int r; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 @@ -39,7 +43,7 @@ int osx_ynbox(char *name, char *msg) [alert addButtonWithTitle:@"No"]; [alert setInformativeText: mmsg]; [alert setAlertStyle: NSInformationalAlertStyle]; - + r = ([alert runModal] == NSAlertFirstButtonReturn); [alert release]; @@ -48,5 +52,8 @@ int osx_ynbox(char *name, char *msg) #endif [mmsg release]; + + UNREFERENCED_PARAMETER(name); + return r; } diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 8576b4c17..49dad50d9 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -688,7 +688,15 @@ int16_t viewangle; int32_t depth; _prmirror mirrors[10]; +#if defined __clang__ && defined __APPLE__ +// XXX: OS X 10.9 deprecated GLUtesselator. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif GLUtesselator* prtess; +#if defined __clang__ && defined __APPLE__ +#pragma clang diagnostic pop +#endif static int16_t cursky; static char curskypal; diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 543ec2c33..2bd322ffd 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -106,7 +106,9 @@ static float lastvidgcb[3]; //static SDL_Surface * loadtarga(const char *fn); // for loading the icon static SDL_Surface *appicon = NULL; +#if !defined(__APPLE__) && !defined(__ANDROID__) static SDL_Surface *loadappicon(void); +#endif static mutex_t m_initprintf; diff --git a/polymer/eduke32/build/src/startosx.editor.m b/polymer/eduke32/build/src/startosx.editor.m index f30009f09..3822ced06 100644 --- a/polymer/eduke32/build/src/startosx.editor.m +++ b/polymer/eduke32/build/src/startosx.editor.m @@ -32,20 +32,27 @@ static id nsapp; - (IBAction)alwaysShowClicked:(id)sender { + UNREFERENCED_PARAMETER(sender); } - (IBAction)fullscreenClicked:(id)sender { + UNREFERENCED_PARAMETER(sender); + // XXX: recalculate the video modes list to take into account the fullscreen status } - (IBAction)cancel:(id)sender { + UNREFERENCED_PARAMETER(sender); + [nsapp abortModal]; } - (IBAction)start:(id)sender { + UNREFERENCED_PARAMETER(sender); + // XXX: write the states of the form controls to their respective homes [nsapp stopModal]; } @@ -146,7 +153,7 @@ int startwin_puts(const char *s) if (!s) return -1; if (startwin == nil) return 1; - ns = [[NSString alloc] initWithCString:s]; + ns = [[NSString alloc] initWithUTF8String:s]; [startwin putsMessage:ns]; [ns release]; @@ -160,7 +167,7 @@ int startwin_settitle(const char *s) if (!s) return -1; if (startwin == nil) return 1; - ns = [[NSString alloc] initWithCString:s]; + ns = [[NSString alloc] initWithUTF8String:s]; [startwin setTitle:ns]; [ns release]; @@ -169,6 +176,8 @@ int startwin_settitle(const char *s) int startwin_idle(void *v) { + UNREFERENCED_PARAMETER(v); + if (startwin) [[startwin window] displayIfNeeded]; return 0; } diff --git a/polymer/eduke32/source/GameListSource.game.h b/polymer/eduke32/source/GameListSource.game.h index 0818cd8a6..78e18ff88 100644 --- a/polymer/eduke32/source/GameListSource.game.h +++ b/polymer/eduke32/source/GameListSource.game.h @@ -7,7 +7,7 @@ * */ -@interface GameListSource : NSObject +@interface GameListSource : NSObject { NSMutableArray *list; } @@ -17,7 +17,7 @@ - (int)findIndexForGrpname:(NSString*)grpname; - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex; + row:(NSInteger)rowIndex; - (int)numberOfRowsInTableView:(NSTableView *)aTableView; @end diff --git a/polymer/eduke32/source/GameListSource.game.m b/polymer/eduke32/source/GameListSource.game.m index 976f6c0a8..733677f61 100644 --- a/polymer/eduke32/source/GameListSource.game.m +++ b/polymer/eduke32/source/GameListSource.game.m @@ -9,6 +9,8 @@ #import +#include "compat.h" + #import "GrpFile.game.h" #import "GameListSource.game.h" @@ -25,7 +27,7 @@ for (p = foundgrps; p; p=p->next) { for (i=0; icrcval == internalgrpfiles[i].crcval) break; if (i == NUMGRPFILES) continue; - [list addObject:[[GrpFile alloc] initWithGrpfile:p andName:[NSString stringWithCString:internalgrpfiles[i].name]]]; + [list addObject:[[GrpFile alloc] initWithGrpfile:p andName:[NSString stringWithCString:internalgrpfiles[i].name encoding:NSUTF8StringEncoding]]]; } } @@ -45,8 +47,8 @@ - (int)findIndexForGrpname:(NSString*)grpname { - int i; - for (i=0; i<[list count]; i++) { + NSUInteger i, listcount = [list count]; + for (i=0; i= 0 && rowIndex < [list count]); + UNREFERENCED_PARAMETER(aTableView); + + NSParameterAssert((NSUInteger)rowIndex < [list count]); switch ([[aTableColumn identifier] intValue]) { case 0: // name column return [[list objectAtIndex:rowIndex] name]; @@ -68,6 +72,8 @@ - (int)numberOfRowsInTableView:(NSTableView *)aTableView { + UNREFERENCED_PARAMETER(aTableView); + return [list count]; } @end diff --git a/polymer/eduke32/source/GrpFile.game.m b/polymer/eduke32/source/GrpFile.game.m index d72b2fa12..83fdb4522 100644 --- a/polymer/eduke32/source/GrpFile.game.m +++ b/polymer/eduke32/source/GrpFile.game.m @@ -31,7 +31,7 @@ } - (NSString *)grpname { - return [NSString stringWithCString:(fg->name)]; + return [NSString stringWithCString:(fg->name) encoding:NSUTF8StringEncoding]; } - (struct grpfile *)entryptr { diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index e193a18c9..229dfbe3a 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -11240,6 +11240,7 @@ int32_t app_main(int32_t argc, const char **argv) #ifdef __APPLE__ if (!usecwd) { + char cwd[BMAX_PATH]; char *homedir = Bgethomedir(); if (homedir) Bsnprintf(cwd, sizeof(cwd), "%s/Library/Logs/eduke32.log", homedir); diff --git a/polymer/eduke32/source/startosx.game.m b/polymer/eduke32/source/startosx.game.m index 07ec7a579..ec50103fe 100644 --- a/polymer/eduke32/source/startosx.game.m +++ b/polymer/eduke32/source/startosx.game.m @@ -79,7 +79,7 @@ static struct soundQuality_t { { int i, mode3d, fullscreen = ([fullscreenButton state] == NSOnState); int idx3d = -1; - int xdim, ydim, bpp; + int xdim = 0, ydim = 0, bpp = 0; if (firstTime) { xdim = settings.xdim3d; @@ -180,20 +180,27 @@ static struct soundQuality_t { - (IBAction)alwaysShowClicked:(id)sender { + UNREFERENCED_PARAMETER(sender); } - (IBAction)fullscreenClicked:(id)sender { + UNREFERENCED_PARAMETER(sender); + [self populateVideoModes:NO]; } - (IBAction)cancel:(id)sender { + UNREFERENCED_PARAMETER(sender); + [nsapp abortModal]; } - (IBAction)start:(id)sender { + UNREFERENCED_PARAMETER(sender); + int mode = [[modeslist3d objectAtIndex:[videoMode3DPUButton indexOfSelectedItem]] intValue]; if (mode >= 0) { settings.xdim3d = validmode[mode].xdim; @@ -241,7 +248,7 @@ static struct soundQuality_t { [[gameList documentView] setDataSource:gamelistsrc]; [[gameList documentView] deselectAll:nil]; - int row = [gamelistsrc findIndexForGrpname:[NSString stringWithCString:settings.selectedgrp]]; + int row = [gamelistsrc findIndexForGrpname:[NSString stringWithCString:settings.selectedgrp encoding:NSUTF8StringEncoding]]; if (row >= 0) { [[gameList documentView] scrollRowToVisible:row]; #if defined(MAC_OS_X_VERSION_10_3) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3) @@ -308,8 +315,6 @@ static StartupWinController *startwin = nil; int startwin_open(void) { - // PK: is this the entry point? - // fix for "ld: absolute address to symbol _NSApp in a different linkage unit not supported" // (OS X 10.6) when building for PPC nsapp = [NSApplication sharedApplication]; @@ -323,7 +328,7 @@ int startwin_open(void) static int soundQualityFrequencies[] = { 48000, 44100, 32000, 24000, 22050 }; static int soundQualitySampleSizes[] = { 16, 8 }; static int soundQualityChannels[] = { 2, 1 }; - int f, b, c, i; + size_t f, b, c, i; i = sizeof(soundQualityFrequencies) * sizeof(soundQualitySampleSizes) * @@ -373,7 +378,7 @@ int startwin_puts(const char *s) if (!s) return -1; if (startwin == nil) return 1; - ns = [[NSString alloc] initWithCString:s]; + ns = [[NSString alloc] initWithUTF8String:s]; [startwin putsMessage:ns]; [ns release]; @@ -387,7 +392,7 @@ int startwin_settitle(const char *s) if (!s) return -1; if (startwin == nil) return 1; - ns = [[NSString alloc] initWithCString:s]; + ns = [[NSString alloc] initWithUTF8String:s]; [startwin setTitle:ns]; [ns release]; @@ -396,6 +401,8 @@ int startwin_settitle(const char *s) int startwin_idle(void *v) { + UNREFERENCED_PARAMETER(v); + if (startwin) [[startwin window] displayIfNeeded]; return 0; }