build top level sources before specific target???

View: New views
2 Messages — Rating Filter:   Alert me  

build top level sources before specific target???

by kd8341 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a project organized as this:
================================
Top level directory sources: top1.c top2.c top3.c ......
   2nd level directory sources: second1.c second2.c .....
================================

My makefile looks like this:
================================
all: target1 target2

target1: depend
   command1

target2:
   command2
.....
================================


Now, I want simply build "target2", so I issue a command like this:
================================
$ make target2
================================

I expect "command2" to be run directly since there is no dependencies for "target2", however, GNU make always compile my top level sources before executing "command2".

I am sure command2 is only to compile sources in 2nd level directory, and it has nothing to do with sources in top level directory (top1.c top2.c ....). I just wonder why GNU make always compile top level sources? and how to avoid this and simply executing "command2"?

Any suggestion??

Thanks!

Kevin




_______________________________________________
Help-make mailing list
Help-make@...
http://lists.gnu.org/mailman/listinfo/help-make

Re: build top level sources before specific target???

by Philip Guenther-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday, October 29, 2009, Kevin <kd8341@...> wrote:
...

> My makefile looks like this:
> ================================
> all: target1 target2
>
> target1: depend
>    command1
>
> target2:
>    command2
> .....
> ================================
>
>
> Now, I want simply build "target2", so I issue a command like this:
> ================================
> $ make target2
> ================================
>
> I expect "command2" to be run directly since there is no dependencies for "target2", however, GNU make always compile my top level sources before executing "command2".
>
> I am sure command2 is only to compile sources in 2nd level directory, and it has nothing to do with sources in top level directory (top1.c top2.c ....). I just wonder why GNU make always compile top level sources? and how to avoid this and simply executing "command2"?
>
> Any suggestion??

With the makefile you show, that shouldn't happen.  Can you show us
your *real* makefile instead of something similar too but not exactly
the same as it?

(You don't know what causes the behavior; why do you think you know
what can be left out of the makefile that's causing your problem?
Doesn't knowing what can left out imply knowing what is causing the
problem?  Don't feel bad; I've seen this all over the place.  I'm just
wondering why it is that people leave out so much information when
asking for assistance.)


Philip Guenther


_______________________________________________
Help-make mailing list
Help-make@...
http://lists.gnu.org/mailman/listinfo/help-make