From f22e202d88b9f860a2c0dade2a083f64c33275f7 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Mon, 24 Nov 2014 08:19:50 +0000 Subject: [PATCH] Fix some things when building on OS X. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4762 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/Makefile.common | 4 +-- polymer/eduke32/build/include/compat.h | 46 +++++++++++++++----------- polymer/eduke32/source/animvpx.c | 2 ++ polymer/eduke32/source/gamevars.h | 3 +- polymer/eduke32/source/sounds.c | 2 ++ 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/polymer/eduke32/Makefile.common b/polymer/eduke32/Makefile.common index e8bb0a48d..59b34c61d 100644 --- a/polymer/eduke32/Makefile.common +++ b/polymer/eduke32/Makefile.common @@ -268,7 +268,7 @@ ifneq ($(RELEASE)$(DEBUGANYWAY),10) OPTIMIZATIONS += $(DEBUGFLAG) endif -CONLYFLAGS=-std=gnu99 -Wimplicit +CONLYFLAGS=-std=gnu99 -Wimplicit -Werror-implicit-function-declaration CPPONLYFLAGS= -fno-exceptions -fno-rtti -Wno-write-strings ASFORMAT=elf$(SYSBITS) ASFLAGS=-s -f $(ASFORMAT) #-g @@ -510,7 +510,7 @@ ifeq (0,$(CLANG)) endif endif -CWARNS := -W -Wall -Werror-implicit-function-declaration \ +CWARNS := -W -Wall \ -Wpointer-arith \ -Wextra \ -Wno-char-subscripts \ diff --git a/polymer/eduke32/build/include/compat.h b/polymer/eduke32/build/include/compat.h index 90300cbab..268506312 100644 --- a/polymer/eduke32/build/include/compat.h +++ b/polymer/eduke32/build/include/compat.h @@ -5,31 +5,14 @@ #ifndef compat_h_ #define compat_h_ -#include - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN -# include -#endif - -#ifdef __APPLE__ -# include -# if !TARGET_OS_IPHONE -# if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3 -# include -# endif -# include -# endif -#endif - #ifdef __GNUC__ -# define EDUKE32_GCC_PREREQ(major, minor) (major > __GNUC__ || (major == __GNUC__ && minor >= __GNUC_MINOR__)) +# define EDUKE32_GCC_PREREQ(major, minor) (major < __GNUC__ || (major == __GNUC__ && minor <= __GNUC_MINOR__)) #else # define EDUKE32_GCC_PREREQ(major, minor) 0 #endif #ifdef __clang__ -# define EDUKE32_CLANG_PREREQ(major, minor) (major > __clang_major__ || (major == __clang_major__ && minor >= __clang_minor__)) +# define EDUKE32_CLANG_PREREQ(major, minor) (major < __clang_major__ || (major == __clang_major__ && minor <= __clang_minor__)) #else # define EDUKE32_CLANG_PREREQ(major, minor) 0 #endif @@ -84,13 +67,34 @@ #define max(x,y) ((x) > (y) ? (x) : (y)) #endif +#ifndef __APPLE__ +# include +#endif + +#ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN +# include +#endif + +#ifdef __APPLE__ +# include +# if !TARGET_OS_IPHONE +# if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3 +# include +# endif +# include +# endif +#endif + // This gives us access to 'intptr_t' and 'uintptr_t', which are // abstractions to the size of a pointer on a given platform // (ie, they're guaranteed to be the same size as a pointer) #undef __USE_MINGW_ANSI_STDIO // Workaround for MinGW-w64. +#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS +#endif #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif @@ -615,7 +619,6 @@ FORCE_INLINE uint16_t system_15bit_rand(void) { return ((uint16_t)rand())&0x7fff # define Bchdir chdir # define Bgetcwd getcwd # endif -# define Bmemalign memalign # define Bopen open # define Bclose close # define Bwrite write @@ -846,6 +849,9 @@ FORCE_INLINE void *xaligned_malloc(const bsize_t alignment, const bsize_t size) { #ifdef _WIN32 void *ptr = _aligned_malloc(size, alignment); +#elif defined __APPLE__ + void *ptr = NULL; + posix_memalign(&ptr, alignment, size); #else void *ptr = memalign(alignment, size); #endif diff --git a/polymer/eduke32/source/animvpx.c b/polymer/eduke32/source/animvpx.c index bc6458e24..773039e08 100644 --- a/polymer/eduke32/source/animvpx.c +++ b/polymer/eduke32/source/animvpx.c @@ -2,7 +2,9 @@ #ifdef USE_LIBVPX +#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS +#endif #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS #endif diff --git a/polymer/eduke32/source/gamevars.h b/polymer/eduke32/source/gamevars.h index b4cae52bb..695f342ec 100644 --- a/polymer/eduke32/source/gamevars.h +++ b/polymer/eduke32/source/gamevars.h @@ -111,7 +111,8 @@ int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags); static inline void A_ResetVars(const int32_t iActor) { - for (int i = 0; i < g_gameVarCount; i++) + int i; + for (i = 0; i < g_gameVarCount; i++) { if ((aGameVars[i].dwFlags & (GAMEVAR_PERACTOR | GAMEVAR_NODEFAULT)) == GAMEVAR_PERACTOR) aGameVars[i].val.plValues[iActor] = aGameVars[i].lDefault; diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index 2950ddb7f..435fa3cc1 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -20,7 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- +#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS +#endif #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS #endif