Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

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

Report this thread to moderator Post Follow-up to this message
Old Post
Marc
10-27-04 01:56 PM


Re: Makefile command on Solaris.
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/

Report this thread to moderator Post Follow-up to this message
Old Post
Michael Fuhr
10-27-04 01:56 PM


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

Report this thread to moderator Post Follow-up to this message
Old Post
Pete Brett
10-27-04 01:56 PM


Re: Makefile command on Solaris.
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?

Report this thread to moderator Post Follow-up to this message
Old Post
Marc
10-28-04 01:57 PM


Re: Makefile command on Solaris.
%% abandon120565@hotmail.com (Marc) writes:

m> mfuhr@fuhr.org (Michael Fuhr) wrote
 

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 Scientis
t

Report this thread to moderator Post Follow-up to this message
Old Post
Paul D. Smith
10-29-04 01:56 AM


Re: Makefile command on Solaris.
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/

Report this thread to moderator Post Follow-up to this message
Old Post
Goran Larsson
10-30-04 01:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:04 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.