Ticket #35172: Portfile

File Portfile, 10.8 KB (added by adfernandes (Andrew Fernandes), 12 years ago)
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 95218 2012-07-07 01:43:48Z adfernandes@macports.org $
3
4PortSystem      1.0
5
6name            boost
7version         1.50.0
8license         Boost-1.0
9categories      devel
10platforms       darwin
11maintainers     adfernandes
12description     Collection of portable C++ source libraries
13
14long_description \
15    Boost provides free portable peer-reviewed C++ \
16    libraries. The emphasis is on portable libraries \
17    which work well with the C++ Standard Library.
18
19homepage        http://www.boost.org
20master_sites    sourceforge
21set distver     [join [split ${version} .] _]
22distname        ${name}_${distver}
23use_bzip2       yes
24
25checksums           md5     52dd00be775e689f55a987baebccc462 \
26                    sha1    ee06f89ed472cf369573f8acf9819fbc7173344e \
27                    rmd160  72e33875d768def47acb5ba8222da4fa56780bab
28
29depends_lib     port:zlib \
30                port:expat \
31                port:bzip2 \
32                port:libiconv \
33                port:icu
34
35patchfiles      patch-tools_build_v2_engine_src_build.sh.diff \
36                patch-tools_build_v2_engine_src_build.jam.diff \
37                patch-bootstrap.sh.diff
38
39post-patch {
40    reinplace "s|%%CONFIGURE.CC%%|${configure.cc}|g" ${worksrcpath}/tools/build/v2/engine/build.sh
41    reinplace "s|%%CONFIGURE.CC%%|${configure.cc}|g" ${worksrcpath}/tools/build/v2/engine/build.jam
42    # When building i386 code with apple-gcc-4.2, boost-1.50.0 adds a '-march=i386' compiler flag
43    # which breaks the atomic intrinsics. The earliest 32-bit intel processors that Apple made
44    # were the Core Solo and Core Duo, so we use the "prescott" architecture for them as per
45    # (http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel#Intel_Core_Solo.2FDuo.2C_Pentium_Dual-Core_T20xx.2FT21xx)
46    # to fix broken 32-bit builds as per (https://trac.macports.org/ticket/35172).
47    reinplace "s|-march=i386|-march=prescott|g" ${worksrcpath}/tools/build/v2/tools/gcc.jam
48}
49
50proc write_jam s {
51    global worksrcpath
52    set config [open ${worksrcpath}/user-config.jam a]
53    puts ${config} ${s}
54    close ${config}
55}
56
57# clang++ produces broken boost libraries (https://trac.macports.org/ticket/31525)
58if {${configure.compiler} == "clang"} {
59    configure.compiler llvm-gcc-4.2
60}
61
62configure.cmd       ./bootstrap.sh
63configure.args      --without-libraries=python \
64                    --without-libraries=mpi \
65                    --with-icu=${prefix}
66
67configure.universal_args
68
69post-configure {
70
71    reinplace -E "s|-install_name \"|&${prefix}/lib/|" \
72        ${worksrcpath}/tools/build/v2/tools/darwin.jam
73
74    # Modified from 'portconfigure.tcl':
75    # set pre-compiler filter to use (ccache/distcc), if any.
76    if {[tbool configure.ccache] && [tbool configure.distcc]} {
77        set filter "ccache "
78        ui_msg "Warning: boost does not support distcc with ccache"
79    } elseif {[tbool configure.ccache]} {
80        set filter "ccache "
81    } elseif {[tbool configure.distcc]} {
82        set filter "distcc "
83    } else {
84        set filter ""
85    }
86    # should support different SDKs (https://trac.macports.org/ticket/33085)
87    write_jam "using darwin : : ${filter}${configure.cxx} ;"
88
89}
90
91# Although bjam can supposedly use parallel builds, it has random failures. See #28878 and #23531.
92# To re-enable it, comment out the below and add '-j${build.jobs}' to 'build.args', also below.
93#
94use_parallel_build  no
95
96build.cmd       ${worksrcpath}/b2
97build.target
98build.args      -d2 \
99                --layout=tagged \
100                --debug-configuration \
101                --user-config=user-config.jam \
102                -sBZIP2_INCLUDE=${prefix}/include \
103                -sBZIP2_LIBPATH=${prefix}/lib \
104                -sEXPAT_INCLUDE=${prefix}/include \
105                -sEXPAT_LIBPATH=${prefix}/lib \
106                -sZLIB_INCLUDE=${prefix}/include \
107                -sZLIB_LIBPATH=${prefix}/lib \
108                -sICU_PATH=${prefix} \
109                variant=release \
110                threading=single,multi \
111                link=static,shared
112
113destroot.cmd            ${worksrcpath}/bjam
114destroot.post_args
115#
116pre-destroot {
117    eval destroot.args ${build.args} --prefix=${destroot}${prefix}
118    system "find ${worksrcpath} -type f -name '*.gch' -exec rm {} \\;"
119}
120
121post-destroot {
122    set docdir ${prefix}/share/doc/${name}
123    xinstall -d ${destroot}${docdir}
124    set l [expr [string length ${worksrcpath}] + 1]
125    fs-traverse f [glob -directory ${worksrcpath} *] {
126        set dest ${destroot}${docdir}/[string range ${f} ${l} end]
127        if {[file isdirectory ${f}]} {
128            if {[file tail ${f}] eq "example"} {
129                copy ${f} ${dest}
130                continue
131            }
132            xinstall -d ${dest}
133        } elseif {[lsearch -exact {css htm html png svg} [string range [file extension ${f}] 1 end]] != -1} {
134            xinstall -m 644 ${f} ${dest}
135        }
136    }
137}
138
139set pythons_suffixes {25 26 27 31 32}
140
141set pythons_ports {}
142foreach s ${pythons_suffixes} {
143    lappend pythons_ports python${s}
144}
145
146proc python_dir {} {
147    global pythons_suffixes
148    foreach s ${pythons_suffixes} {
149        if {[variant_isset python${s}]} {
150            set p python[string index ${s} 0].[string index ${s} 1]
151            return [file normalize [exec ${p} -c "import sys; print(sys.prefix)"]/lib/${p}/site-packages]
152        }
153    }
154    error "Python support not enabled."
155}
156
157foreach s ${pythons_suffixes} {
158    set p python${s}
159    set v [string index ${s} 0].[string index ${s} 1]
160    set i [lsearch -exact ${pythons_ports} ${p}]
161    set c [lreplace ${pythons_ports} ${i} ${i}]
162    eval [subst {
163        variant ${p} description "Build Boost.Python for Python ${v}" conflicts ${c} debug {
164
165            # There is a conflict with python and debug support, so we should really change the 'variant' line above
166            # to end with "conflicts ${c} debug" above. However, we leave it enabled for those who want to try it.
167            # The issue has been reported to both the MacPorts team and the boost team, as per:
168            # <http://trac.macports.org/ticket/23667> and <https://svn.boost.org/trac/boost/ticket/4461>
169
170            depends_lib-append      port:${p}
171            configure.args-delete   --without-libraries=python
172            configure.args-append   --with-python=${prefix}/bin/python${v}
173
174            patchfiles-append   patch-tools-build-v2-tools-python.jam.diff \
175                                patch-tools-build-v2-tools-python-2.jam.diff
176
177            post-patch {
178                reinplace s|@PREFIX@|${prefix}| ${worksrcpath}/tools/build/v2/tools/python.jam
179            }
180
181        }
182    }]
183}
184
185default_variants +no_single +no_static
186
187variant debug description {Builds debug versions of the libraries as well} {
188    build.args-delete   variant=release
189    build.args-append   variant=debug,release
190}
191
192variant no_static description {Disable building static libraries} {
193    build.args-delete   link=shared,static
194    build.args-append   link=shared
195}
196
197variant no_single description {Disable building single-threaded libraries} {
198    build.args-delete   threading=single,multi
199    build.args-append   threading=multi
200}
201
202variant openmpi conflicts debug description {Build Boost.MPI} {
203
204    # There is a conflict with python and debug support, so we should really change the 'variant' line above
205    # to end with "conflicts debug" above. However, we leave it enabled for those who want to try it.
206    # The issue has been reported to both the MacPorts team and the boost team, as per:
207    # <http://trac.macports.org/ticket/23667> and <https://svn.boost.org/trac/boost/ticket/4461>
208
209    depends_lib-append      port:openmpi
210    configure.args-delete   --without-libraries=mpi
211
212    post-configure {
213        write_jam "using mpi : ${prefix}/bin/openmpic++ : : ${prefix}/bin/openmpirun ;"
214    }
215
216    if {![catch python_dir]} {
217
218        patchfiles-append patch-libs-mpi-build-Jamfile.v2.diff
219
220        post-destroot {
221            set site_packages [python_dir]
222            xinstall -d ${destroot}${site_packages}/boost
223            xinstall -m 644 ${worksrcpath}/libs/mpi/build/__init__.py \
224                ${destroot}${site_packages}/boost
225
226            set l ${site_packages}/boost/mpi.so
227            move ${destroot}${prefix}/lib/mpi.so ${destroot}${l}
228            system "install_name_tool -id ${l} ${destroot}${l}"
229        }
230
231    }
232
233}
234
235variant regex_match_extra description \
236        "Enable access to extended capture information of submatches in Boost.Regex" {
237    notes-append "
238You enabled the +regex_match_extra variant\; see the following page for an\
239exhaustive list of the consequences of this feature:
240
241http://www.boost.org/doc/libs/${distver}/libs/regex/doc/html/boost_regex/ref/sub_match.html
242"
243
244    post-patch {
245        reinplace {/#define BOOST_REGEX_MATCH_EXTRA/s:^// ::} \
246            ${worksrcpath}/boost/regex/user.hpp
247    }
248}
249
250if {![variant_isset universal]} {
251    # Honour 'build_arch', if not universal as per #28327
252    if {[lsearch ${build_arch} ppc*] != -1} {
253        build.args-append   architecture=power
254        if {${os.arch} != "powerpc"} {
255            build.args-append   --disable-long-double
256        }
257    } else {
258        if {[lsearch ${build_arch} *86*] != -1} {
259            build.args-append   architecture=x86
260        } else {
261            pre-fetch {
262                error "Current value of 'build_arch' is not supported."
263            }
264        }
265    }
266    if {[lsearch ${build_arch} *64] != -1} {
267        build.args-append   address-model=64
268    } else {
269        build.args-append   address-model=32
270    }
271}
272
273variant universal {
274    build.args-append   pch=off
275
276    if {[lsearch ${universal_archs} ppc*] != -1} {
277        if {[lsearch ${universal_archs} *86*] != -1} {
278            build.args-append   architecture=combined
279        } else {
280            build.args-append   architecture=power
281        }
282
283        if {${os.arch} != "powerpc"} {
284            build.args-append   --disable-long-double
285        }
286    } else {
287        build.args-append   architecture=x86
288    }
289
290    if {[lsearch ${universal_archs} *64] != -1} {
291        if {[lsearch ${universal_archs} i386] != -1 || [lsearch ${universal_archs} ppc] != -1} {
292            build.args-append   address-model=32_64
293            if {[lsearch ${universal_archs} ppc64] == -1} {
294                post-patch {
295                    reinplace "/local support-ppc64 =/s/= 1/= /" ${worksrcpath}/tools/build/v2/tools/darwin.jam
296                }
297            }
298        } else {
299            build.args-append   address-model=64
300        }
301    } else {
302        build.args-append   address-model=32
303    }
304}
305
306platform powerpc {
307    build.args-append   --disable-long-double
308}
309
310platform darwin 8 powerpc {
311    if {[variant_isset universal]} {
312        build.args-append   macosx-version=10.4
313    }
314}
315
316livecheck.type  regex
317livecheck.url   ${homepage}
318livecheck.regex "Version (\\d+\\.\\d+\\.\\d+)"