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

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

after the core rappture library (librappture.so) is created the include
files necessary to compile all other bindings are copied to the top level
include directory. python, perl, matlab, octave and tcl bindings now refer
to this top level include directory to find header files.

fortran and c examples are only compiled if we find a compiler, this check
helps prevent builds from failing before the libraries are installed.

added more checks to the configure script

removed rappture search paths from perl's unix build because perl could find
an older version of rappture and compile against it. I would rather the build
fail and have the person enter a valid prefix.

addrd the -fPIC flag to CFLAGS in src2's makefile

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