amxmodx/dlls/sqlite/Makefile.pl

185 lines
4.2 KiB
Makefile
Raw Normal View History

2005-02-15 17:11:01 +03:00
#!/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 =
2005-02-15 17:11:01 +03:00
# debug - enable gdb debugging
# amd64 - compile for AMD64
# proc=ix86 - assumed not amd64
# clean - clean the specifications above
2005-02-15 20:27:00 +03:00
$PROJECT = "sqlite_amxx";
2005-03-10 01:21:26 +03:00
$sdk = "../../hlsdk/SourceCode";
$mm = "../../metamod/metamod";
$sql = "sqlite-source-3_2_3";
2005-02-15 17:11:01 +03:00
$gccf = "gcc";
2005-02-15 20:27:00 +03:00
@CPP_SOURCE_FILES = ("sqlite.cpp", "sqlite_amx.cpp", "amxxmodule.cpp");
2005-02-15 17:11:01 +03:00
2005-08-24 11:16:45 +04:00
@C_SOURCE_FILES = ("$sql/attach.c", "$sql/auth.c", "$sql/btree.c", "$sql/build.c", "$sql/date.c", "$sql/delete.c", "$sql/func.c", "$sql/hash.c", "$sql/insert.c", "$sql/legacy.c", "$sql/main.c", "$sql/opcodes.c", "$sql/os_unix.c", "$sql/os_win.c", "$sql/pager.c", "$sql/parse.c", "$sql/pragma.c", "$sql/printf.c", "$sql/random.c", "$sql/select.c", "$sql/shell.c", "$sql/table.c", "$sql/tokenize.c", "$sql/trigger.c", "$sql/update.c", "$sql/utf.c", "$sql/util.c", "$sql/vacuum.c", "$sql/vdbe.c", "$sql/vdbeapi.c", "$sql/vdbeaux.c", "$sql/vdbemem.c", "$sql/where.c", "$sql/prepare.c", "$sql/expr.c", "$sql/callback.c", "$sql/alter.c", "$sql/vdbefifo.c", "$sql/complete.c", "$sql/analyze.c");
2005-03-10 01:21:26 +03:00
2005-02-15 17:11:01 +03:00
my %OPTIONS, %OPT;
2005-08-11 23:06:54 +04:00
$OPT{"debug"} = "-DNO_TCL -g -ggdb";
2005-08-24 11:16:45 +04:00
$OPT{"opt"} = "-DNO_TCL -O2 -ffast-math -funroll-loops -fomit-frame-pointer -s -DNDEBUG -Wall -Wno-unknown-pragmas -DOPT_TYPE=\"optimized\"";
2005-02-15 17:11:01 +03:00
2005-03-10 01:21:26 +03:00
$OPTIONS{"include"} = "-I$sdk -I. -I$mm -I$sdk/engine -I$sdk/common -I$sdk/pm_shared -I$sdk/dlls -I$sql";
2005-02-15 17:11:01 +03:00
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;
2005-02-15 17:11:01 +03:00
}
}
$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"};
}
2005-08-24 11:16:45 +04:00
}
2005-02-15 17:11:01 +03:00
if ($OPTIONS{"amd64"})
{
2005-02-15 17:39:36 +03:00
$cflags .= " -m64 -DHAVE_I64 -DSMALL_CELL_SIZE=64 $cflags";
2005-02-15 17:11:01 +03:00
}
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";
}
}
unlink("$outdir/$bin");
if ($OPTIONS{"clean"})
{
`rm $outdir/*.o`;
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);
}
2005-03-10 01:21:26 +03:00
if (!(-d "$outdir/$sql"))
{
mkdir("$outdir/$sql");
}
2005-02-15 17:11:01 +03:00
$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";
2005-08-24 11:16:45 +04:00
$gcc = "$gccf $cflags -fno-rtti -fno-exceptions -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile";
2005-02-15 17:11:01 +03:00
if (-e $ofile)
{
$file_time = (stat($file))[9];
2005-02-15 17:39:36 +03:00
$ofile_time = (stat($file))[9];
2005-02-15 17:11:01 +03:00
if ($file_time > $ofile_time)
{
print "$gcc\n";
`$gcc`;
}
} else {
print "$gcc\n";
`$gcc`;
}
}
2005-03-10 01:21:26 +03:00
for ($i=0; $i<=$#C_SOURCE_FILES; $i++)
2005-02-15 17:11:01 +03:00
{
$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];
2005-02-15 17:39:36 +03:00
$ofile_time = (stat($file))[9];
2005-02-15 17:11:01 +03:00
if ($file_time > $ofile_time)
{
print "$gcc\n";
`$gcc`;
}
} else {
print "$gcc\n";
`$gcc`;
}
}
2005-08-24 11:16:45 +04:00
$gcc = "$gccf $cflags $inc -shared -static-libgcc -ldl -lm @LINK -lz -lcrypt -o $outdir/$bin";
2005-02-15 17:11:01 +03:00
print "$gcc\n";
`$gcc`;