File: Makefile.PL

package info (click to toggle)
libxml-bare-perl 0.53-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 1,380 kB
  • ctags: 223
  • sloc: xml: 15,836; perl: 1,335; ansic: 1,025; cpp: 41; makefile: 2
file content (121 lines) | stat: -rwxr-xr-x 2,970 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/perl
use ExtUtils::MakeMaker;
require 5.006;
my @basics = ( 
    AUTHOR       => 'David Helkowski <cpan@codechild.com>',
    ABSTRACT     => 'A minimal XML parser / schema checker / pretty-printer using C internally.',
    NAME         => 'XML::Bare',
    VERSION_FROM => 'Bare.pm',
    XSOPT        => '-nolinenumbers', # line number defines were causing issues on some platforms
    BUILD_REQUIRES => {
        'Data::Dumper' => 0,
        'English' => 0,
        'File::Find' => 0,
        'File::Temp' => 0,
        'Scalar::Util' => 0,
        'Test::Harness' => 0,
        'Test::More' => '0.94'
    },
    CONFIGURE_REQUIRES => {
        'ExtUtils::MakeMaker' => '6.30'
    },
    PREREQ_PM => {
        Carp => 0,
        DynaLoader => 0,
        Exporter => 0
    },
);

my $cc = getcc();
if( $cc ) {
  push( @basics, CC => $cc );
}
if( $ExtUtils::MakeMaker::VERSION >= 6.31 ) {
  push( @basics, LICENSE => 'perl' );
}

if( $^O eq 'MSWin32' && !$cc ) {
  gen_msvc(); # special case for msvc
}
elsif( $^O eq 'darwin' ) {
  gen_darwin();
}
elsif( $^O eq 'solaris' ) {
  gen_solaris();
}
else {
  gen_cc(); # all others
}
sub gen_msvc {
  require Config;
  my $libpath = Config->{'archlibexp'};
  my $ver = $]*1000000;
  my $sub = $ver % 1000;
  $ver -= $sub;
  $ver /= 1000;
  my $minor = $ver % 1000;
  $ver -= $minor;
  my $major = $ver / 1000;
  WriteMakefile( @basics,
    CCFLAGS   => "/MT /DWIN32 /TP /DNOSTRING",
    LIBS      => ["$libpath\\core\\perl$major$minor.lib"],
    OBJECT    => 'Bare.o parser.o',
    LDDLFLAGS => '/DLL /NODEFAULTLIB:libcmt',
    #OPTIMIZE  => '-Zl -DNDEBUG -O1', # Because -MD is included by default BLEH
  );
}
sub gen_cc {
  WriteMakefile( @basics,
    OBJECT    => 'Bare.o parser.o',
    LDDLFLAGS => '-shared -L/usr/local/lib',
  );
}
sub gen_solaris {
  WriteMakefile( @basics,
    LIBS      => ['-lm'],
    OBJECT    => 'Bare.o parser.o',
    LDDLFLAGS => '-G -L/usr/local/lib', # -G is equiv of -shared
  );
}
sub gen_darwin {
  if( substr(`which gcc`,0,2) eq 'no' ) {
    print "XCode must be installed.\n";
    exit 1;
  }
  WriteMakefile( @basics,
    LIBS      => ['-lm'],
    OBJECT    => 'Bare.o parser.o',
    CCFLAGS   => "-dynamiclib -DDARWIN -fno-common",
    LDDLFLAGS => '',
  );
}
sub getcc {
  my $div = (substr($ENV{'PATH'},0,1) eq '/') ? ':' : ';';
  my @path = split($div,$ENV{'PATH'});
  foreach my $dir ( @path ) {
    return 'gcc' if( -e "$dir/gcc" || -e "$dir/gcc.exe" ); # prefer gcc
    return 'cc'  if( -e "$dir/cc"  || -e "$dir/cc.exe"  );
  }               
  return 0;
}

# The following are hacks to force static linking and so remove need for msvcr## dll
package MY;

sub cflags {
  my $res = shift->SUPER::cflags( @_ );
  if( $^O eq 'MSWin32' ) {
    $res =~ s/-O1/-O2/g;
    $res =~ s/-MD/-MT/g;
  }
  return $res;
}

sub const_loadlibs {
  my $res = shift->SUPER::const_loadlibs( @_ );
  if( $^O eq 'MSWin32' ) {
    $res =~ s/msvcrt\.lib/libcmt\.lib/gi;
  }
  return $res;
}