[En-Nut-Discussion] Readability modification to Makefiles

Bernd Walter enut at cicely.de
Mon Mar 21 23:33:14 CET 2011


On Mon, Mar 21, 2011 at 10:29:42PM +0100, Ulrich Prinz wrote:
> Hehe... yes I know...
> 
> I modified it in some other places too, so if you compile your project,
> it states at the first line, what project it compiles and then it gives
> the compiler calling parameters _one_ time.

Yes, but with ARM and thumb files get different parameters, because
some file are compiled thumb and some can't be compiled thumb.

> I needed that on my own, as I have one code for 8 different sensor
> boards. So depending on what sensor I need, I call
> make BOARD=xx_yy_zzz clean all burn
> and I get
> Buidling: Sensor
> CFLAGS: -I../include  -DAT91SAM7X_EK -DAT91_PLL_MAINCK="18432000"
> -DNUTMEM_SIZE="0xFF00" -DNUTMEM_START="0x00200100" -DBOARD=xx_yy_zzz
> -DNUT_THREAD_IDLESTACK="512" -DNUT_THREAD_MAINSTACK="1024"
> -DNUT_THREAD_TCPSMSTACK="1024" -DNUT_THREAD_DHCPSTACK="1024"
> -DNUT_THREAD_SNTPSTACK="1024" -DFOPEN_MAX=20 -DPHAT_SECTOR_BUFFERS="6"
> -DNIC_PHY_ADDR=1 -DMMC_CS_BIT=SPI0_NPCS3_PA09B -DNUT_WDT_START=yes
> -DMCU_AT91=yes -DMCU_AT91SAM7X=yes -DNUTLUA_STRLIB_IS_STANDARD=yes
> -DNUTLUA_MATHLIB_IS_STANDARD=yes -DNUTLUA_TABLIB_IS_STANDARD=yes
> -DNUTLUA_OPTIMIZE_MEMORY=2 -DNUTLUA_FLOATING_POINT -DLIB_HEAPSIZE=8192
> -DNUT_CPU_FREQ="55000073" -DPLL_MUL_VAL=1300 -DPLL_DIV_VAL=218  -mthumb
>  -mcpu=arm7tdmi -mthumb-interwork -Os -Wall -Wstrict-prototypes -Werror
>   [CC] main.c
>   [CC] sensor.c
>   ...
> 
> So I know what you mean. But it must not be sprayed on the screen that
> you cannot find what you're looking for. In addition, due to different
> length of directory and file names, the compiler output shifts forth and
> back except you hack som other things into the makefiles to keep that
> straight. But even then your eyes need a good pattern detection algorithm :)

I run 2000x1600 resolution on an old CRT ;-)
But yes - it would be better to have all the global -Dxxx inside an
include file instead of the comandline.

> But hey, there is no problem if you want some flexibility.
> There are only a few lines needed to declare the called programs in a
> makefile:
> 
> TRGT   = avr-
> 
> CC     = @$(TRGT)gcc
> AR     = @$(TRGT)ar
> LN     = @$(TRGT)gcc
> CP     = @cp
> 
> So we could do it like this:
> SILENT=@
> CC = $(SILENT)$(TRGT)gcc
> 
> if you need the full output, call make SILENT= clean all burn
> 
> Another thing is that we should have a look on these variables at all.
> All of them are evaluated and extracted at runtime any time they are
> accessed as they are declared with '='. Most of them could be set as
> fixed by declaring them ':=' what makes it obsolete to expand them every
> time they are called. That may improve compiling on slower machines too.
> 
> For the doubts about having to add a @echo "..." line everywhere, there
> is no problem. A good editor helps with his find/replace functions and I
> already did it for any ARM/Cortex related makefile :) I only didn't commit.
> As this is a big change I would check it in as a branch for Harald and
> others to check it is working. Then I would merge it to trunk.

-- 
B.Walter <bernd at bwct.de> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.



More information about the En-Nut-Discussion mailing list