variables given thru shell commands in *.pc files

Basile Starynkevitch basile at
Fri Sep 20 04:44:10 PDT 2013

Hello List,

I'm the main developer of MELT, see for more.

MELT is a high-level lisp-like domain specific language to extend GCC 
(with an implementation available under GPLv3+ license and FSF copyright).

MELT code is translated into C++ which is then compiled (by running make internally)
and then dlopen-ed.

Sometimes, that code may require some external package. I have a syntax 
to facilitate using pkg-config when compiling that generated C++ code
(search for USE-PACKAGE-FROM-PKG-CONFIG in which is a very big generated HTML page)

Unfortunately for me, pkg-config is not exactly universal, and some software
(notably mysql) provide their own pkg-config like thing, e.g. mysql_config

Of course, one could run mysql_config to manually fill the mysql.pc package descriptor.
However, we might want that to happen automatically.

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.

Then we might have a file mysql.pc which could e.g. contain

  ## file mysql.pc
  ## command-expanded variables
  version =| mysql_config --version
  libdir =| mysql_config --variable=pkglibdir
  mysql_cflags =| mysql_config --cflags
  mysql_libs =| mysql_config --libs

  Name: mysql
  Version: ${version}
  Description: MySQL database version ${version}
  Cflags: ${mysql_cflags}
  Libs: ${mysql_libs}
  ## eof mysql.pc

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).

What do you think of all that? Or is there some other ways to do that?

The motivation is that within MELT I would like to stick to pkg-config mostly, and not
have to provide the various other hooks for other *config programs (like mysql_config
and many others). 


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