## Example Makefile to be used for MCF5206
# @author: Copyright 2009,2010 Thomas Reidemeister
# @date: 2009.12.14
# @file: Makefile
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
CC=m68k-elf-gcc
CFLAGS= -Wall -Wextra -m5200 -pipe -nostdlib
LD=m68k-elf-gcc
OBJCPY=m68k-elf-objcopy
OBJDMP=m68k-elf-objdump

all: merged.s19 

firmware.s19: debug.c firmware.c
	$(CC) $(CFLAGS) -Tfirmware.ld -Wl,-Map=firmware.map -o firmware.elf firmware.c debug.c 
	$(OBJDMP) -xdC firmware.elf > firmware.lst
	$(OBJCPY) --output-format=srec firmware.elf firmware.s19

bootloader.s19: debug.c bootloader.c
	$(CC) $(CFLAGS) -Tbootloader.ld -Wl,-Map=bootloader.map -o bootloader.elf start.s debug.c bootloader.c
	$(OBJDMP) -xdC bootloader.elf > bootloader.lst
	$(OBJCPY) --output-format=srec bootloader.elf bootloader.s19

merged.s19: firmware.s19 bootloader.s19
	python merge.py merged.s19 firmware.s19 bootloader.s19
	chmod u+x merged.s19


clean:
	rm -f *.s19 *.o *.map *.elf *.lst
