/
build.pl
executable file
·80 lines (79 loc) · 1.86 KB
/
build.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/perl
use strict;
use Getopt::Std;
my %opt=();
getopts("obct", \%opt);
my $makefile="/home/alex/code/makefile";
my @files = </home/alex/code/*\.*>;
my @cppFiles;
my $file;
sub makeFile($$);
my @oFiles;
my @debugFiles;
my @releaseFiles;
if($opt{t}){
my $cmd="cd /home/alex/code ; etags /home/alex/code/*/*.{h,cpp,sh,pl,py}"; #{c++/*.{h,cpp},shellScripts/*.sh,perl/*.pl,python/*.py}
system($cmd);
exit;
}
foreach $file (@files) {
if($file=~m/(.cpp$)/){
$file =~ s/\/home\/alex\/code\///;
$file =~ m/(.*)\.cpp/;
push(@cppFiles, $file);
push(@oFiles, join('.', $1,"o"));
push(@releaseFiles, join('-', $1,"x86_64-03"));
push(@debugFiles, join('-', $1,"x86_64"));
}
}
open FILE, ">$makefile" or die $!; print FILE "av"; close FILE;
my $cmd="cd /home/alex/code;make;"; #rm makefile; rm *.o
for (my $index=0;$index<@debugFiles;$index++)
{
if($opt{b}){
makeFile("d",$index);
system($cmd);
makeFile("o",$index);
system($cmd);
}elsif($opt{o}){
makeFile("o",$index);
system($cmd);
}
elsif($opt{c}){
if($index eq 0){
system("cd /home/alex/code;rm makefile *-x86_64*");
}
}
else{
makeFile("d",$index);
system($cmd);
}
}
sub makeFile($$)
{
my @whichFile;
my $parms;
my $index=$_[1];
if($_[0] eq "d"){
@whichFile=@debugFiles;
$parms="-I /usr/local/boost_1_47_0 -g";
}
elsif($_[0] eq "o"){
@whichFile=@releaseFiles;
$parms="-I /usr/local/boost_1_47_0";
}
else{
die $!;
}
open FILE, ">$makefile" or die $!;
print FILE "CXX=g++ $parms -Wall -std=gnu++0x\n";
my $line=join(' ',$whichFile[$index],":",$oFiles[$index]);
print FILE "$line\n";
$line=join(' ',"\t","\$(CXX)","-o",$whichFile[$index],$oFiles[$index],"-I.");
print FILE "$line\n";
$line=join(' ',$oFiles[$index],":",$cppFiles[$index]);
print FILE "$line\n";
$line=join(' ',"\t","\$(CXX)","-c",$cppFiles[$index],"-I.");
print FILE "$line\n";
close FILE;
}