Next: Autom4te Cache, Previous: Why Not Imake, Up: FAQ
#define
Installation Directories?My program needs library files, installed indatadir
and similar. If I useAC_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 Installation Directory Variables. There are several means to achieve a similar goal:
AC_DEFINE
but use your makefile to pass the
actual value of datadir
via compilation flags.
See Installation Directory Variables, for the details.
CPPFLAGS
:
CPPFLAGS = -DDATADIR='"$(datadir)"' @CPPFLAGS@
If you are using Automake, you should use AM_CPPFLAGS
instead:
AM_CPPFLAGS = -DDATADIR='"$(datadir)"'
Alternatively, create a dedicated header file:
DISTCLEANFILES = myprog-paths.h myprog-paths.h: Makefile echo '#define DATADIR "$(datadir)"' >$@
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.
This solution does not conform to the GNU Coding Standards.
prefix
, and try to
find prefix
at runtime, this way your package is relocatable.