Re: Using @bindir@ etc. in C headers

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

 



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 $@ $@.tmp
             $(edit) '$(srcdir)/$@.in' >$@.tmp
             chmod +x $@.tmp
             chmod a-w $@.tmp
             mv $@.tmp $@

     autoheader: $(srcdir)/autoheader.in
     autom4te: $(srcdir)/autom4te.in

Not very aesthetically pleasing, but it gets the job done.




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

  Powered by Linux