How to properly add -stdlib=... (and other flags)?

Mojca Miklavec mojca at macports.org
Fri Dec 23 09:07:36 CET 2016


Hi,

I would like to know the best way to add arch flags and stdlib to
ports with exotic build systems (like scons) where this is not handled
automatically by the base.

I'm currently using:

build.args \
CCFLAGS="[get_canonical_archflags cc] -stdlib=${configure.cxx_stdlib}" \
LINKFLAGS="[get_canonical_archflags ld] -stdlib=${configure.cxx_stdlib}"

but that fails on 10.6 where the compiler doesn't know the option `-stdlib=...`.
In this case CCFLAGS are used for both C and C++.

I guess I could use

if {[string match *clang* ${configure.cxx}]} {
    ...
}

but I'm almost sure that there is a better way to:
- add arch flags
- add stdlib flags only if the compiler supports them (and only if
they are needed?)
- potentially add any other flags that MacPorts deems reasonable
without duplicating the logic that's already in the base.

Thank you,
    Mojca


More information about the macports-dev mailing list