autoconf
[Top][All Lists]
Advanced

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

Re: Using @bindir@ etc. in C headers


From: Peter Johansson
Subject: Re: Using @bindir@ etc. in C headers
Date: Fri, 5 Jun 2020 21:07:32 +1000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

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





reply via email to

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