New Makefile, linux compatibility

This commit is contained in:
David Anderson 2005-07-27 16:24:14 +00:00
parent ce043d0633
commit 191acd8e42
9 changed files with 78 additions and 371 deletions

View File

@ -210,7 +210,7 @@ int TeamIds::findTeamId( const char* n )
{
TeamEle* a = head;
while( a ){
if ( !strcmpi(a->name.c_str(),n) )
if ( !stricmp(a->name.c_str(),n) )
return a->id;
a = a->next;
}

View File

@ -1,123 +1,88 @@
MODNAME = amxx_mm
SRCFILES = meta_api.cpp CFile.cpp CString.cpp CVault.cpp vault.cpp\
float.cpp file.cpp modules.cpp CMisc.cpp CTask.cpp string.cpp\
amxmodx.cpp CEvent.cpp CCmd.cpp CLogEvent.cpp srvcmd.cpp strptime.cpp\
CForward.cpp CPlugin.cpp CModule.cpp CMenu.cpp emsg.cpp util.cpp \
amxcore.cpp amxtime.cpp power.cpp amxxlog.cpp fakemeta.cpp mmgr/mmgr.cpp \
amxxfile.cpp CLang.cpp md5.cpp amx.cpp
#use this for amd64, remove the above amx.cpp, and rename amx.cpp to amx.c
#CSRCFILES = amx.c minilzo/minilzo.c
CSRCFILES = minilzo/minilzo.c
#(C)2004-2005 AMX Mod X Development Team
# Makefile written by David "BAILOPAN" Anderson
EXTRA_LIBS_LINUX =
EXTRA_LIBS_WIN32 =
EXTRA_LIBDIRS_LINUX = -Lextra/lib_linux
EXTRA_LIBDIRS_WIN32 = -Lextra/lib_win32
HLSDK = ../hlsdk/SourceCode
MM_ROOT = ../metamod/metamod
EXTRA_INCLUDEDIRS = -Iextra/include
### EDIT BELOW FOR OTHER PROJECTS ###
EXTRA_FLAGS = -Dstrcmpi=strcasecmp
OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe
DEBUG_FLAGS = -g -ggdb3
CPP = gcc
NAME = amxmodx_mm
SDKTOP=../hlsdk
METADIR=../metamod/metamod
OBJECTS = meta_api.cpp CFile.cpp CVault.cpp vault.cpp float.cpp file.cpp modules.cpp \
CMisc.cpp CTask.cpp string.cpp amxmodx.cpp CEvent.cpp CCmd.cpp CLogEvent.cpp \
srvcmd.cpp strptime.cpp amxcore.cpp amxtime.cpp power.cpp amxxlog.cpp fakemeta.cpp \
amxxfile.cpp CLang.cpp md5.cpp emsg.cpp CForward.cpp CPlugin.cpp CModule.cpp \
CMenu.cpp util.cpp amx.cpp
LINK = -lz JIT/amxexecn.o JIT/amxjitsn.o
SDKSRC=$(SDKTOP)/SourceCode
OBJDIR_LINUX=obj.linux
OBJDIR_WIN32=obj.win32
SRCDIR=.
INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/game_shared \
-I$(MM_ROOT) -Lzlib -I$(HLSDK)/common
ifdef windir
OS=WIN32
ifeq "$(DEBUG)" "true"
BIN_DIR = Debug
CFLAGS = $(DEBUG_FLAGS)
else
OS=LINUX
BIN_DIR = Release
CFLAGS = $(OPT_FLAGS)
endif
CC_LINUX=gcc
ifeq "$(OS)" "WIN32"
CC_WIN32=gcc
LD_WINDLL=dllwrap
DEFAULT=win32
CLEAN=clean_win32
else
CC_WIN32=/usr/local/cross-tools/i386-mingw32msvc/bin/gcc
LD_WINDLL=/usr/local/cross-tools/bin/i386-mingw32msvc-dllwrap
DEFAULT=linux win32
CLEAN=clean_both
ifeq "$(MMGR)" "true"
OBJECTS += MMGR/MMGR.CPP
endif
CFLAGS += -DLINUX -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H
#use this for AMD64
#LIBFILE_LINUX = $(MODNAME)_amd64.so
LIBFILE_LINUX = $(MODNAME)_i386.so
LIBFILE_WIN32 = $(MODNAME).dll
TARGET_LINUX = $(OBJDIR_LINUX)/$(LIBFILE_LINUX)
TARGET_WIN32 = $(OBJDIR_WIN32)/$(LIBFILE_WIN32)
FILES_ALL = *.cpp *.h [A-Z]* *.rc
ifeq "$(OS)" "LINUX"
ASRCFILES := $(shell ls -t $(SRCFILES))
ifeq "$(AMD64)" "true"
BINARY = $(NAME)_amd64.so
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
else
ASRCFILES := $(shell dir /b)
BINARY = $(NAME)_i386.so
CFLAGS += -DPAWN_CELL_SIZE=32
OPT_FLAGS += -march=i686
endif
OBJ_LINUX := $(SRCFILES:%.cpp=$(OBJDIR_LINUX)/%.o)
OBJC_LINUX := $(CSRCFILES:%.c=$(OBJDIR_LINUX)/%.o)
OBJ_WIN32 := $(SRCFILES:%.cpp=$(OBJDIR_WIN32)/%.o)
OBJC_WIN32 := $(CSRCFILES:%.c=$(OBJDIR_WIN32)/%.o)
#use this for amd64
#CCOPT = -m64 -g -ggdb3 -DHAVE_I64 -DSMALL_CELL_SIZE=64
CCOPT = -march=i386 -s -DNDEBUG -O2 -fomit-frame-pointer -fno-exceptions -fno-rtti -ffast math
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
INCLUDEDIRS=-I../curl/include -I$(SRCDIR) -I$(METADIR) -I$(SDKSRC)/engine -I$(SDKSRC)/common -I$(SDKSRC)/pm_shared -I$(SDKSRC)/dlls -I$(SDKSRC) $(EXTRA_INCLUDEDIRS)
CFLAGS=-Wall -Wno-unknown-pragmas
ODEF = -DOPT_TYPE=\"optimized\"
CFLAGS:=$(CCOPT) $(CFLAGS) $(ODEF) $(EXTRA_FLAGS)
$(BIN_DIR)/%.o: %.cpp
$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
DO_CC_LINUX=$(CC_LINUX) $(CFLAGS) -fPIC $(INCLUDEDIRS) -o $@ -c $<
DO_CC_WIN32=$(CC_WIN32) $(CFLAGS) $(INCLUDEDIRS) -o $@ -c $<
LINK_LINUX=$(CC_LINUX) $(CFLAGS) -shared -ldl -lm $(OBJ_LINUX) $(OBJC_LINUX) $(EXTRA_LIBDIRS_LINUX) $(EXTRA_LIBS_LINUX) -o $@
LINK_WIN32=$(LD_WINDLL) -mwindows --def $(MODNAME).def --add-stdcall-alias $(OBJ_WIN32) $(OBJC_WIN32) $(EXTRA_LIBDIRS_WIN32) $(EXTRA_LIBS_WIN32) -o $@
all:
mkdir -p $(BIN_DIR)
$(MAKE) amxmodx
$(OBJDIR_LINUX)/%.o: $(SRCDIR)/%.c
$(DO_CC_LINUX)
amd64:
$(MAKE) all AMD64=true
$(OBJDIR_LINUX)/%.o: $(SRCDIR)/%.cpp
$(DO_CC_LINUX)
amd64_mmgr:
$(MAKE) all AMD64=true MMGR=true
$(OBJDIR_WIN32)/%.o: $(SRCDIR)/%.c
$(DO_CC_WIN32)
amd64_debug_mmgr:
$(MAKE) all AMD64=true DEBUG=true MMGR=true
$(OBJDIR_WIN32)/%.o: $(SRCDIR)/%.cpp
$(DO_CC_WIN32)
amd64_debug:
$(MAKE) all AMD64=true DEBUG=true
default: $(DEFAULT)
mmgr:
$(MAKE) all MMGR=true
$(TARGET_LINUX): $(OBJDIR_LINUX) $(OBJ_LINUX) $(OBJC_LINUX)
$(LINK_LINUX)
debug_mmgr:
$(MAKE) all MMGR=true DEBUG=true
$(TARGET_WIN32): $(OBJDIR_WIN32) $(OBJ_WIN32) $(OBJC_WIN32)
$(LINK_WIN32)
amxmodx: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
$(OBJDIR_LINUX):
mkdir $@
mkdir $@/mmgr
debug:
$(MAKE) all DEBUG=true
$(OBJDIR_WIN32):
mkdir $@
mkdir $@/mmgr
win32: $(TARGET_WIN32)
linux: $(TARGET_LINUX)
clean: $(CLEAN)
clean_both:
-rm -f $(OBJDIR_LINUX)/*
-rm -f $(OBJDIR_WIN32)/*
clean_win32:
del /q $(OBJDIR_WIN32)
default: all
clean:
rm -rf Release/*.o
rm -rf Release/$(BINARY)
rm -rf Debug/*.o
rm -rf Debug/$(BINARY)

View File

@ -1,256 +0,0 @@
#!/usr/bin/perl
#(C)2004 AMX Mod X Development Team
# by David "BAILOPAN" Anderson
# output will occur in bin.x.proc
# where x is debug or opt and proc is ix86 or amd64
# You must use this script from the amxmodx src dir
#options =
# jit - use the JIT
# debug - enable gdb debugging
# amd64 - compile for AMD64 (impiles no jit)
# proc=ix86 - assumed not amd64
# clean - clean the specifications above
# asm - for ASM implementation
# !! TODO - add memory mananger support
# lineop - for JIT only, uses slow version
$PROJECT = "amxmodx_mm";
$sdk = "../hlsdk/SourceCode";
$mm = "../metamod/metamod";
$gccf = "gcc";
$ccf = "cc";
$amd64_lstdc = "-lstdc++";
@CPP_SOURCE_FILES = ("meta_api.cpp", "CFile.cpp", "CVault.cpp", "vault.cpp", "float.cpp", "file.cpp", "modules.cpp", "CMisc.cpp", "CTask.cpp", "string.cpp", "amxmodx.cpp", "CEvent.cpp", "CCmd.cpp", "CLogEvent.cpp", "srvcmd.cpp", "strptime.cpp", "amxcore.cpp", "amxtime.cpp", "power.cpp", "amxxlog.cpp", "fakemeta.cpp", "amxxfile.cpp", "CLang.cpp", "md5.cpp", "emsg.cpp", "CForward.cpp", "CPlugin.cpp", "CModule.cpp", "CMenu.cpp", "util.cpp");
@C_SOURCE_FILES = ();
my %OPTIONS, %OPT;
$OPT{"debug"} = "-g -ggdb";
$OPT{"opt"} = "-O2 -ffast-math -funroll-loops -fomit-frame-pointer -s -DNDEBUG -Wall -Wno-unknown-pragmas -DOPT_TYPE=\"optimized\" -fno-exceptions -fno-rtti";
$OPTIONS{"include"} = "-I$sdk -I. -I$mm -I$sdk/engine -I$sdk/common -I$sdk/pm_shared -I$sdk/dlls";
while ($cmd = shift)
{
if ($cmd =~ /asm/)
{
if ($OPTIONS{"amd64"})
{
die "You cannot compile the ASM core with AMD64 yet.\n";
} else {
$OPTIONS{"asm"} = 1;
}
}
if ($cmd =~ /jit/)
{
if ($OPTIONS{"amd64"})
{
die "You cannot compile the JIT and AMD64 yet.\n";
} else {
$OPTIONS{"jit"} = 1;
}
} elsif ($cmd =~ /amd64/) {
if ($OPTIONS{"jit"} || $OPTIONS{"asm"})
{
die "You cannot compile the JIT or ASM and AMD64 yet.\n";
} else {
$OPTIONS{"amd64"} = 1;
}
} elsif ($cmd =~ /debug/) {
$OPTIONS{"debug"} = 1;
} elsif ($cmd =~ /proc=i(\d)86/) {
$proc = $1;
if ($OPTIONS{"amd64"})
{
die "You cannot compile for i".$proc."86 and AMD64.\n";
} else {
$OPTIONS{"proc"} = "i".$proc."86";
}
} elsif ($cmd =~ /clean/) {
$OPTIONS{"clean"} = 1;
} elsif ($cmd =~ /lineop/) {
$OPTIONS{"lineop"} = 1;
}
}
$gcc = `$gccf --version`;
if ($gcc =~ /2\.9/)
{
#if ($OPTIONS{"jit"})
#{
# push(@CPP_SOURCE_FILES, "amx.cpp");
# $OPT{"opt"} .= " -malign-loops=2 -malign-jumps=2 -malign-functions=2";
# } else {
`ln -s amx.cpp amx.c`;
push(@C_SOURCE_FILES, "amx.c");
# }
} else {
if ($OPTIONS{"amd64"})
{
`ln -s amx.cpp amx.c`;
push(@C_SOURCE_FILES, "amx.c");
} else {
push(@CPP_SOURCE_FILES, "amx.cpp");
}
$OPT{"opt"} .= " -falign-loops=2 -falign-jumps=2 -falign-functions=2";
}
if ($OPTIONS{"debug"})
{
$cflags = $OPT{"debug"};
} else {
if (!$OPTIONS{"amd64"})
{
$proc = $OPTIONS{"proc"};
if (!$proc)
{
$proc = 3;
}
$cflags = "-march=i".$proc."86 ".$OPT{"opt"};
} else {
$cflags = $OPT{"opt"};
}
}
if ($OPTIONS{"amd64"})
{
$cflags = " -m64 -DSMALL_CELL_SIZE=64 -DHAVE_I64 $cflags";
}
if ($OPTIONS{"jit"})
{
$cflags .= " -DJIT";
}
if ($OPTIONS{"asm"})
{
$cflags .= " -DASM32";
}
if ($OPTIONS{"debug"})
{
$outdir = "bin.debug";
} else {
$outdir = "bin.opt";
}
if ($OPTIONS{"amd64"})
{
$outdir .= ".amd64";
$bin = $PROJECT."_amd64.so";
} else {
$proc = $OPTIONS{"proc"};
if ($proc)
{
$outdir .= ".i".$proc."86";
$bin = $PROJECT."_i".$proc."86.so";
} else {
$outdir .= ".i386";
$bin = $PROJECT."_i386.so";
}
}
if ($OPTIONS{"clean"})
{
`rm $outdir/*.o`;
`rm $outdir/$bin`;
die("Project cleaned.\n");
}
#create the dirs
#build link list
my @LINK;
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
{
$file = $CPP_SOURCE_FILES[$i];
$file =~ s/\.cpp/\.o/;
push(@LINK, $outdir."/".$file);
}
for ($i=0; $i<=$#C_SOURCE_FILES; $i++)
{
$file = $C_SOURCE_FILES[$i];
$file =~ s/\.c/\.o/;
push(@LINK, $outdir."/".$file);
}
if ($OPTIONS{"jit"})
{
if ($OPTIONS{"lineop"}) {
push(@LINK, "JIT/jits-lineop.o");
} else {
push(@LINK, "JIT/jits.o");
}
}
if ($OPTIONS{"amd64"})
{
push(@LINK, "zlib/libz64.a");
push(@LINK, $amd64_lstdc);
} else {
push(@LINK, "zlib/libz.a");
}
if ($OPTIONS{"asm"})
{
push(@LINK, "amxexecn.o");
}
if (!(-d $outdir))
{
mkdir($outdir);
}
if (!(-d "$outdir/JIT"))
{
mkdir("$outdir/JIT");
}
$inc = $OPTIONS{"include"};
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
{
$file = $CPP_SOURCE_FILES[$i];
$ofile = $file;
$ofile =~ s/\.cpp/\.o/;
$ofile = "$outdir/$ofile";
$gcc = "$gccf $cflags -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile";
if (-e $ofile)
{
$file_time = (stat($file))[9];
$ofile_time = (stat($ofile))[9];
if ($file_time > $ofile_time)
{
`rm $ofile`;
print "$gcc\n";
`$gcc`;
}
} else {
print "$gcc\n";
`$gcc`;
}
}
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
{
$file = $C_SOURCE_FILES[$i];
$ofile = $file;
$ofile =~ s/\.c/\.o/;
$ofile = "$outdir/$ofile";
$gcc = "$ccf $cflags -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile";
if (-e $ofile)
{
$file_time = (stat($file))[9];
$ofile_time = (stat($ofile))[9];
if ($file_time > $ofile_time)
{
print "$gcc\n";
`$gcc`;
}
} else {
print "$gcc\n";
`$gcc`;
}
}
$gcc = "$gccf $cflags -shared -ldl -lm @LINK -o $outdir/$bin";
print "$gcc\n";
`$gcc`;

View File

@ -1520,14 +1520,6 @@ static cell AMX_NATIVE_CALL get_players(AMX *amx, cell *params) /* 4 param */
continue;
if ((flags & 16) && (pPlayer->teamId != team) )
continue;
/*if ( flags & 16 ) {
if (flags & 64){
if (strcmpi(pPlayer->team.c_str(),sptemp))
continue;
}
else if (strcmp(pPlayer->team.c_str(),sptemp))
continue;
}*/
if (flags & 32){
if (flags & 64){
if (stristr(pPlayer->name.c_str(),sptemp)==NULL)
@ -1564,7 +1556,7 @@ static cell AMX_NATIVE_CALL find_player(AMX *amx, cell *params) /* 1 param */
continue;
if (flags&1){
if (flags&2048) {
if (strcmpi(pPlayer->name.c_str(),sptemp))
if (stricmp(pPlayer->name.c_str(),sptemp))
continue;
}
else if (strcmp(pPlayer->name.c_str(),sptemp))
@ -1593,7 +1585,7 @@ static cell AMX_NATIVE_CALL find_player(AMX *amx, cell *params) /* 1 param */
}
if (flags&16){
if (flags&2048) {
if (strcmpi(pPlayer->team.c_str(),sptemp))
if (stricmp(pPlayer->team.c_str(),sptemp))
continue;
}
else if (strcmp(pPlayer->team.c_str(),sptemp))
@ -2874,7 +2866,7 @@ static cell AMX_NATIVE_CALL find_plugin_byfile(AMX *amx, cell *params)
if (params[2])
{
func = strcmpi;
func = strcasecmp;
} else {
func = strcmp;
}

View File

@ -36,6 +36,7 @@
#ifdef __linux__
#include <unistd.h>
#include <stdlib.h>
#include "sclinux.h"
#endif
#include <ctype.h> //tolower, etc
#include "string.h"

View File

@ -229,7 +229,7 @@ public:
// defined in meta_api.cpp
extern CFakeMeta g_FakeMeta;
#endif FAKEMETA
#endif //FAKEMETA
#endif // #ifndef __FAKEMETA_H__

View File

@ -1338,3 +1338,4 @@ C_DLLEXPORT int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, in
return g_FakeMeta.GetNewDLLFunctions_Post(pNewFunctionTable, interfaceVersion, &gNewDLLFunctionTable_Post);
}
#endif

View File

@ -33,6 +33,7 @@
#include <malloc.h>
#include <stdlib.h>
#include <sys/mman.h>
#include "sclinux.h"
#endif
#include "amxmodx.h"
#include "osdep.h" // sleep, etc
@ -484,10 +485,10 @@ int CheckModules(AMX *amx, char error[128])
{
amx_GetLibrary(amx, i, buffer, sizeof(buffer)-1);
found = false;
if (strcmpi(buffer, "float")==0)
if (stricmp(buffer, "float")==0)
continue;
isdbi = false;
if (strcmpi(buffer, "dbi")==0)
if (stricmp(buffer, "dbi")==0)
isdbi = true;
for (a=g_modules.begin(); a; ++a)
{
@ -508,7 +509,7 @@ int CheckModules(AMX *amx, char error[128])
break;
}
} else {
if (info->logtag && (strcmpi(info->logtag, buffer) == 0))
if (info->logtag && (stricmp(info->logtag, buffer) == 0))
{
found = true;
break;
@ -1370,10 +1371,6 @@ REAL MNF_CellToReal(cell x)
return *(REAL*)&x;
}
#ifdef __linux__
#define _vsnprintf vsnprintf
#endif
void MNF_Log(const char *fmt, ...)
{
char msg[3072];

View File

@ -20,6 +20,13 @@
#define stricmp(a,b) strcasecmp(a,b)
#define strnicmp(a,b,c) strncasecmp(a,b,c)
#if defined __linux__ && !defined _snprintf
#define _snprintf snprintf
#endif
#if defined __linux__ && !defined _vsnprintf
//#define _vsnprintf vsnprintf
#endif
/*
* WinWorld wants '\'. Unices do not.
*/