#######################################################################
#
# Filename:    makefile
# 
# Description: Makefile for the Monitor and Control 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,moncont.map


all: moncont.exe

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

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

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

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

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

moncont.o: moncont.c serial.h led.h buzzer.h cli.h
	$(XCC) $(CFLAGS) moncont.c

moncontdbg.exe: moncont.o serial.o led.o buzzer.o cli.o commands.o
	$(LD) $(LDFLAGS) -o $@ led.o buzzer.o serial.o cli.o commands.o moncont.o

moncont.exe: moncontdbg.exe
	$(STRIP) --remove-section=.comment moncontdbg.exe -o $@

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