File: darwin.pl

package info (click to toggle)
libaudio-scan-perl 0.93%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,152 kB
  • sloc: ansic: 11,482; perl: 241; sh: 48; makefile: 2
file content (50 lines) | stat: -rw-r--r-- 1,578 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl

use Config;

if ( $Config{myarchname} =~ /i386/ ) {
    my $arch;
    
    # Match arch options with the running perl
    if ( my @archs = $Config{ccflags} =~ /-arch ([^ ]+)/g ) {
        $arch = join( '', map { "-arch $_ " } @archs );
        
        if ( -e 'MANIFEST.SKIP' ) {
            # XXX for development, use only one arch to speed up compiles
            $arch = '-arch x86_64 ';
        }
    }
    
    # Read OS version
    my $sys = `/usr/sbin/system_profiler SPSoftwareDataType`;
    my ($osx_ver) = $sys =~ /Mac OS X.*(10\.[^ ]+)/;
    if ( $osx_ver gt '10.5' ) {
        # Running 10.6+, build as 10.5+
        if ( -d '/Developer/SDKs/MacOSX10.5.sdk' ) {
            $arch .= "-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5";
        }
        else {
            # 10.5 SDK not installed, use 10.6
            $arch .= "-isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6";
        }
    }
    else {
        # 5.8.x, build for 10.3+
        $arch .= "-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.3";
    }
    
    print "Adding $arch\n";
    
    my $ccflags   = $Config{ccflags};
    my $ldflags   = $Config{ldflags};
    my $lddlflags = $Config{lddlflags};
    
    # Remove extra -arch flags from these
    $ccflags  =~ s/-arch\s+\w+//g;
    $ldflags  =~ s/-arch\s+\w+//g;
    $lddlflags =~ s/-arch\s+\w+//g;
    
    $self->{CCFLAGS} = "$arch -I/usr/include $ccflags";
    $self->{LDFLAGS} = "$arch -L/usr/lib $ldflags";
    $self->{LDDLFLAGS} = "$arch -L/usr/lib $lddlflags";
}