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

Last change on this file since 136583 was 136583, checked in by larryv@…, 4 years ago

{llvm,clang}-*: Build out-of-source

Upstream has deprecated in-source builds.

Revbump clang-3.4 and clang-3.5 because their in-source builds
incorrectly installed some intermediate build files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 16.0 KB
Line 
1# $Id: Portfile 136583 2015-05-22 18:54:24Z larryv@macports.org $
2
3PortSystem              1.0
4PortGroup select        1.0
5
6set llvm_version        3.3
7revision                7
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 larryv
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 that 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_build       port:cctools
48    depends_skip_archcheck-append cctools ld64 subversion
49
50    default_variants    +analyzer
51}
52
53#fetch.type              svn
54#svn.revision            180025
55
56#set compiler_rt_rev     ${svn.revision}
57#set libcxx_rev          ${svn.revision}
58#version                 ${llvm_version}-r${svn.revision}
59#worksrcdir              trunk
60#svn.url                 http://llvm.org/svn/llvm-project/llvm/trunk
61#worksrcdir              release_33
62#svn.url                 http://llvm.org/svn/llvm-project/llvm/branches/release_33
63#default_variants-append +assertions
64
65version                 ${llvm_version}
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-3.3.src.tar.gz \
73                    rmd160  22878ad746c50b02a7ac8713dd6f8c95c7af4220 \
74                    sha256  68766b1e70d05a25e2f502e997a3cb3937187a3296595cf6e0977d5cd6727578 \
75                    cfe-3.3.src.tar.gz \
76                    rmd160  ff5d684c83b0c1aa36595dcb457da80b58eaf58f \
77                    sha256  b1b55de4ab3a57d3e0331a83e0284610191c77d924e3446498d9113d08dfb996 \
78                    compiler-rt-3.3.src.tar.gz \
79                    rmd160  943675fe098d1fc197d381f55ad9a72681652d09 \
80                    sha256  0e2f3180d6316e6c43f064fdd406c5c6515e682c5f31c57c28335b68c7525423 \
81                    libcxx-3.3.src.tar.gz \
82                    rmd160  b97ba28e87d30dfe5b4f540ce20a190ac0bcab9c \
83                    sha256  c403ed18d2992719c794cdd760dc87a948b62a7c2a07beb39eb984dfeb1679f1
84
85patchfiles      install_target.patch \
86                0001-Fix-regular-expression-to-work-with-multiple-digit-v.patch \
87                tiger.patch \
88                tiger-shlib.patch
89
90patch.pre_args  -p1
91
92if {${subport} == "clang-${llvm_version}"} {
93    if {${distfiles} != ""} {
94        distfiles-append     cfe-${version}.src${extract.suffix} compiler-rt-${version}.src${extract.suffix} libcxx-${version}.src${extract.suffix}
95    }
96
97    patchfiles-append    tiger-shlib-clang.patch tiger-libclang.patch scan-build-PR-35006.patch \
98                         0001-Comment-out-SL-cctools-workaround.patch \
99                         mavericks-libc++.patch \
100                         snowleopard-cmath.patch \
101                         yosemite-deployment-target.patch \
102                         export_dynamic.patch
103
104    build.target        clang-only
105    destroot.target     install-clang
106}
107
108build.env-append        VERBOSE=1 \
109                        REQUIRES_RTTI=1
110destroot.env-append     VERBOSE=1 \
111                        REQUIRES_RTTI=1
112
113configure.dir           ${workpath}/build
114build.dir               ${configure.dir}
115
116configure.optflags
117configure.cppflags
118configure.ldflags
119configure.cmd           ${worksrcpath}/configure
120configure.pre_args-delete --prefix=${prefix}
121configure.args          --enable-bindings=none --enable-libffi --enable-shared --enable-jit \
122                        --enable-optimized --disable-profiling --enable-pic \
123                        --enable-debug-symbols --disable-debug-runtime \
124                        --prefix="${sub_prefix}" --disable-assertions
125
126if {${subport} == "llvm-${llvm_version}"} {
127    select.group        llvm
128    select.file         ${filespath}/mp-${subport}
129} elseif {${subport} == "clang-${llvm_version}"} {
130    select.group        clang
131    select.file         ${filespath}/mp-${subport}
132}
133
134# g++-4.0 fails to build some of the newer C++ for ppc
135# Intel looks ok, but I prefer using gcc-4.2 for consistency
136compiler.blacklist gcc-4.0
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-delete --disable-assertions
159    configure.args-append --enable-assertions
160}
161
162platform darwin {
163    if {${build_arch} eq "i386"} {
164        configure.pre_args-append --build=i686-apple-darwin${os.major}
165    } elseif {${build_arch} eq "ppc"} {
166        configure.pre_args-append --build=powerpc-apple-darwin${os.major}
167    } elseif {${build_arch} eq "ppc64"} {
168        configure.pre_args-append --build=powerpc64-apple-darwin${os.major}
169    } else {
170        configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
171    }
172
173    if {[string match "*ppc*" [get_canonical_archs]]} {
174        # http://trac.macports.org/ticket/33987
175        configure.args-append --with-optimize-option=-Os
176        configure.optflags    -Os
177    }
178
179    if {${subport} == "clang-${llvm_version}" && ${os.major} <= 9} {
180        patchfiles-append leopard-no-asan.patch 0001-Leopard-Default-to-fno-blocks.patch
181    }
182
183    # TODO: The llvm build system sets a 10.1 deployment target on Yosemite
184    if {[vercmp ${macosx_deployment_target} 10.10] >= 0} {
185        macosx_deployment_target 10.9
186    }
187
188    if {${os.major} < 9} {
189        # Tiger's DevTools make has issues with the nested ifs in compiler-rt
190        depends_run-append      port:gmake
191        build.cmd               ${prefix}/bin/gmake
192
193        post-configure {
194            reinplace "/^RPATH/s/=.*/=/" ${worksrcpath}/Makefile.config
195        }
196    }
197}
198
199post-extract {
200    if {${subport} == "clang-${llvm_version}"} {
201        #system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/trunk clang"
202        #system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/branches/release_33 clang"
203        file rename ${workpath}/cfe-${llvm_version}.src ${worksrcpath}/tools/clang
204
205        #system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt"
206        #system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/branches/release_33 compiler-rt"
207        file rename ${workpath}/compiler-rt-${llvm_version}.src ${worksrcpath}/projects/compiler-rt
208
209        #system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/trunk libcxx"
210        #system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/branches/release_33 libcxx"
211        file rename ${workpath}/libcxx-${llvm_version}.src ${worksrcpath}/projects/libcxx
212    }
213}
214
215post-patch {
216    if {${subport} == "clang-${llvm_version}"} {
217        # http://trac.macports.org/ticket/33272
218        if {![variant_isset arm_runtime]} {
219            reinplace {/^SubDirs/ s/arm//} ${worksrcpath}/projects/compiler-rt/lib/Makefile.mk
220            reinplace {/^UniversalArchs/ s/arm[^ )]* *//g} ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk
221
222            reinplace {/cc_kext_ios5/ s/^/#/} ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk
223            reinplace {s/cc_kext_ios5.a//} ${worksrcpath}/tools/clang/runtime/compiler-rt/Makefile
224        }
225 
226        reinplace {s/VERBOSE := 0/VERBOSE := 1/} ${worksrcpath}/projects/compiler-rt/make/config.mk
227    }
228}
229
230post-destroot {
231    file mkdir ${destroot}${prefix}/share/doc
232    file rename ${destroot}${sub_prefix}/docs/llvm ${destroot}${prefix}/share/doc/${subport}
233
234    foreach bin [glob ${destroot}${sub_prefix}/bin/*] {
235        set bin_filename [string map "${sub_prefix} ${prefix}" ${bin}]-${suffix}
236        set exec_path [string map "${destroot}${sub_prefix} ${sub_prefix}" ${bin}]
237
238        xinstall -m 755 "${filespath}/llvm-bin" "${bin_filename}"
239        reinplace "s:EXEC_PATH:${exec_path}:" "${bin_filename}"
240    }
241
242    if {${subport} == "llvm-${llvm_version}"} {
243        # r156389 (a5d2435409858728970202226d0bbbee508fe408) temporarilary removed llvm man pages
244        #foreach man [glob ${destroot}${sub_prefix}/share/man/man1/*.1] {
245        #    set basename [string map "${destroot}${sub_prefix}/share/man/man1/ {}" ${man}]
246        #    file rename ${man} ${destroot}${prefix}/share/man/man1/[string map ".1 -${suffix}.1" ${basename}]
247        #}
248
249        foreach liba [glob ${destroot}${sub_prefix}/lib/*dylib] {
250            set liba_nodr [string map "${destroot} {}" ${liba}]
251            system "install_name_tool -id ${liba_nodr} ${liba}"
252
253            foreach libb [glob ${destroot}${sub_prefix}/lib/*dylib] {
254                set libb_base [string map "${destroot}${sub_prefix}/lib/ {}" ${libb}]
255                set libb_nodr [string map "${destroot} {}" ${libb}]
256
257                system "install_name_tool -change @executable_path/../lib/${libb_base} ${libb_nodr} ${liba}"
258            }
259        }
260    } elseif {${subport} == "clang-${llvm_version}"} {
261        system "ditto ${worksrcpath}/projects/libcxx/include ${destroot}${sub_prefix}/lib/c++/v1"
262
263        # http://trac.macports.org/ticket/33207
264        ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
265
266        system "install_name_tool -id ${sub_prefix}/lib/libclang.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
267        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"
268        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"
269
270        if {${os.major} > 9} {
271            # http://trac.macports.org/ticket/38527
272            system "install_name_tool -id ${sub_prefix}/lib/clang/${llvm_version}/lib/darwin/libclang_rt.asan_osx_dynamic.dylib ${destroot}${sub_prefix}/lib/clang/${llvm_version}/lib/darwin/libclang_rt.asan_osx_dynamic.dylib"
273        }
274    }
275}
276
277if {${subport} == "llvm-${llvm_version}"} {
278    variant ocaml description {Enable generation of OCaml binding} {
279        depends_lib-append   port:ocaml
280
281        configure.args-delete --enable-bindings=none
282        configure.args-append --enable-bindings=ocaml
283
284        destroot.args-append  OVERRIDE_libdir=${sub_prefix}/lib
285    }
286} elseif {${subport} == "clang-${llvm_version}"} {
287    variant arm_runtime description {Build and install the arm runtime for iOS development (requires iOS SDK)} {}
288
289    # The iOS SDK was shipped with all Xcode releases after 4.0
290    if {[info exists xcodeversion] && [vercmp "4.0" ${xcodeversion}] <= 0} {
291       default_variants-append +arm_runtime
292    }
293
294    set pythonver ""
295    set pythonverdot ""
296
297    if {![variant_isset python25] && ![variant_isset python26]} {
298        default_variants-append +python27
299    }
300
301    variant python25 conflicts python26 python27 description {Use python 2.5} {
302        set pythonver 25
303        set pythonverdot 2.5
304        depends_build-append port:python25
305        configure.args-append --with-python=${prefix}/bin/python2.5
306    }
307
308    variant python26 conflicts python25 python27 description {Use python 2.6} {
309        set pythonver 26
310        set pythonverdot 2.6
311        depends_build-append port:python26
312        configure.args-append --with-python=${prefix}/bin/python2.6
313    }
314
315    variant python27 conflicts python25 python26 description {Use python 2.7} {
316        set pythonver 27
317        set pythonverdot 2.7
318        depends_build-append port:python27
319        configure.args-append --with-python=${prefix}/bin/python2.7
320    }
321
322    variant analyzer description {Install clang static analyzer} {
323        if {[string equal "${pythonver}" ""]} {
324            ui_error "You must select a python variant to use the clang static analyzer (+analyzer)"
325            error "Invalid variant combination"
326        }
327
328        depends_run-append port:perl5 port:python${pythonver}
329
330        post-patch {
331            reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5|g" \
332                ${worksrcpath}/tools/clang/tools/scan-build/ccc-analyzer \
333                ${worksrcpath}/tools/clang/tools/scan-build/c++-analyzer \
334                ${worksrcpath}/tools/clang/tools/scan-build/scan-build
335            reinplace "s|/usr/bin/env python|${prefix}/bin/python${pythonverdot}|g" \
336                ${worksrcpath}/tools/clang/tools/scan-build/set-xcode-analyzer \
337                ${worksrcpath}/tools/clang/tools/scan-view/scan-view
338        }
339
340        post-destroot {
341            file mkdir ${destroot}${sub_prefix}/libexec
342            file copy ${worksrcpath}/tools/clang/tools/scan-build ${destroot}${sub_prefix}/libexec/scan-build
343            file copy ${worksrcpath}/tools/clang/tools/scan-view ${destroot}${sub_prefix}/libexec/scan-view
344
345            file delete -force ${destroot}${sub_prefix}/libexec/scan-build/.svn
346            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/.svn
347            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/Resources/.svn
348
349            ln -s ${sub_prefix}/libexec/scan-build/scan-build ${destroot}${sub_prefix}/bin/scan-build
350            ln -s ${sub_prefix}/libexec/scan-view/scan-view ${destroot}${sub_prefix}/bin/scan-view
351            ln -s ${sub_prefix}/bin ${destroot}${sub_prefix}/libexec/scan-build/bin
352
353            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-build-${suffix}"
354            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-build:" "${destroot}${prefix}/bin/scan-build-${suffix}"
355
356            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-view-${suffix}"
357            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-view:" "${destroot}${prefix}/bin/scan-view-${suffix}"
358        }
359    }
360}
361
362livecheck.type          none
Note: See TracBrowser for help on using the repository browser.