Unix Programming - Makefile command on Solaris.

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2004 > Makefile command on Solaris.





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 Makefile command on Solaris.
Marc

2004-10-27, 7:48 am

I am trying to create a makefile with a complicated command on
Solaris.

If I do the following at the prompt:


bash-2.03$ for I in `find de -type f -name "*.cc"` ;do echo hallo
;done


It works fine, I get a number of times 'hallo'.

But if I call the makefile below:
------------------------------------------------------------------
LIBMARC= ./libMarc.so

all: ./libMarc.so

clean:
-rm -f core *.o $(LIBMARC)


$(LIBMARC): de

for I in `find de -type f -name "*.cc"` ; do echo hallo ;done
------------------------------------------------------------------

I get:

bash-2.03$ make -f make_marc
make: Fatal error in reader: make_marc, line 12: Unexpected command
seen.



Any idea why?

I am actually copying this from another makefile that was used on AIX
unix, in which the total command was:

---------------------------------------
....
....

(LIBSIEM): de

for I in `find de -type f -name "*.cc"` ; do OBJ=`basename $$I | cut
-d "." -f 1` ; OBJ="$$OBJ.o"; echo $$OBJ ; $(CC) $(CCFLAGS) -c $$I -o
$$OBJ ; done
OBJS=`ls *.o` ; ar r ./libSiem.a $$OBJS


################################
--------------------------------------

Do you know of anything in the above that is right in AIX but could
not be used on Solaris?
Michael Fuhr

2004-10-27, 7:48 am

abandon120565@hotmail.com (Marc) writes:

> $(LIBMARC): de
>
> for I in `find de -type f -name "*.cc"` ; do echo hallo ;done
> ------------------------------------------------------------------
>
> I get:
>
> bash-2.03$ make -f make_marc
> make: Fatal error in reader: make_marc, line 12: Unexpected command
> seen.


You're probably missing a leading tab. The message you posted has
a tab on the line following "$(LIBMARC): de", but then there's a
newline and a few spaces in front of the "for" loop.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Pete Brett

2004-10-27, 7:48 am

abandon120565@hotmail.com (Marc) wrote:

>$(LIBMARC): de
>
> for I in `find de -type f -name "*.cc"` ; do echo hallo ;done
>------------------------------------------------------------------
>
>I get:
>
>bash-2.03$ make -f make_marc
>make: Fatal error in reader: make_marc, line 12: Unexpected command
>seen.


Each line containing a command must start with a tab character (equivalent
number of spaces is not a substitute).

Pete
Marc

2004-10-28, 7:48 am

mfuhr@fuhr.org (Michael Fuhr) wrote

> You're probably missing a leading tab.


Thanks I'll try that, it is something I was not aware of. Why do I
have to write a tab there? It seems just to punish the people who did
not read the manual?
Paul D. Smith

2004-10-28, 5:51 pm

%% abandon120565@hotmail.com (Marc) writes:

m> mfuhr@fuhr.org (Michael Fuhr) wrote
[vbcol=seagreen]

m> Thanks I'll try that, it is something I was not aware of. Why do I
m> have to write a tab there? It seems just to punish the people who did
m> not read the manual?

In make syntax it's legal to prefix variable settings, targets,
etc. with whitespace:

FOO=bar
FOOBAR=biz
BIBAZ=bloz

foobar : bizbaz
foo : bar

etc.


So, make needs to know the difference between lines which are supposed
to be interpreted by make (variable settings, targets, etc.) and lines
which are supposed to be shell commands used to build a target, and not
interpreted by make.

It makes this distinction by using a TAB character as the first
character on the line: any line that you want to be considered a command
to build a target must have a TAB as the first character.


Yes, using a whitespace character like this as the delimiter was a very
bad idea, but 25+ years ago or so when make syntax was invented it
probably didn't seem so bad--and now we have hundreds of thousands of
makefiles written this way.

--
-------------------------------------------------------------------------------
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
Goran Larsson

2004-10-30, 7:46 am

In article <417e2169.673446625@news.business.ntl.com>,
Pete Brett <pbrett@quaNlOitrSoPlAcMorp.com> wrote:

> Each line containing a command must start with a tab character (equivalent
> number of spaces is not a substitute).


That is not the whole truth. The command can either be on the same line
as the target and dependency, or on its own line. If it is on the same
line as the target then the line must not start with a tab. If it is on
its own line then the line must start with a tab.

target : dependency ; command

target : dependency
<tab>command

--
Göran Larsson http://www.mitt-eget.com/
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com