| [ < ] | [ > ] | [ << ] | [ 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_DEFINEbut use your makefile to pass the actual value ofdatadirvia 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_CPPFLAGSinstead:AM_CPPFLAGS = -DDATADIR='"$(datadir)"'
Alternatively, create a dedicated header file:
DISTCLEANFILES = myprog-paths.h myprog-paths.h: Makefile echo '#define DATADIR "$(datadir)"' >$@ - -
Use
AC_DEFINEbut haveconfigurecompute the literal value ofdatadirand others. Many people have wrapped macros to automate this task; for an example, see the macroAC_DEFINE_DIRfrom 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 findprefixat runtime, this way your package is relocatable.
