Re: make distcheck and the /etc dir

2007-06-10 Thread Ralf Wildenhues
Hello, and sorry for chiming in so late,

* Noah Slater wrote on Mon, Jun 04, 2007 at 06:57:43PM CEST:
# Makefile.am for installing configuration data
etcdir=/etc/lx2005
etc_DATA = serlog.conf
 
 This is seriously broken. What if my /etc directory is read-only, for 
 example.

Exactly.

 This breaks any hope of getting a VPATH build.

You're confusing build tree (which has to do with VPATH) and install
tree (which doesn't) here.

 When I run 'make distcheck' it fails as it cannot install the files to
 '/etc/lx2005'.
 
 Indeed, because distcheck makes sure the build uses VPATH.

But that's not cause of the failure: distcheck makes sure files can be
installed at all by the current user (to somewhere below `pwd` or
TMPDIR).

I think Stepan and others corrected most other things in this thread
already.

Cheers,
Ralf




Re: make distcheck and the /etc dir

2007-06-10 Thread Ralf Wildenhues
Hello,

* Daniel Leidert wrote on Mon, Jun 04, 2007 at 07:38:18PM CEST:
 Am Montag, den 04.06.2007, 15:56 +0200 schrieb Jason Curl:
  
 # Makefile.am for installing configuration data
 etcdir=/etc/lx2005
 
 This line misses a $(DESTDIR) to not break package builds and distcheck.

No, it doesn't.

 etc_DATA = serlog.conf
 [snip]
  The configuration that gets copied depends on the 'configure' script 
  setting the variable $(MACHINE).
  
  When I run 'make distcheck' it fails as it cannot install the files to 
  '/etc/lx2005'. I would very much like the location of the configuration 
  files to be independent of $(prefix) as the locations my project 
  searches are independent of where it was installed.
 
 No problem: But you should add the DESTDIR variable to hardcoded paths.

Only in rules.

Cheers,
Ralf
-- 
apologies for brevity -- typing one-handed ATM




Re: make distcheck and the /etc dir

2007-06-10 Thread Daniel Leidert
Am Sonntag, den 10.06.2007, 09:01 +0200 schrieb Ralf Wildenhues:
 * Daniel Leidert wrote on Mon, Jun 04, 2007 at 07:38:18PM CEST:
  Am Montag, den 04.06.2007, 15:56 +0200 schrieb Jason Curl:
   
  # Makefile.am for installing configuration data
  etcdir=/etc/lx2005
  
  This line misses a $(DESTDIR) to not break package builds and distcheck.
 
 No, it doesn't.
 
  etc_DATA = serlog.conf
  [snip]
   The configuration that gets copied depends on the 'configure' script 
   setting the variable $(MACHINE).
   
   When I run 'make distcheck' it fails as it cannot install the files to 
   '/etc/lx2005'. I would very much like the location of the configuration 
   files to be independent of $(prefix) as the locations my project 
   searches are independent of where it was installed.
  
  No problem: But you should add the DESTDIR variable to hardcoded paths.
 
 Only in rules.

You are right. I already found my mistake.

Regards, Daniel





Re: make distcheck and the /etc dir

2007-06-05 Thread Daniel Leidert
Am Montag, den 04.06.2007, 22:15 +0100 schrieb Noah Slater:
  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/__init__.py.in'
 that is has the following lines:
[snip]
 Now, when ./configure is run this file is generated and placed at
 'lib/foo/__init__.py' 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.

Well, that has some limitations. It's possible, that you need to
evaluate a variable with eval more than just once (e.g. $datadir needs
at least two eval calls). People often use a loop to do this. IMHO it's
easier to use DEFS instead here:

DEFS += -DSYSCONFDIR=\$(sysconfdir)\ -DPKGDATADIR=\$(pkgdatadir)\

and don't use config.h for this.

Regards, Daniel





Re: make distcheck and the /etc dir

2007-06-05 Thread Stepan Kasal
Hello Jason,

On Mon, Jun 04, 2007 at 07:25:16PM +0200, Jason Curl wrote:
 Sounds like my best solution would be to use the sysconf_DATA option. 

this was also the fist solution which came to my mind.

 Any ideas how to take 'sysconfdir' and somehow import it into my program 
 so it knows where the default configuration files are?

See `info Autoconf FAQ defining' for general instructions.
A correction, though:
I'd use
  AM_CPPFLAGS = -DDATADIR='$(datadir)'
instead of modifying CPPFLAGS.

I think it is OK to use the default value of sysconfdir and let the
user configure with --sysconfdir=/etc if that is what they want.
(GNU/Linux distributions often set that in their build scripts.)

It is possible to do some hacks in configure.ac so that the default
is /etc.  (And you can then use DISTCHECK_CONFIGURE_FLAGS to revert
that change for distcheck, so that it passes.)

 I'm also concerned about overwriting a users old configuration file. So 
 any ideas how I can operate on any existing files before they're 
 overwritten? For example, I might try a merge, or just copy the files as 
 a backup before overwriting them.

I guess that in that case it might be best to foget about
sysconf_DATA, and use install-exec-local for the installation of
the config file.  (You would use EXTRA_DIST to distribute your
default config file, of course.)

This thread got quite a big quickly; if a particular question
remained unansewered, feel free to post it again, under a new
subject.

Have a nice day,
Stepan Kasal




make distcheck and the /etc dir

2007-06-04 Thread Jason Curl

Hello,

I have a project where the program expects the configuration files to be 
stored in '/etc/lx2005'. Appropriately, I've got such a Makefile.am:


  # Makefile.am for installing configuration data
  etcdir=/etc/lx2005
  etc_DATA = serlog.conf

  CLEANFILES = serlog.conf

  EXTRA_DIST = serlog.conf.generic \
 serlog.conf.busybox \
 serlog.conf.cygwin  \
 serlog.conf.linux   \
 serlog.conf.solaris \
 serlog.conf.freebsd \
 serlog.conf.interix \
 serlog.conf.darwin

  # When we 'make' we create a copy of the configuration file that was
  # determined during 'configure' time.
  serlog.conf: @top_srcdir@/serlog/etc/serlog.conf.$(MACHINE)
cp -f @top_srcdir@/serlog/etc/serlog.conf.$(MACHINE) serlog.conf

The configuration that gets copied depends on the 'configure' script 
setting the variable $(MACHINE).


When I run 'make distcheck' it fails as it cannot install the files to 
'/etc/lx2005'. I would very much like the location of the configuration 
files to be independent of $(prefix) as the locations my project 
searches are independent of where it was installed.


Installing to my remote file system is easy enough and it works:
  make DESTDIR=/mnt/remotefs install

How can I get 'make distcheck' to work with this configuration? 
Alternatively, I'm open for other ideas of implementation.


Thanks  Best Regards,
Jason.




Re: make distcheck and the /etc dir

2007-06-04 Thread Noah Slater

   # Makefile.am for installing configuration data
   etcdir=/etc/lx2005
   etc_DATA = serlog.conf


This is seriously broken. What if my /etc directory is read-only, for example.

This breaks any hope of getting a VPATH build.


When I run 'make distcheck' it fails as it cannot install the files to
'/etc/lx2005'.


Indeed, because distcheck makes sure the build uses VPATH.


I would very much like the location of the configuration
files to be independent of $(prefix) as the locations my project
searches are independent of where it was installed.


This is a Bad Thing IMO. You should alter your program to look in
multiple places for it's configuration. If you are certain that the
configuration file should live here despite the wishes of the
installer your program should by default it will check for
'/etc/lx2005' and failing back to '$(prefix)/lx2005' - though this is
still broken.


How can I get 'make distcheck' to work with this configuration?


You cannot.


Alternatively, I'm open for other ideas of implementation.


Why is it so important for configuration files to live at /etc?




Re: make distcheck and the /etc dir

2007-06-04 Thread deckrider

On 6/4/07, Jason Curl [EMAIL PROTECTED] wrote:

Hello,

I have a project where the program expects the configuration files to be
stored in '/etc/lx2005'. Appropriately, I've got such a Makefile.am:

   # Makefile.am for installing configuration data
   etcdir=/etc/lx2005


I often struggle with this, and have to refer to this FAQ:

http://sources.redhat.com/automake/automake.html#Hard_002dCoded-Install-Paths




Re: make distcheck and the /etc dir

2007-06-04 Thread Noah Slater

http://sources.redhat.com/automake/automake.html#Hard_002dCoded-Install-Paths

Informative. Though I still maintain that it's a Bad Thing. Heh.




Re: make distcheck and the /etc dir

2007-06-04 Thread Jason Curl

deckrider wrote:

On 6/4/07, Jason Curl [EMAIL PROTECTED] wrote:

Hello,

I have a project where the program expects the configuration files to be
stored in '/etc/lx2005'. Appropriately, I've got such a Makefile.am:

   # Makefile.am for installing configuration data
   etcdir=/etc/lx2005


I often struggle with this, and have to refer to this FAQ:

http://sources.redhat.com/automake/automake.html#Hard_002dCoded-Install-Paths 



Very useful, thankyou Sir.

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?


I might have to change my policy to not bother looking in various 
directories for configuration files (see my post reply to Noah), which 
depends on an answer to above. Or does somebody else have an algorithm 
to calculate where the configuration files are based on the location of 
the executable (relatively system portable).


I'm also concerned about overwriting a users old configuration file. So 
any ideas how I can operate on any existing files before they're 
overwritten? For example, I might try a merge, or just copy the files as 
a backup before overwriting them.


Thanks,
Jason.




Re: make distcheck and the /etc dir

2007-06-04 Thread Daniel Leidert
Am Montag, den 04.06.2007, 15:56 +0200 schrieb Jason Curl:
 Hello,
 
 I have a project where the program expects the configuration files to be 
 stored in '/etc/lx2005'. Appropriately, I've got such a Makefile.am:
 
# Makefile.am for installing configuration data
etcdir=/etc/lx2005

This line misses a $(DESTDIR) to not break package builds and distcheck.

etc_DATA = serlog.conf
[snip]
 The configuration that gets copied depends on the 'configure' script 
 setting the variable $(MACHINE).
 
 When I run 'make distcheck' it fails as it cannot install the files to 
 '/etc/lx2005'. I would very much like the location of the configuration 
 files to be independent of $(prefix) as the locations my project 
 searches are independent of where it was installed.

No problem: But you should add the DESTDIR variable to hardcoded paths.
If you use sysconfdir etc.pp, you don't need to add the DESTDIR variable
explicitly.

 Installing to my remote file system is easy enough and it works:
make DESTDIR=/mnt/remotefs install

And the configuration file then is inside /etc and not /mnt/remotefs?
Why? And BTW: That should be done using --prefix=/mnt/remotefs
--sysconfdir=/etc and not DESTDIR (IMHO). DESTDIR is used e.g. for
creating packages (e.g. Debian packages). With your usage of this
variable, you break the possibility to package your software, because it
will try to write to /etc in every case.

 How can I get 'make distcheck' to work with this configuration? 
 Alternatively, I'm open for other ideas of implementation.

BTW: If you use

etcdir=${sysconfdir}

you can set

DISTCHECK_CONFIGURE_FLAGS = --sysconfdir=/etc

And if you want to make this the default, set it in your configure
script:

AC_SUBST([sysconfdir],[/etc])

However, you should carefully think about this. I personally would leave
it up to the user to choose a directory.

Regards, Daniel





Re: make distcheck and the /etc dir

2007-06-04 Thread deckrider

On 6/4/07, deckrider [EMAIL PROTECTED] wrote:

On 6/4/07, Jason Curl [EMAIL PROTECTED] wrote:
 Daniel Leidert wrote:
  BTW: If you use
 
  etcdir=${sysconfdir}
 
  you can set
 
  DISTCHECK_CONFIGURE_FLAGS = --sysconfdir=/etc
 
  And if you want to make this the default, set it in your configure
  script:
 
  AC_SUBST([sysconfdir],[/etc])
 
  However, you should carefully think about this. I personally would leave
  it up to the user to choose a directory.

 After comments from previous posts I'm thinking how I can then take the
 prefix the user provided and put that in config.h that the program can
 then read to know where the configuration files are. I'll now have to
 learn how to extend the installation to make backups of any old
 configurations that might be there.

 Doing AC_SUBST([sysconfdir],[/etc]) brings back the original problem and
 doesn't help.

When you use automake, you get all these nice user-controlled things
like --prefix and --sysconfdir (even if you don't want them).  I
generally advise to use them instead of working to not use them,
thereby confusing the user who might be running './configure --help'
and seeing that they exist and finding later that your packages is
working to ignore them.

You may find some additional interesting information here (automake
uses autoconf):

http://www.gnu.org/software/autoconf/manual/autoconf.html#Installation-Directory-Variables

In short, assuming that the configure.ac/Makefile.am you are working
on controls the installation of the c/c++ compiled software that wants
to look for this configuration file, I would recommend against any
configure.ac stuff and instead do something like this in your
Makefile.am:

AM_CPPFLAGS = -DSYSCONFDIR=\$(sysconfdir)\


oopsI mean this:

AM_CPPFLAGS = -DSYSCONFDIR=\$(sysconfdir)\


This works because automake will supply you with a sysconfdir value
(either a default one, or one provided by the user).






Re: make distcheck and the /etc dir

2007-06-04 Thread Noah Slater

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/__init__.py.in'
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_PACKAGE_TARNAME = @PACKAGE_TARNAME@
_GNU_DATAROOTDIR = _expand_variable(@datarootdir@, prefix=_GNU_PREFIX)

DEFAULT_CONFIGURATION_DIRECTORY = _expand_variable(
   @pkgconfdir@, prefix=_GNU_PREFIX)
DEFAULT_DOCUMENTATION_DIRECTORY = _expand_variable(@docdir@,
   datarootdir=_GNU_DATAROOTDIR, PACKAGE_TARNAME=_GNU_PACKAGE_TARNAME)
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/__init__.py' 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.

Noah

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