integrate osx build hints as indicated in #192
[rrdtool.git] / bindings / perl-shared / Makefile.PL
1 use ExtUtils::MakeMaker;
2 use Config;
3 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
4 # the contents of the Makefile that is written.
5
6 # if the last argument when calling Makefile.PL is RPATH=/... and ... is the
7 # path to librrd.so then the Makefile will be written such that RRDs.so knows
8 # where to find librrd.so later on ... 
9 my $R="";
10 if ($ARGV[-1] =~ /RPATH=(\S+)/){
11         pop @ARGV;
12         my $rp = $1;
13         for ($^O){
14                 /linux/   && do{ $R = "-Wl,--rpath -Wl,$rp"};
15                 /hpux/    && do{ $R = "+b$rp"};
16                 /solaris/ && do{ $R = "-R$rp"};
17                 /bsd/     && do{ $R = "-R$rp"};
18                 /aix/     && do{ $R = "-Wl,-blibpath:$rp"};
19         }
20 }
21
22 # darwin works without this because librrd contains its
23 # install_name which will includes the final location of the
24 # library after it is installed. This install_name gets transfered
25 # to the perl shared object.
26
27 my $librrd;
28 if ($^O eq 'darwin'){
29         $librrd = '-lrrd';
30 }
31 else {
32         $librrd = "-L../../src/.libs/ $R -lrrd";
33 }
34
35 WriteMakefile(
36     'NAME'         => 'RRDs',
37     'VERSION_FROM' => 'RRDs.pm', # finds $VERSION
38     'DEFINE'       => "-DPERLPATCHLEVEL=$Config{PATCHLEVEL}",
39     'INC'          => '-I../../src',
40     # Perl will figure out which one is valid
41     #'dynamic_lib'  => {'OTHERLDFLAGS' => "$librrd -lm"},
42     'depend'       => {'RRDs.c' => "../../src/librrd.la"},
43     'LDFROM'       => '$(OBJECT) '.$librrd, 
44     'realclean'    => {FILES => 't/demo?.rrd t/demo?.png' },
45     ($^O eq 'darwin') ? ( 'LDDLFLAGS'    => "-L../../src/.libs/ $Config{lddlflags}" ) : ()
46 );
47