For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > March 2006 > GNU Make: Is it illegal to include within targets?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author GNU Make: Is it illegal to include within targets?
nopa

2006-03-29, 4:04 am

Hi,

I've a Makefile which I thought to be legal because it always worked
fine in the past with non-GNU versions of Make.

First I've a command file named "commands.incl", like this (for
example):

---cut here---
cp here there
cd mydir ; make depend
---cut here---

(where every line begins by one and just one TAB)

And then I've a Makefile like this:

all:
make alltools
make allstuff
include commands.incl
make therestoftestuff

alltools:
blah blah blah


When trying this with GNU Make it complains "commands commence before
first target. Stop.", and the error is reported at line 1 of
"commands.incl". The docs say that it's because there's a line
beginning with Tab, and outside of a target.

It's true that the line 1 of "commands.incl" begins with a Tab, but
it's _INSIDE_ of the "all:" target. And, as I said, it works with
commercial versions of Make.

What's happenning? Does GNU Make assume that "include" also means "end
of target"?

Thanks

Paul D. Smith

2006-03-29, 7:02 pm

%% "nopa" <nopaperfound@yahoo.com> writes:

n> First I've a command file named "commands.incl", like this

n> ---cut here---
n> cp here there
n> cd mydir ; make depend
n> ---cut here---

n> (where every line begins by one and just one TAB)
n> And then I've a Makefile like this:

n> all:
n> make alltools
n> make allstuff
n> include commands.incl
n> make therestoftestuff

n> When trying this with GNU Make it complains "commands commence
n> before first target. Stop.", and the error is reported at line 1 of
n> "commands.incl". The docs say that it's because there's a line
n> beginning with Tab, and outside of a target.

n> What's happenning? Does GNU Make assume that "include" also means
n> "end of target"?

Correct. Rules cannot "contain" include files like this in GNU make.

--
-------------------------------------------------------------------------------
Paul D. Smith <psmith@gnu.org> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
Måns Rullgård

2006-03-29, 7:02 pm

"nopa" <nopaperfound@yahoo.com> writes:

> Hi,
>
> I've a Makefile which I thought to be legal because it always worked
> fine in the past with non-GNU versions of Make.
>
> First I've a command file named "commands.incl", like this (for
> example):
>
> ---cut here---
> cp here there
> cd mydir ; make depend
> ---cut here---
>
> (where every line begins by one and just one TAB)
>
> And then I've a Makefile like this:
>
> all:
> make alltools
> make allstuff
> include commands.incl
> make therestoftestuff
>
> alltools:
> blah blah blah
>
> When trying this with GNU Make it complains "commands commence before
> first target. Stop.", and the error is reported at line 1 of
> "commands.incl". The docs say that it's because there's a line
> beginning with Tab, and outside of a target.
>
> It's true that the line 1 of "commands.incl" begins with a Tab, but
> it's _INSIDE_ of the "all:" target. And, as I said, it works with
> commercial versions of Make.


The include directive is not standardized at all.

--
Måns Rullgård
mru@inprovide.com
Thomas Dickey

2006-03-29, 7:02 pm

In comp.unix.programmer Måns Rullgård <mru@inprovide.com> wrote:
> "nopa" <nopaperfound@yahoo.com> writes:


....[color=darkred]
[color=darkred]
> The include directive is not standardized at all.


He did not use the word "standard", but referred to "always" and
"commercial" without citing a specific instance (aside from the
implication that commercial and GNU are the only categories to
consider). There are some relatively modern platforms without an
include facility in their make program, but they're in the minority.
Even among those that do provide an include-feature, the syntax and
behavior vary.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Måns Rullgård

2006-03-29, 7:02 pm

Thomas Dickey <dickey@saltmine.radix.net> writes:

> In comp.unix.programmer Måns Rullgård <mru@inprovide.com> wrote:
>
> ...
>
>
> He did not use the word "standard", but referred to "always" and
> "commercial" without citing a specific instance (aside from the
> implication that commercial and GNU are the only categories to
> consider). There are some relatively modern platforms without an
> include facility in their make program, but they're in the minority.
> Even among those that do provide an include-feature, the syntax and
> behavior vary.


By saying it is not standardized I meant that there is no reason to
expect consistency across implementations.

--
Måns Rullgård
mru@inprovide.com
Thomas Dickey

2006-03-30, 7:02 pm

Måns Rullgård <mru@inprovide.com> wrote:
> Thomas Dickey <dickey@saltmine.radix.net> writes:


[color=darkred]
> By saying it is not standardized I meant that there is no reason to
> expect consistency across implementations.


yes, but: "standardized" tends to be used in the sense that there are
agreed-upon characteristics by the predominant players, while the OP was
reporting what I would term "conventional" behavior, which (as you
observed) is not necessarily part of a "standard", even if a majority
of the players implement the feature.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com