# List all object files here:
OBJECTS      = hello.o

# List all compiler options here:
# For maximum debug capacities no optimalisation is used:
GCC_OPTIONS  = 
# e.g. optimize for minimal memory usage:
#GCC_OPTIONS = -Os -fomit-frame-pointer
# e.g. optimize for maximum speed:
#GCC_OPTIONS = -O3 -fomit-frame-pointer

LDSCRIPT     = evb.ld
LD_OPTIONS   = 

GCCBINDIR    = C:/Program Files/THRSim11/gcc/m6811-elf/bin/
UTILSDIR     = C:/Program Files/THRSim11/utils/
OBJCOPY      = $(GCCBINDIR)/objcopy.exe
GCC          = $(GCCBINDIR)/gcc.exe
AS           = $(GCCBINDIR)/as.exe
RM           = $(UTILSDIR)/rm.exe
MAKE         = $(UTILSDIR)/make.exe

.PHONY : all
all : hello.s a.s19 a.out

.PHONY : clean
clean :
	$(RM) -f $(OBJECTS) hello.s19 hello.out

.PHONY : build
build :
	$(MAKE) clean
	$(MAKE)

a.s19 : a.out
	$(OBJCOPY) -O srec a.out a.s19

a.out : $(SCRIPT) $(OBJECTS)
	$(GCC) -m68hc11 $(LD_OPTIONS) -T $(LDSCRIPT) $(OBJECTS)

%.o : %.c
	$(GCC) -g -c -m68hc11 -Wall $(GCC_OPTIONS) $<

%.o : %.cpp
	$(GCC) -g -c -m68hc11 -Wall $(GCC_OPTIONS) $<

%.o : %.s
	$(AS) --gdwarf2 -mlong -m68hc11 -o $*.o $<

%.s : %.cpp
	$(GCC) -S -g -c -m68hc11 -Wall $(GCC_OPTIONS) $<


