source: trunk/perl/Makefile.PL @ 481

Last change on this file since 481 was 481, checked in by nkissebe, 16 years ago

Initial revision of Perl binding for Rappture

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