I'm using scons to build a linux C based ruby extension. What is the "right" way to get the include paths right? By "right" I mean it works out of the box on 1.9 and 1.8.
I don't want to use the mkmf/Makefile solution.
Thanks! Dave
If you were using autoconf, you could borrow ruby.ac from rice:
http://github.com/jameskilton/rice/blob/master/ruby.ac
or since you are using a different build system, you can duplicate its behavior. To summarize what it does:
$RUBY -rrbconfig -e "puts(Config::CONFIG['$1'] || '')" <variable>
where $RUBY is the ruby interpreter (sometimes interpreters get installed with a different name, e.g. ruby1.8 or ruby1.9) and <variable> is the desired config variable
if ${ruby_config_rubyhdrdir} is empty: (e.g. ruby 1.8)
CPPFLAGS="-I${ruby_config_archdir}
else:
CPPFLAGS="-I${ruby_config_rubyhdrdir} ${ruby_config_rubyhdrdir}/${arch}
CFLAGS="${ruby_config_CFLAGS} ${ruby_config_CCDLFLAGS}"
LDFLAGS="-L${ruby_config_archdir} -L${ruby_config_libdir} ${ruby_config_LDFLAGS}"
LIBS="${ruby_config_LIBS} ${ruby_config_DLDLIBS}"
where the variables ${ruby_config_*} are determined using the config command above, e.g.:
ruby_config_foo=$RUBY -rrbconfig -e "puts(Config::CONFIG['$1'] || '')" foo