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

Joshua Root jmr at macports.org
Fri Dec 23 10:17:49 CET 2016


On 2016-12-23 20:07 , Mojca Miklavec wrote:
> 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.

You can use ${configure.cxxflags} for the latter two.

- Josh


More information about the macports-dev mailing list