source: trunk/dports/devel/cctools/Portfile

Last change on this file was 153814, checked in by jeremyhu@…, 12 months ago

cctools, ld64: Default to +llvm34 on Lion (cf #46897)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.4 KB
Line 
1# $Id: Portfile 153814 2016-10-12 09:20:28Z ryandesign@macports.org $
2
3PortSystem              1.0
4
5name                    cctools
6# Xcode 7.3.1
7version                 886
8revision                6
9set ld64_version        264.3.102
10categories              devel
11platforms               darwin
12maintainers             jeremyhu openmaintainer
13license                 {APSL-2 GPL-2+}
14installs_libs           no
15description             Compiler Tools for Mac OS X and Darwin
16long_description        A set of essential tools to support development \
17                        on Mac OS X and Darwin. Conceptually similar \
18                        similar to binutils on other platforms.
19
20homepage                http://opensource.apple.com/source/${name}/
21master_sites            http://opensource.apple.com/tarballs/${name} \
22                        http://opensource.apple.com/tarballs/ld64
23
24distfiles               ld64-${ld64_version}.tar.gz ${name}-${version}.tar.gz
25
26checksums               ld64-264.3.102.tar.gz \
27                        rmd160  c8169a8dd591989abdf45c0834397891ec72b458 \
28                        sha256  307f73678a3e5c9ed4d1bcf77da7399d84efac32916c5df6cd477c3b5c36f953 \
29                        cctools-886.tar.gz \
30                        rmd160  ecd54d8b4ec062909044c003b7e5bd638729cf57 \
31                        sha256  f3a4fa7dad4a54d862b1d9f48e3dfb25fc532c9cf46a041cf8134694328a8878
32
33depends_build           port:libunwind-headers
34
35patchfiles \
36    cctools-829-lto.patch \
37    PR-37520.patch \
38    cctools-839-static-dis_info.patch \
39    PR-12400897.patch \
40    cctools-862-prunetrie.patch \
41    not-clang.patch
42
43variant universal {}
44
45if {${os.major} < 11} {
46    patchfiles-append snowleopard-strnlen.patch
47}
48
49set all_llvm_variants {llvm38 llvm39 llvmdev}
50if {${os.major} < 10} {
51    lappend all_llvm_variants llvm33
52}
53if {${os.major} < 12} {
54    lappend all_llvm_variants llvm34
55}
56array set llvm_variant_version {llvm33 3.3 llvm34 3.4 llvm38 3.8 llvm39 3.9 llvmdev devel}
57set llvm_version {}
58
59foreach variantname $all_llvm_variants {
60    set this_llvm_version $llvm_variant_version($variantname)
61    variant $variantname conflicts {*}[ldelete $all_llvm_variants $variantname] description "Use llvm-${this_llvm_version} for libLTO, llvm-mc, llvm-size, and llvm-nm" "
62        set llvm_version        $this_llvm_version
63        depends_lib-append      port:llvm-${this_llvm_version}
64    "
65}
66
67proc some_llvm_variant_set {} {
68    global all_llvm_variants
69    foreach variantname $all_llvm_variants {
70        if {[variant_isset $variantname]} {
71            return yes
72        }
73    }
74    return no
75}
76
77if {![some_llvm_variant_set]} {
78    if {${os.major} == 10 || ${os.major} == 11} {
79        default_variants +llvm34
80    } elseif {${os.major} == 9} {
81        # Using llvm-3.3 to break dependency cycle (https://trac.macports.org/ticket/52091)
82        default_variants +llvm33
83    }
84
85    if {![some_llvm_variant_set] && ${os.major} >= 9} {
86        default_variants +llvm38
87    }
88}
89
90set has_llvm_nm true
91set has_llvm_size true
92
93if {${llvm_version} eq "3.3" || ${llvm_version} eq "3.4" || ${llvm_version} eq ""} {
94    set has_llvm_nm         false
95    set has_llvm_size       false
96}
97
98use_configure           no
99destroot.args           RAW_DSTROOT=${destroot} DSTROOT=${destroot}${prefix} RC_ProjectSourceVersion=${version}
100
101post-extract {
102    file copy ${worksrcpath}/../ld64-${ld64_version}/src/other/PruneTrie.cpp ${worksrcpath}/misc
103    system "touch ${worksrcpath}/../ld64-${ld64_version}/src/abstraction/configure.h"
104}
105
106post-patch {
107    # We don't want to build cctools ld.  We want to use ld64
108    reinplace "/^SUBDIRS_32/s/ld//" ${worksrcpath}/Makefile
109    reinplace "/^COMMON_SUBDIRS/s/ ld / /" ${worksrcpath}/Makefile
110
111    # Use our chosen version of llvm
112    if {${llvm_version} ne ""} {
113        reinplace "s:\"llvm-mc\":\"llvm-mc-mp-${llvm_version}\":" ${worksrcpath}/as/driver.c
114        reinplace "s:@@LLVM_LIBDIR@@:${prefix}/libexec/llvm-${llvm_version}/lib:" ${worksrcpath}/libstuff/lto.c
115    }
116
117    foreach file [glob ${worksrcpath}/{*/,}Makefile] {
118        reinplace "s:/usr/local:@PREFIX@:g" ${file}
119        reinplace "s:/usr:@PREFIX@:g" ${file}
120        reinplace "s:@PREFIX@:${prefix}:g" ${file}
121        reinplace "s:${prefix}/efi:${prefix}:g" ${file}
122        reinplace "s:/Developer${prefix}:${prefix}:g" ${file}
123        reinplace "s:${prefix}/man:${prefix}/share/man:g" ${file}
124
125        # Don't strip installed binaries
126        reinplace "s:\\(install .*\\)-s :\\1:g" ${file}
127
128        if {${os.major} < 10} {
129            reinplace "s:${prefix}/bin/mig:/usr/bin/mig:g" ${file}
130        }
131    }
132}
133
134use_configure   no
135use_parallel_build  yes
136
137# https://trac.macports.org/ticket/43745
138configure.cflags-append -std=gnu99
139
140build.target    all
141
142set cxx_stdlibflags {}
143if {[string match *clang* ${configure.cxx}]} {
144    set cxx_stdlibflags -stdlib=${configure.cxx_stdlib}
145}
146
147configure.cppflags-append -I${worksrcpath}/../ld64-${ld64_version}/src/abstraction -I${worksrcpath}/../ld64-${ld64_version}/src/other -I${worksrcpath}/include
148
149pre-build {
150    build.args-append \
151        RC_ProjectSourceVersion=${version} \
152        USE_DEPENDENCY_FILE=NO \
153        BUILD_DYLIBS=NO \
154        CC="${configure.cc} ${configure.cflags}" \
155        CXX="${configure.cxx} ${configure.cxxflags}" \
156        CXXLIB="${cxx_stdlibflags}" \
157        TRIE=-DTRIE_SUPPORT \
158        RC_ARCHS="[get_canonical_archs]" \
159        SDK="${configure.cppflags}"
160
161    if {${llvm_version} ne ""} {
162        build.args-append \
163            LTO=-DLTO_SUPPORT \
164            RC_CFLAGS="[get_canonical_archflags] `llvm-config-mp-${llvm_version} --cflags`" \
165            LLVM_MC="llvm-mc-mp-${llvm_version}"
166    } else {
167        build.args-append \
168            LTO= \
169            RC_CFLAGS="[get_canonical_archflags]"
170    }
171}
172
173pre-destroot {
174    destroot.args-append \
175        RC_ProjectSourceVersion=${version} \
176        USE_DEPENDENCY_FILE=NO \
177        BUILD_DYLIBS=NO \
178        CC="${configure.cc} ${configure.cflags}" \
179        CXX="${configure.cxx} ${configure.cxxflags}" \
180        CXXLIB="${cxx_stdlibflags}" \
181        TRIE=-DTRIE_SUPPORT \
182        RC_ARCHS="[get_canonical_archs]" \
183        SDK="${configure.cppflags}"
184
185    if {${llvm_version} ne ""} {
186        destroot.args-append \
187            LTO=-DLTO_SUPPORT \
188            RC_CFLAGS="[get_canonical_archflags] `llvm-config-mp-${llvm_version} --cflags`" \
189            LLVM_MC="llvm-mc-mp-${llvm_version}"
190    } else {
191        destroot.args-append \
192            LTO= \
193            RC_CFLAGS="[get_canonical_archflags]"
194    }
195}
196
197platform macosx {
198    build.args-append RC_OS="macos"
199    destroot.args-append RC_OS="macos"
200}
201
202destroot.target install_tools
203destroot.args-append DSTROOT=${destroot}
204post-destroot {
205    file delete -force ${destroot}${prefix}/OpenSourceLicenses
206    file delete -force ${destroot}${prefix}/OpenSourceVersions
207    file delete -force ${destroot}${prefix}/RelNotes
208
209    if {${os.major} < 10} {
210        file delete -force ${destroot}/Developer
211    }
212
213    # Provided by port:cctools-headers
214    file delete -force ${destroot}${prefix}/include
215
216    file delete -force ${destroot}${prefix}/bin/nm
217    if {${has_llvm_nm}} {
218        ln -s llvm-nm-mp-${llvm_version} ${destroot}${prefix}/bin/nm
219    } else {
220        ln -s nm-classic ${destroot}${prefix}/bin/nm
221    }
222
223    file delete -force ${destroot}${prefix}/bin/size
224    if {${has_llvm_size}} {
225        ln -s llvm-size-mp-${llvm_version} ${destroot}${prefix}/bin/size
226    } else {
227        ln -s size-classic ${destroot}${prefix}/bin/size
228    }
229}
230
231livecheck.type          regex
232livecheck.regex         "${name}-(\[\\d.\]+)"
Note: See TracBrowser for help on using the repository browser.