[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make distcheck and the /etc dir

From: Noah Slater
Subject: Re: make distcheck and the /etc dir
Date: Mon, 4 Jun 2007 22:15:32 +0100

Sounds like my best solution would be to use the "sysconf_DATA" option.
Any ideas how to take 'sysconfdir' and somehow import it into my program
so it knows where the default configuration files are?

Well, I use Python and I have a file called 'lib/foo/'
that is has the following lines:

def _expand_variable(composite_value, **kwargs):
   composite_value = re.sub('\{|\}', '', composite_value)
   value_template = string.Template(composite_value)
   value = value_template.substitute(**kwargs)
   return value

_GNU_PREFIX = "@prefix@"
_GNU_DATAROOTDIR = _expand_variable("@datarootdir@", prefix=_GNU_PREFIX)

   "@pkgconfdir@", prefix=_GNU_PREFIX)
DEFAULT_DOCUMENTATION_DIRECTORY = _expand_variable("@docdir@",
DEFAULT_LOCALE_DIRECTORY = _expand_variable(
   "@localedir@", datarootdir=_GNU_DATAROOTDIR)
DEFAULT_LOG_DIRECTORY = _expand_variable("@pkglogdir@", prefix=_GNU_PREFIX)

Now, when ./configure is run this file is generated and placed at
'lib/foo/' and hence is available to me a run-time with all
the user configured paths.

If you are using C I believe the recommended way is to use a header
file with a bunch of defines that gets customised at ./configure time.

Or does somebody else have an algorithm
to calculate where the configuration files are based on the location of
the executable (relatively system portable).

Once your program has baked in configuration like above you can use
any method (like environment variables) to override the defaults.

Hope this helps.


"Creativity can be a social contribution, but only in so
far as society is free to use the results." - R. Stallman

reply via email to

[Prev in Thread] Current Thread [Next in Thread]