Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
make: Implicit linking rule with given executable name
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
alex.blackbit
Advocate
Advocate


Joined: 26 Jul 2005
Posts: 2395

PostPosted: Sun Jan 20, 2013 2:16 pm    Post subject: make: Implicit linking rule with given executable name Reply with quote

Hi,

I want to have a Makefile rule that means
Quote:
Dear make,

please produce an executable called 'foo', it's dependencies is: 'goo.o'.
I will not give you an explicit rule for that, because I don't have special needs.

Kind regards,
-Computeruser

This seems to be trivial, but my 2 approaches failed:
Code:
$ cat Makefile
foo: goo.o
$ make
cc   -c -o goo.o  goo.c
$
Code:
$ cat Makefile
foo: goo.c
$ make
make: Nothing to be done for `foo'.
$

As already stated I do not want to create an explicit rule for that, the implicit rule for that should be good enough:
Code:
%: %.c
#  recipe to execute (built-in):
        $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@

Though, when the name of the rule matches the basename of the object file, make does what I intended:
Code:
$ cat Makefile
goo: goo.c
$ make
cc   goo.c -o goo
$
Code:
$ cat Makefile
goo: goo.o
$ make
cc   -c goo.o goo.c
cc   goo.o -o goo
$

As it seems I have a kind of misunderstanding about Makefile rules.
Any hints welcome.
Thanks in advance.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum