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

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

{clang,llvm}-*: Fix the license

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