Quantcast

AC_DEFINE_UNQUOTED does not expand $libexecdir

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

AC_DEFINE_UNQUOTED does not expand $libexecdir

Richard B. Kreckel-2
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.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AC_DEFINE_UNQUOTED does not expand $libexecdir

Russ Allbery-3
"Richard B. Kreckel" <[hidden email]> 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 ([hidden email])              <http://www.eyrie.org/~eagle/>

Loading...