source: trunk/dports/devel/ld64/Portfile @ 102082

Last change on this file since 102082 was 102082, checked in by jeremyhu@…, 7 years ago

ld64: Use compiler.blacklist

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.9 KB
Line 
1# $Id: Portfile 102082 2013-01-27 18:57:00Z jeremyhu@macports.org $
2
3PortSystem              1.0
4
5# cctools uses a static library from this port when it builds, please
6# revbump cctools whenever this port updates
7
8name                    ld64
9# XCode 4.5
10version                 134.9
11revision                1
12categories              devel
13platforms               darwin
14maintainers             jeremyhu
15homepage                http://opensource.apple.com/source/${name}/
16master_sites            http://opensource.apple.com/tarballs/${name}/
17license                 APSL-2
18depends_build           port:libunwind-headers \
19                        path:include/mach-o/dyld_priv.h:dyld-headers \
20                        path:include/mach-o/arm/reloc.h:cctools-headers
21description             ld64 is the new mach-o linker
22long_description        ld64 combines several object files and libraries, \
23                        resolves references, and produces an ouput file.
24
25checksums               rmd160  9464743da9603af5e5a8f27c51e2fea177e0c1c5 \
26                        sha256  938bad7aa53999ca9e2b6e6d55a1ccbec0bd2afc743ce8c1a0e8f9ccc6d6df1b
27
28patchfiles              ld64-version.patch ld64-133-no-CrashReporterClient.h.patch ld64-134-PR-36654.patch ld64-134-missing-include.patch
29
30# We don't set llvmXX as the default variant on Tiger because it would introduce a
31# dependency cycle as llvm requires apple-gcc42 and ld64 to build correctly.  Users
32# wanting LTO support in ld64 on Tiger can install the +llvm variant after llvm
33# has been installed.
34if {![variant_isset llvm29] && ![variant_isset llvm30] && ![variant_isset llvm31] && ![variant_isset llvm32] && ${os.major} >= 9} {
35    default_variants +llvm31
36
37    # Leopard/powerpc has the option to not be LTO
38    if {![variant_isset llvm31] && ${os.arch} != "powerpc"} {
39        ui_error "Your platform cannot be configured without LTO support in ld64.  Please enable one of the llvmXX variants, and try again."
40        return -code error "Your platform cannot be configured without LTO support in ld64.  Please enable one of the llvmXX variants, and try again."
41    }
42}
43
44variant universal {}
45
46set llvm_version {}
47variant llvm29 conflicts llvm30 llvm31 llvm32 description {Use llvm-2.9 for libLTO} {
48    set llvm_version        2.9
49    depends_lib-append      port:llvm-${llvm_version}
50}
51
52variant llvm30 conflicts llvm29 llvm31 llvm32 description {Use llvm-3.0 for libLTO} {
53    set llvm_version        3.0
54    depends_lib-append      port:llvm-${llvm_version}
55}
56
57variant llvm31 conflicts llvm29 llvm30 llvm32 description {Use llvm-3.1 for libLTO} {
58    set llvm_version        3.1
59    depends_lib-append      port:llvm-${llvm_version}
60}
61
62variant llvm32 conflicts llvm29 llvm30 llvm31 description {Use llvm-3.2 for libLTO} {
63    set llvm_version        3.2
64    depends_lib-append      port:llvm-${llvm_version}
65}
66
67set makefile "Makefile-133"
68
69if {${os.arch} == "powerpc" || ${os.major} < 9} {
70    # XCode 3.2.6
71    # 127.2 should work for powerpc, but it will require some build fixes.
72    version             97.17
73    revision            2
74    checksums           rmd160  d52df7d7f741c8bedd29cbac73dbb9db992b4795 \
75                        sha256  02bd46af0809eaa415d096d7d41c3e8e7d80f7d8d181840866fb87f036b4e089
76    supported_archs     x86_64 i386 ppc
77
78    set makefile        "Makefile-97"
79
80    patchfiles-delete   ld64-133-no-CrashReporterClient.h.patch ld64-134-PR-36654.patch ld64-134-missing-include.patch
81    patchfiles-append   ld64-97-no-LTO.patch ld64-97-ppc-branch-island.patch
82} elseif {${os.major} < 11} {
83    # XCode 4.2
84    # This was the last ld64 release that supported linking ppc executables.
85    version             127.2
86    revision            6
87    checksums           rmd160  8ee709341549a1944732daef6ebab7ef1acfcc6e \
88                        sha256  97b75547b2bd761306ab3e15ae297f01e7ab9760b922bc657f4ef72e4e052142
89    supported_archs     i386 x86_64
90
91    set makefile        "Makefile-127"
92
93    patchfiles-delete   ld64-133-no-CrashReporterClient.h.patch
94    patchfiles-append   ld64-127-any-cctools.patch
95}
96
97platform darwin 8 {
98    pre-fetch {
99        if {[variant_isset llvm29] || [variant_isset llvm30] || [variant_isset llvm31] || [variant_isset llvm32]} {
100            if {![file exists ${prefix}/bin/llvm-config-mp-${llvm_version}]} {
101                ui_error "You must first install ld64 without llvm support to build llvm.  After llvm is installed, you can reinstall ld64 with the llvm variant."
102                return -code error "You must first install ld64 without llvm support to build llvm.  After llvm is installed, you can reinstall ld64 with the llvm variant."
103            }
104        }
105    }
106
107    post-patch {
108        reinplace "s:-Wl,-exported_symbol,__mh_execute_header::g" \
109            ${worksrcpath}/Makefile
110    }
111}
112
113compiler.blacklist gcc-4.0
114
115# TODO: base should do this: http://trac.macports.org/ticket/32542
116if {[portconfigure::compiler_is_port ${configure.compiler}]} {
117    depends_build-append port:$portconfigure::compiler_name_map(${configure.compiler})
118    depends_skip_archcheck-append $portconfigure::compiler_name_map(${configure.compiler})
119}
120
121post-extract {
122    file copy ${filespath}/${makefile} ${worksrcpath}/Makefile
123}
124
125post-patch {
126    reinplace "s|@@VERSION@@|${version}|g" \
127        ${worksrcpath}/src/ld/Options.cpp
128
129    if {${os.major} < 9} {
130        # No CommonCrypto, use openssl
131        reinplace "s:<CommonCrypto/CommonDigest.h>:<openssl/md5.h>:" \
132            ${worksrcpath}/src/ld/MachOWriterExecutable.hpp
133        reinplace "s:CC_MD5:MD5:" \
134            ${worksrcpath}/src/ld/MachOWriterExecutable.hpp
135    }
136}
137
138configure {
139    system "cd ${worksrcpath} && ${build.cmd} src/ld/configure.h"
140}
141
142build.args \
143    CC="${configure.cc}" \
144    CXX="${configure.cxx}" \
145    OTHER_CPPFLAGS="${configure.cppflags}" \
146    OTHER_CFLAGS="${configure.cflags} [get_canonical_archflags]" \
147    OTHER_CXXFLAGS="${configure.cxxflags} [get_canonical_archflags]" \
148    OTHER_LDFLAGS="${configure.ldflags} [get_canonical_archflags]"
149
150if {${os.major} >= 11} {
151    build.args-append \
152        RC_SUPPORTED_ARCHS="armv6 armv7 i386 x86_64"
153}
154
155destroot.args \
156    PREFIX=${prefix}
157
158pre-build {
159    if {[variant_isset llvm29] || [variant_isset llvm30] || [variant_isset llvm31]  || [variant_isset llvm32]} {
160        build.args-append LLVM_CONFIG=${prefix}/bin/llvm-config-mp-${llvm_version}
161    }
162
163    if {${os.major} < 9} {
164        build.args-append OTHER_LDFLAGS_LD64=-lcrypto
165    }   
166}
167
168post-destroot {
169    # ${prefix}/bin/ld will always use the llvm we built against
170    # ${prefix}/libexec/ld64/ld uses relative linking for use with the llvm ports
171    file mkdir ${destroot}${prefix}/libexec/ld64
172    file copy ${destroot}${prefix}/bin/ld ${destroot}${prefix}/libexec/ld64/ld
173
174    if {[variant_isset llvm29] || [variant_isset llvm30] || [variant_isset llvm31] || [variant_isset llvm32]} {
175        system "install_name_tool -change ${prefix}/libexec/llvm-${llvm_version}/lib/libLTO.dylib \
176                @executable_path/../lib/libLTO.dylib ${destroot}${prefix}/libexec/ld64/ld"
177    }
178}
179
180livecheck.type          regex
181livecheck.regex         "${name}-(\[\\d.\]+)"
Note: See TracBrowser for help on using the repository browser.