Next: Autom4te Cache, Previous: Why Not Imake, Up: FAQ [Contents][Index]
#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 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)"' >$@
The Gnulib module ‘configmake’ provides such a header with all the standard directory variables defined, see configmake in GNU Gnulib.
AC_DEFINE
but have configure
compute the literal
value of datadir
and others. Many people have wrapped macros to
automate this task; for an example, see 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.
Next: Autom4te Cache, Previous: Why Not Imake, Up: FAQ [Contents][Index]