source: trunk/perl/Makefile.PL.in @ 708

Last change on this file since 708 was 708, checked in by dkearney, 17 years ago

updateing build system for rappture and language bindings.
librappture now includes a static version of libscew.
this means librappture needs to be linked directly against libexpat.
removed references to libscew from language bindings' makefiles.
corrected matlab and octave makefiles to only compile when dependencies are updated.
added --libdir flag so you can install platform dependent files into lib64 on 64-bit systems.
adjusted the rappture.env file to add lib64 directories to search paths incase they exist.

File size: 5.2 KB
RevLine 
[497]1use 5.008;
2use ExtUtils::MakeMaker;
3use Config;
4use File::Spec;
5
6$CC = $Config{"cc"};
7$LD = $Config{"ld"};
8
9if ($ARGV[0] eq "DEBUG") {
10        shift @ARGV;
11        $DEBUG = 1;
12}
13
14if ($^O ne "MSWin32") {
15    $CC = '@CXX@';
16    $LD = '@CXX@';
[546]17    if ($^O eq 'darwin') {
18        @LDDLFLAGS = ( q[-bundle],
19                       q[-bundle_loader /usr/bin/perl],
20                       q[-L/usr/local/lib],
21                       q[-L$(PERL_INC) -lperl]
22                     );
23    }
[708]24    @EXPAT_INC_SEARCHPATH = ( "@prefix@/include",
[497]25        "/apps/rappture/include", "/opt/rappture/include",
[708]26        "/usr/local/include", "/opt/include", "../../expat-2.0.0/lib",
27        "../../expat/lib", "/apps/expat-2.0.0/lib", "/apps/expat/lib",
[497]28        "/opt/expat-2.0.0/lib", "/opt/expat/lib" );
29    $EXPAT_INC="expat.h";
30    @RAPPTURE_INC_SEARCHPATH = ( "@prefix@/include",
[708]31        "../src/core", "../include", "/apps/rappture/include",
32        "/opt/rappture/include", "/usr/local/include", "/opt/include");
[516]33    $RAPPTURE_INC = "rappture.h";
[497]34    @EXPAT_LIB_SEARCHPATH = ( "@prefix@/lib",
[708]35        "/apps/rappture/lib", "/opt/rappture/lib",
36        "/usr/local/lib", "/opt/lib", "../../expat-2.0.0/lib",
37        "../../expat/lib", "/apps/expat-2.0.0/lib", "/apps/expat/lib",
[497]38        "/opt/expat-2.0.0/lib", "/opt/expat/lib" );
39    @EXPAT_LIBS=("libexpat.so", "libexpat.a");
40    @RAPPTURE_LIB_SEARCHPATH = ( "@prefix@/lib",
[708]41        "../src", "/apps/rappture/lib", "/opt/rappture/lib",
42        "/usr/local/lib", "/opt/lib" );
[497]43    @RAPPTURE_LIBS=("librappture.so","librappture.a");
[708]44}
[497]45else {
46    if ($Config{"cc"} eq "cl") {
[708]47        $CFLAGS = "/TP /EHsc";
[497]48        @LIBS = ("msvcprt.lib");
49    }
50
51    @EXPAT_INC_SEARCHPATH = ( "C:\\Program Files\\Rappture\\include",
52        "C:\\opt\\rappture\\include", "C:\\opt\\include",
53        "..\\..\\expat-2.0.0\\lib", "..\\..\\expat\\lib",
54        "C:\\Program Files\\Expat-2.0.0\\Source\\lib",
55        "C:\\Program Files\\Expat\\Source\\lib",
56        "C:\\opt\\expat-2.0.0\\lib", "C:\\opt\\expat\\lib" );
57    $EXPAT_INC="expat.h";
58    @RAPPTURE_INC_SEARCHPATH = ( "C:\\Program Files\\Rappture\\include",
59        "C:\\opt\\rappture\\include", "C:\\opt\\include", "..\\include" );
[516]60    $RAPPTURE_INC = "rappture.h";
[497]61    @EXPAT_LIB_SEARCHPATH = ( "C:\\Program Files\\Rappture\\lib",
62        "C:\\opt\\rappture\\lib", "C:\\opt\\lib",
63        "..\\..\\expat-2.0.0\\lib\\Release_static",
64        "..\\..\\expat\\lib\\Release_static",
65        "C:\\Program Files\\Expat-2.0.0\\StaticLibs",
66        "C:\\Program Files\\Expat\\StaticLibs",
67        "C:\\opt\\expat-2.0.0\\lib\\Release_static",
68        "C:\\opt\\expat\\lib\\Release_static" );
69    @EXPAT_LIBS=("libexpat.lib", "libexpatMT.lib");
70    @RAPPTURE_LIB_SEARCHPATH = ( "C:\\Program Files\\Rappture\\lib",
71        "C:\\opt\\rappture\\lib", "C:\\opt\\lib", "..\\src" );
72    @RAPPTURE_LIBS=("librappture.lib");
73}
74
75sub
76find_include {
77    my ($dirs, $filename, $incref) = @_;
78    foreach $component (@$dirs) {
79        if (-e File::Spec->catfile($component, $filename)) {
80            ($sdir = $component) =~ s/\\/\\\\/g;
81            if (!(grep /^-I$sdir/, @$incref)) {
82                push @$incref, "-I$component";
83            }
84            return 1;
85            last;
86        }
87    }
88
89    return 0;
90}
91
92sub
93find_lib {
94    my ($dirs, $filenames, $libref) = @_;
95
96    SEARCH: foreach $component (@$dirs) {
97        foreach $lib (@$filenames) {
98            $file = File::Spec->catfile($component, $lib);
99            if (-e $file) {
100                if ($lib =~ /^lib(.+)(.a|.so)$/) {
101                    if (grep /^-L$component/, @$libref) {
102                        push @$libref, "-l$1";
103                    }
104                    else {
105                        push @$libref, "-L$component -l$1";
106                    }
107                }
108                else {
109                    push @$libref, $file;
110                }
111                return 1;
112                last SEARCH;
113            }
114        }
115    }
116    return 0;
117}
118
119find_include(\@EXPAT_INC_SEARCHPATH, $EXPAT_INC, \@INCLUDES);
120find_include(\@RAPPTURE_INC_SEARCHPATH, $RAPPTURE_INC, \@INCLUDES);
121find_lib(\@EXPAT_LIB_SEARCHPATH, \@EXPAT_LIBS, \@LIBS);
122find_lib(\@RAPPTURE_LIB_SEARCHPATH, \@RAPPTURE_LIBS, \@LIBS);
123
124WriteMakefile(
125    NAME              => 'Rappture',
126    VERSION_FROM      => 'lib/Rappture.pm', # finds $VERSION
127    PREREQ_PM         => {}, # e.g., Module::Name => 1.1
128    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
129      (ABSTRACT_FROM  => 'lib/Rappture.pm', # retrieve abstract from module
130       AUTHOR         => 'Nicholas J. Kisseberth') : ()),
131    LIBS              => ["@LIBS"],
132    DEFINE            => "$CFLAGS",
133    INC               => "@INCLUDES",
134    CC                => $CC,
135    LD                => $LD,
[546]136    LDDLFLAGS         => "@LDDLFLAGS",
[497]137    XSOPT             => '-C++',
138);
139
140package MY;
141use Config;
142
143sub dynamic_lib {
144        my $inherited = shift->SUPER::dynamic_lib(@_);
145        if (($^O eq "MSWin32") && ($Config{'cc'} eq "cl")) {
146            $inherited .= "\tMT.EXE -manifest \$@.manifest -outputresource:\$@;2\n";
147            $inherited .= "\t\$(RM_F) \$@.manifest\n";
148        }
149        return($inherited);
150}
151
152
Note: See TracBrowser for help on using the repository browser.