[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
20.5 How Do I #define
Installation Directories?
My program needs library files, installed in
I get
|
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:
- -
Do not use
AC_DEFINE
but use your makefile to pass the actual value ofdatadir
via compilation flags. See section 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@
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)"' >$@
- -
Use
AC_DEFINE
but haveconfigure
compute the literal value ofdatadir
and others. Many people have wrapped macros to automate this task; for an example, see the macroAC_DEFINE_DIR
from the Autoconf Macro Archive.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 findprefix
at runtime, this way your package is relocatable.