NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Makefile

August 31, 2016
by dfitzgerald
dfitzgerald's Avatar

Anyone know what -upload in makefile is for? Is this a command?

Ex. all: initialload-upload

From makefile initialload.

Thanks

September 01, 2016
by Rick_S
Rick_S's Avatar

In the Makefile,

GCCFLAGS=-g -Os -Wall -mmcu=atmega328p
LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm
AVRDUDEFLAGS=-c avr109 -p m328p -b 115200 -P  com1
LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all:    initialload-upload

initialload.hex:    initialload.c
    make -C ../libnerdkits
    avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o initialload.o initialload.c ${LINKOBJECTS}
    avr-objcopy -j .text -O ihex initialload.o initialload.hex

initialload.ass:    initialload.hex
    avr-objdump -S -d initialload.o > initialload.ass

initialload-upload: initialload.hex
    avrdude ${AVRDUDEFLAGS} -U flash:w:initialload.hex:a

the line that says initialload-upload: initialload.hex, the words before the colon initialload-upload are the section title. So after the contants are set at the top, section all: calls section initialload-upload as a pre-requisate. In other words all needs initialload-upload to be done before doing anything in it's section. Then initialload-upload has a pre-rquisate of initialload.hex. Which jumps to that section. initialload.hex needs to see initialload.c (your file it is going to compile) If that file is available, then initialload.hex executes the three tabbed lines below it then upon success returns to initialload-upload and processes the line below it, which upon success returns to all and finishes because all has no lines below it.

Hope that cleared it up without making it too muddy.

Rick

September 02, 2016
by dfitzgerald
dfitzgerald's Avatar

Very good Rick. Thanks a lot for clearing up the questions I had about the make file. Not muddy at all.

September 07, 2016
by Ralphxyz
Ralphxyz's Avatar

You could spend a lot of time learning about Make files:

It gets deeper and deeper the further you go.

Make files

I am going to re learn the fundamentals again as I have some projects I have to do.

Wonder where I put the Nerdkit instruction manual, that is still the best fundamental document I have seen.

Ralph

Post a Reply

Please log in to post a reply.

Did you know that one NerdKits customer discovered that his hamster ran several miles in a night using his kit and a Hall-effect sensor? Learn more...