On Sat, Nov 18, 2006 at 11:18:14AM +0100, Georg Baum wrote:

> I use debian unstable, and the autoconf from sarge. That works fine. If you 
> have a bit of autoconf knowledge it would be really great if you could 
> review our Makefile.am's and find out whether we need to change anything 
> (somebody posted a list of things to look for in one of the old threads).

The autoconf 2.60 announcement warns about this:

* Some directory variables have been added, and others adjusted to
  changes in the GNU Coding Standards.  If your package expands
  '$datadir', '$infodir', or '$mandir' anywhere, you need to check your
  package, and possibly adjust it accordingly.  The nodes 'Changed
  Directory Variables' and 'Defining Directories' in the manual have
  more information; be sure to read them.


I report below the contents of the two nodes mentioned above.
ATM I have no time to look at this, though.


4.7.3 Changed Directory Variables
---------------------------------

In Autoconf 2.60, the set of directory variables has changed, and the
defaults of some variables have been adjusted (*note Installation
Directory Variables::) to changes in the GNU Coding Standards.
Notably, `datadir', `infodir', and `mandir' are now expressed in terms
of `datarootdir'.  If you are upgrading from an earlier Autoconf
version, you may need to adjust your files to ensure that the directory
variables are substituted correctly (*note Defining Directories::), and
that a definition of `datarootdir' is in place.  For example, in a
`Makefile.in', adding

     datarootdir = @datarootdir@

is usually sufficient.  If you use Automake to create `Makefile.in', it
will add this for you.

   To help with the transition, Autoconf warns about files that seem to
use `datarootdir' without defining it.  In some cases, it then expands
the value of `$datarootdir' in substitutions of the directory
variables.  The following example shows such a warning:

     $ cat configure.ac
     AC_INIT
     AC_CONFIG_FILES([Makefile])
     AC_OUTPUT
     $ cat Makefile.in
     prefix = @prefix@
     datadir = @datadir@
     $ autoconf
     $ configure
     configure: creating ./config.status
     config.status: creating Makefile
     config.status: WARNING:
                    Makefile.in seems to ignore the --datarootdir setting
     $ cat Makefile
     prefix = /usr/local
     datadir = ${prefix}/share

   Usually one can easily change the file to accommodate both older and
newer Autoconf releases:

     $ cat Makefile.in
     prefix = @prefix@
     datarootdir = @datarootdir@
     datadir = @datadir@
     $ configure
     configure: creating ./config.status
     config.status: creating Makefile
     $ cat Makefile
     prefix = /usr/local
     datarootdir = ${prefix}/share
     datadir = ${datarootdir}
   In some cases, however, the checks may not be able to detect that a
suitable initialization of `datarootdir' is in place, or they may fail
to detect that such an initialization is necessary in the output file.
If, after auditing your package, there are still spurious `configure'
warnings about `datarootdir', you may add the line

     AC_DEFUN([AC_DATAROOTDIR_CHECKED])

to your `configure.ac' to disable the warnings.  This is an exception
to the usual rule that you should not define a macro whose name begins
with `AC_' (*note Macro Names::).




19.5 How Do I `#define' Installation Directories?
=================================================

     My program needs library files, installed in `datadir' and
     similar.  If I use
          AC_DEFINE_UNQUOTED([DATADIR], [$datadir],
            [Define to the read-only architecture-independent
             data directory.])

     I get
          #define DATADIR "${prefix}/share"

As already explained, this behavior is on purpose, mandated by the GNU
Coding Standards, see *Note Installation Directory Variables::.  There
are several means to achieve a similar goal:

   - Do not use `AC_DEFINE' but use your makefile to pass the actual
     value of `datadir' via compilation flags.  *Note Installation
     Directory Variables::, for the details.

   - This solution can be simplified when compiling a program: you may
     either extend the `CPPFLAGS':

          CPPFLAGS = -DDATADIR='"$(datadir)"' @CPPFLAGS@

     or create a dedicated header file:

          DISTCLEANFILES = datadir.h
          datadir.h: Makefile
                  echo '#define DATADIR "$(datadir)"' >$@

   - Use `AC_DEFINE' but have `configure' compute the literal value of
     `datadir' and others.  Many people have wrapped macros to automate
     this task.  For instance, the macro `AC_DEFINE_DIR' from the
     Autoconf Macro Archive (http://autoconf-archive.cryp.to/).

     This solution does not conform to the GNU Coding Standards.

   - Note that all the previous solutions hard wire the absolute name of
     these directories in the executables, which is not a good
     property.  You may try to compute the names relative to `prefix',
     and try to find `prefix' at runtime, this way your package is
     relocatable.  Some macros are already available to address this
     issue: see `adl_COMPUTE_RELATIVE_PATHS' and
     `adl_COMPUTE_STANDARD_RELATIVE_PATHS' on the Autoconf Macro
     Archive (http://autoconf-archive.cryp.to/).


-- 
Enrico

Reply via email to