source: trunk/dports/lang/llvm-3.1/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.8 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.1
7revision                6
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     156798
65set libcxx_rev          ${compiler_rt_rev}
66epoch                   1
67master_sites            http://llvm.org/releases/${version}
68extract.suffix          .tar.gz
69distfiles               llvm-${version}.src${extract.suffix}
70worksrcdir              llvm-${version}.src
71
72checksums               llvm-${version}.src${extract.suffix} \
73                        sha1    234c96e73ef81aec9a54da92fc2a9024d653b059 \
74                        rmd160  ceb0ef36ab6109da7a8568b04de759752dbee5a7 \
75                        sha256  1ea05135197b5400c1f88d00ff280d775ce778f8f9ea042e25a1e1e734a4b9ab \
76                        clang-${version}.src${extract.suffix} \
77                        sha1    19f33b187a50d22fda2a6f9ed989699a9a9efd62 \
78                        rmd160  5ae09d3d69d4f1e50e07f6bf3474da96e6a84feb \
79                        sha256  ff63e215dcd3e2838ffdea38502f8d35bab17e487f3c3799579961e452d5a786 \
80                        compiler-rt-${version}.src${extract.suffix} \
81                        sha1    62b7646eee6c81f3078ea398fee160b264b5bd84 \
82                        rmd160  c09239db5e798396b34d98f3ffdb9b4f2456b84e \
83                        sha256  1bd4624e7465b05ea713198f19c1c235bae2d35a411c15a4648300bc74294f5c
84
85patchfiles      install_target.patch \
86                tiger.patch \
87                tiger-shlib.patch
88
89patch.pre_args  -p1
90
91if {${subport} == "clang-${llvm_version}"} {
92    if {${distfiles} != ""} {
93        distfiles-append     clang-${version}.src${extract.suffix} compiler-rt-${version}.src${extract.suffix}
94    }
95
96    patchfiles-append    tiger-shlib-clang.patch tiger-libclang.patch scan-build-PR-35006.patch
97
98    build.target        clang-only
99    destroot.target     install-clang
100}
101
102build.env-append        VERBOSE=1 REQUIRE_RTTI=1
103destroot.env-append     VERBOSE=1 REQUIRE_RTTI=1
104configure.cppflags
105configure.ldflags
106configure.pre_args-delete --prefix=${prefix}
107configure.args          --enable-bindings=none --enable-libffi --enable-shared --enable-jit \
108                        --enable-optimized --disable-profiling --enable-pic \
109                        --enable-debug-symbols --disable-debug-runtime \
110                        --prefix="${sub_prefix}"
111
112if {${subport} == "llvm-${llvm_version}"} {
113    select.group        llvm
114    select.file         ${filespath}/mp-${subport}
115} elseif {${subport} == "clang-${llvm_version}"} {
116    select.group        clang
117    select.file         ${filespath}/mp-${subport}
118}
119
120# g++-4.0 fails to build some of the newer C++ for ppc
121# Intel looks ok, but I prefer using gcc-4.2 for consistency
122compiler.blacklist gcc-4.0
123
124# TODO: base should do this: http://trac.macports.org/ticket/32542
125if {[info exists portconfigure::compiler_name_map(${configure.compiler})]} {
126    depends_build-append port:$portconfigure::compiler_name_map(${configure.compiler})
127
128    # base 2.1.x ignores the argument and just use ${configure.compiler}
129    if {[portconfigure::arch_flag_supported ${configure.compiler}]} {
130        depends_skip_archcheck-append $portconfigure::compiler_name_map(${configure.compiler})
131    }
132
133    if {[string match macports-gcc* ${configure.compiler}]} {
134        depends_lib-append port:$portconfigure::compiler_name_map(${configure.compiler})
135    }
136}
137
138variant universal {
139    build.env-append \
140        UNIVERSAL=1 \
141        UNIVERSAL_ARCH="[get_canonical_archs]"
142    destroot.env-append \
143        UNIVERSAL=1 \
144        UNIVERSAL_ARCH="[get_canonical_archs]"
145
146    post-extract {
147        # workaround a bug in Apple's shipped gcc driver-driver, patched in
148        # ours with driverdriver-num_infiles.patch
149        if {${configure.compiler} == "gcc-4.0" ||
150            ${configure.compiler} == "gcc-4.2" ||
151            ${configure.compiler} == "llvm-gcc-4.2"} {
152            system "echo \"static int ___ignoreme;\" > ${worksrcpath}/tools/llvm-shlib/ignore.c"
153        }
154    }
155}
156
157variant assertions description "Enable assertions for error detection (has performance impacts, especially on JIT)" {
158    configure.args-append --enable-assertions
159}
160
161platform darwin {
162    if {${build_arch} == "i386" } {
163        configure.pre_args-append --build=i686-apple-darwin${os.major}
164    } elseif {${build_arch} == "ppc" } {
165        configure.pre_args-append --build=powerpc-apple-darwin${os.major}
166    } elseif {${build_arch} == "ppc64" } {
167        configure.pre_args-append --build=powerpc64-apple-darwin${os.major}
168    } else {
169        configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
170    }
171
172    if {[string match "*ppc*" [get_canonical_archs]]} {
173        # http://trac.macports.org/ticket/33987
174        configure.args-append --with-optimize-option=-Os
175    }
176}
177
178platform darwin 8 {
179    # Tiger's DevTools make has issues with the nested ifs in compiler-rt
180    depends_run-append      port:gmake
181    depends_skip_archcheck-append gmake
182    build.cmd               ${prefix}/bin/gmake
183    destroot.cmd            ${prefix}/bin/gmake
184
185    post-configure {
186        reinplace "/^RPATH/s/=.*/=/" ${worksrcpath}/Makefile.config
187    }
188}
189
190post-extract {
191    if {${subport} == "clang-${llvm_version}"} {
192        #system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/trunk clang"
193        #system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/branches/release_31 clang"
194        file rename ${workpath}/clang-${llvm_version}.src ${worksrcpath}/tools/clang
195
196        #system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt"
197        #system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/branches/release_31 compiler-rt"
198        file rename ${workpath}/compiler-rt-${llvm_version}.src ${worksrcpath}/projects/compiler-rt
199
200        system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/trunk libcxx"
201        #system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/branches/release_31 libcxx"
202        #file rename ${workpath}/libcxx-${llvm_version}.src ${worksrcpath}/projects/libcxx
203    }
204}
205
206post-patch {
207    if {${subport} == "llvm-${llvm_version}"} {
208        # http://trac.macports.org/ticket/33207
209        reinplace "/LLVMINTERP/s/-lli/-lli-${suffix}/" ${worksrcpath}/tools/llvm-ld/llvm-ld.cpp
210    } elseif {${subport} == "clang-${llvm_version}"} {
211        # http://trac.macports.org/ticket/33272
212        if {![variant_isset arm_runtime]} {
213            reinplace {/^SubDirs/ s/arm//} ${worksrcpath}/projects/compiler-rt/lib/Makefile.mk
214            reinplace {/^UniversalArchs/ s/arm[^ )]* *//g} ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk
215        }
216    }
217}
218
219post-destroot {
220    file mkdir ${destroot}${prefix}/share/doc
221    file rename ${destroot}${sub_prefix}/docs/llvm ${destroot}${prefix}/share/doc/${subport}
222
223    foreach bin [glob ${destroot}${sub_prefix}/bin/*] {
224        set bin_filename [string map "${sub_prefix} ${prefix}" ${bin}]-${suffix}
225        set exec_path [string map "${destroot}${sub_prefix} ${sub_prefix}" ${bin}]
226
227        xinstall -m 755 "${filespath}/llvm-bin" "${bin_filename}"
228        reinplace "s:EXEC_PATH:${exec_path}:" "${bin_filename}"
229    }
230
231    if {${subport} == "llvm-${llvm_version}"} {
232        foreach man [glob ${destroot}${sub_prefix}/share/man/man1/*.1] {
233            set basename [string map "${destroot}${sub_prefix}/share/man/man1/ {}" ${man}]
234            file rename ${man} ${destroot}${prefix}/share/man/man1/[string map ".1 -${suffix}.1" ${basename}]
235        }
236
237        foreach liba [glob ${destroot}${sub_prefix}/lib/*dylib] {
238            set liba_nodr [string map "${destroot} {}" ${liba}]
239            system "install_name_tool -id ${liba_nodr} ${liba}"
240
241            foreach libb [glob ${destroot}${sub_prefix}/lib/*dylib] {
242                set libb_base [string map "${destroot}${sub_prefix}/lib/ {}" ${libb}]
243                set libb_nodr [string map "${destroot} {}" ${libb}]
244
245                system "install_name_tool -change @executable_path/../lib/${libb_base} ${libb_nodr} ${liba}"
246            }
247        }
248    } elseif {${subport} == "clang-${llvm_version}"} {
249        system "ditto ${worksrcpath}/projects/libcxx/include ${destroot}${sub_prefix}/lib/c++/v1"
250
251        # http://trac.macports.org/ticket/33207
252        ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
253
254        system "install_name_tool -id ${sub_prefix}/lib/libclang.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
255        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"
256        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"
257    }
258}
259
260if {${subport} == "llvm-${llvm_version}"} {
261    variant ocaml description {Enable generation of OCaml binding} {
262        depends_lib-append   port:ocaml
263
264        configure.args-delete --enable-bindings=none
265        configure.args-append --enable-bindings=ocaml
266
267        destroot.args-append  OVERRIDE_libdir=${sub_prefix}/lib
268    }
269} elseif {${subport} == "clang-${llvm_version}"} {
270    variant arm_runtime description {Build and install the arm runtime for iOS development (requires iOS SDK)} {}
271
272    set pythonver ""
273    set pythonverdot ""
274
275    if {![variant_isset python25] && ![variant_isset python26]} {
276        default_variants +python27
277    }
278
279    variant python25 conflicts python26 python27 description {Use python 2.5} {
280        set pythonver 25
281        set pythonverdot 2.5
282    }
283
284    variant python26 conflicts python25 python27 description {Use python 2.6} {
285        set pythonver 26
286        set pythonverdot 2.6
287    }
288
289    variant python27 conflicts python25 python26 description {Use python 2.7} {
290        set pythonver 27
291        set pythonverdot 2.7
292    }
293
294    variant analyzer description {Install clang static analyzer} {
295        if {[string equal "${pythonver}" ""]} {
296            ui_error "You mush select a python variant to use the clang static analyzer (+analyzer)"
297            error "Invalid variant combination"
298        }
299
300        depends_run-append port:perl5 port:python${pythonver}
301
302        post-patch {
303            reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5|g" \
304                ${worksrcpath}/tools/clang/tools/scan-build/ccc-analyzer \
305                ${worksrcpath}/tools/clang/tools/scan-build/c++-analyzer \
306                ${worksrcpath}/tools/clang/tools/scan-build/scan-build
307            reinplace "s|/usr/bin/env python|${prefix}/bin/python${pythonverdot}|g" \
308                ${worksrcpath}/tools/clang/tools/scan-build/set-xcode-analyzer \
309                ${worksrcpath}/tools/clang/tools/scan-view/scan-view
310        }
311
312        post-destroot {
313            file mkdir ${destroot}${sub_prefix}/libexec
314            file copy ${worksrcpath}/tools/clang/tools/scan-build ${destroot}${sub_prefix}/libexec/scan-build
315            file copy ${worksrcpath}/tools/clang/tools/scan-view ${destroot}${sub_prefix}/libexec/scan-view
316
317            file delete -force ${destroot}${sub_prefix}/libexec/scan-build/.svn
318            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/.svn
319            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/Resources/.svn
320
321            ln -s ${sub_prefix}/libexec/scan-build/scan-build ${destroot}${sub_prefix}/bin/scan-build
322            ln -s ${sub_prefix}/libexec/scan-view/scan-view ${destroot}${sub_prefix}/bin/scan-view
323            ln -s ${sub_prefix}/bin ${destroot}${sub_prefix}/libexec/scan-build/bin
324
325            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-build-${suffix}"
326            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-build:" "${destroot}${prefix}/bin/scan-build-${suffix}"
327
328            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-view-${suffix}"
329            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-view:" "${destroot}${prefix}/bin/scan-view-${suffix}"
330        }
331    }
332}
333
334livecheck.type          none
Note: See TracBrowser for help on using the repository browser.