# Hey Emacs, this is a -*- makefile -*-
#
# WinARM template makefile 
# by Martin Thomas, Kaiserslautern, Germany 
# <eversmith@heizung-thomas.de>
#
# based on the WinAVR makefile written by Eric B. Weddington, Jrg Wunsch, et al.
# Released to the Public Domain
# Please read the make user manual!
#
#
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make program = Download the hex file to the device, using lpc21isp
#
# (TODO: make filename.s = Just compile filename.c into the assembler code only)
#
# To rebuild project do "make clean" then "make all".
#
# Changelog:
# - 17. Feb. 2005  - added thumb-interwork support (mth)
# - 28. Apr. 2005  - added C++ support (mth)
# - 29. Arp. 2005  - changed handling for lst-Filename (mth)
#

# dest path
TARGET = project\bin\logic
#source dir
FSOURCE = project\src
#source path
SOURCE = $(FSOURCE)\src
#linker file name
LINKFILE = \linkopts

# Define programs and commands.
SHELL = sh
CC = gcc\arm-elf-gcc
CPP = gcc\arm-elf-g++
OBJCOPY = gcc\arm-elf-objcopy
OBJDUMP = gcc\arm-elf-objdump
SIZE = gcc\arm-elf-size
NM = gcc\arm-elf-nm
REMOVE = rm -f
COPY = cp


all: clean obj elf binary killdep

clean:
#	$(REMOVE) $(TARGET).*
#	$(REMOVE) $(TARGET).elf
#	$(REMOVE) $(TARGET).bin

obj:
	@echo
	@echo $(MSG_COMPILING) $<
	$(CC) -O1 -g -c -std=c99 -mthumb $(SOURCE).c -o $(TARGET).o
elf:
	@echo
	@echo $(MSG_COMPILING) $<
	$(CC) -mcpu=arm7tdmi  $(TARGET).o -mthumb -mno-fpu -lc -lgcc   -nostartfiles -T$(FSOURCE)$(LINKFILE).ld -o $(TARGET).elf $<
binary:
	@echo
	@echo $(MSG_COMPILING) $<
	$(OBJCOPY) -O binary $(TARGET).elf $(TARGET).bin $<
killdep:
	$(REMOVE) $(TARGET).o
	$(REMOVE) $(TARGET).elf

# Include the dependency files.
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)


# Listing of phony targets.
.PHONY : all begin finish end sizebefore sizeafter gccversion \
build elf hex lss sym clean clean_list program

