🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
3 messages
3 total messages Started by nopa Wed, 29 Mar 2006 09:52
GNU Make: Is it illegal to include within targets?
#3718
Author: nopa
Date: Wed, 29 Mar 2006 09:52
40 lines
2208 bytes
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
Re: GNU Make: Is it illegal to include within targets?
#3719
Author: Paul D. Smith
Date: Wed, 29 Mar 2006 18:04
33 lines
2379 bytes
%% "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
Re: GNU Make: Is it illegal to include within targets?
#3720
Author: Måns Rullgård
Date: Wed, 29 Mar 2006 18:37
42 lines
2212 bytes
"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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads