[497] | 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") {
|
---|
[718] | 10 | shift @ARGV;
|
---|
| 11 | $DEBUG = 1;
|
---|
[497] | 12 | }
|
---|
| 13 |
|
---|
| 14 | if ($^O ne "MSWin32") {
|
---|
| 15 | $CC = '@CXX@';
|
---|
| 16 | $LD = '@CXX@';
|
---|
[546] | 17 | if ($^O eq 'darwin') {
|
---|
[718] | 18 | @LDDLFLAGS = ( q[-bundle],
|
---|
| 19 | q[-bundle_loader /usr/bin/perl],
|
---|
[546] | 20 | q[-L/usr/local/lib],
|
---|
| 21 | q[-L$(PERL_INC) -lperl]
|
---|
| 22 | );
|
---|
| 23 | }
|
---|
[872] | 24 | @RAPPTURE_INC_SEARCHPATH = ( "@prefix@/include",
|
---|
| 25 | "../include", "/usr/local/include", "/opt/include");
|
---|
| 26 | $RAPPTURE_INC = "rappture.h";
|
---|
[708] | 27 | @EXPAT_INC_SEARCHPATH = ( "@prefix@/include",
|
---|
| 28 | "/usr/local/include", "/opt/include", "../../expat-2.0.0/lib",
|
---|
| 29 | "../../expat/lib", "/apps/expat-2.0.0/lib", "/apps/expat/lib",
|
---|
[497] | 30 | "/opt/expat-2.0.0/lib", "/opt/expat/lib" );
|
---|
| 31 | $EXPAT_INC="expat.h";
|
---|
[872] | 32 | @RAPPTURE_LIB_SEARCHPATH = ( "@prefix@/lib",
|
---|
| 33 | "@libdir@",
|
---|
| 34 | "../src", "/usr/local/lib", "/opt/lib" );
|
---|
| 35 | @RAPPTURE_LIBS=("librappture.so","librappture.a");
|
---|
[497] | 36 | @EXPAT_LIB_SEARCHPATH = ( "@prefix@/lib",
|
---|
[718] | 37 | "@libdir@",
|
---|
[708] | 38 | "/usr/local/lib", "/opt/lib", "../../expat-2.0.0/lib",
|
---|
| 39 | "../../expat/lib", "/apps/expat-2.0.0/lib", "/apps/expat/lib",
|
---|
[497] | 40 | "/opt/expat-2.0.0/lib", "/opt/expat/lib" );
|
---|
| 41 | @EXPAT_LIBS=("libexpat.so", "libexpat.a");
|
---|
[708] | 42 | }
|
---|
[497] | 43 | else {
|
---|
| 44 | if ($Config{"cc"} eq "cl") {
|
---|
[708] | 45 | $CFLAGS = "/TP /EHsc";
|
---|
[497] | 46 | @LIBS = ("msvcprt.lib");
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[718] | 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",
|
---|
[497] | 54 | "C:\\opt\\expat-2.0.0\\lib", "C:\\opt\\expat\\lib" );
|
---|
| 55 | $EXPAT_INC="expat.h";
|
---|
[718] | 56 | @RAPPTURE_INC_SEARCHPATH = ( "C:\\Program Files\\Rappture\\include",
|
---|
[497] | 57 | "C:\\opt\\rappture\\include", "C:\\opt\\include", "..\\include" );
|
---|
[516] | 58 | $RAPPTURE_INC = "rappture.h";
|
---|
[718] | 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",
|
---|
[497] | 63 | "C:\\Program Files\\Expat-2.0.0\\StaticLibs",
|
---|
[718] | 64 | "C:\\Program Files\\Expat\\StaticLibs",
|
---|
| 65 | "C:\\opt\\expat-2.0.0\\lib\\Release_static",
|
---|
[497] | 66 | "C:\\opt\\expat\\lib\\Release_static" );
|
---|
| 67 | @EXPAT_LIBS=("libexpat.lib", "libexpatMT.lib");
|
---|
[718] | 68 | @RAPPTURE_LIB_SEARCHPATH = ( "C:\\Program Files\\Rappture\\lib",
|
---|
[497] | 69 | "C:\\opt\\rappture\\lib", "C:\\opt\\lib", "..\\src" );
|
---|
| 70 | @RAPPTURE_LIBS=("librappture.lib");
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | sub
|
---|
| 74 | find_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 | }
|
---|
[718] | 82 | return 1;
|
---|
[497] | 83 | last;
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | return 0;
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | sub
|
---|
| 91 | find_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 | }
|
---|
[718] | 109 | return 1;
|
---|
[497] | 110 | last SEARCH;
|
---|
| 111 | }
|
---|
| 112 | }
|
---|
| 113 | }
|
---|
| 114 | return 0;
|
---|
| 115 | }
|
---|
| 116 |
|
---|
[872] | 117 | find_include(\@RAPPTURE_INC_SEARCHPATH, $RAPPTURE_INC, \@INCLUDES);
|
---|
[497] | 118 | find_include(\@EXPAT_INC_SEARCHPATH, $EXPAT_INC, \@INCLUDES);
|
---|
[872] | 119 | find_lib(\@RAPPTURE_LIB_SEARCHPATH, \@RAPPTURE_LIBS, \@LIBS);
|
---|
[497] | 120 | find_lib(\@EXPAT_LIB_SEARCHPATH, \@EXPAT_LIBS, \@LIBS);
|
---|
| 121 |
|
---|
| 122 | WriteMakefile(
|
---|
| 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,
|
---|
[546] | 134 | LDDLFLAGS => "@LDDLFLAGS",
|
---|
[497] | 135 | XSOPT => '-C++',
|
---|
| 136 | );
|
---|
| 137 |
|
---|
| 138 | package MY;
|
---|
| 139 | use Config;
|
---|
| 140 |
|
---|
| 141 | sub dynamic_lib {
|
---|
[718] | 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);
|
---|
[497] | 148 | }
|
---|
| 149 |
|
---|
| 150 |
|
---|