Ticket #39808: Portfile

File Portfile, 11.7 KB (added by bradc6 (Bradley Clemetson), 11 years ago)

Proposed PortFile

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