Best way to get compile-time configuration for building/linking against Ruby?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello list,

I want to embed the Ruby interpreter in a project and am currently
fiddeling
with getting Ruby’s compile-time configuration, e.g. include and
libraries
paths. I cannot use ‘mkmf’ for various reasons.

Currently, I’m running something like that:

  • —%<—
    ruby -rrbconfig -e ‘puts
    RbConfig::expand("#{RbConfig::CONFIG[“rubyhdrdir”]}/$(arch)")’
  • —>%—

I trust there is a better/more elegant way of solving this? If so, what
would it be?

Thanks a lot in advance,
Eric

P. S. Any chance the Ruby sources would include a pkg-config file or
something similar in the near future?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkyLiVkACgkQhS0drJ3goJIuDgCfdi5BFxOyLKRwT2frpbqvLRi/
rXoAnit39lRbdsdghe0ESM3K7W9fGo1B
=qJTI
-----END PGP SIGNATURE-----

paths. I cannot use ‘mkmf’ for various reasons.

I would call out to mkmf with a fake ext and “see” what it uses.
-r

I trust there is a better/more elegant way of solving this? If so, what

i use this

gist:575279 · GitHub

makes it simple to import the output into any program that can parse
yaml|json.

-a

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Roger,
Ara,

thanks for your answers. I should have been a bit clearer with my
request;
sorry.

Thing is, I’m using Autotools (autoconf et al), so I cannot hardcore
paths
for obvious reasons, and parsing JSON or YAML is from the table, too.
So,
“more elegant” basically meant: Something that’s easy to use from a
shell
script (i.e., configure.ac).

Does sombody have another suggestion? :slight_smile:

  Eric

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkyLp6gACgkQhS0drJ3goJKhPgCeOeOS+aXsju/RbP6kxkyvcJ0S
rsQAn3oZE2fWFoSKmdqZwGielp5wxWKd
=EOp6
-----END PGP SIGNATURE-----

On Sep 11, 1:01 pm, Eric MSP Veith [email protected] wrote:

for obvious reasons, and parsing JSON or YAML is from the table, too. So,
“more elegant” basically meant: Something that’s easy to use from a shell
script (i.e., configure.ac).

Does sombody have another suggestion? :slight_smile:

A workaround will be create ruby as static library (–enable-static –
disable-shared) during Ruby configure phase.

Then, create a program entry point (your program) and link against
libruby library.

You can check how that is done for projects like exerb, is Windows and
MinGW, but you can get the idea form it:

HTH,