Re: Using @bindir@ etc. in C headers

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

 



Hi Florian,


On 5/6/20 8:57 pm, Florian Weimer wrote:
I would like to define macros containing the standard paths, like this:

#define BINDIR "@bindir@"

It does not work due to this code in lib/autoconf/general.m4 (which
appears to be predate DESTDIR support):

# Installation directory options.
# These are left unexpanded so users can "make install exec_prefix=/foo"
# and all the variables that are supposed to be based on exec_prefix
# by default will actually change.
# Use braces instead of parens because sh, perl, etc. also accept them.
# (The list follows the same order as the GNU Coding Standards.)
AC_SUBST([bindir],         ['${exec_prefix}/bin'])dnl
AC_SUBST([sbindir],        ['${exec_prefix}/sbin'])dnl

Is there are generally approved way to work around this?  The manual
tells us to use -D preprocessor arguments, but I'd prefer the
explicitness of defining the macros via a header file.


I have the following in my Makefile.am, which I believe I borrowed from the manual of autoconf or automake. BUILT_SOURCES makes the header file be created before any compilation and CLEANFILES makes the header file be removed by 'make clean'.


CLEANFILES += configmake.h

BUILT_SOURCES += configmake.h

configmake.h: Makefile
    echo '#define BINDIR "$(bindir)"' >$@


Cheers,

Peter


Thanks,
Florian






[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux