variables given thru shell commands in *.pc files

Basile Starynkevitch basile at
Fri Sep 20 05:41:17 PDT 2013

On Fri, Sep 20, 2013 at 02:24:46PM +0200, Michał Górny wrote:
> Dnia 2013-09-20, o godz. 13:44:10
> Basile Starynkevitch <basile at> napisał(a):
> > I was thinking of adding some syntax to get pkg-config variables shell expanded. 
> > So having in some *.pc a line like
> >   somevar =| some-command
> > would like the backquote or the $(...) notation in shells assign to somevar 
> > the output given by some-command.
> > I would believe that such feature might be easy to implement (basically, calling popen).
> > I do admit that it may open security risks (since some command is arbitrarily run).
> How would that work for cross-compiling? Currently you can use
> pkg-config compiled on build host to read data from target's .pc files.

Thanks to Michał Górny for his remark (which I don't entirely understand BTW,
because I am not expert on pkg-config)

In my example (see previous message) I was basically dynamically redirecting 
pkg-config to mysql_config. I guess that in a cross-compiling setting, 
the mysql_config would be configured/usable for cross-compilation etc...
(as much as pkg-config is).

So I don't really understand your objection. But I admit that I am not 
very familiar with the practice of cross-compilation. BTW, pkg-config 
(like mysql_config) is not a cross-build tool, but just a glorified text acesssor 
(it finds indirectly some text in some *.pc; I just suggested to enable popen 
-and not just fopen- for that case).

Perhaps the some-command should be previous variable-expanded and this 
might ease cross-compilation (because the command which will be running 
would depend on build/host/target settings...)

Actually, I don't understand exactly the details of pkg-config for 

Another possiblity might be to embed some scripting language (perhaps Guile or 
maybe Python) inside pkg-config. (AFAIK, GNU make 4.0 will embed Guile).

Or what do you suggest to enable indirection from pkg-config to mysql_config?
(generating the mysql.pc statically from output of mysql_config is too error prone)


email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***

More information about the pkg-config mailing list