Re: making config files

2010-01-15 Thread Daniel Pocock





You probably mean $(top_builddir)

Thanks - I'll fix that one

%: %.tmpl $(FIXCONFIG)
 $(FIXCONFIG) $<


AFAIU, %: %.tmpl is GNU Make specific and won't work with other makes.

I realised the same thing and took it out

and put something like the following into each Makefile.am:

include $(top_srcdir)/ganglia.inc

bin_SCRIPTS = ganglia-config

The problem with doing this via a config script is that it will not 
honor a sequence such as:

./configure
make prefix=/opt
make install

because the value '/opt' will not propagate to the generated files. It 
is required by GNU Coding Standards, but of course something you can 
completely ignore as long as you don't claim you follow GCS.
Yes, I realise that would happen - that's why I'm trying to find another 
way to do it
However, things like ganglia-config should be generated during the 
install phase, although the default behavior for the _SCRIPTS primary 
appears to be processing ganglia-config.in during the build phase - 
is there a recommended way it can be influenced to delay processing 
until the install phase?



I don't understand why you are against creating files during 'make 
all', but couldn't automake's install-exec-local target help you here?
That is what I have done actually - but I wanted something more concise, 
e.g.


bin_GENSCRIPTS = script1 script2 script3

with all the logic happening behind the scenes.  Currently I have to 
list a rule (at least two lines of code) for each of script1, script2, ...


My current implementation is now in SVN, would you mind having a quick 
look at my Makefile.am and gmond/Makefile.am?  Is this the right way to 
use the install-* rules?


http://ganglia.svn.sourceforge.net/viewvc/ganglia/trunk/monitor-core/






Re: making config files

2010-01-14 Thread Peter Johansson

On 1/14/10 7:28 AM, Daniel Pocock wrote:


This is how I've been going about it: create $(top_srcdir)/ganglia.inc 
like so:


FIXCONFIG = $(top)/scripts/fixconfig


You probably mean $(top_builddir)

%: %.tmpl $(FIXCONFIG)
 $(FIXCONFIG) $<


AFAIU, %: %.tmpl is GNU Make specific and won't work with other makes.

and put something like the following into each Makefile.am:

include $(top_srcdir)/ganglia.inc

bin_SCRIPTS = ganglia-config

The problem with doing this via a config script is that it will not 
honor a sequence such as:

./configure
make prefix=/opt
make install

because the value '/opt' will not propagate to the generated files. It 
is required by GNU Coding Standards, but of course something you can 
completely ignore as long as you don't claim you follow GCS.
However, things like ganglia-config should be generated during the 
install phase, although the default behavior for the _SCRIPTS primary 
appears to be processing ganglia-config.in during the build phase - is 
there a recommended way it can be influenced to delay processing until 
the install phase?



I don't understand why you are against creating files during 'make all', 
but couldn't automake's install-exec-local target help you here?


http://sources.redhat.com/automake/automake.html#Extending-Installation


cheers,
Peter





Re: making config files

2010-01-14 Thread Daniel Pocock

Russ Allbery wrote:

Daniel Pocock  writes:

  

Thanks for that - the sed example appears to be the type of thing I want.



  

However, is there a more concise way to do this?  I was thinking there may
be some way to invoke sed or m4 on a template in much the way that gcc is
invoked for *.c



Half of that equation would be a more generic script.  Attached is what we
use for INN (which has a bunch of INN-specific bits, but also has the
basic framework for things).
  

The script seems fine - I've located it in your source tree here
http://inn.eyrie.org/svn/trunk/support/

and examples of how you use it here:
http://inn.eyrie.org/svn/trunk/scripts/

The other half would be to set up a way of automatically running that
script on particular files, and that's something I've never done.  I just
write explicit rules.

  
This is what interests me - although I could list out the rules for each 
target, I would like to try and do everything with automake


This is how I've been going about it: create $(top_srcdir)/ganglia.inc 
like so:


FIXCONFIG = $(top)/scripts/fixconfig

%: %.tmpl $(FIXCONFIG)
 $(FIXCONFIG) $<

and put something like the following into each Makefile.am:

include $(top_srcdir)/ganglia.inc

bin_SCRIPTS = ganglia-config

However, things like ganglia-config should be generated during the 
install phase, although the default behavior for the _SCRIPTS primary 
appears to be processing ganglia-config.in during the build phase - is 
there a recommended way it can be influenced to delay processing until 
the install phase?







Re: making config files

2010-01-13 Thread Russ Allbery
Daniel Pocock  writes:

> Thanks for this - it may be just what we need to get some nasty hacks out
> of configure.in

> In case I use this as-is, can you kindly confirm that it is compatible
> with the Ganglia license?
> http://ganglia.svn.sourceforge.net/viewvc/ganglia/trunk/monitor-core/COPYING?revision=560&view=markup

Yeah, using that license is fine.  It's part of INN, which is under a
different form of the BSD license, but I wrote it, and I have no
objections to you using it under the license you link to above.

-- 
Russ Allbery (r...@stanford.edu) 




Re: making config files

2010-01-13 Thread Daniel Pocock

Russ Allbery wrote:

Daniel Pocock  writes:

  

Thanks for that - the sed example appears to be the type of thing I want.



  

However, is there a more concise way to do this?  I was thinking there may
be some way to invoke sed or m4 on a template in much the way that gcc is
invoked for *.c



Half of that equation would be a more generic script.  Attached is what we
use for INN (which has a bunch of INN-specific bits, but also has the
basic framework for things).

The other half would be to set up a way of automatically running that
script on particular files, and that's something I've never done.  I just
write explicit rules.

  

Hi Russ,

Thanks for this - it may be just what we need to get some nasty hacks 
out of configure.in


In case I use this as-is, can you kindly confirm that it is compatible 
with the Ganglia license?

http://ganglia.svn.sourceforge.net/viewvc/ganglia/trunk/monitor-core/COPYING?revision=560&view=markup

Regards,

Daniel




Re: making config files

2010-01-13 Thread Russ Allbery
Daniel Pocock  writes:

> Thanks for that - the sed example appears to be the type of thing I want.

> However, is there a more concise way to do this?  I was thinking there may
> be some way to invoke sed or m4 on a template in much the way that gcc is
> invoked for *.c

Half of that equation would be a more generic script.  Attached is what we
use for INN (which has a bunch of INN-specific bits, but also has the
basic framework for things).

The other half would be to set up a way of automatically running that
script on particular files, and that's something I've never done.  I just
write explicit rules.

-- 
Russ Allbery (r...@stanford.edu) 

#! /bin/sh

##  $Id: fixconfig.in 8471 2009-05-17 08:25:35Z iulius $
##
##  Make variable substitutions in configuration files.
##
##  This script does something very similar to what config.status does, but
##  it fully resolves the various path variables (prefix, exec_prefix, etc.)
##  so that they don't contain any variable substitutions.  It's easier to
##  do this in a separate script than try to use eval or the like to resolve
##  the variable names inside configure, particularly since prefix and
##  exec_prefix aren't set until the end of the script.

# The paths set by configure.
pref...@prefix@
exec_pref...@exec_prefix@
bind...@bindir@
libexecd...@libexecdir@
libd...@libdir@
sbind...@sbindir@
sysconfd...@sysconfdir@

# Additional paths specific to INN.
controld...@controldir@
dbd...@dbdir@
filterd...@filterdir@
httpd...@httpdir@
libperld...@libperldir@
logd...@logdir@
rund...@rundir@
spoold...@spooldir@
tmpd...@tmpdir@

# Additional variables that are substituted into configuration files.
do_pgpveri...@do_pgpverify@
hostna...@hostname@
sendma...@sendmail@

# We can probably just assume sed is on the path, but since we have it, we may
# as well use it.
s...@sed@

input="$1"
if [ -z "$input" ] ; then
echo "No input file specified" >&2
exit 1
fi

output="$2"
if [ -z "$output" ] ; then
output=`echo "$input" | $SED -e 's/\.in$//'`
fi
if [ x"$input" = x"$output" ] ; then
echo "No output file specified and input file doesn't end in .in" >&2
exit 1
fi

$SED -e "s,@pref...@],$prefix,g" \
 -e "s,@bind...@],$bindir,g" \
 -e "s,@libexecd...@],$libexecdir,g" \
 -e "s,@libd...@],$libdir,g" \
 -e "s,@sbind...@],$sbindir,g" \
 -e "s,@sysconfd...@],$sysconfdir,g" \
 -e "s,@controld...@],$CONTROLDIR,g" \
 -e "s,@dbd...@],$DBDIR,g" \
 -e "s,@filterd...@],$FILTERDIR,g" \
 -e "s,@httpd...@],$HTTPDIR,g" \
 -e "s,@libperld...@],$LIBPERLDIR,g" \
 -e "s,@logd...@],$LOGDIR,g" \
 -e "s,@rund...@],$RUNDIR,g" \
 -e "s,@spoold...@],$SPOOLDIR,g" \
 -e "s,@tmpd...@],$tmpdir,g" \
 -e "s,@do_pgpveri...@],$DO_PGPVERIFY,g" \
 -e "s,@hostna...@],$HOSTNAME,g" \
 -e "s,@sendma...@],$SENDMAIL,g" < "$input" > "$output"


Re: making config files

2010-01-13 Thread Daniel Pocock

Peter Johansson wrote:

Daniel Pocock wrote:




Therefore, I felt that I should be aiming to have the config files 
generated at the last moment - probably during `make install', just 
before they are installed.  Can anyone suggest best practice for 
doing this?



please refer to

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





Thanks for that - the sed example appears to be the type of thing I want.

However, is there a more concise way to do this?  I was thinking there 
may be some way to invoke sed or m4 on a template in much the way that 
gcc is invoked for *.c





Re: making config files

2010-01-13 Thread Peter Johansson

Daniel Pocock wrote:




Therefore, I felt that I should be aiming to have the config files 
generated at the last moment - probably during `make install', just 
before they are installed.  Can anyone suggest best practice for doing 
this?



please refer to

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


cheers,
Peter





making config files

2010-01-13 Thread Daniel Pocock



Hi,

I've been working on a project, Ganglia, that is built with autotools

Included in the source tree are templates for various configuration 
files (e.g. modpython.conf.in).  Some of these include hard coded paths.


It seems appropriate to replace the hardcoded paths with substitutions 
(e.g. @sysconfdir@) - however, if the template is processed by 
configure, then the generated config file sometimes includes a value 
like ${prefix}/etc rather than an absolute path like /opt/ganglia-3.1/etc


Therefore, I felt that I should be aiming to have the config files 
generated at the last moment - probably during `make install', just 
before they are installed.  Can anyone suggest best practice for doing this?


Regards,

Daniel