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