Skip to content
CJBB edited this page Sep 13, 2010 · 14 revisions

I should like to point out that the makefile output will not always be as awful as previously described.

A short explaination for those new to makefiles.

A makefile is a set of instructions for the compiler to use, which tells the compiler what to do with the source files to make the output file.

It looks at the timestamps of the files, and if any sources are newer than the output, it processes those source files. Thus if you use ‘make’ twice without any changes inbetween, the 2nd output should just read “Target is up to date” i.e. nothing needs doing.

The following is an output of the makefile, not the makefile itself.

The rather long output is mostly repeated commands.

If we rename all instances of:
"-mmcu=msp430×1612 -g -O3 -Wall -Wcast-align -Wcast-qual -Wimplicit -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wstrict-prototypes -Wswitch -Wunused"
TO

“-SWITCHES

the output becomes (once neatly formatted):

msp430-gcc -M -SWITCHES main.c cpuclockinit.c initPorts.c adc.c led.c AdcLut.c MazeManipulation.c MapMaze.c Motor2.c Setup.c DeadEndBlocking.c Alignment.c MazeSolving.c Error.c >main.d

msp430-gcc -SWITCHES -c -o main.o main.c

msp430-gcc -SWITCHES -c -o cpuclockinit.o cpuclockinit.c

msp430-gcc -SWITCHES -c -o initPorts.o initPorts.c

msp430-gcc -SWITCHES -c -o adc.o adc.c

msp430-gcc -SWITCHES -c -o led.o led.c

msp430-gcc -SWITCHES -c -o AdcLut.o AdcLut.c

msp430-gcc -SWITCHES -c -o MazeManipulation.o MazeManipulation.c

msp430-gcc -SWITCHES -c -o MapMaze.o MapMaze.c

msp430-gcc -SWITCHES -c -o Motor2.o Motor2.c

msp430-gcc -SWITCHES -c -o Setup.o Setup.c

msp430-gcc -SWITCHES -c -o DeadEndBlocking.o DeadEndBlocking.c

msp430-gcc -SWITCHES -c -o Alignment.o Alignment.c

msp430-gcc -SWITCHES -c -o MazeSolving.o MazeSolving.c

msp430-gcc -SWITCHES -c -o Error.o Error.c

msp430-gcc main.o cpuclockinit.o initPorts.o adc.o led.o AdcLut.o MazeManipulation.o MapMaze.o Motor2.o Setup.o DeadEndBlocking.o Alignment.o MazeSolving.o Error.o -mmcu=msp430×1612 -Wl -o main.elf

So, what is actually happening here?

Lets take the first line:

msp430-gcc -M -SWITCHES main.c cpuclockinit.c initPorts.c adc.c led.c AdcLut.c MazeManipulation.c MapMaze.c Motor2.c Setup.c DeadEndBlocking.c Alignment.c MazeSolving.c Error.c >main.d

This says that “msp430-gcc” (the GNU C Compiler for the MSP430) has been invoked (with various parameters a.k.a. switches). It is compiling a list of dependancies into a file called “main.d”

The rest of the lines (excluding the last one) are just the compiler being invoked to compile the specified source file (xxx.c) into the object file (xxx.o).

The final line invokes msp430-gcc to collect all the opject files and put them all together as file that can be downloaded to the MCU (called an ELF file – xxx.elf)

The switches are instructions to the compiler to do certain tidying up and neat and generally clever things. e.g. -O3 instructs the compiler to use “Level 3 Optimisation” – the highest level. This casues the comiler to do clever things and makes the compiled code nice and small.

CJBB

Clone this wiki locally