@verbatim
# Define the source files

SOURCE = boot.S main.c harware.c

# What is the name of the final thing

RESULT = example

# Where do we find the libraries

LIBDIR = /usr/local/armlib/lib

# what libraries do we use? We will only use the C library, optimised
# for size, THUMB mode but interworking enabled.

LIBS = c-tis

# Define the flags for the C compiler

CFLAGS = -std=gnu99 -g -Os -g -pipe -ffreestanding -fno-common \
		 -pedantic -Wall -Wextra -Werror -Wundef -Wmissing-declarations \
		 -Wshadow -Wwrite-strings -Wmissing-field-initializers \
		 -mcpu=arm7tdmi -mthumb -mthumb-interwork \
		 -fno-inline-small-functions -fno-strict-aliasing -fwrapv \
		 -fno-delete-null-pointer-checks -fshort-wchar

# Define the flags for the assembler

CFLAGS = -std=gnu99 -g -g -pipe -ffreestanding -fno-common \
		 -pedantic -Wall -Wextra -Werror \ 
		 -mcpu=arm7tdmi -mthumb -mthumb-interwork

# Define the flags for the linker


# Top level targets

all:	$(RESULT).hex

clean:
	rm *.o *.d $(RESULT).abs $(RESULT).hex

# How to make a hex file out of the absolute file

$(RESULT).hex:	$(RESULT).abs
	$(OC) -O ihex $< $@

# How to link the whole thing

$(RESULT).abs:	$(patsubst %,%.o,$(basename $(FILES)))
	$(CC)

# Define the command to compile C source.
# We will also create a .d file with the dependencies

%.o:	%.c
	$(CC) $(CFLAGS) -c -o $@ -MF $*.d $<

# Define the assembler command

%.o:	%.S
	$(CC) $(AFLAGS) -c -o $@ -MF $*.d $<
@endverbatim

