merger_(configure|build)_args and related tricks for universal?
Ryan Schmidt
ryandesign at macports.org
Fri Mar 11 12:04:41 PST 2011
On Mar 11, 2011, at 12:53, Bayard Bell wrote:
> I've noticed this trick used in various ports (spidermonkey, libiconv, openssl) to allow variation between the arches used in a universal build, seemingly by building a hash/dict/associative array/don't-know-the-problem-term-for-Tcl of arch-specific settings that are set/appended/whatever and then sourced as the arches are iterated through. To use lang/xercesc as an example:
>
> proc bits_arg_for_arch {arch} {
> switch ${arch} {
> x86_64 -
> ppc64 { return {-b 64} }
> i386 -
> ppc { return {-b 32} }
> }
> }
>
> if {[variant_isset universal]} {
> foreach arch {x86_64 ppc64 i386 ppc} {
> set merger_configure_args(${arch}) [bits_arg_for_arch ${arch}]
> }
> } else {
> configure.args-append [bits_arg_for_arch ${configure.build_arch}]
> }
>
> Maybe a little easier to read, at least for an untutored eye such as mine, would be math/arpack:
>
> if { ! [variant_isset universal]} {
> build.args-append home=${worksrcpath}
> if { ${build_arch}=="x86_64" || ${build_arch}=="ppc64" } {
> build.args-append FFLAGS='-O2 -m64'
> } else {
> build.args-append FFLAGS='-O2 -m32'
> }
> } else {
> foreach arch {x86_64 i386 ppc ppc64} {
> set merger_build_args(${arch}) home=${worksrcpath}-${arch}
> if { ${arch}=="x86_64" || ${arch}=="ppc64" } {
> lappend merger_build_args(${arch}) FFLAGS='-O2 -m64'
> } else {
> lappend merger_build_args(${arch}) FFLAGS='-O2 -m32'
> }
> }
>
> }
>
> I was trying to use these to fix an upstream dependency for a Python module I was trying to port, but I haven't been able either to get it to work as I might intuit (no evidence of arguments being merged in adapting from the latter example with minor changes) or to find any documentation to explain how it's supposed to work. I don't know Tcl at all, which isn't nearly well enough to work out the mechanics quickly from the source, so I thought I'd ask here. Happy to write up a HOWTO for posterity if someone can smack me with a clue stick.
These only work if you are using the universal variant provided by the muniversal portgroup. If you're instead using the universal variant provided by MacPorts base, all archs are compiled at once with the same arguments / environment variables.
The available variables in the muniversal portgroup are explained a bit in the comments at the top of the portgroup:
http://trac.macports.org/browser/trunk/dports/_resources/port1.0/group/muniversal-1.0.tcl
More information about the macports-users
mailing list