[Top][All Lists]

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

Re: Question about recursive make

From: Sam Ravnborg
Subject: Re: Question about recursive make
Date: Sat, 23 May 2009 00:03:24 +0200
User-agent: Mutt/

On Fri, May 22, 2009 at 04:24:51PM -0500, Erik Lotspeich wrote:
> Hi,
> I have a question about recursive make.  I have the FSF GNU Make book by
> Richard Stallman & Roland McGrath (covering Make version 3.77).  In this
> book, it describes the following as equivalent:
> cd dirname && $(MAKE)
> $(MAKE) -C dirname
> It seems that these are not equivalent, however.  When integrating a
> Makefile system with the Linux Kernel build system, these two forms have
> different effects.  The first form works; the second form doesn't.
> I will clarify what I mean by integrating with the Linux Kernel build
> system.  For building with the Linux Kernel I will have a Makefile in a
> directory (e.g. kernelmod) that looks like this:
> module: mymodule.c
>         make -C $(KDIR) M=$(PWD) PWD=$(PWD) module
> In a directory one up from this Makefile, I would like to be able to write:
> $(MAKE) -C kernelmod
> This leaves kernel files such as modules.order and Modules.symvers in
> this toplevel directory.  If I use the following:
> cd kernelmod && $(MAKE)
> Then, the files are in the kernelmod directory, as expected.
> Any help sorting this out would be greatly appreciated.

You should realize that the value of $(PWD) is set by the shell,
and not by make.
So when you write:

    $(MAKE) -C kernelmod

then the shell will set PWD to the current directory when make was executed.

But then when you write:

    cd kernelmod && $(MAKE)

Then the shell will update PWD for each command so PWD is set as you expect when
you call make.

The solution is simple - use $(CURDIR) which is set by make.


reply via email to

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