~ubuntu-branches/ubuntu/natty/libxml-bare-perl/natty

« back to all changes in this revision

Viewing changes to Makefile.PL

  • Committer: Bazaar Package Importer
  • Author(s): Antonio Radici
  • Date: 2009-01-31 17:28:53 UTC
  • Revision ID: james.westby@ubuntu.com-20090131172853-hptyu448d89nsje4
Tags: upstream-0.40+dfsg.1
ImportĀ upstreamĀ versionĀ 0.40+dfsg.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
use ExtUtils::MakeMaker;
 
3
require 5.006;
 
4
my @basics = ( AUTHOR       => 'David Helkowski <cpan@codechild.com>',
 
5
               ABSTRACT     => 'A minimal XML parser that uses C to generate a folded perl hash.',
 
6
               NAME         => 'XML::Bare',
 
7
               VERSION_FROM => 'Bare.pm',
 
8
               PREREQ_PM    => { Carp => 0, Exporter => 0, DynaLoader => 0 },
 
9
               #OPTIMIZE     => '-O3 -msse2 -march=pentium4 --omit-frame-pointer',
 
10
             );
 
11
if( $ExtUtils::MakeMaker::VERSION >= 6.31 ) {
 
12
  push( @basics, LICENSE => 'perl' );
 
13
}
 
14
 
 
15
if( $^O eq 'MSWin32' && !has_cc() ) {
 
16
  gen_msvc(); # special case for msvc
 
17
}
 
18
elsif( $^O eq 'darwin' ) {
 
19
  gen_darwin(); # darwin
 
20
}
 
21
else {
 
22
  gen_cc(); # all others
 
23
}
 
24
sub gen_msvc {
 
25
  require Config;
 
26
  my $libpath = Config->{'archlibexp'};
 
27
  my $ver = $]*1000; # correct for possibile division problems
 
28
  my ($major,$minor,$sub) = unpack("AA3xA3","$ver");
 
29
  $major *= 1; $minor *= 1; $sub *= 1;
 
30
  WriteMakefile( @basics,
 
31
    CCFLAGS   => "/MT /DWIN32 /TP /DNOSTRING",
 
32
    LIBS      => ["$libpath\\core\\perl$major$minor.lib"],
 
33
    OBJECT    => 'Bare.o parser.o',
 
34
    LDDLFLAGS => '/DLL',
 
35
  );
 
36
}
 
37
sub gen_cc {
 
38
  WriteMakefile( @basics,
 
39
    LIBS      => ['-lm'],
 
40
    OBJECT    => 'Bare.o parser.o',
 
41
    LDDLFLAGS => '-shared -L/usr/local/lib',
 
42
  );
 
43
}
 
44
sub gen_darwin {
 
45
  if( substr(`which gcc`,0,2) eq 'no' ) {
 
46
    print "XCode must be installed.\n";
 
47
    exit 1;
 
48
  }
 
49
  WriteMakefile( @basics,
 
50
    LIBS      => ['-lm'],
 
51
    OBJECT    => 'Bare.o parser.o',
 
52
    CCFLAGS   => "-dynamiclib -DDARWIN -fno-common",
 
53
    LDDLFLAGS => '',
 
54
  );
 
55
}
 
56
sub has_cc {
 
57
  my $div = (substr($ENV{'PATH'},0,1) eq '/') ? ':' : ';';
 
58
  my @path = split($div,$ENV{'PATH'});
 
59
  foreach my $dir ( @path ) {
 
60
    return 1 if( -e "$dir/cc" ||
 
61
                 -e "$dir/gcc" ||
 
62
                 -e "$dir/cc.exe" ||
 
63
                 -e "$dir/gcc.exe" ); }
 
64
  return 0;
 
65
}