source: trunk/dports/lang/llvm-3.3/Portfile @ 102174

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

misc: Update compiler dependency workaround for #32542, see #37817

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 14.1 KB
Line 
1# $Id: Portfile 102174 2013-01-29 07:53:39Z jeremyhu@macports.org $
2
3PortSystem              1.0
4PortGroup select        1.0
5
6set llvm_version        3.3
7name                    llvm-${llvm_version}
8subport                 clang-${llvm_version} {}
9set suffix              mp-${llvm_version}
10set sub_prefix          ${prefix}/libexec/llvm-${llvm_version}
11dist_subdir             llvm
12categories              lang
13platforms               darwin
14license                 NCSA
15maintainers             jeremyhu
16
17if {${subport} == "llvm-${llvm_version}"} {
18    homepage            http://llvm.org/
19    description         llvm is a next generation compiler infrastructure
20    long_description    The LLVM Core libraries provide a modern source- and \
21                        target-independent optimizer, along with code \
22                        generation support for many popular CPUs (as well as \
23                        some less common ones!) These libraries are built \
24                        around a well specified code representation known as \
25                        the LLVM intermediate representation ("LLVM IR").
26
27    depends_lib         port:libffi
28    depends_run         bin:perl:perl5 port:llvm_select
29} elseif {${subport} == "clang-${llvm_version}"} {
30    homepage            http://clang.llvm.org/
31    description         C, C++, Objective C and Objective C++ compiler
32    long_description    Clang is an "LLVM native" C/C++/Objective-C compiler, \
33                        which aims to deliver amazingly fast compiles (e.g. \
34                        about 3x faster than GCC when compiling Objective-C \
35                        code in a debug configuration), extremely useful error \
36                        and warning messages and to provide a platform for \
37                        building great source level tools. The included Clang \
38                        Static Analyzer is a tool automatically finds bugs in \
39                        your code, and is a great example of the sort of tool \
40                        that can be built using the Clang frontend as a \
41                        library to parse C/C++ code.
42
43    depends_lib         port:llvm-${llvm_version} port:libffi
44    depends_run         port:clang_select port:ld64
45    depends_extract     bin:svn:subversion
46    depends_skip_archcheck-append ld64 subversion
47
48    default_variants    +analyzer
49}
50
51fetch.type              svn
52svn.revision            173279
53
54set compiler_rt_rev     ${svn.revision}
55set libcxx_rev          ${svn.revision}
56version                 ${llvm_version}-r${svn.revision}
57worksrcdir              trunk
58svn.url                 http://llvm.org/svn/llvm-project/llvm/trunk
59#worksrcdir              release_33
60#svn.url                 http://llvm.org/svn/llvm-project/llvm/branches/release_33
61default_variants-append +assertions
62
63#version                 ${llvm_version}
64#set compiler_rt_rev     150641
65#set libcxx_rev          ${compiler_rt_rev}
66#epoch                   1
67#master_sites            http://llvm.org/releases/${version}
68#extract.suffix          .tar.gz
69#distfiles               llvm-${version}.src${extract.suffix}
70#worksrcdir              llvm-${version}.src
71
72patchfiles      install_target.patch \
73                tiger.patch \
74                tiger-shlib.patch
75
76patch.pre_args  -p1
77
78if {${subport} == "clang-${llvm_version}"} {
79    if {${distfiles} != ""} {
80        distfiles-append     clang-${version}.src${extract.suffix} compiler-rt-${version}.src${extract.suffix}
81    }
82
83    patchfiles-append    tiger-shlib-clang.patch tiger-libclang.patch scan-build-PR-35006.patch \
84                         0001-Comment-out-SL-cctools-workaround.patch
85
86    build.target        clang-only
87    destroot.target     install-clang
88}
89
90build.env-append        VERBOSE=1 REQUIRE_RTTI=1
91destroot.env-append     VERBOSE=1 REQUIRE_RTTI=1
92configure.cppflags
93configure.ldflags
94configure.pre_args-delete --prefix=${prefix}
95configure.args          --enable-bindings=none --enable-libffi --enable-shared --enable-jit \
96                        --enable-optimized --disable-profiling --enable-pic \
97                        --enable-debug-symbols --disable-debug-runtime \
98                        --prefix="${sub_prefix}"
99
100if {${subport} == "llvm-${llvm_version}"} {
101    select.group        llvm
102    select.file         ${filespath}/mp-${subport}
103} elseif {${subport} == "clang-${llvm_version}"} {
104    select.group        clang
105    select.file         ${filespath}/mp-${subport}
106}
107
108# g++-4.0 fails to build some of the newer C++ for ppc
109# Intel looks ok, but I prefer using gcc-4.2 for consistency
110compiler.blacklist gcc-4.0
111
112# TODO: base should do this: http://trac.macports.org/ticket/32542
113if {[info exists portconfigure::compiler_name_map(${configure.compiler})]} {
114    depends_build-append port:$portconfigure::compiler_name_map(${configure.compiler})
115
116    # base 2.1.x ignores the argument and just use ${configure.compiler}
117    if {[portconfigure::arch_flag_supported ${configure.compiler}]} {
118        depends_skip_archcheck-append $portconfigure::compiler_name_map(${configure.compiler})
119    }
120
121    if {[string match macports-gcc* ${configure.compiler}]} {
122        depends_lib-append port:$portconfigure::compiler_name_map(${configure.compiler})
123    }
124}
125
126variant universal {
127    build.env-append \
128        UNIVERSAL=1 \
129        UNIVERSAL_ARCH="[get_canonical_archs]"
130    destroot.env-append \
131        UNIVERSAL=1 \
132        UNIVERSAL_ARCH="[get_canonical_archs]"
133
134    post-extract {
135        # workaround a bug in Apple's shipped gcc driver-driver, patched in
136        # ours with driverdriver-num_infiles.patch
137        if {${configure.compiler} == "gcc-4.0" ||
138            ${configure.compiler} == "gcc-4.2" ||
139            ${configure.compiler} == "llvm-gcc-4.2"} {
140            system "echo \"static int ___ignoreme;\" > ${worksrcpath}/tools/llvm-shlib/ignore.c"
141        }
142    }
143}
144
145variant assertions description "Enable assertions for error detection (has performance impacts, especially on JIT)" {
146    configure.args-append --enable-assertions
147}
148
149platform darwin {
150    if {${build_arch} == "i386" } {
151        configure.pre_args-append --build=i686-apple-darwin${os.major}
152    } elseif {${build_arch} == "ppc" } {
153        configure.pre_args-append --build=powerpc-apple-darwin${os.major}
154    } elseif {${build_arch} == "ppc64" } {
155        configure.pre_args-append --build=powerpc64-apple-darwin${os.major}
156    } else {
157        configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
158    }
159
160    if {[string match "*ppc*" [get_canonical_archs]]} {
161        # http://trac.macports.org/ticket/33987
162        configure.args-append --with-optimize-option=-Os
163    }
164
165    if {${subport} == "clang-${llvm_version}" && ${os.major} <= 9} {
166        patchfiles-append leopard-no-asan.patch
167    }
168}
169
170platform darwin 8 {
171    # Tiger's DevTools make has issues with the nested ifs in compiler-rt
172    depends_run-append      port:gmake
173    depends_skip_archcheck-append gmake
174    build.cmd               ${prefix}/bin/gmake
175    destroot.cmd            ${prefix}/bin/gmake
176
177    post-configure {
178        reinplace "/^RPATH/s/=.*/=/" ${worksrcpath}/Makefile.config
179    }
180}
181
182post-extract {
183    if {${subport} == "clang-${llvm_version}"} {
184        system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/trunk clang"
185        #system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/branches/release_33 clang"
186        #file rename ${workpath}/clang-${llvm_version}.src ${worksrcpath}/tools/clang
187
188        system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt"
189        #system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/branches/release_33 compiler-rt"
190        #file rename ${workpath}/compiler-rt-${llvm_version}.src ${worksrcpath}/projects/compiler-rt
191
192        system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/trunk libcxx"
193        #system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/branches/release_33 libcxx"
194        #file rename ${workpath}/libcxx-${llvm_version}.src ${worksrcpath}/projects/libcxx
195    }
196}
197
198post-patch {
199    if {${subport} == "clang-${llvm_version}"} {
200        # http://trac.macports.org/ticket/33272
201        if {![variant_isset arm_runtime]} {
202            reinplace {/^SubDirs/ s/arm//} ${worksrcpath}/projects/compiler-rt/lib/Makefile.mk
203            reinplace {/^UniversalArchs/ s/arm[^ )]* *//g} ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk
204
205            reinplace {/cc_kext_ios5/ s/^/#/} ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk
206            reinplace {s/cc_kext_ios5.a//} ${worksrcpath}/tools/clang/runtime/compiler-rt/Makefile
207        }
208    }
209}
210
211post-destroot {
212    file mkdir ${destroot}${prefix}/share/doc
213    file rename ${destroot}${sub_prefix}/docs/llvm ${destroot}${prefix}/share/doc/${subport}
214
215    foreach bin [glob ${destroot}${sub_prefix}/bin/*] {
216        set bin_filename [string map "${sub_prefix} ${prefix}" ${bin}]-${suffix}
217        set exec_path [string map "${destroot}${sub_prefix} ${sub_prefix}" ${bin}]
218
219        xinstall -m 755 "${filespath}/llvm-bin" "${bin_filename}"
220        reinplace "s:EXEC_PATH:${exec_path}:" "${bin_filename}"
221    }
222
223    if {${subport} == "llvm-${llvm_version}"} {
224        # r156389 (a5d2435409858728970202226d0bbbee508fe408) temporarilary removed llvm man pages
225        #foreach man [glob ${destroot}${sub_prefix}/share/man/man1/*.1] {
226        #    set basename [string map "${destroot}${sub_prefix}/share/man/man1/ {}" ${man}]
227        #    file rename ${man} ${destroot}${prefix}/share/man/man1/[string map ".1 -${suffix}.1" ${basename}]
228        #}
229
230        foreach liba [glob ${destroot}${sub_prefix}/lib/*dylib] {
231            set liba_nodr [string map "${destroot} {}" ${liba}]
232            system "install_name_tool -id ${liba_nodr} ${liba}"
233
234            foreach libb [glob ${destroot}${sub_prefix}/lib/*dylib] {
235                set libb_base [string map "${destroot}${sub_prefix}/lib/ {}" ${libb}]
236                set libb_nodr [string map "${destroot} {}" ${libb}]
237
238                system "install_name_tool -change @executable_path/../lib/${libb_base} ${libb_nodr} ${liba}"
239            }
240        }
241    } elseif {${subport} == "clang-${llvm_version}"} {
242        system "ditto ${worksrcpath}/projects/libcxx/include ${destroot}${sub_prefix}/lib/c++/v1"
243
244        # http://trac.macports.org/ticket/33207
245        ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
246
247        system "install_name_tool -id ${sub_prefix}/lib/libclang.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
248        system "install_name_tool -change @executable_path/../lib/libLLVM-${llvm_version}svn.dylib ${sub_prefix}/lib/libLLVM-${llvm_version}svn.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
249        system "install_name_tool -change @executable_path/../lib/libLLVM-${llvm_version}.dylib ${sub_prefix}/lib/libLLVM-${llvm_version}.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
250    }
251}
252
253if {${subport} == "llvm-${llvm_version}"} {
254    variant ocaml description {Enable generation of OCaml binding} {
255        depends_lib-append   port:ocaml
256
257        configure.args-delete --enable-bindings=none
258        configure.args-append --enable-bindings=ocaml
259
260        destroot.args-append  OVERRIDE_libdir=${sub_prefix}/lib
261    }
262} elseif {${subport} == "clang-${llvm_version}"} {
263    variant arm_runtime description {Build and install the arm runtime for iOS development (requires iOS SDK)} {}
264
265    set pythonver ""
266    set pythonverdot ""
267
268    if {![variant_isset python25] && ![variant_isset python26]} {
269        default_variants +python27
270    }
271
272    variant python25 conflicts python26 python27 description {Use python 2.5} {
273        set pythonver 25
274        set pythonverdot 2.5
275    }
276
277    variant python26 conflicts python25 python27 description {Use python 2.6} {
278        set pythonver 26
279        set pythonverdot 2.6
280    }
281
282    variant python27 conflicts python25 python26 description {Use python 2.7} {
283        set pythonver 27
284        set pythonverdot 2.7
285    }
286
287    variant analyzer description {Install clang static analyzer} {
288        if {[string equal "${pythonver}" ""]} {
289            ui_error "You mush select a python variant to use the clang static analyzer (+analyzer)"
290            error "Invalid variant combination"
291        }
292
293        depends_run-append port:perl5 port:python${pythonver}
294
295        post-patch {
296            reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5|g" \
297                ${worksrcpath}/tools/clang/tools/scan-build/ccc-analyzer \
298                ${worksrcpath}/tools/clang/tools/scan-build/c++-analyzer \
299                ${worksrcpath}/tools/clang/tools/scan-build/scan-build
300            reinplace "s|/usr/bin/env python|${prefix}/bin/python${pythonverdot}|g" \
301                ${worksrcpath}/tools/clang/tools/scan-build/set-xcode-analyzer \
302                ${worksrcpath}/tools/clang/tools/scan-view/scan-view
303        }
304
305        post-destroot {
306            file mkdir ${destroot}${sub_prefix}/libexec
307            file copy ${worksrcpath}/tools/clang/tools/scan-build ${destroot}${sub_prefix}/libexec/scan-build
308            file copy ${worksrcpath}/tools/clang/tools/scan-view ${destroot}${sub_prefix}/libexec/scan-view
309
310            file delete -force ${destroot}${sub_prefix}/libexec/scan-build/.svn
311            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/.svn
312            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/Resources/.svn
313
314            ln -s ${sub_prefix}/libexec/scan-build/scan-build ${destroot}${sub_prefix}/bin/scan-build
315            ln -s ${sub_prefix}/libexec/scan-view/scan-view ${destroot}${sub_prefix}/bin/scan-view
316            ln -s ${sub_prefix}/bin ${destroot}${sub_prefix}/libexec/scan-build/bin
317
318            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-build-${suffix}"
319            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-build:" "${destroot}${prefix}/bin/scan-build-${suffix}"
320
321            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-view-${suffix}"
322            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-view:" "${destroot}${prefix}/bin/scan-view-${suffix}"
323        }
324    }
325}
326
327livecheck.type          none
Note: See TracBrowser for help on using the repository browser.