source: trunk/dports/lang/llvm-3.4/Portfile @ 137992

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

inc. revision to rebuild library dependents of ocaml (ocaml update to version 4.02.2)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 19.6 KB
Line 
1# $Id: Portfile 137992 2015-06-24 16:17:51Z mww@macports.org $
2
3PortSystem              1.0
4PortGroup select        1.0
5PortGroup compiler_blacklist_versions 1.0
6
7set llvm_version        3.4
8set llvm_version_no_dot 34
9name                    llvm-${llvm_version}
10revision                7
11subport                 clang-${llvm_version} {
12    revision            8
13}
14set suffix              mp-${llvm_version}
15set sub_prefix          ${prefix}/libexec/llvm-${llvm_version}
16dist_subdir             llvm
17categories              lang
18platforms               darwin
19license                 NCSA
20maintainers             jeremyhu larryv
21
22if {${subport} eq "llvm-${llvm_version}"} {
23    homepage            http://llvm.org/
24    description         llvm is a next generation compiler infrastructure
25    long_description    The LLVM Core libraries provide a modern source- and \
26                        target-independent optimizer, along with code \
27                        generation support for many popular CPUs (as well as \
28                        some less common ones!) These libraries are built \
29                        around a well specified code representation known as \
30                        the LLVM intermediate representation ("LLVM IR").
31
32    depends_lib         port:libffi port:ncurses port:zlib
33    depends_run         bin:perl:perl5 port:llvm_select
34} elseif {${subport} eq "clang-${llvm_version}"} {
35    homepage            http://clang.llvm.org/
36    description         C, C++, Objective C and Objective C++ compiler
37    long_description    Clang is an "LLVM native" C/C++/Objective-C compiler, \
38                        which aims to deliver amazingly fast compiles (e.g. \
39                        about 3x faster than GCC when compiling Objective-C \
40                        code in a debug configuration), extremely useful error \
41                        and warning messages and to provide a platform for \
42                        building great source level tools. The included Clang \
43                        Static Analyzer is a tool that automatically finds bugs in \
44                        your code, and is a great example of the sort of tool \
45                        that can be built using the Clang frontend as a \
46                        library to parse C/C++ code.
47
48    depends_lib         port:libxml2 port:llvm-${llvm_version} port:python27
49    depends_run         port:clang_select port:ld64
50    depends_extract     bin:svn:subversion
51    depends_build       port:cctools
52    depends_skip_archcheck-append cctools ld64 subversion
53
54    # Clang doesn't actually use any of these, but the LLVM makefile
55    # system overlinks its binaries. Remove (or convert to build deps?)
56    # after #46040 is resolved.
57    depends_lib-append  port:libffi port:ncurses port:zlib
58
59    default_variants    +analyzer
60}
61
62#fetch.type              svn
63#svn.revision            198150
64#
65#set compiler_rt_rev     ${svn.revision}
66#set libcxx_rev          ${svn.revision}
67#set clang-modernize_rev ${svn.revision}
68#version                 ${llvm_version}-r${svn.revision}
69#worksrcdir              trunk
70#svn.url                 http://llvm.org/svn/llvm-project/llvm/trunk
71#worksrcdir              release_${llvm_version_no_dot}
72#svn.url                 http://llvm.org/svn/llvm-project/llvm/branches/release_${llvm_version_no_dot}
73#default_variants-append +assertions
74
75version                 ${llvm_version}.2
76epoch                   1
77master_sites            http://llvm.org/releases/${version} http://llvm.org/releases/${llvm_version}
78extract.suffix          .tar.gz
79distfiles               llvm-${version}.src${extract.suffix}
80worksrcdir              llvm-${version}.src
81
82if {${distfiles} ne ""} {
83    if {${subport} eq "llvm-${llvm_version}"} {
84        if {[variant_isset polly]} {
85            distfiles-append     polly-${llvm_version}.src${extract.suffix}
86        }
87    } elseif {${subport} eq "clang-${llvm_version}"} {
88        distfiles-append     cfe-${version}.src${extract.suffix} compiler-rt-${llvm_version}.src${extract.suffix} libcxx-${version}.src${extract.suffix} clang-tools-extra-${llvm_version}.src${extract.suffix}
89    }
90}
91
92checksums           llvm-3.4.2.src.tar.gz \
93                    rmd160  5fab44850977afccee34b21c6d339bc8dea21fce \
94                    sha256  17038d47069ad0700c063caed76f0c7259628b0e79651ce2b540d506f2f1efd7 \
95                    polly-3.4.src.tar.gz \
96                    rmd160  995dc606934494344e2bdc20c1d1f49bf0cedd3c \
97                    sha256  9f1a5fb73dddc0afe47a0f4108dea818e0d1d16485899141957f87f75fa50ee7 \
98                    cfe-3.4.2.src.tar.gz \
99                    rmd160  f6b177408f5f9d3a453d41f1f60534f8e1e2845b \
100                    sha256  5ba6f5772f8d00f445209356a7daf83c5bca2da5acd10de517ad2359ae95bc10 \
101                    compiler-rt-3.4.src.tar.gz \
102                    rmd160  530225a44fa743f80df759e5354a0854eb422306 \
103                    sha256  f37c89b1383ce462d47537a0245ac798600887a9be9f63073e16b79ed536ab5c \
104                    libcxx-3.4.2.src.tar.gz \
105                    rmd160  7984caf2d055ea967544107ae1f948c77556d764 \
106                    sha256  826543ee2feb5d3313b0705145255ebb2ed8d52eace878279c2525ccde6e727c \
107                    clang-tools-extra-3.4.src.tar.gz \
108                    rmd160  8af0af0ead94bd50b1e6cbdcde5c4770bba5de0d \
109                    sha256  ba85187551ae97fe1c8ab569903beae5ff0900e21233e5eb5389f6ceab1028b4
110
111patch.pre_args  -p1
112patchfiles \
113        0001-MacPorts-Only-Update-install-targets-for-clang-subpo.patch \
114        0002-MacPorts-Only-Skip-checking-for-python-in-configure.patch \
115        0003-MacPorts-Only-Fix-sample-project-regex-to-work-with-.patch \
116        0004-Set-the-Mach-O-CPU-Subtype-to-ppc7400-when-targeting.patch \
117        0005-_CS_DARWIN_USER-macros-available-on-darwin-9.-Thanks.patch \
118        0006-Fix-dylib-install-name-when-building-on-Tiger.patch \
119        0007-Define-EXC_MASK_CRASH-and-MACH_EXCEPTION_CODES-if-th.patch \
120        llvm-skip-unittests.patch
121
122if {${subport} eq "clang-${llvm_version}"} {
123    patchfiles-append \
124        1001-MacPorts-Only-Prepare-clang-format-for-replacement-w.patch \
125        1002-MacPorts-Only-Fix-name-of-scan-view-executable-insid.patch \
126        1003-MacPorts-Only-Fix-libclang_rt-dylib-ids.patch \
127        1004-MacPorts-Only-Relocate-clang-resources-using-llvm-ve.patch \
128        1005-Call-powerpc-darwin-external-tools-with-arch-ppc.patch \
129        1006-Default-to-ppc7400-for-OSX-10.5.patch \
130        1007-reinstate-fno-objc-legacy-dispatch-behavior-when-the.patch \
131        1008-Change-__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__.patch \
132        1009-Only-call-setpriority-PRIO_DARWIN_THREAD-0-PRIO_DARW.patch \
133        1010-Fix-dylib-install-name-when-building-on-Tiger.patch \
134        2001-MacPorts-Only-Comment-out-SL-cctools-workaround.patch \
135        2002-On-darwin-build-ppc-slices-of-the-compiler-runtime-i.patch \
136        3001-buildit-build-fix-for-Leopard.patch \
137        3002-buildit-Set-compatibility-version-to-RC_ProjectSourc.patch \
138        3003-Fix-local-and-iterator-when-building-with-Lion-and-n.patch \
139        3004-Fix-missing-long-long-math-prototypes-when-using-the.patch \
140        3005-implement-atomic-using-mutex-lock_guard-for-64b-ops-.patch \
141        compiler_rt-toolchain.patch
142
143    # I'm not sure if we need to delete this.  It seems to build fine with it
144    # present, but we used to explicitly only use this patch for the llvm subport.
145    patchfiles-delete \
146        0002-MacPorts-Only-Skip-checking-for-python-in-configure.patch
147
148    # Introduces a failure during build (-arch ?? passed to ld), to be investigated:
149    patchfiles-delete \
150        1005-Call-powerpc-darwin-external-tools-with-arch-ppc.patch
151
152    build.target        clang-only
153    destroot.target     install-clang
154}
155
156build.env-append        VERBOSE=1 \
157                        REQUIRES_RTTI=1
158destroot.env-append     VERBOSE=1 \
159                        REQUIRES_RTTI=1
160
161configure.dir           ${workpath}/build
162build.dir               ${configure.dir}
163
164configure.cmd           ${worksrcpath}/configure
165configure.pre_args-delete --prefix=${prefix}
166configure.args          --enable-bindings=none --enable-libffi --enable-shared --enable-jit \
167                        --enable-optimized --disable-profiling --enable-pic \
168                        --enable-debug-symbols --disable-debug-runtime \
169                        --prefix="${sub_prefix}" --disable-assertions
170
171if {${subport} eq "llvm-${llvm_version}"} {
172    select.group        llvm
173    select.file         ${filespath}/mp-${subport}
174} elseif {${subport} eq "clang-${llvm_version}"} {
175    select.group        clang
176    select.file         ${filespath}/mp-${subport}
177
178    configure.args-append --with-python=${prefix}/bin/python2.7
179}
180
181# g++-4.0 fails to build some of the newer C++ for ppc. Intel looks ok, but I prefer using gcc-4.2 for consistency
182# Leopard's gcc-4.2 (5577) miscompiles llvm-3.4 for i386.
183# XCode 4.3's clang (318.x) fails per https://trac.macports.org/ticket/44161
184compiler.blacklist gcc-4.0 {gcc-4.2 <= 5577} {clang < 421}
185
186variant universal {
187    build.env-append \
188        UNIVERSAL=1 \
189        UNIVERSAL_ARCH="[get_canonical_archs]"
190    destroot.env-append \
191        UNIVERSAL=1 \
192        UNIVERSAL_ARCH="[get_canonical_archs]"
193
194    post-extract {
195        # workaround a bug in Apple's shipped gcc driver-driver, patched in
196        # ours with driverdriver-num_infiles.patch
197        if {${configure.compiler} eq "gcc-4.0" ||
198            ${configure.compiler} eq "gcc-4.2" ||
199            ${configure.compiler} eq "llvm-gcc-4.2"} {
200            system "echo \"static int ___ignoreme;\" > ${worksrcpath}/tools/llvm-shlib/ignore.c"
201        }
202    }
203}
204
205variant assertions description "Enable assertions for error detection (has performance impacts, especially on JIT)" {
206    configure.args-delete --disable-assertions
207    configure.args-append --enable-assertions
208}
209
210platform darwin {
211    if {${build_arch} eq "i386"} {
212        configure.pre_args-append --build=i686-apple-darwin${os.major}
213    } elseif {${build_arch} eq "ppc"} {
214        configure.pre_args-append --build=powerpc-apple-darwin${os.major}
215    } elseif {${build_arch} eq "ppc64"} {
216        configure.pre_args-append --build=powerpc64-apple-darwin${os.major}
217    } else {
218        configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
219    }
220
221    if {[string match "*ppc*" [get_canonical_archs]]} {
222        # http://trac.macports.org/ticket/33987
223        configure.args-append --with-optimize-option=-Os
224        configure.optflags    -Os
225    }
226
227    if {${subport} eq "clang-${llvm_version}" && ${os.major} <= 9} {
228        patchfiles-append leopard-no-asan.patch leopard-no-blocks.patch
229    }
230
231    # TODO: The llvm build system sets a 10.1 deployment target on Yosemite
232    if {[vercmp ${macosx_deployment_target} 10.10] >= 0} {
233        macosx_deployment_target 10.9
234    }
235
236    if {${os.major} < 10} {
237        post-patch {
238            reinplace "/TARGETS_TO_BUILD=/s/R600//" ${worksrcpath}/configure
239        }
240    }
241
242    if {${os.major} < 9} {
243        # Tiger's DevTools make has issues with the nested ifs in compiler-rt
244        depends_run-append      port:gmake
245        build.cmd               ${prefix}/bin/gmake
246
247        post-configure {
248            reinplace "/^RPATH/s/=.*/=/" ${worksrcpath}/Makefile.config
249        }
250    }
251}
252
253post-extract {
254    if {${subport} eq "llvm-${llvm_version}"} {
255        if {[variant_isset polly]} {
256            if {${worksrcdir} eq "trunk"} {
257                system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/polly/trunk polly"
258            } elseif {${worksrcdir} eq "release_${llvm_version_no_dot}" } {
259                system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/polly/branches/release_${llvm_version_no_dot} polly"
260            } else {
261                file rename ${workpath}/polly-${llvm_version} ${worksrcpath}/tools/polly
262            }
263        }
264    } elseif {${subport} eq "clang-${llvm_version}"} {
265        if {${worksrcdir} eq "trunk"} {
266            system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/trunk clang"
267            system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt"
268            system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/trunk libcxx"
269            system "cd ${worksrcpath}/tools/clang/tools && svn co -r ${clang-modernize_rev} http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra"
270        } elseif {${worksrcdir} eq "release_${llvm_version_no_dot}" } {
271            system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/branches/release_${llvm_version_no_dot} clang"
272            system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/branches/release_${llvm_version_no_dot} compiler-rt"
273            system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/branches/release_${llvm_version_no_dot} libcxx"
274            system "cd ${worksrcpath}/tools/clang/tools && svn co -r ${clang-modernize_rev} http://llvm.org/svn/llvm-project/clang-tools-extra/branches/release_${llvm_version_no_dot} extra"
275        } else {
276            file rename ${workpath}/cfe-${version}.src ${worksrcpath}/tools/clang
277            file rename ${workpath}/compiler-rt-${llvm_version} ${worksrcpath}/projects/compiler-rt
278            file rename ${workpath}/libcxx-${version}.src ${worksrcpath}/projects/libcxx
279            file rename ${workpath}/clang-tools-extra-${llvm_version} ${worksrcpath}/tools/clang/tools/extra
280        }
281    }
282}
283
284post-patch {
285    if {${subport} eq "clang-${llvm_version}"} {
286        # http://trac.macports.org/ticket/33272
287        if {![variant_isset arm_runtime]} {
288            reinplace {/^SubDirs/ s/arm//} ${worksrcpath}/projects/compiler-rt/lib/Makefile.mk
289            reinplace {/^UniversalArchs/ s/arm[^ )]* *//g} ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk
290
291            reinplace {/cc_kext_ios5/ s/^/#/} ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk
292            reinplace {s/cc_kext_ios5.a//} ${worksrcpath}/tools/clang/runtime/compiler-rt/Makefile
293        }
294
295        reinplace {s/VERBOSE := 0/VERBOSE := 1/} ${worksrcpath}/projects/compiler-rt/make/config.mk
296
297        reinplace "s|@@PREFIX@@|${prefix}|g" \
298            ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk \
299            ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin_embedded.mk
300    }
301}
302
303post-destroot {
304    file mkdir ${destroot}${prefix}/share/doc
305    file rename ${destroot}${sub_prefix}/docs/llvm ${destroot}${prefix}/share/doc/${subport}
306
307    foreach bin [glob ${destroot}${sub_prefix}/bin/*] {
308        set bin_filename [string map "${sub_prefix} ${prefix}" ${bin}]-${suffix}
309        set exec_path [string map "${destroot}${sub_prefix} ${sub_prefix}" ${bin}]
310
311        xinstall -m 755 "${filespath}/llvm-bin" "${bin_filename}"
312        reinplace "s:EXEC_PATH:${exec_path}:" "${bin_filename}"
313    }
314
315    if {${subport} eq "llvm-${llvm_version}"} {
316        # r156389 (a5d2435409858728970202226d0bbbee508fe408) temporarilary removed llvm man pages
317        #foreach man [glob ${destroot}${sub_prefix}/share/man/man1/*.1] {
318        #    set basename [string map "${destroot}${sub_prefix}/share/man/man1/ {}" ${man}]
319        #    file rename ${man} ${destroot}${prefix}/share/man/man1/[string map ".1 -${suffix}.1" ${basename}]
320        #}
321    } elseif {${subport} eq "clang-${llvm_version}"} {
322        system "ditto ${worksrcpath}/projects/libcxx/include ${destroot}${sub_prefix}/lib/c++/v1"
323
324        # http://trac.macports.org/ticket/33207
325        ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
326    }
327}
328
329if {${subport} eq "llvm-${llvm_version}"} {
330    variant polly description {Provide the polly polyhedral optimizer} {
331        patchfiles-append polly-isl-0.13.patch
332
333        depends_lib-append \
334            port:gmp \
335            path:lib/pkgconfig/isl.pc:isl \
336            path:lib/pkgconfig/cloog-isl.pc:cloog
337    }
338
339    variant ocaml description {Enable generation of OCaml binding} {
340        depends_lib-append   port:ocaml
341
342        configure.args-delete --enable-bindings=none
343        configure.args-append --enable-bindings=ocaml
344
345        destroot.args-append  OVERRIDE_libdir=${sub_prefix}/lib
346    }
347} elseif {${subport} eq "clang-${llvm_version}"} {
348    variant arm_runtime description {Build and install the arm runtime for iOS development (requires iOS SDK)} {}
349
350    # The iOS SDK was shipped with all Xcode releases after 4.0
351    if {[info exists xcodeversion] && [vercmp "4.0" ${xcodeversion}] <= 0} {
352       default_variants-append +arm_runtime
353    }
354
355    variant analyzer description {Install clang static analyzer} {
356        depends_run-append port:perl5
357
358        post-patch {
359            reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5|g" \
360                ${worksrcpath}/tools/clang/tools/scan-build/ccc-analyzer \
361                ${worksrcpath}/tools/clang/tools/scan-build/c++-analyzer \
362                ${worksrcpath}/tools/clang/tools/scan-build/scan-build
363            reinplace "s|/usr/bin/env python|${prefix}/bin/python2.7|g" \
364                ${worksrcpath}/tools/clang/tools/scan-build/set-xcode-analyzer \
365                ${worksrcpath}/tools/clang/tools/scan-view/scan-view
366        }
367
368        post-destroot {
369            file mkdir ${destroot}${sub_prefix}/libexec
370            file copy ${worksrcpath}/tools/clang/tools/scan-build ${destroot}${sub_prefix}/libexec/scan-build
371            file copy ${worksrcpath}/tools/clang/tools/scan-view ${destroot}${sub_prefix}/libexec/scan-view
372
373            file delete -force ${destroot}${sub_prefix}/libexec/scan-build/.svn
374            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/.svn
375            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/Resources/.svn
376
377            ln -s ${sub_prefix}/libexec/scan-build/scan-build ${destroot}${sub_prefix}/bin/scan-build
378            ln -s ${sub_prefix}/libexec/scan-view/scan-view ${destroot}${sub_prefix}/bin/scan-view
379            ln -s ${sub_prefix}/bin ${destroot}${sub_prefix}/libexec/scan-build/bin
380
381            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-build-${suffix}"
382            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-build:" "${destroot}${prefix}/bin/scan-build-${suffix}"
383
384            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-view-${suffix}"
385            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-view:" "${destroot}${prefix}/bin/scan-view-${suffix}"
386        }
387    }
388
389
390    post-patch {
391        reinplace "s|@CLANG_FORMAT_PATH@|${prefix}/bin/clang-format-${suffix}|g" \
392            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-bbedit.applescript \
393            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-diff.py            \
394            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-sublime.py         \
395            ${worksrcpath}/tools/clang/tools/clang-format/clang-format.el                 \
396            ${worksrcpath}/tools/clang/tools/clang-format/clang-format.py
397    }
398
399    post-destroot {
400        file mkdir ${destroot}${sub_prefix}/libexec
401        file copy ${worksrcpath}/tools/clang/tools/clang-format ${destroot}${sub_prefix}/libexec/clang-format
402
403        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/.svn
404        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/Makefile
405        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/Release+Debug+Asserts
406        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/CMakeLists.txt
407        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/ClangFormat.cpp
408    }
409}
410
411livecheck.type          none
Note: See TracBrowser for help on using the repository browser.