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

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

ld64: Revbump to build with newer cctools-headers and dyld-headers. See #36026

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