diff --git a/source/amx/osdefs.h b/source/amx/osdefs.h index 29804ab..ae9162a 100644 --- a/source/amx/osdefs.h +++ b/source/amx/osdefs.h @@ -37,6 +37,8 @@ #if defined __FreeBSD__ #include +#elif defined __APPLE__ + #include #elif defined LINUX #include #endif diff --git a/source/compiler/CMakeLists.txt b/source/compiler/CMakeLists.txt index 6f0feda..005ff4a 100644 --- a/source/compiler/CMakeLists.txt +++ b/source/compiler/CMakeLists.txt @@ -43,6 +43,15 @@ endif() configure_file(svnrev.h.in svnrev.h) include_directories(${CMAKE_CURRENT_BINARY_DIR}) +IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-logical-op-parentheses") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-ignored-attributes") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-incompatible-pointer-types-discards-qualifiers") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format") +ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + # The Pawn compiler shared library set(PAWNC_SRCS sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c scexpand.c sci18n.c sclist.c scmemfil.c scstate.c scvars.c @@ -66,7 +75,8 @@ add_library(pawnc SHARED ${PAWNC_SRCS}) if(WATCOM) #Watcom C/C++ does not support a .DEF file for the exports set_target_properties(pawnc PROPERTIES LINK_FLAGS "/exp=libpawnc") endif() -if(UNIX AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") +if(UNIX AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug" + AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") # Unix exports all symbols by default; we want only a very select few exported symbols add_custom_command(TARGET pawnc POST_BUILD COMMAND strip ARGS -K pc_compile -K pc_addconstant -K pc_addtag -K pc_enablewarning ${CMAKE_BINARY_DIR}/libpawnc.so) endif() diff --git a/source/compiler/memfile.h b/source/compiler/memfile.h index 5b4930f..8cef0d0 100644 --- a/source/compiler/memfile.h +++ b/source/compiler/memfile.h @@ -8,7 +8,7 @@ #ifndef _INCLUDE_MEMFILE_H #define _INCLUDE_MEMFILE_H -#ifdef MACOS +#ifdef __APPLE__ #include #else #include diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 53d4483..41f49e2 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -40,6 +40,10 @@ #include /* from BinReloc, see www.autopackage.org */ #endif +#if defined __APPLE__ + #include +#endif + #if defined FORTIFY #include #endif @@ -472,19 +476,20 @@ int pc_compile(int argc, char *argv[]) char *tname,*sname; FILE *ftmp,*fsrc; int fidx; + ftmp = NULL; #if defined __WIN32__ || defined _WIN32 tname=_tempnam(NULL,"pawn"); #elif defined __MSDOS__ || defined _Windows tname=tempnam(NULL,"pawn"); - #elif defined(MACOS) && !defined(__MACH__) - /* tempnam is not supported for the Macintosh CFM build. */ - error(104,get_sourcefile(1)); - tname=NULL; - sname=NULL; + #elif defined(__APPLE__) + int tfd; + tfd=mkstemp("/tmp/pawnXXXXXX"); + ftmp=fdopen(tfd, "wt"); #else tname=tempnam(NULL,"pawn"); #endif - ftmp=(FILE*)pc_createsrc(tname); + if (ftmp==NULL) + ftmp=(FILE*)pc_createsrc(tname); for (fidx=0; (sname=get_sourcefile(fidx))!=NULL; fidx++) { unsigned char tstring[128]; fsrc=(FILE*)pc_opensrc(sname); diff --git a/source/compiler/sc6.c b/source/compiler/sc6.c index df6b61a..04c38f8 100644 --- a/source/compiler/sc6.c +++ b/source/compiler/sc6.c @@ -215,7 +215,7 @@ static char *stripwhitespace(char *str) { if (*str!='\0') { size_t len = strlen(str); - size_t i; + int i; for (i=len-1; i>=0; i--) { if (!isspace(str[i])) { str[i+1]='\0'; diff --git a/source/linux/sclinux.h b/source/linux/sclinux.h index f22497a..3b4af2c 100644 --- a/source/linux/sclinux.h +++ b/source/linux/sclinux.h @@ -40,6 +40,12 @@ # define __BIG_ENDIAN BIG_ENDIAN #endif +#if defined __APPLE__ +# define __BYTE_ORDER BYTE_ORDER +# define __LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN +# define __BIG_ENDIAN __DARWIN_BIG_ENDIAN +#endif + #if !defined __BYTE_ORDER # error "Can't figure computer byte order (__BYTE_ORDER macro not found)" #endif