source: trunk/dports/lang/llvm-2.9/Portfile @ 102101

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

llvm*: Use compiler.blacklist

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 14.4 KB
Line 
1# $Id: Portfile 102101 2013-01-28 05:32:14Z 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 {[portconfigure::compiler_is_port ${configure.compiler}]} {
123    depends_build-append port:$portconfigure::compiler_name_map(${configure.compiler}) port:ld64 port:cctools
124    depends_skip_archcheck-append $portconfigure::compiler_name_map(${configure.compiler}) ld64 cctools
125}
126
127variant universal {
128    build.env-append \
129        UNIVERSAL=1 \
130        UNIVERSAL_ARCH="[get_canonical_archs]"
131    destroot.env-append \
132        UNIVERSAL=1 \
133        UNIVERSAL_ARCH="[get_canonical_archs]"
134
135    post-extract {
136        # workaround a bug in Apple's shipped gcc driver-driver, patched in
137        # ours with driverdriver-num_infiles.patch
138        if {${configure.compiler} == "gcc-4.0" ||
139            ${configure.compiler} == "gcc-4.2" ||
140            ${configure.compiler} == "llvm-gcc-4.2"} {
141            system "echo \"static int ___ignoreme;\" > ${worksrcpath}/tools/llvm-shlib/ignore.c"
142        }
143    }
144}
145
146variant assertions description "Enable assertions for error detection (has performance impacts, especially on JIT)" {
147    configure.args-append --enable-assertions
148}
149
150platform darwin {
151    if {${build_arch} == "i386" } {
152        configure.pre_args-append --build=i686-apple-darwin${os.major}
153    } elseif {${build_arch} == "ppc" } {
154        configure.pre_args-append --build=powerpc-apple-darwin${os.major}
155    } elseif {${build_arch} == "ppc64" } {
156        configure.pre_args-append --build=powerpc64-apple-darwin${os.major}
157    } else {
158        configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
159    }
160
161    if {[string match "*ppc*" [get_canonical_archs]]} {
162        # http://trac.macports.org/ticket/33987
163        configure.args-append --with-optimize-option=-Os
164    }
165}
166
167platform darwin 8 {
168    # Tiger's DevTools make has issues with the nested ifs in compiler-rt
169    depends_run-append      port:gmake
170    depends_skip_archcheck-append gmake
171    build.cmd               ${prefix}/bin/gmake
172    destroot.cmd            ${prefix}/bin/gmake
173
174    post-configure {
175        reinplace "/^RPATH/s/=.*/=/" ${worksrcpath}/Makefile.config
176    }
177}
178
179post-extract {
180    if {${subport} == "clang-${llvm_version}"} {
181        #system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/trunk clang"
182        #system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/branches/release_30 clang"
183        file rename ${workpath}/clang-${llvm_version} ${worksrcpath}/tools/clang
184
185        system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt"
186        #system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/branches/release_30 compiler-rt"
187        #file rename ${workpath}/compiler-rt-${llvm_version} ${worksrcpath}/projects/compiler-rt
188
189        #system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/trunk libcxx"
190        #system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/branches/release_30 libcxx"
191        #file rename ${workpath}/libcxx-${llvm_version} ${worksrcpath}/projects/libcxx
192    }
193}
194
195post-patch {
196    if {${subport} == "llvm-${llvm_version}"} {
197        # http://trac.macports.org/ticket/33207
198        reinplace "/LLVMINTERP/s/-lli/-lli-${suffix}/" ${worksrcpath}/tools/llvm-ld/llvm-ld.cpp
199    } elseif {${subport} == "clang-${llvm_version}"} {
200        # http://trac.macports.org/ticket/33272
201        if {![variant_isset arm_runtime]} {
202            reinplace {/^RuntimeLibrary.darwin.Configs/ s/arm[^ ]* *//g} ${worksrcpath}/tools/clang/runtime/Makefile
203            reinplace {/^SubDirs/ s/arm//} ${worksrcpath}/projects/compiler-rt/lib/Makefile.mk
204            reinplace {/^UniversalArchs/ s/arm[^ )]* *//g} ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk
205            reinplace {/^Configs/ s/arm[^ )]* *//g} ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk
206        }
207    }
208}
209
210post-destroot {
211    file mkdir ${destroot}${prefix}/share/doc
212    file rename ${destroot}${sub_prefix}/docs/llvm ${destroot}${prefix}/share/doc/${subport}
213
214    foreach bin [glob ${destroot}${sub_prefix}/bin/*] {
215        set bin_filename [string map "${sub_prefix} ${prefix}" ${bin}]-${suffix}
216        set exec_path [string map "${destroot}${sub_prefix} ${sub_prefix}" ${bin}]
217
218        xinstall -m 755 "${filespath}/llvm-bin" "${bin_filename}"
219        reinplace "s:EXEC_PATH:${exec_path}:" "${bin_filename}"
220    }
221
222    if {${subport} == "llvm-${llvm_version}"} {
223        foreach man [glob ${destroot}${sub_prefix}/share/man/man1/*.1] {
224            set basename [string map "${destroot}${sub_prefix}/share/man/man1/ {}" ${man}]
225            file rename ${man} ${destroot}${prefix}/share/man/man1/[string map ".1 -${suffix}.1" ${basename}]
226        }
227
228        foreach liba [glob ${destroot}${sub_prefix}/lib/*dylib] {
229            set liba_nodr [string map "${destroot} {}" ${liba}]
230            system "install_name_tool -id ${liba_nodr} ${liba}"
231
232            foreach libb [glob ${destroot}${sub_prefix}/lib/*dylib] {
233                set libb_base [string map "${destroot}${sub_prefix}/lib/ {}" ${libb}]
234                set libb_nodr [string map "${destroot} {}" ${libb}]
235
236                system "install_name_tool -change @executable_path/../lib/${libb_base} ${libb_nodr} ${liba}"
237            }
238        }
239    } elseif {${subport} == "clang-${llvm_version}"} {
240        #system "ditto ${worksrcpath}/projects/libcxx/include ${destroot}${sub_prefix}/lib/c++/v1"
241
242        # http://trac.macports.org/ticket/33207
243        ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
244
245        system "install_name_tool -id ${sub_prefix}/lib/libclang.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
246        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"
247        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"
248    }
249}
250
251if {${subport} == "llvm-${llvm_version}"} {
252    variant ocaml description {Enable generation of OCaml binding} {
253        depends_lib-append   port:ocaml
254
255        configure.args-delete --enable-bindings=none
256        configure.args-append --enable-bindings=ocaml
257
258        destroot.args-append  OVERRIDE_libdir=${sub_prefix}/lib
259    }
260} elseif {${subport} == "clang-${llvm_version}"} {
261    variant arm_runtime description {Build and install the arm runtime for iOS development (requires iOS SDK)} {}
262
263    set pythonver ""
264    set pythonverdot ""
265
266    if {![variant_isset python25] && ![variant_isset python26]} {
267        default_variants +python27
268    }
269
270    variant python25 conflicts python26 python27 description {Use python 2.5} {
271        set pythonver 25
272        set pythonverdot 2.5
273    }
274
275    variant python26 conflicts python25 python27 description {Use python 2.6} {
276        set pythonver 26
277        set pythonverdot 2.6
278    }
279
280    variant python27 conflicts python25 python26 description {Use python 2.7} {
281        set pythonver 27
282        set pythonverdot 2.7
283    }
284
285    variant analyzer description {Install clang static analyzer} {
286        if {[string equal "${pythonver}" ""]} {
287            ui_error "You mush select a python variant to use the clang static analyzer (+analyzer)"
288            error "Invalid variant combination"
289        }
290
291        depends_run-append port:perl5 port:python${pythonver}
292
293        post-patch {
294            reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5|g" \
295                ${worksrcpath}/tools/clang/tools/scan-build/ccc-analyzer \
296                ${worksrcpath}/tools/clang/tools/scan-build/c++-analyzer \
297                ${worksrcpath}/tools/clang/tools/scan-build/scan-build
298            reinplace "s|/usr/bin/env python|${prefix}/bin/python${pythonverdot}|g" \
299                ${worksrcpath}/tools/clang/tools/scan-build/set-xcode-analyzer \
300                ${worksrcpath}/tools/clang/tools/scan-view/scan-view
301        }
302
303        post-destroot {
304            file mkdir ${destroot}${sub_prefix}/libexec
305            file copy ${worksrcpath}/tools/clang/tools/scan-build ${destroot}${sub_prefix}/libexec/scan-build
306            file copy ${worksrcpath}/tools/clang/tools/scan-view ${destroot}${sub_prefix}/libexec/scan-view
307
308            file delete -force ${destroot}${sub_prefix}/libexec/scan-build/.svn
309            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/.svn
310            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/Resources/.svn
311
312            ln -s ${sub_prefix}/libexec/scan-build/scan-build ${destroot}${sub_prefix}/bin/scan-build
313            ln -s ${sub_prefix}/libexec/scan-view/scan-view ${destroot}${sub_prefix}/bin/scan-view
314            ln -s ${sub_prefix}/bin ${destroot}${sub_prefix}/libexec/scan-build/bin
315
316            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-build-${suffix}"
317            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-build:" "${destroot}${prefix}/bin/scan-build-${suffix}"
318
319            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-view-${suffix}"
320            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-view:" "${destroot}${prefix}/bin/scan-view-${suffix}"
321        }
322    }
323}
324
325livecheck.type          none
Note: See TracBrowser for help on using the repository browser.