[comp.sys.sgi] Makefile whitespace... a neophyte question.

SERRER@ODIN.NRC.CA (Martin Serrer) (05/14/91)

Hello Makefile experts...

  Please excuse the dumb question but this is driving me crazy...
Given the following specification in a Makefile:

wave: wave.o wagen.o
        ${CC} ${LDFLAGS} ${OBJS} -o $@ ${LIBS}

  If the whitespace before the ${CC} is a <tab>, everything is fine. But try
using <spaces> and the following 'helpful' error appears...

Make: file `Makefile' line 11: must be a separator (: or ::) for rules.  Stop.

  Could someone explain this. I do a lot of cutting and pasting between windows
and <tabs> automagically become <spaces> in the destination window so I run into
this problem frequently. I've RTFM and yes it mumbles something about 'commands
may appear on lines beginning with a tab immediately following a dependency
line' etc.
  Was this an unfortunate choice of syntax back in pre-history and is cast in
stone or can something be done about it. I always thought that 'white space is
white space is white space'

+-----------------------------------------------------------------------------+
| Martin Serrer                           Bldg.M32,  Montreal Rd.             |
| 613-993-9442                            National Research Council of Canada,|
| Martin.Serrer@nrc.ca                    Ottawa,  Ontario,  Canada  K1A-0R6  |
+------------------- Software Rusts, Rust never Sleeps -----------------------+

portuesi@tweezers.esd.sgi.com (Michael Portuesi) (05/15/91)

In article <76A4A8F2A29F002123@NRCNET.NRC.CA>, SERRER@ODIN.NRC.CA
(Martin Serrer) writes:
||> wave: wave.o wagen.o
|>         ${CC} ${LDFLAGS} ${OBJS} -o $@ ${LIBS}
|> 
|>   If the whitespace before the ${CC} is a <tab>, everything is
|> fine. But try
|> using <spaces> and the following 'helpful' error appears...

Correct.  The line containing the commands to be executed if the
target needs to be rebuilt must begin with a tab, or else make will
barf.

|>   Was this an unfortunate choice of syntax back in pre-history and
|> is cast in
|> stone or can something be done about it.

It was an unfortunate choice of syntax back and pre-history and is
cast in stone.  Sorry.

|>I always thought that 'white space is
|> white space is white space'

To all civil language parsers, it is.

-- 
__
\/  Michael Portuesi   Silicon Graphics, Inc.   portuesi@sgi.com

"High Eagle Road is tacky.  Trust us.  We're queer.  We understand
these things."  -- Jonathan Katz

jackr@dblues.wpd.sgi.com (John "Jack" Repenning) (05/15/91)

In article <1991May14.185121.8893@zola.esd.sgi.com> portuesi@tweezers.esd.sgi.com (Michael Portuesi) writes:

   It was an unfortunate choice of syntax back and pre-history and is
   cast in stone.  Sorry.

	There is, in fact a story (possibly apocryphal) on the matter.
At some time or other, Steve Feldman, who wrote make originally, is
said to have realized that this rule requiring a tab here was really a
bad idea - but too late to change it, since "he already had ten
users"!


Jack Repenning			9U-530	     jackr@wpd.sgi.com
Silicon Graphics, Inc.		            Off:(415) 335-7477
Systems Software Technology Center	    Fax:(415) 969-2314

scotts@qsp.COM (Scott Simpers) (05/16/91)

In article <76A4A8F2A29F002123@NRCNET.NRC.CA> SERRER@ODIN.NRC.CA (Martin Serrer) writes:
>Hello Makefile experts...
>
>  Please excuse the dumb question but this is driving me crazy...
>
>  Was this an unfortunate choice of syntax back in pre-history and is cast in
>stone or can something be done about it. I always thought that 'white space is
>white space is white space'

That's the best description of it I've heard yet.  Yes, you MUST have a TAB
there, as you found out.  NO, there is no good reason I've ever heard for 
distinguishing between types of whitespace (anybody got one?).  Live and
learn.  This is part of what somebody once called "the lore of unix".

Scott Simpers
Quality Software Products                    voice: (213)410-0303
5711 W Slauson Avenue  Suite 240             fax: (213)410-0124
Culver City, CA  90230                       ...uunet!qsp!scotts