µTasker Forum

µTasker Forum => ATMELTM AT91SAM7X and AVR32 => Topic started by: coflynn on January 14, 2009, 11:39:45 PM

Title: Makefile syntax
Post by: coflynn on January 14, 2009, 11:39:45 PM
Hi,

I was curious why the uTasker makefiles seem a little 'crazy'? aka they use hard links everywhere, rather than having one 'SRC =' section where all the source files are used?

And for instance lines like this:

Code: [Select]
Build\startup_gnu.o: ..\..\..\Hardware\SAM7X\startup_gnu.s uTaskerV1.3_FLASH.ld
$(GCC) $(C_FLAGS)  -D _GNU -D _HW_SAM7X -g -c -Os ..\..\..\Hardware\SAM7X\startup_gnu.s -o Build\startup_gnu.o

Can be replaced by using the $< and $@ to get the first and second argument, so you don't have to change things in two places:

Code: [Select]
Build\startup_gnu.o: ..\..\..\Hardware\SAM7X\startup_gnu.s uTaskerV1.3_FLASH.ld
$(GCC) $(C_FLAGS)  -D _GNU -D _HW_SAM7X -g -c -Os $< -o $@

Just seems a little unusual compared to how most make files I see!

Regards,

  -Colin
Title: Re: Makefile syntax
Post by: mark on January 15, 2009, 12:02:07 AM
Hi Colin

Yes, you are correct that the make files could be written more concisely. The explanation is that I am not that experience with the syntax so am basically glad when they work (!) - since the demo project is controlled centrally using defines in config.h all sources are always present and so there is usually no need to do any further changes there.

Your tip about using the $< and $@ is useful and I will certainly clean up a bit with it.
In fact I think that the C_FLAGS can also be modified to include the extra parameters -D_GNU -D_HW_SAM7X -g -Os. Am I correct?
This would, for example, allow changing the optimization level at one position if required.

Regards

Mark
Title: Re: Makefile syntax
Post by: coflynn on January 15, 2009, 12:14:50 AM
Hi Mark,

Yes - it would allow you to do that! I might try to clean one up and send it to you... probably sometime in the next few days...

There's a little "magic" to Makefiles it takes time to figure out ;-)

Regards,

  -Colin