make it compile on OS X
This commit is contained in:
parent
8de7022753
commit
8afb73c00c
@ -37,6 +37,8 @@
|
||||
|
||||
#if defined __FreeBSD__
|
||||
#include <sys/endian.h>
|
||||
#elif defined __APPLE__
|
||||
#include <machine/endian.h>
|
||||
#elif defined LINUX
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
@ -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()
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef _INCLUDE_MEMFILE_H
|
||||
#define _INCLUDE_MEMFILE_H
|
||||
|
||||
#ifdef MACOS
|
||||
#ifdef __APPLE__
|
||||
#include <malloc/malloc.h>
|
||||
#else
|
||||
#include <malloc.h>
|
||||
|
@ -40,6 +40,10 @@
|
||||
#include <binreloc.h> /* from BinReloc, see www.autopackage.org */
|
||||
#endif
|
||||
|
||||
#if defined __APPLE__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined FORTIFY
|
||||
#include <alloc/fortify.h>
|
||||
#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);
|
||||
|
@ -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';
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user