Sets a target name that the user can then use to configure various
“with” options with on the command line by using that name. For
example, if the target is set to “foo”, then the user could use the
–with-foo-dir=prefix, –with-foo-include=dir and –with-foo-lib=dir
command line options to tell where to search for header/library files.
You may pass along additional parameters to specify default values. If one
is given it is taken as default prefix, and if two are given they
are taken as “include” and “lib” defaults in that order.
In any case, the return value will be an array of determined “include”
and “lib” directories, either of which can be nil if no corresponding
command line option is given when no default value is specified.
Note that dir_config only adds
to the list of places to search for libraries and include files. It does
not link the libraries into your application.
# File lib/mkmf.rb, line 1699
def dir_config(target, idefault=nil, ldefault=nil)
if dir = with_config(target + "-dir", (idefault unless ldefault))
defaults = Array === dir ? dir : dir.split(File::PATH_SEPARATOR)
idefault = ldefault = nil
end
idir = with_config(target + "-include", idefault)
$arg_config.last[1] ||= "${#{target}-dir}/include"
ldir = with_config(target + "-lib", ldefault)
$arg_config.last[1] ||= "${#{target}-dir}/#{_libdir_basename}"
idirs = idir ? Array === idir ? idir.dup : idir.split(File::PATH_SEPARATOR) : []
if defaults
idirs.concat(defaults.collect {|d| d + "/include"})
idir = ([idir] + idirs).compact.join(File::PATH_SEPARATOR)
end
unless idirs.empty?
idirs.collect! {|d| "-I" + d}
idirs -= Shellwords.shellwords($CPPFLAGS)
unless idirs.empty?
$CPPFLAGS = (idirs.quote << $CPPFLAGS).join(" ")
end
end
ldirs = ldir ? Array === ldir ? ldir.dup : ldir.split(File::PATH_SEPARATOR) : []
if defaults
ldirs.concat(defaults.collect {|d| "#{d}/#{_libdir_basename}"})
ldir = ([ldir] + ldirs).compact.join(File::PATH_SEPARATOR)
end
$LIBPATH = ldirs | $LIBPATH
[idir, ldir]
end