#######################################################################
#
# Filename:    makefile
# 
# Description: Makefile for the Improved Blinking LED program.
#
# Copyright (c) 2006 Anthony Massa and Michael Barr.  All rights reserved.
# This code is from the book Programming Embedded Systems, With C and
# GNU Development Tools, 2nd Edition.
# It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.
# You may study, use, and modify it for any non-commercial purpose,
# including teaching and use in open-source projects.
# You may distribute it non-commercially as long as you retain this notice.
# For a commercial use license, or to purchase the book,
# please visit http://www.oreilly.com/catalog/embsys2.
#
#######################################################################


XCC     = arm-elf-gcc
LD      = arm-elf-gcc
STRIP   = arm-elf-strip
CFLAGS  = -g -c -Wall -mcpu=xscale -I../include --specs=redboot.specs
LDFLAGS = -mcpu=xscale -g --specs=redboot.specs -Wl,-Ttext,0x400000 -Wl,-Map,blink.map


all: blink.exe

led.o: led.c led.h
	$(XCC) $(CFLAGS) led.c

timer.o: timer.c timer.h
	$(XCC) $(CFLAGS) timer.c

blink.o: blink.c led.h timer.h
	$(XCC) $(CFLAGS) blink.c

blinkdbg.exe: blink.o led.o timer.o
	$(LD) $(LDFLAGS) -o $@ led.o timer.o blink.o

blink.exe: blinkdbg.exe
	$(STRIP) --remove-section=.comment blinkdbg.exe -o $@

clean:
	-rm -f *.exe *.o blink.map
