-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.pl
67 lines (48 loc) · 1.26 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
#!perl
use strict;
use warnings;
use FindBin;
use IPC::Cmd 'can_run';
use Getopt::Long;
my $debug = 0;
my $install = 0;
my $apxs = 'apxs2';
my @flags = do { no warnings; qw[-a -c -Wl,-Wall -Wl,-lm]; };
my $my_lib = 'mod_statsd.c';
my @inc;
my @link;
GetOptions(
debug => \$debug,
"apxs=s" => \$apxs,
"flags=s@" => \@flags,
"inc=s@" => \@inc,
"link=s@" => \@link,
install => \$install,
) or die usage();
unless( can_run( $apxs ) ) {
die "Could not find '$apxs' in your path.\n\n" .
"On Ubuntu/Debian, try 'sudo apt-get install apache2-dev'\n\n";
}
### from apxs man page:
### * -Wl,-lX to link against X
### * -Wc,-DX to tell gcc to -D(efine) X
### * -I to include other dirs
my @cmd = ( $apxs, @flags );
### By default we don't install, but with this flag we do.
push @cmd, '-i' if $install;
### extra include dirs
push @cmd, map { "-I $_" } $FindBin::Bin, @inc;
### libraries to link against
push @cmd, map { "-Wl,-l$_" } @link;
### enable debug?
push @cmd, "-Wc,-DDEBUG" if $debug;
### our module
push @cmd, $my_lib;
warn "\n\nAbout to run:\n\t@cmd\n\n";
system( @cmd ) and die $?;
sub usage {
my $me = $FindBin::Script;
return qq[
$me [--debug] [--inc /some/dir,..] [--link some_lib]
\n];
}