# You can put your build options here
-include config.mk

all: main.bin

main.bin: main.c
	# use GCC as lint...
	gcc -DNOTGCC6809 -std=c99 -pedantic -Wall -Wextra -Wshadow -c -O1 -Wno-unused-variable -Wno-unused-function -Wno-unknown-pragmas -Wno-unused-parameter main.c
	# this is to compare asm output to examine peephole opts
	cmoc -O0 --vectrex -Wsign-compare --verbose main.c > /dev/null 2>&1
	mv main.asm main.asm-unopt
	cmoc --vectrex -Wsign-compare --verbose main.c
	cp main.bin main-cmoc.bin
	# compile an executable with GCC - may be useful for debugging
	gcc -DNOTGCC6809 -g -c main.c 2> /dev/null
	objdump -S main.o > main.x86
	# ~/bin/ctohtml main.c > main.c.html
	gcc -DNOTGCC6809 -o main main.o
	# finally test gcc6809 compatibility as best we can, until I get gcc6809 running on linux
	## cannot now that I am using asm...   gcc -Igcc/vectrex -c -Wno-unused-variable -Wno-unused-function -Wno-unknown-pragmas -Wno-unused-parameter main.c

clean:
	rm -f main main.o main.x86 main.asm-unopt main.o main.asm # main.c.html

.PHONY: all clean
