Ticket #54198: gcc7+with_libgcc.diff

File gcc7+with_libgcc.diff, 4.1 KB (added by RJVB (René Bertin), 7 years ago)

single-build variants

  • lang/gcc7/Portfile

    a b  
    33PortSystem 1.0
    44PortGroup select 1.0
    55PortGroup compiler_blacklist_versions 1.0
     6PortGroup active_variants 1.1
    67
    78name                gcc7
    89subport             libgcc {}
     
    144145if {${subport} eq "libgcc"} {
    145146    conflicts       libgcc-devel
    146147    long_description-append \
    147                     This port installs the standard runtime libraries, including libstdc++.
     148                    This port installs the standard runtime libraries, including libstdc++. \
     149                    Users building from source can install port:${name}+with_libgcc \
     150                    and port:${subport}+stub to avoid building everything twice.
     151
     152    variant stub description "Use when the standard libraries are provided by the main port:${name}+with_libgcc" {}
    148153
    149154    # http://trac.macports.org/ticket/35770
    150155    # http://trac.macports.org/ticket/38814
     
    158163    # version should continue to provide a subport for that and older gcc
    159164    # versions.
    160165
     166    if {![catch {set result [active_variants ${name} with_libgcc {}]}]} {
     167        if {${result}} {
     168            default_variants-append +stub
     169        }
     170    }
     171    if {[variant_isset stub]} {
     172        # reset the depspecs to just port:${name}
     173        depends_lib     port:${name}
     174        require_active_variants ${name} with_libgcc
     175
     176        use_configure   no
     177        fetch           {}
     178        extract         {}
     179        patch           {}
     180        build           {}
     181        destroot {
     182            # install symlinks to the set of standardLibs that have in this case been
     183            # installed by the main port. In other words, use the reverse logic to the
     184            # comparable foreach loop in the main port's post-destroot, minus the deleting.
     185            xinstall -m 755 -d ${destroot}${prefix}/lib/libgcc
     186            foreach dylib ${standardLibs} {
     187                # Different OS versions (eg: Leopard) or architectures (eg: PPC) don't produce all the dylibs
     188                # https://trac.macports.org/ticket/40098
     189                # https://trac.macports.org/ticket/40100
     190                if {[file exists ${prefix}/lib/${name}/${dylib}]} {
     191                    ln -s ${prefix}/lib/${name}/${dylib} ${destroot}${prefix}/lib/libgcc/${dylib}
     192                }
     193
     194                if {[variant_isset universal]} {
     195                    foreach archdir [glob ${prefix}/lib/${name}/*/] {
     196                        if {[file exists ${archdir}/${dylib}]} {
     197                            ln -s ${archdir}/${dylib} ${destroot}${prefix}/lib/libgcc/${dylib}
     198                        }
     199                    }
     200                }
     201            }
     202        }
     203    } else {
     204    ## default libgcc variant
    161205    depends_lib-delete path:lib/libgcc/libgcc_s.1.dylib:libgcc
     206    require_active_variants ${name} "" with_libgcc
    162207
    163208    configure.args-delete --libdir=${prefix}/lib/${name}
    164209    configure.args-append --libdir=${prefix}/lib/libgcc
     
    219264        # For binary compatibility with binaries that linked against the old libstdcxx port
    220265        ln -s libgcc/libstdc++.6.dylib ${destroot}${prefix}/lib/libstdc++.6.dylib
    221266    }
     267    ## end default libgcc variant
     268    }
    222269
    223270} else {
    224271
     272variant with_libgcc description "Include the standard libraries instead of getting them from port:libgcc. Speeds up building from source." {}
     273
    225274depends_run-append         port:gcc_select
     275if {[variant_isset with_libgcc]} {
     276    # we install libgcc's content ourselves
     277    depends_lib-delete path:lib/libgcc/libgcc_s.1.dylib:libgcc
     278}
    226279
    227280post-destroot {
    228281    file delete ${destroot}${prefix}/share/info/dir
     
    234287        file rename ${file} ${newfile}
    235288    }
    236289
     290    if {![variant_isset with_libgcc]} {
     291    ## default gcc7 variant
    237292    foreach dylib ${standardLibs} {
    238293        # Different OS versions (eg: Leopard) or architectures (eg: PPC) don't produce all the dylibs
    239294        # https://trac.macports.org/ticket/40098
     
    252307            }
    253308        }
    254309    }
     310    ## end default gcc7 variant
     311    }
    255312}
    256313
    257314select.group        gcc