# Makefile for the CyBorn OS for the classic Cybiko
# The filetype for the OS is binary - not ELF or coff

# 'lib' is the library for lowlevel routines for the cybiko
# 'libstd' contains routines that emulate the standard c library

# make sure that the path for tools points to the GCC toolchain dir for H8S
TOOLPATH=../../tools/bin/h8300-hms-

# object files to start then execute the OS
OBJFILES = crt0.o schedule.o timer.o context.o sync.o task.o
#task.o
#cyborn.o
#testraw.o aroooga.o twilitez.o whizpop.o

# library path that has low-level drivers
LIBPATH = ../lib/

# library path for interfacing to 'C'
STDLIBPATH = ../libstd/

# ALL of the includes go in here - just cuz
INCLUDES = ../include


# Eventually this makefile will generate the OS
#  it will have to be flashed into flash by a flash writer running in RAM

# Special macros:
#   $@ is the name of the file to be made
#   $< is the name of the related file that caused the action


%.o: %.c Makefile
	$(TOOLPATH)gcc.exe -ms -O2 -Wall -I $(INCLUDES) -fomit-frame-pointer -c -o $@ $<

%.o: %.s
	$(TOOLPATH)as.exe  -o $@ $<

%.o: %.S
	$(TOOLPATH)gcc.exe -c -I $(INCLUDES) -o $@ $<


# THE target
kernel : $(OBJFILES) Makefile
	$(TOOLPATH)ld.exe -T cybikoboot.ld $(OBJFILES) --relax -o kernel

# convert the coff file to a binary that the cybiko bootloader can understand
#cyborn.boot: cyborn.coff
#	cp cyborn.coff cyborn.boot
#	$(TOOLPATH)objcopy.exe cyborn.boot -O binary -I coff-h8300


# link everything here
#cyborn.coff: $(OBJFILES) $(LIBPATH)libcyborn.a
#	$(TOOLPATH)ld.exe -T cybikoboot.ld $(OBJFILES) $(STDLIBPATH)libcystd.a $(LIBPATH)libcyborn.a --relax -o cyborn.coff



clean:
	rm *.o
#	cyborn.coff cyborn.boot

