autoconf
[Top][All Lists]
Advanced

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

Re: question about sysconfdir


From: Akim Demaille
Subject: Re: question about sysconfdir
Date: 31 May 2001 18:14:31 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (GTK)

>>>>> "matt" == Matthew R MacIntyre <address@hidden> writes:

matt> Hi,

matt> I want to have a configuration file in the sysconfdir for my
matt> program, but if I put AC_DEFINE(CONFFILE,
matt> "$sysconfdir/file.conf"), I end up with the path being
matt> "${prefix}/etc/file.conf" which is pretty meaningless to C.
matt> I've seen people hack it by just saying "$prefix/etc/file.conf"
matt> in the configure.in, but this doesn't seem to be the right thing
matt> to do. Should I do that, or is there a way to use the
matt> sysconfdir?

Installation Directory Variables
--------------------------------

   The following variables specify the directories where the package
will be installed, see *Note Variables for Installation Directories:
(standards)Directory Variables, for more information.  See the end of
this section for details on when and how to use these variables.

 - Variable: bindir
     The directory for installing executables that users run.

 - Variable: datadir
     The directory for installing read-only architecture-independent
     data.

 - Variable: exec_prefix
     The installation prefix for architecture-dependent files.  By
     default it's the same as PREFIX.  You should avoid installing
     anything directly to EXEC_PREFIX.  However, the default value for
     directories containing architecture-dependent files should be
     relative to EXEC_PREFIX.

 - Variable: includedir
     The directory for installing C header files.

 - Variable: infodir
     The directory for installing documentation in Info format.

 - Variable: libdir
     The directory for installing object code libraries.

 - Variable: libexecdir
     The directory for installing executables that other programs run.

 - Variable: localstatedir
     The directory for installing modifiable single-machine data.

 - Variable: mandir
     The top-level directory for installing documentation in man format.

 - Variable: oldincludedir
     The directory for installing C header files for non-gcc compilers.

 - Variable: prefix
     The common installation prefix for all files. If EXEC_PREFIX is
     defined to a different value, PREFIX is used only for
     architecture-independent files.

 - Variable: sbindir
     The directory for installing executables that system
     administrators run.

 - Variable: sharedstatedir
     The directory for installing modifiable architecture-independent
     data.

 - Variable: sysconfdir
     The directory for installing read-only single-machine data.

   Most of these variables have values that rely on `prefix' or
`exec_prefix'.  It is on purpose that the directory output variables
keep them unexpanded: typically address@hidden@' will be replaced by
`${prefix}/share', not `/usr/local/share'.

   This behavior is mandated by the GNU coding standards, so that when
the user runs:

`make'
     she can still specify a different prefix from the one specified to
     `configure', in which case, if needed, the package shall hard code
     dependencies to her late desires.

`make install'
     she can specify a different installation location, in which case
     the package _must_ still depend on the location which was compiled
     in (i.e., never recompile when `make install' is run).  This is an
     extremely important feature, as many people may decide to install
     all the files of a package grouped together, and then install
     links from the final locations to there.

   In order to support these features, it is essential that `datadir'
remains being defined as `${prefix}/share' to depend upon the current
value of `prefix'.

   A corollary is that you should not use these variables but in
Makefiles.  For instance, instead of trying to evaluate `datadir' in
`configure' and hardcoding it in Makefiles using e.g.
`AC_DEFINE_UNQUOTED(DATADIR, "$datadir")', you should add
`-DDATADIR="$(datadir)"' to your `CFLAGS'.

   Similarly you should not rely on `AC_OUTPUT_FILES' to replace
`datadir' and friends in your shell scripts and other files, rather let
`make' manage their replacement.  For instance Autoconf ships templates
of its shell scripts ending with `.sh', and uses this Makefile snippet:

     .sh:
             rm -f $@ address@hidden
             sed 's,@datadir\@,$(pkgdatadir),g' $< >address@hidden
             chmod +x address@hidden
             mv address@hidden $@

   Three things are noteworthy:

address@hidden@'
     The backslash prevents `configure' from replacing address@hidden@' in
     the sed expression itself.

`$(pkgdatadir)'
     Don't use address@hidden@'!  Use the matching makefile variable
     instead.

`,'
     Don't use `/' in the sed expression(s) since most probably the
     variables you use, such as `$(pkgdatadir)', will contain some.



reply via email to

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