BUILD_DIR_PURE := build.raspbian
BUILD_DIR := $(BUILD_DIR_PURE)/

PITREX_DIR := ../pitrex/pitrex/
VECTREX_DIR := ../pitrex/vectrex/
CFLAGS := -g -I../pitrex/ -DPIZERO -DRPI0
# CFLAGS := -Ofast -I../pitrex/ -DPIZERO -DRPI0
CC := gcc

.PHONY: pitrexLib
.PHONY: dirCheck


all:	dirCheck pitrexLib draft4
	echo All up to date

dirCheck:
	if [ ! -d $(BUILD_DIR_PURE) ]; then mkdir $(BUILD_DIR_PURE); fi

clean:
	$(RM) $(BUILD_DIR)*.* *~ hello fonttest bootmsg calibrate window maze perspective

pitrexLib:
	$(MAKE) -C $(PITREX_DIR) -f Makefile.raspbian all
	$(MAKE) -C $(VECTREX_DIR) -f Makefile.raspbian all

$(BUILD_DIR)draft4.o: draft4.h  boardgfx.h  decls.h  diags.h  headers.h  intro.h  main.c  messages.h  actions.h  init.h
	$(CC) $(CFLAGS) -o $(BUILD_DIR)draft4.o -c main.c

draft4: $(BUILD_DIR)draft4.o pitrexLib
	$(RM) draft4
	$(CC) $(CFLAGS) -o draft4 \
	$(PITREX_DIR)$(BUILD_DIR)bcm2835.o \
	$(PITREX_DIR)$(BUILD_DIR)pitrexio-gpio.o \
	$(VECTREX_DIR)$(BUILD_DIR)vectrexInterface.o \
	$(VECTREX_DIR)$(BUILD_DIR)osWrapper.o \
	$(VECTREX_DIR)$(BUILD_DIR)baremetalUtil.o \
	$(BUILD_DIR)draft4.o
