$(top_srcdir) in Makefile.am

Michael Matz matz at kde.org
Tue Oct 29 21:54:17 GMT 2002


On Tue, 29 Oct 2002, Adriaan de Groot wrote:

> In many Makefile.am's I see constructions like the following:

Many?  Which?  I see this construct in exactly three Makefile.am's, two of
them being useless (koffice/filters/xsltfilter/{export,import}/Makefile.am),
because never used in the sources, and one in
./kdelibs/kdoctools/Makefile.am, where it indeed is used in xslt.cpp.

> AM_CPPFLAGS = -DSRCDIR="\"$(shell (cd $(top_srcdir)/kdoctools && pwd))\""
> all other considerations [1,2,3] aside, it seems like $abs_top_srcdir which
> autoconf sets is just the thing to use here.

If all still works, then this is Ok, yes (although see below).

> Is there any particular reason besides [4] that this isn't used

> [1] It's ugly.


> [2] Why aren't backticks `(cd $(top_srcdir)/kdoctools && pwd)` sufficient?

$(shell) is a GNU make function, whereas `` is a shell functionality.  The
difference is, that you can use `` only in the shell functions (i.e. the
commands invoked for creating a target), whereas you can use $(shell)
anywhere in the Makefile.  Compare e.g.:

b: `echo *`
        echo $^

c: $(shell echo *)
        echo $^

The first target is invalid (it depends on the file "`echo" and "*`"),
whereas the second target depends on all files in the current dir.

> [3] It doesn't work with bmake.


> [4] Unfortunately, it doesn't work that easily. It doesn't get substituted
> automatically, as far as i can tell, and adding an AC_SUBST(abs_top_srcdir)
> gives me blanks instead of what I expect. I can _see_ code in configure
> assigning a value to the variables, and when I print them later they're empty
> again.

This is an error in the fast-perl machinery.  It doesn't duplicate enough
of the sed expressions, which also means, that it wasn't working with
older autoconf versions (but probably something like 2.13).  I.e. this
needs changes in admin/config.pl.  The underlying problem is, that this
particular variable (like some others, like e.g. "$(srcdir)") are not
handled by the normal AC_SUBST() but are special-cased.


More information about the kde-core-devel mailing list