summaryrefslogtreecommitdiff
path: root/systems/texlive/tlnet/tlpkg/tlperl/lib/ExtUtils/CBuilder/Platform/darwin.pm
blob: 7e8ae7a4c717280500b51b2e34251a769baca947 (plain)
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
package ExtUtils::CBuilder::Platform::darwin;

use warnings;
use strict;
use ExtUtils::CBuilder::Platform::Unix;
use Config;

our $VERSION = '0.280238'; # VERSION
our @ISA = qw(ExtUtils::CBuilder::Platform::Unix);

my ($osver) = split /\./, $Config{osvers};
my $apple_cor = $^X eq "/usr/bin/perl" && $osver >= 18;

sub compile {
  my $self = shift;
  my $cf = $self->{config};

  # -flat_namespace isn't a compile flag, it's a linker flag.  But
  # it's mistakenly in Config.pm as both.  Make the correction here.
  local $cf->{ccflags} = $cf->{ccflags};
  $cf->{ccflags} =~ s/-flat_namespace//;

  # XCode 12 makes this fatal, breaking tons of XS modules
  $cf->{ccflags} .= ($cf->{ccflags} ? ' ' : '').'-Wno-error=implicit-function-declaration';

  $self->SUPER::compile(@_);
}

sub arg_include_dirs {
    my $self = shift;

    if ($apple_cor) {
        my $perl_inc = $self->perl_inc;
        return map {
           $_ eq $perl_inc ? ("-iwithsysroot", $_ ) : "-I$_"
        } @_;
    }
    else {
        return $self->SUPER::arg_include_dirs(@_);
    }
}

1;