Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Sep 2002 16:08:11 +0100
From:      Bruce M Simpson <bms@spc.org>
To:        Roman Neuhauser <neuhauser@bellavista.cz>
Cc:        Chuck Robey <chuckr@chuckr.org>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: two make questions
Message-ID:  <20020923150811.GI23343@spc.org>
In-Reply-To: <20020923143523.GA30361@freepuppy.bellavista.cz>
References:  <20020923133431.GZ30361@freepuppy.bellavista.cz> <20020923095217.O332-100000@april.chuckr.org> <20020923143523.GA30361@freepuppy.bellavista.cz>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Sep 23, 2002 at 04:35:23PM +0200, Roman Neuhauser wrote:
>     thanks a lot for your reply. You're right: I'm viewing Makefiles
>     as sequential programs, which obviously (even to me) is not quite
>     true, but I'm having difficulty getting rid of this.

Yeah, it takes a bit of getting used to. Make lets you define a dependency
graph, and various transformations/instructions that can be applied to
each node in that graph. In that respect it's more like a Caesar salad,
the dependencies are the lettuce and the variables are croutons. Making it
work is the dressing; you have to add it yourself ;-)

"Managing Projects with Make" from O'Reilly is a good introduction but it's
a tad dated. Also, make has a habit of being different from one platform
to the next. I particularly like the BSD pmake, but Solaris make is different
still, and GNU make is a law unto itself.

>     Now, saying "don't do it" is nice, but I'd like to know why.  Why
>     doesn't this work?  Also, what documentation (besides the source) is
>     there that covers variable scopes?  See the second message for the
>     problem description.

The scope of a Makefile macro (variable) seems to be limited to the current
invocation, unless you explicitly export things as environment variables,
or set them on a command line when re-invoking Make. Depending on what you
want to do this can get quite complicated. Have a look at /usr/src/Makefile
which actually reinvokes itself quite a bit (and includes things from
Makefile.inc which may *also* do that!).

Nik Clayton mentioned a tool to automatically diagram makefile dependency
graphs by target at the last FreeBSD UKUG meeting, using graphviz, but I
can't recall its name.

>     I can fix the behavior with conditional assignment to DESTDIR (?=)
>     in the Makefile, but still would like to understand what's causing
>     make to behave the way it does.

If you're including any standard makefile templates you may wish to
review those; as well as /etc/make.conf and /etc/defaults/make.conf.
You probably also want to look at the MAKEOBJDIRPREFIX behaviour in
the make(1) man page.

BMS

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020923150811.GI23343>