#
# Makefile for to make stuffs
# Created by goddess of chaos
# OpenWii - YOLD 3173
#

COMDIRS = mn10200 $(chip)

#these are phoney targets
.PHONY: subs $(COMDIRS)

all: checkargs subs

checkargs:
#check for required arguments
ifndef chip
	@$(MAKE) -s help
	@false
else 
ifndef drive
	@$(MAKE) -s help
	@false
else
ifdef withbootloader
	@echo "Make with boot loader..."
endif
	@echo "Here we go..."
endif
endif

subs: $(COMDIRS)

#rules for building anything in the subdirs (in this case make stuff!)
$(COMDIRS): 
	@$(MAKE) -C $@ $(MAKEARGS)

help:
	@echo "How to use me blah blah"
	@echo "make drive=dms chip=chiip"
	@echo "make drive=d2b chip=msp430"
	@echo "make drive=d2b chip=msp430 clean"
	@echo "add withbootloader=yes if you want to include the bootloader in the firmware"
	@echo "etc etc"

cleanchip: MAKEARGS = clean
cleanchip: checkargs $(chip)
	@echo "cleaned up a bit"

clean: MAKEARGS = clean
clean: checkargs subs
	@echo "cleaned up a bit"
