On 6/5/20 6:57 AM, 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):
>
> ...
>
> 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.
The autoconf manual's "Installation Directory Variables" section says
the following...
Similarly, you should not rely on AC_CONFIG_FILES to replace datadir
and friends in your shell scripts and other files; instead, let make
manage their replacement. For instance Autoconf ships templates of its
shell scripts ending with `.in', and uses a makefile snippet similar
to the following to build scripts like autoheader and autom4te:
edit = sed \
-e 's|@datadir[@]|$(pkgdatadir)|g' \
-e 's|@prefix[@]|$(prefix)|g'
autoheader autom4te: Makefile
rm -f $@ [email protected]
$(edit) '$(srcdir)/[email protected]' >[email protected]
chmod +x [email protected]
chmod a-w [email protected]
mv [email protected] $@
autoheader: $(srcdir)/autoheader.in
autom4te: $(srcdir)/autom4te.in
Not very aesthetically pleasing, but it gets the job done.