[En-Nut-Discussion] Can't correctly build NutOS 4.8.9 on Fedora 14 for Ethernut 2.1b

Bernard Fouché bernard.fouche at kuantic.com
Tue Apr 19 12:27:01 CEST 2011


Hi Harald.

I found the problem in nut/Makerules.avr-gcc. Instead of having:

%o: %c
     $(CC)  ...etc..

one needs:

%.o: %.c
     $(CC) ...etc...

(a dot after each '%')

Changing this I can recompile everything!

My make(1) version is GNU Make 3.82.

The problem is that the built-in rule '%.o' in the compiler has 
precedence over the '%o' rule defined in the Makefile. More exactly, 
with the original Makerules.avr-gcc, make(1) faces two rules to build an 
objet file. Since the stem is shorter with the built-in rule '%.o' 
compared with rule '%o', then make(1) activates the '%.o' rule. This is 
documented here: 
http://www.gnu.org/software/make/manual/make.html#Pattern-Match

One can confirm this with:

%.o: %.c

%o : %c
     $(CC) ...etc...

In that case the built-in rule '%.o' is removed from make(1) before 
considering the new one: it works since only '%o' remains, there is no 
competition between rules and the length of the stem is not considered.

It is also possible to run make(1) with the '-r' option to remove 
built-in rules and it also works while it allows to keep 
Makefiles.avr-gcc as is.

Other possibilities:

- force built-in rules removal by having for instance:

Makerules-nobuiltin:
%.o: %.c

%.o: %.cc
etc.

And then in Makerules.avr-gcc (and for other targets):

include $(top_srcdir)/Makerules-nobuiltin

This way you dont depend in the '-r' option is ever different versions 
of make are used on Windows, Linux, MacOS, etc.

     Bernard



More information about the En-Nut-Discussion mailing list