Merge branch 'osx'
This commit is contained in:
commit
f99e141b75
@ -1,4 +1,4 @@
|
|||||||
project(pawnamx)
|
project(pawnamx C)
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
# check for optional include files
|
# check for optional include files
|
||||||
@ -50,9 +50,6 @@ if(WIN32)
|
|||||||
set_target_properties(amxArgs PROPERTIES LINK_FLAGS "/export:amx_ArgsInit /export:amx_ArgsCleanup /export:amx_ArgsSetCmdLine")
|
set_target_properties(amxArgs PROPERTIES LINK_FLAGS "/export:amx_ArgsInit /export:amx_ArgsCleanup /export:amx_ArgsSetCmdLine")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(UNIX)
|
|
||||||
add_custom_command(TARGET amxArgs POST_BUILD COMMAND strip ARGS -K amx_ArgsInit -K amx_ArgsCleanup -K amx_ArgsSetCmdLine ${CMAKE_BINARY_DIR}/amxArgs.so)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# amxDGram
|
# amxDGram
|
||||||
set(DGRAM_SRCS amxdgram.c amx.c)
|
set(DGRAM_SRCS amxdgram.c amx.c)
|
||||||
@ -66,9 +63,6 @@ if(WIN32)
|
|||||||
set_target_properties(amxDGram PROPERTIES LINK_FLAGS "/export:amx_DGramInit /export:amx_DGramCleanup")
|
set_target_properties(amxDGram PROPERTIES LINK_FLAGS "/export:amx_DGramInit /export:amx_DGramCleanup")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(UNIX)
|
|
||||||
add_custom_command(TARGET amxDGram POST_BUILD COMMAND strip ARGS -K amx_DGramInit -K amx_DGramCleanup ${CMAKE_BINARY_DIR}/amxDGram.so)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# amxFile
|
# amxFile
|
||||||
set(FILE_SRCS amxfile.c amx.c)
|
set(FILE_SRCS amxfile.c amx.c)
|
||||||
@ -82,9 +76,6 @@ if(WIN32)
|
|||||||
set_target_properties(amxFile PROPERTIES LINK_FLAGS "/export:amx_FileInit /export:amx_FileCleanup")
|
set_target_properties(amxFile PROPERTIES LINK_FLAGS "/export:amx_FileInit /export:amx_FileCleanup")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(UNIX)
|
|
||||||
add_custom_command(TARGET amxFile POST_BUILD COMMAND strip ARGS -K amx_FileInit -K amx_FileCleanup ${CMAKE_BINARY_DIR}/amxFile.so)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# amxFixed
|
# amxFixed
|
||||||
set(FIXED_SRCS fixed.c amx.c)
|
set(FIXED_SRCS fixed.c amx.c)
|
||||||
@ -100,7 +91,6 @@ if(WIN32)
|
|||||||
endif()
|
endif()
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_link_libraries(amxFixed m)
|
target_link_libraries(amxFixed m)
|
||||||
add_custom_command(TARGET amxFixed POST_BUILD COMMAND strip ARGS -K amx_FixedInit -K amx_FixedCleanup ${CMAKE_BINARY_DIR}/amxFixed.so)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# amxFloat
|
# amxFloat
|
||||||
@ -117,7 +107,6 @@ if(WIN32)
|
|||||||
endif()
|
endif()
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_link_libraries(amxFloat m)
|
target_link_libraries(amxFloat m)
|
||||||
add_custom_command(TARGET amxFloat POST_BUILD COMMAND strip ARGS -K amx_FloatInit -K amx_FloatInit ${CMAKE_BINARY_DIR}/amxFloat.so)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# amxProcess
|
# amxProcess
|
||||||
@ -143,7 +132,6 @@ if(WIN32)
|
|||||||
endif()
|
endif()
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_link_libraries(amxProcess dl)
|
target_link_libraries(amxProcess dl)
|
||||||
add_custom_command(TARGET amxProcess POST_BUILD COMMAND strip ARGS -K amx_ProcessInit -K amx_ProcessCleanup ${CMAKE_BINARY_DIR}/amxProcess.so)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# amxString
|
# amxString
|
||||||
@ -158,9 +146,6 @@ if(WIN32)
|
|||||||
set_target_properties(amxString PROPERTIES LINK_FLAGS "/export:amx_StringInit /export:amx_StringCleanup")
|
set_target_properties(amxString PROPERTIES LINK_FLAGS "/export:amx_StringInit /export:amx_StringCleanup")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(UNIX)
|
|
||||||
add_custom_command(TARGET amxString POST_BUILD COMMAND strip ARGS -K amx_StringInit -K amx_StringCleanup ${CMAKE_BINARY_DIR}/amxString.so)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# amxTime
|
# amxTime
|
||||||
set(TIME_SRCS amxtime.c amx.c)
|
set(TIME_SRCS amxtime.c amx.c)
|
||||||
@ -174,9 +159,6 @@ if(WIN32)
|
|||||||
set_target_properties(amxTime PROPERTIES LINK_FLAGS "/export:amx_TimeInit /export:amx_TimeCleanup")
|
set_target_properties(amxTime PROPERTIES LINK_FLAGS "/export:amx_TimeInit /export:amx_TimeCleanup")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(UNIX)
|
|
||||||
add_custom_command(TARGET amxTime POST_BUILD COMMAND strip ARGS -K amx_TimeInit -K amx_TimeCleanup ${CMAKE_BINARY_DIR}/amxTime.so)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Simple run-time (example program)
|
# Simple run-time (example program)
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
#if defined __FreeBSD__
|
#if defined __FreeBSD__
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
|
#elif defined __APPLE__
|
||||||
|
#include <machine/endian.h>
|
||||||
#elif defined LINUX
|
#elif defined LINUX
|
||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
project(pawnc)
|
project(pawnc C)
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake)
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake)
|
||||||
@ -22,6 +22,17 @@ if(HAVE_ALLOCA_H)
|
|||||||
add_definitions(-DHAVE_ALLOCA_H)
|
add_definitions(-DHAVE_ALLOCA_H)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# check for optional library functions
|
||||||
|
include(CheckFunctionExists)
|
||||||
|
check_function_exists(strlcpy HAVE_STRLCPY)
|
||||||
|
if(HAVE_STRLCPY)
|
||||||
|
add_definitions(-DHAVE_STRLCPY)
|
||||||
|
endif()
|
||||||
|
check_function_exists(strlcat HAVE_STRLCAT)
|
||||||
|
if(HAVE_STRLCAT)
|
||||||
|
add_definitions(-DHAVE_STRLCAT)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS /J)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS /J)
|
||||||
endif()
|
endif()
|
||||||
@ -66,10 +77,6 @@ add_library(pawnc SHARED ${PAWNC_SRCS})
|
|||||||
if(WATCOM) #Watcom C/C++ does not support a .DEF file for the exports
|
if(WATCOM) #Watcom C/C++ does not support a .DEF file for the exports
|
||||||
set_target_properties(pawnc PROPERTIES LINK_FLAGS "/exp=libpawnc")
|
set_target_properties(pawnc PROPERTIES LINK_FLAGS "/exp=libpawnc")
|
||||||
endif()
|
endif()
|
||||||
if(UNIX AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
# 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()
|
|
||||||
|
|
||||||
# The Pawn compiler driver (console program)
|
# The Pawn compiler driver (console program)
|
||||||
set(PAWNCC_SRCS pawncc.c)
|
set(PAWNCC_SRCS pawncc.c)
|
||||||
|
@ -178,6 +178,43 @@ void *pc_createsrc(char *filename)
|
|||||||
return fopen(filename,"wt");
|
return fopen(filename,"wt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* pc_createtmpsrc()
|
||||||
|
* Creates a temporary source file with a unique name for writing.
|
||||||
|
* Return:
|
||||||
|
* The function must return a pointer, which is used as a "magic cookie" to
|
||||||
|
* all I/O functions. When failing to open the file for reading, the
|
||||||
|
* function must return NULL.
|
||||||
|
*/
|
||||||
|
void *pc_createtmpsrc(char **filename)
|
||||||
|
{
|
||||||
|
char *tname=NULL;
|
||||||
|
FILE *ftmp=NULL;
|
||||||
|
|
||||||
|
#if defined __WIN32__ || defined _WIN32
|
||||||
|
tname=_tempnam(NULL,"pawn");
|
||||||
|
ftmp=fopen(tname,"wt");
|
||||||
|
#elif defined __MSDOS__ || defined _Windows
|
||||||
|
tname=tempnam(NULL,"pawn");
|
||||||
|
ftmp=fopen(tname,"wt");
|
||||||
|
#else
|
||||||
|
static const char template[]="/tmp/pawnXXXXXX";
|
||||||
|
ftmp=NULL;
|
||||||
|
if ((tname=malloc(sizeof(template)))!=NULL) {
|
||||||
|
int fdtmp;
|
||||||
|
strncpy(tname,template,sizeof(template));
|
||||||
|
if ((fdtmp=mkstemp(tname)) >= 0) {
|
||||||
|
ftmp=fdopen(fdtmp,"wt");
|
||||||
|
} else {
|
||||||
|
free(tname);
|
||||||
|
tname=NULL;
|
||||||
|
} /* if */
|
||||||
|
} /* if */
|
||||||
|
#endif
|
||||||
|
if (filename!=NULL)
|
||||||
|
*filename=tname;
|
||||||
|
return ftmp;
|
||||||
|
}
|
||||||
|
|
||||||
/* pc_closesrc()
|
/* pc_closesrc()
|
||||||
* Closes a source file (or include file). The "handle" parameter has the
|
* Closes a source file (or include file). The "handle" parameter has the
|
||||||
* value that pc_opensrc() returned in an earlier call.
|
* value that pc_opensrc() returned in an earlier call.
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "lstring.h"
|
#include "lstring.h"
|
||||||
|
|
||||||
#if !defined HAVE_SAFESTR
|
#if !defined HAVE_STRLCPY
|
||||||
|
|
||||||
/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */
|
/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */
|
||||||
|
|
||||||
@ -63,6 +63,10 @@ strlcpy(char *dst, const char *src, size_t siz)
|
|||||||
return(s - src - 1); /* count does not include NUL */
|
return(s - src - 1); /* count does not include NUL */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* if !defined HAVE_STRLCPY */
|
||||||
|
|
||||||
|
#if !defined HAVE_STRLCAT
|
||||||
|
|
||||||
/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
|
/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -121,4 +125,4 @@ strlcat(char *dst, const char *src, size_t siz)
|
|||||||
return(dlen + (s - src)); /* count does not include NUL */
|
return(dlen + (s - src)); /* count does not include NUL */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* #if !defined HAVE_SAFESTR */
|
#endif /* #if !defined HAVE_STRLCAT */
|
||||||
|
@ -7,11 +7,20 @@
|
|||||||
#define HAVE_SAFESTR
|
#define HAVE_SAFESTR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined HAVE_SAFESTR
|
#if defined HAVE_SAFESTR
|
||||||
|
#define HAVE_STRLCPY
|
||||||
|
#define HAVE_STRLCAT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined HAVE_STRLCPY
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
strlcpy(char *dst, const char *src, size_t siz);
|
strlcpy(char *dst, const char *src, size_t siz);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined HAVE_STRLCAT
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
strlcat(char *dst, const char *src, size_t siz);
|
strlcat(char *dst, const char *src, size_t siz);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#ifndef _INCLUDE_MEMFILE_H
|
#ifndef _INCLUDE_MEMFILE_H
|
||||||
#define _INCLUDE_MEMFILE_H
|
#define _INCLUDE_MEMFILE_H
|
||||||
|
|
||||||
#ifdef MACOS
|
#ifdef __APPLE__
|
||||||
#include <malloc/malloc.h>
|
#include <malloc/malloc.h>
|
||||||
#else
|
#else
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
@ -40,6 +40,10 @@
|
|||||||
#include <binreloc.h> /* from BinReloc, see www.autopackage.org */
|
#include <binreloc.h> /* from BinReloc, see www.autopackage.org */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined __APPLE__
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined FORTIFY
|
#if defined FORTIFY
|
||||||
#include <alloc/fortify.h>
|
#include <alloc/fortify.h>
|
||||||
#endif
|
#endif
|
||||||
@ -250,6 +254,43 @@ void *pc_createsrc(char *filename)
|
|||||||
return fopen(filename,"w");
|
return fopen(filename,"w");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* pc_createtmpsrc()
|
||||||
|
* Creates a temporary source file with a unique name for writing.
|
||||||
|
* Return:
|
||||||
|
* The function must return a pointer, which is used as a "magic cookie" to
|
||||||
|
* all I/O functions. When failing to open the file for reading, the
|
||||||
|
* function must return NULL.
|
||||||
|
*/
|
||||||
|
void *pc_createtmpsrc(char **filename)
|
||||||
|
{
|
||||||
|
char *tname=NULL;
|
||||||
|
FILE *ftmp=NULL;
|
||||||
|
|
||||||
|
#if defined __WIN32__ || defined _WIN32
|
||||||
|
tname=_tempnam(NULL,"pawn");
|
||||||
|
ftmp=fopen(tname,"wt");
|
||||||
|
#elif defined __MSDOS__ || defined _Windows
|
||||||
|
tname=tempnam(NULL,"pawn");
|
||||||
|
ftmp=fopen(tname,"wt");
|
||||||
|
#else
|
||||||
|
static const char template[]="/tmp/pawnXXXXXX";
|
||||||
|
ftmp=NULL;
|
||||||
|
if ((tname=malloc(sizeof(template)))!=NULL) {
|
||||||
|
int fdtmp;
|
||||||
|
strncpy(tname,template,sizeof(template));
|
||||||
|
if ((fdtmp=mkstemp(tname)) >= 0) {
|
||||||
|
ftmp=fdopen(fdtmp,"wt");
|
||||||
|
} else {
|
||||||
|
free(tname);
|
||||||
|
tname=NULL;
|
||||||
|
} /* if */
|
||||||
|
} /* if */
|
||||||
|
#endif
|
||||||
|
if (filename!=NULL)
|
||||||
|
*filename=tname;
|
||||||
|
return ftmp;
|
||||||
|
}
|
||||||
|
|
||||||
/* pc_closesrc()
|
/* pc_closesrc()
|
||||||
* Closes a source file (or include file). The "handle" parameter has the
|
* Closes a source file (or include file). The "handle" parameter has the
|
||||||
* value that pc_opensrc() returned in an earlier call.
|
* value that pc_opensrc() returned in an earlier call.
|
||||||
@ -472,19 +513,7 @@ int pc_compile(int argc, char *argv[])
|
|||||||
char *tname,*sname;
|
char *tname,*sname;
|
||||||
FILE *ftmp,*fsrc;
|
FILE *ftmp,*fsrc;
|
||||||
int fidx;
|
int fidx;
|
||||||
#if defined __WIN32__ || defined _WIN32
|
ftmp=pc_createtmpsrc(&tname);
|
||||||
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;
|
|
||||||
#else
|
|
||||||
tname=tempnam(NULL,"pawn");
|
|
||||||
#endif
|
|
||||||
ftmp=(FILE*)pc_createsrc(tname);
|
|
||||||
for (fidx=0; (sname=get_sourcefile(fidx))!=NULL; fidx++) {
|
for (fidx=0; (sname=get_sourcefile(fidx))!=NULL; fidx++) {
|
||||||
unsigned char tstring[128];
|
unsigned char tstring[128];
|
||||||
fsrc=(FILE*)pc_opensrc(sname);
|
fsrc=(FILE*)pc_opensrc(sname);
|
||||||
|
@ -40,6 +40,12 @@
|
|||||||
# define __BIG_ENDIAN BIG_ENDIAN
|
# define __BIG_ENDIAN BIG_ENDIAN
|
||||||
#endif
|
#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
|
#if !defined __BYTE_ORDER
|
||||||
# error "Can't figure computer byte order (__BYTE_ORDER macro not found)"
|
# error "Can't figure computer byte order (__BYTE_ORDER macro not found)"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user