Ticket #68481: Portfile.boost183WIP2

File Portfile.boost183WIP2, 19.9 KB (added by artkiver (グレェ), 6 months ago)

another WIP Portfile for boost 1.83

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
3PortSystem      1.0
4PortGroup       compiler_blacklist_versions 1.0
5PortGroup       mpi 1.0
6PortGroup       active_variants 1.1
7
8version         1.83.0
9
10set branch      [join [lrange [split ${version} .] 0 1] .]
11set tag         [string map {. {}} ${branch}]
12
13name            boost${tag}
14
15# Revision is set below in the `if {$subport eq $name} { ... }` statement
16# The boost-numpy subport has its own revision number
17
18checksums           rmd160  f717744c1fd0fbed55a4b6f43f457904c092126a \
19                    sha256  6478edfe2f3305127cffe8caf73ea0176c53769f4bf1585be237eb30798c3b8e \
20                    size    122892751
21
22license         Boost-1
23categories      devel
24platforms       darwin
25maintainers     {michaelld @michaelld} \
26                {mascguy @mascguy} \
27                openmaintainer
28
29description     Collection of portable C++ source libraries
30
31long_description \
32    Boost provides free portable peer-reviewed C++ \
33    libraries. The emphasis is on portable libraries \
34    which work well with the C++ Standard Library.
35
36homepage        http://www.boost.org
37master_sites    https://boostorg.jfrog.io/artifactory/main/release/${version}/source/
38set distver     [join [split ${version} .] _]
39distname        boost_${distver}
40use_bzip2       yes
41
42compiler.cxx_standard     2011
43compiler.blacklist-append {clang < 1000}
44
45depends_lib-append \
46                port:bzip2 \
47                port:expat \
48                path:lib/pkgconfig/icu-uc.pc:icu \
49                port:libiconv \
50                port:lzma \
51                port:zlib \
52                port:zstd
53
54post-extract {
55    fs-traverse dir ${workpath} {
56        if {[file isdirectory ${dir}]} {
57            file attributes ${dir} -permissions a+rx
58        }
59    }
60    # Enforce correct compiler and flags are used to build b2
61    xinstall -m 755 -d ${workpath}/bin
62    ln -s ${configure.cxx} ${workpath}/bin/clang++
63    ln -s ${configure.cc}  ${workpath}/bin/clang
64    # Also link gcc/g++ for older systems
65    # https://trac.macports.org/ticket/63120
66    ln -s ${configure.cxx} ${workpath}/bin/g++
67    ln -s ${configure.cc}  ${workpath}/bin/gcc
68}
69configure.env-append  PATH=${workpath}/bin:$env(PATH)
70build.env-append      PATH=${workpath}/bin:$env(PATH)
71
72# Install prefix for this port
73set bprefix ${prefix}/libexec/boost/${branch}
74
75# patch-apple-clang-no-libcxx.diff fixes a clang configuration error
76# that occurs on OS X 10.7 and 10.8 due to the assumption that if
77# clang is the compiler in use it must be using libc++.  Apple Clang
78# uses libstdc++ by default on these OS versions.  The patch adds an
79# additional BOOST_* configuration flag that is set if Apple clang is
80# being used but libc++ is not.  This flag is then used to prevent
81# boost or a dependent package from using functions such as
82# std::forward that are only available in libc++.  Fixes build of
83# libcdr on these OS versions without affecting build on 10.6 and less
84# (where clang is not the default compiler) or 10.9 and up (where
85# libc++ is the default).
86#patchfiles-append patch-apple-clang-no-libcxx.diff
87
88# libcxxabi installed by the libcxx port on the buildbot does not
89# have the cxa_thread_atexit support, so until this is fixed
90# we have to force thread_local off on < 10.7 when using libc++
91# patchfiles-append patch-boost-libcpp-force-thread-local-off.diff
92
93# temporary patch to fix: explicit template instanciations in
94# boost::serialization don't get exported with all compilers; this fix
95# is already in the boost repo & will be part of a future release. See
96# also the following tickets:
97# https://trac.macports.org/ticket/48717
98# https://svn.boost.org/trac/boost/ticket/11671
99# patchfiles-append patch-export_serialization_explicit_template_instantiations.diff
100
101# revert the default tagged library name changes in 1.69.0 <
102# libboost_<component>-<threading>-<arch>.dylib > back to 1.68.0
103# format: libboost_<component>-<threading>.dylib; where <component> is
104# the component name (e.g., system, thread), <threading> is either mt
105# or st (multi or single), and <arch> is the build arch (x86, x64,
106# p64, p32).
107# patchfiles-append patch-revert-lib-name-tagged.diff
108
109# Fix the context-switching code on PPC32. 10.4 and 10.5 lack makecontext/
110# swapcontext (provided by ucontext.h), so they require functioning ASM code.
111# https://github.com/boostorg/context/pull/215
112# patchfiles-append patch-boost-context-asm.diff
113
114# https://github.com/boostorg/fiber/pull/306
115# patchfiles-append patch-fix-fiber.diff
116
117# Upstream c++17 fix: https://github.com/boostorg/functional/commit/6a573e4
118# patchfiles-append patch-boost-functional.diff
119
120# Availability.h -> AvailabilityMacros.h on Tiger
121# The attempted fix:
122# https://github.com/boostorg/core/commit/128d9314d6f814930400c46c9afd34399d19132b
123# is insufficient because GCC 6/7 still defines __cpp_lib_uncaught_exceptions
124# in the absence of __STRICT_ANSI__
125platform darwin 8 {
126    patchfiles-append patch-tiger-availability.diff
127}
128
129# posix_memalign introduced in 10.6
130platform darwin {
131    if {${os.major} < 10} {
132        patchfiles-append patch-boost-aligned-alloc.diff
133    }
134}
135
136# see https://trac.macports.org/wiki/UsingTheRightCompiler
137# patchfiles-append patch-compiler.diff
138post-patch {
139    reinplace "s|__MACPORTS_CXX__|${configure.cxx}|g" ${worksrcpath}/tools/build/src/tools/clang-darwin.jam
140}
141
142# Define BOOST_CLANG_VERSION correctly when LLVM.org clang is used instead of Apple clang.
143# https://github.com/boostorg/config/pull/487
144# patchfiles-append patch-boost-clang-version-llvmorg-on-apple.diff
145
146# Build issue on some older systems
147# ld: warning: option -s is obsolete and being ignored
148# ld: internal error: atom not found in symbolIndex(__ZNSt3__1plIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_12basic_stringIT_T0_T1_EERKS9_SB_) for architecture x86_64
149# patchfiles-append patch-b2-build-older-OSes.diff
150
151proc write_jam s {
152    global worksrcpath
153    set config [open ${worksrcpath}/user-config.jam a]
154    puts ${config} ${s}
155    close ${config}
156}
157
158compilers.choose   cc cxx
159mpi.setup          -gcc
160
161# NOTE: although technically Boost does not require C++11 compliance
162# for building, doing so allows for building on more OSs than without.
163# Further: Building Boost using C++11 compliance does not seem to then
164# require ports depending on Boost to also require C++11 compliance,
165# and requiring it does make such building easier for those ports.
166configure.cxxflags-append -std=gnu++11
167compiler.cxx_standard   2011
168
169# This flag fixes the return type of unsetenv(3)
170# See: https://trac.macports.org/ticket/63121
171platform darwin 8 {
172    configure.cxxflags-append -D__DARWIN_UNIX03=1
173}
174
175# It turns out that ccache and distcc can produce boost libraries that, although they
176# compile without warning, have all sorts of runtime errors especially with pointer corruption.
177# Since most people will now use MacPorts' pre-compiled boost, this should not be a problem.
178configure.ccache    no
179configure.distcc    no
180
181configure.cmd       ./bootstrap.sh
182configure.args      --without-libraries=python \
183                    --without-libraries=mpi \
184                    --with-icu=${prefix}
185
186# boost build scripts default to clang on darwin
187if {[string match *gcc* ${configure.compiler}]} {
188    configure.args-append --with-toolset=gcc
189}
190
191# Boost's PPC32 ASM code in the context module was only recently fixed (see
192# patch above). PPC64 is still broken.
193platform darwin {
194    if {${build_arch} eq "ppc64"} {
195        configure.args-append   --without-libraries=context \
196                                --without-libraries=coroutine
197    }
198}
199
200configure.universal_args
201
202post-configure {
203
204    reinplace -E "s|-install_name \"|&${bprefix}/lib/|" \
205        ${worksrcpath}/tools/build/src/tools/darwin.jam
206
207    set compileflags ""
208    if {[string length ${configure.sdkroot}] != 0} {
209        set compileflags "<compileflags>\"-isysroot ${configure.sdkroot}\""
210    }
211
212    set cxx_stdlibflags {}
213    if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} ne ""} {
214        set cxx_stdlibflags -stdlib=${configure.cxx_stdlib}
215    }
216
217    # see https://trac.macports.org/ticket/55857
218    # see https://svn.boost.org/trac10/ticket/13454
219    write_jam "using darwin : : ${configure.cxx} : <asmflags>\"${configure.cflags} [get_canonical_archflags cc]\" <cflags>\"${configure.cflags} [get_canonical_archflags cc]\" <cxxflags>\"${configure.cxxflags} [get_canonical_archflags cxx] ${cxx_stdlibflags}\" ${compileflags} <linkflags>\"${configure.ldflags} ${cxx_stdlibflags}\" : ;"
220
221}
222
223build.cmd       ${worksrcpath}/b2
224build.target
225build.args      -d2 \
226                --layout=tagged \
227                --debug-configuration \
228                --user-config=user-config.jam \
229                -sBZIP2_INCLUDE=${prefix}/include \
230                -sBZIP2_LIBPATH=${prefix}/lib \
231                -sEXPAT_INCLUDE=${prefix}/include \
232                -sEXPAT_LIBPATH=${prefix}/lib \
233                -sZLIB_INCLUDE=${prefix}/include \
234                -sZLIB_LIBPATH=${prefix}/lib \
235                -sICU_PATH=${prefix} \
236                variant=release \
237                threading=single,multi \
238                link=static,shared \
239                runtime-link=shared \
240                -j${build.jobs} \
241                --no-cmake-config
242
243destroot.cmd    ${worksrcpath}/b2
244destroot.post_args
245
246pre-destroot {
247    destroot.args {*}${build.args} --prefix=${destroot}${bprefix}
248    system "find ${worksrcpath} -type f -name '*.gch' -exec rm {} \\;"
249}
250
251proc boost_docs_install {} {
252    global bprefix destroot worksrcpath name
253
254    set docdir ${bprefix}/share/doc/${name}
255    xinstall -d ${destroot}${docdir}
256    set l [expr [string length ${worksrcpath}] + 1]
257    fs-traverse f [glob -directory ${worksrcpath} *] {
258        set dest ${destroot}${docdir}/[string range ${f} ${l} end]
259        if {[file isdirectory ${f}]} {
260            if {[file tail ${f}] eq "example"} {
261                copy ${f} ${dest}
262                continue
263            }
264            xinstall -d ${dest}
265        } elseif {[lsearch -exact {css htm html png svg} [string range [file extension ${f}] 1 end]] != -1} {
266            xinstall -m 644 ${f} ${dest}
267        }
268    }
269}
270
271post-destroot {
272    if {[variant_isset docs]} {
273        boost_docs_install
274    }
275}
276
277set pythons_versions {3.12}
278
279set pythons_ports {}
280foreach v ${pythons_versions} {
281    lappend pythons_ports python[string map {. {}} ${v}]
282}
283
284proc python_dir {} {
285    global pythons_versions
286    foreach p ${pythons_versions} {
287        set s [string map {. {}} ${p}]
288        if {[variant_isset python${s}]} {
289            return [file normalize [exec ${p} -c "import sys; print(sys.prefix)"]/lib/${p}/site-packages]
290        }
291    }
292    error "Python support not enabled."
293}
294
295foreach v ${pythons_versions} {
296    set s [string map {. {}} ${v}]
297    set p python${s}
298    set i [lsearch -exact ${pythons_ports} ${p}]
299    set c [lreplace ${pythons_ports} ${i} ${i}]
300    if { ${s} > 30 } { set bppatch "patch-boost-python3.diff" } else { set bppatch "" }
301    variant ${p} description "Build Boost.Python for Python ${v}" conflicts {*}${c} debug "
302
303        # There is a conflict with python and debug support, so we should really change the 'variant' line above
304        # to end with 'conflicts ${c} debug' above. However, we leave it enabled for those who want to try it.
305        # The issue has been reported to both the MacPorts team and the boost team, as per:
306        # <http://trac.macports.org/ticket/23667> and <https://svn.boost.org/trac/boost/ticket/4461>
307
308        depends_lib-append      port:${p}
309        configure.args-delete   --without-libraries=python
310        configure.args-append   --with-python=${prefix}/bin/python${v} --with-python-root=${prefix}/bin/python${v}
311
312        patchfiles-append   ${bppatch} patch-tools-build-src-tools-python.jam.diff \
313                            patch-tools-build-src-tools-python-2.jam.diff
314
315        post-patch {
316            reinplace s|@FRAMEWORKS_DIR@|${frameworks_dir}| ${worksrcpath}/tools/build/src/tools/python.jam
317        }
318    "
319}
320
321if {![variant_isset debug]} {
322    set selected_python python311
323    foreach v ${pythons_versions} {
324        set s [string map {. {}} ${v}]
325        if {[variant_isset python${s}]} {
326            set selected_python python${s}
327        }
328    }
329    default_variants +${selected_python}
330}
331
332post-destroot {
333    # To avoid checking for all Python variants, don't fail if no libs exist
334    foreach f [glob -nocomplain ${destroot}${bprefix}/lib/*python*.dylib] {
335        set tf [file tail ${f}]
336        ln -s ${tf} ${destroot}${bprefix}/lib/[string map "${selected_python} python3" ${tf}]
337        ln -s ${tf} ${destroot}${bprefix}/lib/[string map "${selected_python} python"  ${tf}]
338    }
339}
340
341default_variants +no_single +no_static
342
343variant debug description {Builds debug versions of the libraries as well} {
344    build.args-delete   variant=release
345    build.args-append   variant=debug,release
346}
347
348variant no_static description {Disable building static libraries} {
349    build.args-delete   link=static,shared
350    build.args-append   link=shared
351}
352
353variant no_single description {Disable building single-threaded libraries} {
354    build.args-delete   threading=single,multi
355    build.args-append   threading=multi
356}
357
358subport ${name}-numpy {
359    revision 3
360    description Boost.Numpy library
361    long_description {*}${description}
362    depends_lib port:boost${tag}
363    foreach v ${pythons_versions} {
364        set s [string map {. {}} ${v}]
365        if {[variant_isset python${s}]} {
366            depends_lib-append port:py${s}-numpy
367            require_active_variants boost python${s}
368        }
369    }
370    if {[variant_isset no_static]} {
371        require_active_variants boost no_static
372    } else {
373        require_active_variants boost "" no_static
374    }
375    if {[variant_isset no_single]} {
376        require_active_variants boost no_single
377    } else {
378        require_active_variants boost "" no_single
379    }
380}
381
382if {$subport eq $name} {
383
384    revision 8
385
386#    patchfiles-append patch-disable-numpy-extension.diff
387
388    variant regex_match_extra description \
389        "Enable access to extended capture information of submatches in Boost.Regex" {
390        notes-append "
391        You enabled the +regex_match_extra variant\; see the following page for an\
392        exhaustive list of the consequences of this feature:
393
394    http://www.boost.org/doc/libs/${distver}/libs/regex/doc/html/boost_regex/ref/sub_match.html
395"
396
397        post-patch {
398            reinplace {/#define BOOST_REGEX_MATCH_EXTRA/s:^// ::} \
399                ${worksrcpath}/boost/regex/user.hpp
400        }
401    }
402
403    variant docs description {Enable building documentation} {
404        # No configure changes, etc; we simply check 'variant_isset' elsewhere
405    }
406
407    post-destroot {
408        delete file {*}[glob ${destroot}${bprefix}/include/boost/python/numpy*]
409    }
410
411    if {[mpi_variant_isset]} {
412
413        # see https://trac.macports.org/ticket/49748
414        # see http://www.openradar.me/25313838
415        configure.ldflags-append -Lstage/lib
416
417        # There is a conflict with debug support.
418        # The issue has been reported to both the MacPorts team and the boost team, as per:
419        # <http://trac.macports.org/ticket/23667> and <https://svn.boost.org/trac/boost/ticket/4461>
420        if {[variant_isset debug]} {
421            return -code error "+debug variant conflicts with mpi"
422        }
423
424        configure.args-delete   --without-libraries=mpi
425
426        post-configure {
427            write_jam "using mpi : ${mpi.cxx} : : ${mpi.exec} ;"
428        }
429
430        if {![catch python_dir]} {
431
432            patchfiles-append patch-libs-mpi-build-Jamfile.v2.diff
433
434            post-destroot {
435                set site_packages [python_dir]
436                xinstall -d ${destroot}${site_packages}/boost
437                xinstall -m 644 ${worksrcpath}/libs/mpi/build/__init__.py \
438                    ${destroot}${site_packages}/boost
439
440                set f ${destroot}${bprefix}/lib/mpi.so
441                if {[info exists ${f}]} {
442                    set l ${site_packages}/boost/mpi.so
443                    move ${f} ${destroot}${l}
444                    system "install_name_tool -id ${l} ${destroot}${l}"
445                }
446            }
447
448        }
449    }
450
451    livecheck.type  regex
452    livecheck.url   http://www.boost.org/users/download/
453    livecheck.regex Version (\\d+\\.\\d+\\.\\d+)</span>
454} else {
455    post-destroot {
456        move {*}[glob ${destroot}${bprefix}/lib/libboost_numpy*] ${destroot}${bprefix}
457        move {*}[glob ${destroot}${bprefix}/include/boost/python/numpy*] ${destroot}${bprefix}
458        # if an mpi variant *and* a python variant is selected, then a binary
459        # python module called mpi.so gets installed, so delete ${frameworks_dir}
460        delete ${destroot}${bprefix}${frameworks_dir} \
461            ${destroot}${bprefix}/include \
462            ${destroot}${bprefix}/lib \
463            ${destroot}${bprefix}/share
464        file mkdir ${destroot}${bprefix}/lib ${destroot}${bprefix}/include/boost/python
465        move {*}[glob ${destroot}${bprefix}/libboost_numpy*] ${destroot}${bprefix}/lib
466        move {*}[glob ${destroot}${bprefix}/numpy*] ${destroot}${bprefix}/include/boost/python
467    }
468
469    livecheck.type  none
470}
471
472if {!${universal_possible} || ![variant_isset universal]} {
473    if {[lsearch ${build_arch} arm*] != -1} {
474        build.args-append address-model=64 architecture=arm
475    } else {
476        if {[lsearch ${build_arch} ppc*] != -1} {
477            build.args-append architecture=power
478            if {${os.arch} ne "powerpc"} {
479                build.args-append --disable-long-double
480            }
481        } else {
482            if {[lsearch ${build_arch} *86*] != -1} {
483                build.args-append architecture=x86
484            } else {
485                pre-fetch {
486                    error "Current value of 'build_arch' (${build_arch}) is not supported."
487                }
488            }
489            if {[lsearch ${build_arch} *64] != -1} {
490                build.args-append address-model=64
491            } else {
492                build.args-append address-model=32
493            }
494        }
495    }
496}
497
498variant universal {
499    build.args-append   pch=off
500
501    if {[lsearch ${configure.universal_archs} arm*] != -1} {
502        build.args-append address-model=64 architecture=arm+x86
503    } else {
504        if {[lsearch ${configure.universal_archs} ppc*] != -1} {
505            if {[lsearch ${configure.universal_archs} *86*] != -1} {
506                build.args-append architecture=arm+x86
507            } else {
508                build.args-append architecture=power
509            }
510            if {${os.arch} ne "powerpc"} {
511                build.args-append --disable-long-double
512            }
513        } else {
514            build.args-append architecture=x86
515        }
516        if {[lsearch ${configure.universal_archs} *64] != -1} {
517            if {[lsearch ${configure.universal_archs} i386] != -1 || [lsearch ${configure.universal_archs} ppc] != -1} {
518                build.args-append address-model=32_64
519                if {[lsearch ${configure.universal_archs} ppc64] == -1} {
520                    post-patch {
521                        reinplace "/local support-ppc64 =/s/= 1/= /" ${worksrcpath}/tools/build/src/tools/darwin.jam
522                    }
523                }
524            } else {
525                build.args-append address-model=64
526            }
527        } else {
528            build.args-append address-model=32
529        }
530    }
531}
532
533platform powerpc {
534    build.args-append   --disable-long-double
535}
536
537platform darwin 8 powerpc {
538    if {[variant_isset universal]} {
539        build.args-append   macosx-version=10.4
540    }
541}
542
543# As of Boost 1.70.0, Boost provides CMake find scripts for itself
544# that are installed by default. Those provided in 1.70.0 were broken
545# in multiple ways; many fixed were added before 1.71.0. That said,
546# we're not installing them by default at this time, but instead
547# providing an option to install them for testing / evaluation
548# purposes. We will likely enable these scripts in the future since it
549# is likely that CMake will stop providing them once the
550# Boost-provided version is stable.
551variant cmake_scripts description {Install Boost CMake find scripts} {
552    build.args-delete --no-cmake-config
553}