new makefile
This commit is contained in:
parent
0447c39a97
commit
cefad23b72
|
@ -1,103 +1,66 @@
|
|||
MODNAME = cstrike_amxx
|
||||
SRCFILES = CstrikePlayer.cpp cstrike.cpp amxxmodule.cpp
|
||||
#(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 -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 = cstrike_amxx
|
||||
|
||||
AMXDIR=../amxmodx
|
||||
SDKTOP=../hlsdk
|
||||
METADIR=../metamod/metamod
|
||||
OBJECTS = CstrikePlayer.cpp cstrike.cpp amxxmodule.cpp
|
||||
|
||||
LINK =
|
||||
|
||||
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
|
||||
CFLAGS += -DLINUX -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H
|
||||
|
||||
ifeq "$(AMD64)" "true"
|
||||
BINARY = $(NAME)_amd64.so
|
||||
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
||||
LINK += -lstdc++
|
||||
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
|
||||
BINARY = $(NAME)_i386.so
|
||||
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
|
||||
OPT_FLAGS += -march=i686
|
||||
endif
|
||||
|
||||
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
|
||||
|
||||
$(BIN_DIR)/%.o: %.cpp
|
||||
$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
LIBFILE_LINUX = $(MODNAME)_i386.so
|
||||
LIBFILE_WIN32 = $(MODNAME).dll
|
||||
TARGET_LINUX = $(OBJDIR_LINUX)/$(LIBFILE_LINUX)
|
||||
TARGET_WIN32 = $(OBJDIR_WIN32)/$(LIBFILE_WIN32)
|
||||
all:
|
||||
mkdir -p $(BIN_DIR)
|
||||
$(MAKE) cstrike
|
||||
|
||||
FILES_ALL = *.cpp *.h [A-Z]* *.rc
|
||||
ifeq "$(OS)" "LINUX"
|
||||
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)
|
||||
amd64:
|
||||
$(MAKE) all AMD64=true
|
||||
|
||||
CCOPT = -march=i386 -O6 -ffast-math -funroll-loops \
|
||||
-fomit-frame-pointer -s -DNDEBUG
|
||||
cstrike: $(OBJ_LINUX)
|
||||
$(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)
|
||||
CFLAGS=-Wall -Wno-unknown-pragmas
|
||||
ODEF = -DOPT_TYPE=\"optimized\"
|
||||
CFLAGS:=$(CCOPT) $(CFLAGS) $(ODEF) $(EXTRA_FLAGS)
|
||||
debug:
|
||||
$(MAKE) all DEBUG=true
|
||||
|
||||
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) $(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 $@
|
||||
default: all
|
||||
|
||||
$(OBJDIR_LINUX)/%.o: $(SRCDIR)/%.cpp
|
||||
$(DO_CC_LINUX)
|
||||
|
||||
$(OBJDIR_WIN32)/%.o: $(SRCDIR)/%.cpp
|
||||
$(DO_CC_WIN32)
|
||||
|
||||
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)
|
||||
clean:
|
||||
rm -rf Release/*.o
|
||||
rm -rf Release/$(BINARY)
|
||||
rm -rf Debug/*.o
|
||||
rm -rf Debug/$(BINARY)
|
||||
|
||||
|
|
|
@ -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 = "cstrike_amxx";
|
||||
$sdk = "../hlsdk/SourceCode";
|
||||
$mm = "../metamod/metamod";
|
||||
$gccf = "gcc";
|
||||
|
||||
@CPP_SOURCE_FILES = ("CstrikePlayer.cpp", "cstrike.cpp", "amxxmodule.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 -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 $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 -ldl -lm @LINK -o $outdir/$bin";
|
||||
print "$gcc\n";
|
||||
`$gcc`;
|
Loading…
Reference in New Issue
Block a user