source: trunk/dports/lang/clang-3.2/Portfile @ 97401

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

{clang,dragonegg,llvm}-3.2: Bump to r163175

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.7 KB
Line 
1# $Id: Portfile 97401 2012-09-04 23:45:00Z jeremyhu@macports.org $
2
3PortSystem              1.0
4PortGroup select        1.0
5
6set llvm_version        3.2
7revision                0
8name                    clang-${llvm_version}
9set suffix              mp-${llvm_version}
10set sub_prefix          ${prefix}/libexec/llvm-${llvm_version}
11dist_subdir             llvm
12categories              lang
13platforms               darwin
14maintainers             jeremyhu openmaintainer
15license                 NCSA
16description             C, C++, Objective C and Objective C++ compiler
17long_description        Clang is an "LLVM native" C/C++/Objective-C compiler, \
18                        which aims to deliver amazingly fast compiles (e.g. \
19                        about 3x faster than GCC when compiling Objective-C \
20                        code in a debug configuration), extremely useful error \
21                        and warning messages and to provide a platform for \
22                        building great source level tools. The included Clang \
23                        Static Analyzer is a tool automatically finds bugs in \
24                        your code, and is a great example of the sort of tool \
25                        that can be built using the Clang frontend as a \
26                        library to parse C/C++ code.
27
28homepage                http://clang.llvm.org/
29
30depends_lib             port:llvm-${llvm_version} port:libffi
31depends_run             port:clang_select
32
33default_variants        +analyzer
34
35fetch.type              svn
36svn.revision            163175
37version                 ${llvm_version}-r${svn.revision}
38set compiler_rt_rev     ${svn.revision}
39worksrcdir              trunk
40svn.url                 http://llvm.org/svn/llvm-project/llvm/trunk
41#worksrcdir              release_32
42#svn.url                 http://llvm.org/svn/llvm-project/llvm/branches/release_32
43default_variants-append +assertions
44
45#version                 ${llvm_version}
46#set compiler_rt_rev     150641
47#epoch                   1
48#master_sites            http://llvm.org/releases/${version}/
49#extract.suffix          .tar.gz
50#distfiles               llvm-${version}.src${extract.suffix} clang-${version}.src${extract.suffix} compiler-rt-${version}.src${extract.suffix}
51#worksrcdir              llvm-${version}.src
52
53patchfiles      install_target.patch \
54                tiger.patch  \
55                tiger-shlib.patch \
56                tiger-shlib-clang.patch \
57                scan-build-PR-35006.patch
58patch.pre_args  -p1
59
60build.target            clang-only
61destroot.target         install-clang
62build.env-append        VERBOSE=1 REQUIRE_RTTI=1
63destroot.env-append     VERBOSE=1 REQUIRE_RTTI=1
64configure.cppflags
65configure.ldflags
66configure.pre_args-delete --prefix=${prefix}
67configure.args          --enable-bindings=none --enable-libffi --enable-shared --enable-jit \
68                        --enable-optimized --disable-profiling \
69                        --enable-debug-symbols --disable-debug-runtime \
70                        --prefix="${sub_prefix}"
71
72select.group    clang
73select.file     ${filespath}/mp-${name}
74
75# g++-4.0 fails to build some of the newer C++ for ppc
76# Intel looks ok, but I prefer using gcc-4.2 for consistency
77if {${configure.compiler} == "gcc-4.0"} {
78    configure.compiler gcc-4.2
79    if {![file exists ${configure.cc}]} {
80        depends_build-append port:apple-gcc42 port:ld64 port:cctools
81        depends_skip_archcheck-append apple-gcc42 ld64 cctools
82
83        configure.compiler apple-gcc-4.2
84    }
85}
86
87variant universal {
88    build.env-append \
89        UNIVERSAL=1 \
90        UNIVERSAL_ARCH="[get_canonical_archs]"
91    destroot.env-append \
92        UNIVERSAL=1 \
93        UNIVERSAL_ARCH="[get_canonical_archs]"
94
95    post-extract {
96        # workaround a bug in Apple's shipped gcc driver-driver, patched in
97        # ours with driverdriver-num_infiles.patch
98        if {${configure.compiler} == "gcc-4.0" ||
99            ${configure.compiler} == "gcc-4.2"} {
100            system "echo \"static int ___ignoreme;\" > ${worksrcpath}/tools/llvm-shlib/ignore.c"
101        }
102    }
103}
104
105variant assertions description "Enable assertions for error detection (has performance impacts, especially on JIT)" {
106    configure.args-append --enable-assertions
107}
108
109platform darwin {
110    depends_run-append      port:ld64
111    depends_skip_archcheck-append ld64
112
113    if {${build_arch} == "i386" } {
114        configure.pre_args-append --build=i686-apple-darwin${os.major}
115    } elseif {${build_arch} == "ppc" } {
116        configure.pre_args-append --build=powerpc-apple-darwin${os.major}
117    } elseif {${build_arch} == "ppc64" } {
118        configure.pre_args-append --build=powerpc64-apple-darwin${os.major}
119    } else {
120        configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
121    }
122
123    if {[string match "*ppc*" [get_canonical_archs]]} {
124        # http://trac.macports.org/ticket/33987
125        configure.args-append --with-optimize-option=-Os
126    }
127}
128
129platform darwin 8 {
130    # Tiger's DevTools make has issues with the nested ifs in compiler-rt
131    depends_run-append      port:gmake
132    depends_skip_archcheck-append gmake
133    build.cmd               ${prefix}/bin/gmake
134    destroot.cmd            ${prefix}/bin/gmake
135
136    post-configure {
137        reinplace "/^RPATH/s/=.*/=/" ${worksrcpath}/Makefile.config
138    }
139}
140
141post-extract {
142    system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/trunk clang"
143    #system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/branches/release_32 clang"
144    #file rename ${workpath}/clang-${llvm_version}.src ${worksrcpath}/tools/clang
145    system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt"
146    #system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/branches/release_32 compiler-rt"
147    #file rename ${workpath}/compiler-rt-${llvm_version}.src ${worksrcpath}/projects/compiler-rt
148}
149
150variant arm_runtime description {Build and install the arm runtime for iOS development (requires iOS SDK)} {}
151
152post-patch {
153    # http://trac.macports.org/ticket/33272
154    if {![variant_isset arm_runtime]} {
155        reinplace {/^SubDirs/ s/arm//} ${worksrcpath}/projects/compiler-rt/lib/Makefile.mk
156        reinplace {/^UniversalArchs/ s/arm[^ )]* *//g} ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk
157    }
158
159    if {! [file exists /usr/include/dispatch/dispatch.h]} {
160        reinplace {/^SubDirs/ s/asan//} ${worksrcpath}/projects/compiler-rt/lib/Makefile.mk
161    }
162
163}
164
165set pythonver ""
166set pythonverdot ""
167
168if {![variant_isset python25] && ![variant_isset python26]} {
169    default_variants +python27
170}
171
172variant python25 conflicts python26 python27 description {Use python 2.5} {
173    set pythonver 25
174    set pythonverdot 2.5
175}
176
177variant python26 conflicts python25 python27 description {Use python 2.6} {
178    set pythonver 26
179    set pythonverdot 2.6
180}
181
182variant python27 conflicts python25 python26 description {Use python 2.7} {
183    set pythonver 27
184    set pythonverdot 2.7
185}
186
187variant analyzer description {Install clang static analyzer} {
188    if {[string equal "${pythonver}" ""]} {
189        ui_error "You mush select a python variant to use the clang static analyzer (+analyzer)"
190        error "Invalid variant combination"
191    }
192
193    depends_run-append port:perl5 port:python${pythonver}
194
195    post-patch {
196        reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5|g" \
197            ${worksrcpath}/tools/clang/tools/scan-build/ccc-analyzer \
198            ${worksrcpath}/tools/clang/tools/scan-build/c++-analyzer \
199            ${worksrcpath}/tools/clang/tools/scan-build/scan-build
200        reinplace "s|/usr/bin/env python|${prefix}/bin/python${pythonverdot}|g" \
201            ${worksrcpath}/tools/clang/tools/scan-build/set-xcode-analyzer \
202            ${worksrcpath}/tools/clang/tools/scan-view/scan-view
203    }
204
205    post-destroot {
206        file mkdir ${destroot}${sub_prefix}/libexec
207        file copy ${worksrcpath}/tools/clang/tools/scan-build ${destroot}${sub_prefix}/libexec/scan-build
208        file copy ${worksrcpath}/tools/clang/tools/scan-view ${destroot}${sub_prefix}/libexec/scan-view
209
210        file delete -force ${destroot}${sub_prefix}/libexec/scan-build/.svn
211        file delete -force ${destroot}${sub_prefix}/libexec/scan-view/.svn
212        file delete -force ${destroot}${sub_prefix}/libexec/scan-view/Resources/.svn
213
214        ln -s ${sub_prefix}/libexec/scan-build/scan-build ${destroot}${sub_prefix}/bin/scan-build
215        ln -s ${sub_prefix}/libexec/scan-view/scan-view ${destroot}${sub_prefix}/bin/scan-view
216        ln -s ${sub_prefix}/bin ${destroot}${sub_prefix}/libexec/scan-build/bin
217
218        xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-build-${suffix}"
219        reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-build:" "${destroot}${prefix}/bin/scan-build-${suffix}"
220
221        xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-view-${suffix}"
222        reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-view:" "${destroot}${prefix}/bin/scan-view-${suffix}"
223    }
224}
225
226post-destroot {
227    foreach bin [glob ${destroot}${sub_prefix}/bin/*] {
228        set bin_filename [string map "${sub_prefix} ${prefix}" ${bin}]-${suffix}
229        set exec_path [string map "${destroot}${sub_prefix} ${sub_prefix}" ${bin}]
230
231        xinstall -m 755 "${filespath}/llvm-bin" "${bin_filename}"
232        reinplace "s:EXEC_PATH:${exec_path}:" "${bin_filename}"
233    }
234
235    # http://trac.macports.org/ticket/33207
236    ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
237
238    system "install_name_tool -id ${sub_prefix}/lib/libclang.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
239    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"
240}
Note: See TracBrowser for help on using the repository browser.