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

Last change on this file since 546 was 546, checked in by dkearney, 15 years ago

adjusted the lddlflags in makefile so perl knows where to find libperl.dylib, which is needed to build darwin bundles

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