New makefile

This commit is contained in:
David Anderson 2005-08-02 08:12:47 +00:00
parent 70bff9c430
commit 686dadc9c5
3 changed files with 49 additions and 261 deletions

View File

@ -278,7 +278,10 @@ public:
String substr(unsigned int index, int num = npos) String substr(unsigned int index, int num = npos)
{ {
if (!v) if (!v)
return String(""); {
String b("");
return b;
}
String ns; String ns;

View File

@ -1,103 +1,66 @@
MODNAME = engine_amxx #(C)2004-2005 AMX Mod X Development Team
SRCFILES = engine.cpp entity.cpp messages.cpp forwards.cpp amxxmodule.cpp amxxapi.cpp globals.cpp # Makefile written by David "BAILOPAN" Anderson
EXTRA_LIBS_LINUX = HLSDK = ../hlsdk/SourceCode
EXTRA_LIBS_WIN32 = MM_ROOT = ../metamod/metamod
EXTRA_LIBDIRS_LINUX = -Lextra/lib_linux
EXTRA_LIBDIRS_WIN32 = -Lextra/lib_win32
EXTRA_INCLUDEDIRS = -Iextra/include -I../amxmodx ### 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 = engine_amxx
AMXDIR=../amxmodx OBJECTS = amxxmodule.cpp amxxapi.cpp engine.cpp entity.cpp globals.cpp forwards.cpp messages.cpp
SDKTOP=../hlsdk
METADIR=../metamod/metamod
LINK =
SDKSRC=$(SDKTOP)/SourceCode INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/game_shared \
OBJDIR_LINUX=obj.linux -I$(MM_ROOT) -Lzlib -I$(HLSDK)/common
OBJDIR_WIN32=obj.win32
SRCDIR=.
ifdef windir ifeq "$(DEBUG)" "true"
OS=WIN32 BIN_DIR = Debug
CFLAGS = $(DEBUG_FLAGS)
else else
OS=LINUX BIN_DIR = Release
CFLAGS = $(OPT_FLAGS)
endif endif
CC_LINUX=gcc-2.95 CFLAGS += -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H
ifeq "$(OS)" "WIN32"
CC_WIN32=gcc ifeq "$(AMD64)" "true"
LD_WINDLL=dllwrap BINARY = $(NAME)_amd64.so
DEFAULT=win32 CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
CLEAN=clean_win32 LINK += -lstdc++
else else
CC_WIN32=/usr/local/cross-tools/i386-mingw32msvc/bin/gcc BINARY = $(NAME)_i386.so
LD_WINDLL=/usr/local/cross-tools/bin/i386-mingw32msvc-dllwrap CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
DEFAULT=linux win32 OPT_FLAGS += -march=i686
CLEAN=clean_both
endif endif
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
$(BIN_DIR)/%.o: %.cpp
$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
LIBFILE_LINUX = $(MODNAME)_i386.so all:
LIBFILE_WIN32 = $(MODNAME).dll mkdir -p $(BIN_DIR)
TARGET_LINUX = $(OBJDIR_LINUX)/$(LIBFILE_LINUX) $(MAKE) engine
TARGET_WIN32 = $(OBJDIR_WIN32)/$(LIBFILE_WIN32)
FILES_ALL = *.cpp *.h [A-Z]* *.rc amd64:
ifeq "$(OS)" "LINUX" $(MAKE) all AMD64=true
ASRCFILES := $(shell ls -t $(SRCFILES))
else
ASRCFILES := $(shell dir /b)
endif
OBJ_LINUX := $(SRCFILES:%.cpp=$(OBJDIR_LINUX)/%.o)
OBJ_WIN32 := $(SRCFILES:%.cpp=$(OBJDIR_WIN32)/%.o)
CCOPT = -march=i386 -O2 -ffast-math -funroll-loops \ engine: $(OBJ_LINUX)
-fomit-frame-pointer -s -DNDEBUG $(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
INCLUDEDIRS=-I../curl/include -I$(SRCDIR) -I$(AMXDIR) -I$(METADIR) -I$(SDKSRC)/engine -I$(SDKSRC)/common -I$(SDKSRC)/pm_shared -I$(SDKSRC)/dlls -I$(SDKSRC) $(EXTRA_INCLUDEDIRS) debug:
CFLAGS=-Wall -Wno-unknown-pragmas $(MAKE) all DEBUG=true
ODEF = -DOPT_TYPE=\"optimized\"
CFLAGS:=$(CCOPT) $(CFLAGS) $(ODEF) $(EXTRA_FLAGS)
DO_CC_LINUX=$(CC_LINUX) $(CFLAGS) -fPIC $(INCLUDEDIRS) -o $@ -c $< default: all
DO_CC_WIN32=$(CC_WIN32) $(CFLAGS) $(INCLUDEDIRS) -o $@ -c $<
LINK_LINUX=$(CC_LINUX) $(CFLAGS) -shared -ldl -lm $(OBJ_LINUX) $(EXTRA_LIBDIRS_LINUX) $(EXTRA_LIBS_LINUX) -o $@
LINK_WIN32=$(LD_WINDLL) -mwindows --def $(MODNAME).def --add-stdcall-alias $(OBJ_WIN32) $(EXTRA_LIBDIRS_WIN32) $(EXTRA_LIBS_WIN32) -o $@
$(OBJDIR_LINUX)/%.o: $(SRCDIR)/%.cpp clean:
$(DO_CC_LINUX) rm -rf Release/*.o
rm -rf Release/$(BINARY)
$(OBJDIR_WIN32)/%.o: $(SRCDIR)/%.cpp rm -rf Debug/*.o
$(DO_CC_WIN32) rm -rf Debug/$(BINARY)
default: $(DEFAULT)
$(TARGET_LINUX): $(OBJDIR_LINUX) $(OBJ_LINUX)
$(LINK_LINUX)
$(TARGET_WIN32): $(OBJDIR_WIN32) $(OBJ_WIN32)
$(LINK_WIN32)
$(OBJDIR_LINUX):
mkdir $@
$(OBJDIR_WIN32):
mkdir $@
win32: $(TARGET_WIN32)
linux: $(TARGET_LINUX)
clean: $(CLEAN)
clean_both:
-rm -f $(OBJDIR_LINUX)/*
-rm -f $(OBJDIR_WIN32)/*
clean_win32:
del /q $(OBJDIR_WIN32)

View File

@ -1,178 +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 project src dir
#options =
# debug - enable gdb debugging
# amd64 - compile for AMD64
# proc=ix86 - assumed not amd64
# clean - clean the specifications above
$PROJECT = "engine_amxx";
$sdk = "../hlsdk/SourceCode";
$mm = "../metamod/metamod";
$gccf = "gcc";
@CPP_SOURCE_FILES = ("amxxmodule.cpp", "forwards.cpp", "messages.cpp", "entity.cpp", "globals.cpp", "amxxapi.cpp", "engine.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 =~ /amd64/) {
$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;
}
}
$gcc = `$gccf --version`;
if ($gcc =~ /2\.9/)
{
$OPT{"opt"} .= " -malign-loops=2 -malign-jumps=2 -malign-functions=2";
} else {
$OPT{"opt"} .= " -falign-loops=2 -falign-jumps=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 $cflags";
}
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 (!(-d $outdir))
{
mkdir($outdir);
}
$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)
{
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 = "cc $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 -fPIC -ldl -lm -o $outdir/$bin @LINK";
print "$gcc\n";
`$gcc`;