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