
export HEADERS_PATH=$(PROJECT_PATH)/src/headers/
export KERNEL_PATH=$(PROJECT_PATH)/../PreOs/sdk/include/c/

export CC=tigcc -c
export LD=tigcc
export AR=tigcc -ar

ifeq ($(DEBUG),TRUE)
	export CFLAGS=-Os -Wall -W -Wwrite-strings -ffunction-sections -fdata-sections -Werror-implicit-function-declaration --optimize-code --cut-ranges -g
	export ASFLAGS=-WA,-t
	export LDFLAGS=
	export DEBUGFILES=*.dbg
else
	export CFLAGS=-Os -Wall -W -Wwrite-strings -ffunction-sections -fdata-sections -Werror-implicit-function-declaration --optimize-code --cut-ranges
	export ASFLAGS=-WA,-t
	export LDFLAGS=--remove-unused --optimize-relocs --optimize-code --cut-ranges --reorder-sections --merge-constants --omit-bss-init
	export DEBUGFILES=
endif

export CALCS=-DUSE_TI89 -DUSE_TI92PLUS -DUSE_V200

export HIBLIB_HEADERS=$(HIBLIB_PATH)/hibtypes.h $(HIBLIB_PATH)/hiblib.h
export HIBLIBA_HEADERS=$(HIBLIBA_PATH)/hibliba.h $(HIBLIBA_PATH)/hiblang.h
export KERNEL_HEADERS=$(KERNEL_PATH)/kernel.h

all : test

cp :
	@echo "Copying files"
	@cp $(HIBLIB) ..
	@cp $(HIBTEST) ..
	@ls -l ../*.??z
	
send : $(HIBLIB) $(HIBTEST)
	@echo "Sending files to TiEmu"
	@tilp -cmdline -calc=ti89 -link=tie -port=2 $(HIBLIB) $(HIBTEST)

test : lib liba
	make -C hibtest

lib :
	make -C hiblib

liba : lib
	make -C hibliba
	
clean :
	make -C hibtest clean
	make -C hiblib clean
	make -C hibliba clean
	