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

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

ld64: Fix logic for ppc branch islands (#37300).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.8 KB
Line 
1# $Id: Portfile 100514 2012-12-14 16:57:41Z 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
11set llvm_version        3.0
12categories              devel
13platforms               darwin
14maintainers             mfeiri 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
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
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            5
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
113if {${configure.compiler} == "gcc-4.0"} {
114    configure.compiler gcc-4.2
115    if {![file exists ${configure.cc}]} {
116        depends_build-append port:apple-gcc42
117        depends_skip_archcheck-append apple-gcc42
118        configure.compiler apple-gcc-4.2
119    }
120}
121
122post-extract {
123    file copy ${filespath}/${makefile} ${worksrcpath}/Makefile
124}
125
126post-patch {
127    reinplace "s|@@VERSION@@|${version}|g" \
128        ${worksrcpath}/src/ld/Options.cpp
129
130    if {${os.major} < 9} {
131        # No CommonCrypto, use openssl
132        reinplace "s:<CommonCrypto/CommonDigest.h>:<openssl/md5.h>:" \
133            ${worksrcpath}/src/ld/MachOWriterExecutable.hpp
134        reinplace "s:CC_MD5:MD5:" \
135            ${worksrcpath}/src/ld/MachOWriterExecutable.hpp
136    }
137}
138
139configure {
140    system "cd ${worksrcpath} && ${build.cmd} src/ld/configure.h"
141}
142
143build.args \
144    CC="${configure.cc}" \
145    CXX="${configure.cxx}" \
146    OTHER_CPPFLAGS="${configure.cppflags}" \
147    OTHER_CFLAGS="${configure.cflags} [get_canonical_archflags]" \
148    OTHER_CXXFLAGS="${configure.cxxflags} [get_canonical_archflags]" \
149    OTHER_LDFLAGS="${configure.ldflags} [get_canonical_archflags]"
150
151if {${os.major} >= 11} {
152    build.args-append \
153        RC_SUPPORTED_ARCHS="armv6 armv7 i386 x86_64"
154}
155
156destroot.args \
157    PREFIX=${prefix}
158
159pre-build {
160    if {[variant_isset llvm29] || [variant_isset llvm30] || [variant_isset llvm31]  || [variant_isset llvm32]} {
161        build.args-append LLVM_CONFIG=${prefix}/bin/llvm-config-mp-${llvm_version}
162    }
163
164    if {${os.major} < 9} {
165        build.args-append OTHER_LDFLAGS_LD64=-lcrypto
166    }   
167}
168
169post-destroot {
170    # ${prefix}/bin/ld will always use the llvm we built against
171    # ${prefix}/libexec/ld64/ld uses relative linking for use with the llvm ports
172    file mkdir ${destroot}${prefix}/libexec/ld64
173    file copy ${destroot}${prefix}/bin/ld ${destroot}${prefix}/libexec/ld64/ld
174
175    if {[variant_isset llvm29] || [variant_isset llvm30] || [variant_isset llvm31] || [variant_isset llvm32]} {
176        system "install_name_tool -change ${prefix}/libexec/llvm-${llvm_version}/lib/libLTO.dylib \
177                @executable_path/../lib/libLTO.dylib ${destroot}${prefix}/libexec/ld64/ld"
178    }
179}
180
181livecheck.type          regex
182livecheck.regex         "${name}-(\[\\d.\]+)"
Note: See TracBrowser for help on using the repository browser.