# List all object files here:
OBJECTS      = windmeter.o

# List all compiler options here:
# For maximum debug capacities no optimalisation is used:
#GCC_OPTIONS  = -mshort
# optimize for minimal memory usage: 
# Optimalisation is needed to fit program into EEPROM!
GCC_OPTIONS  = -mshort -Os -fomit-frame-pointer
# e.g. optimize for maximum speed:
#GCC_OPTIONS  = -mshort -O3 -fomit-frame-pointer

AS_OPTIONS   =
LD_OPTIONS   = -mshort
LDSCRIPT     = simplex3_eeprom.ld

GCCBINDIR    = C:/Program Files/THRSim11/gcc/bin
UTILSDIR     = C:/Program Files/THRSim11/utils
OBJCOPY      = $(GCCBINDIR)/m6811-elf-objcopy.exe
GCC          = $(GCCBINDIR)/m6811-elf-gcc.exe
AS           = $(GCCBINDIR)/m6811-elf-as.exe
RM           = $(UTILSDIR)/rm.exe
MAKE         = $(UTILSDIR)/make.exe

.PHONY : all
all : a.s19 a.out

.PHONY : clean
clean :
	$(RM) -f $(OBJECTS) a.s19 a.out

.PHONY : build
build :
	$(MAKE) clean
	$(MAKE)

a.s19 : a.out
	$(OBJCOPY) -O srec a.out a.s19

a.out : $(LDSCRIPT) $(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 -m68hc11 $(AS_OPTIONS) -o $*.o $<
