[Top][All Lists]

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

Re: AC_DEFINE_UNQUOTED does not expand $libexecdir

From: Russ Allbery
Subject: Re: AC_DEFINE_UNQUOTED does not expand $libexecdir
Date: Sun, 03 Apr 2016 11:37:09 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

"Richard B. Kreckel" <address@hidden> writes:

> Instead, it leaves it unexpeded as ${exec_prefix}/libexec, which is
> unusable within C code. This has been explained very well here:
> http://stackoverflow.com/questions/8264827/pass-directory-to-c-application-from-compiler

> The workaround is cumbersome: it requires us to fiddle with CPPFLAGS in
> the Makefile. Seriously, this can't be a feature.

It's also explained very well in the Autoconf manual.  I'm not sure anyone
is horribly happy with how this works and with the number of people who
are surprised by it, but it's difficult to find a different way to
implement the requirements of the GNU Coding Standards in this area.

|    Most of these variables have values that rely on 'prefix' or
| 'exec_prefix'.  It is deliberate that the directory output variables
| keep them unexpanded: typically '@datarootdir@' is replaced by
| '${prefix}/share', not '/usr/local/share', and '@datadir@' is replaced
| by '${datarootdir}'.
|    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 should hard code
|      dependencies corresponding to the make-specified prefix.
| '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
| 'datarootdir' remains defined as '${prefix}/share', so that its value
| can be expanded based on the current value of 'prefix'.
|    A corollary is that you should not use these variables except in
| makefiles.  For instance, instead of trying to evaluate 'datadir' in
| 'configure' and hard-coding it in makefiles using e.g.,
| 'AC_DEFINE_UNQUOTED([DATADIR], ["$datadir"], [Data directory.])', you
| should add '-DDATADIR='$(datadir)'' to your makefile's definition of
| 'CPPFLAGS' ('AM_CPPFLAGS' if you are also using Automake).
|    Similarly, you should not rely on 'AC_CONFIG_FILES' to replace
| 'bindir' and friends in your shell scripts and other files; instead, let
| 'make' manage their replacement.

There are more details in this section ("Installation Directory
Variables") about how to write Makefile rules to do this substitution.

Russ Allbery (address@hidden)              <http://www.eyrie.org/~eagle/>

reply via email to

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