.PHONY: clean client stub loader boot test

all: boot test

client:
	@$(MAKE) -C client

install:
	@$(MAKE) -C client install

stub:
	@$(MAKE) -C stub

loader:
	@$(MAKE) -C loader

boot/source/stub_bin.S: stub/stub.bin
	@$(DEVKITPPC)/bin/bin2s -a 32 stub/stub.bin > \
		boot/source/stub_bin.S

boot/source/loader_dol.S: loader/loader.dol
	@$(DEVKITPPC)/bin/bin2s -a 32 loader/loader.dol > \
		boot/source/loader_dol.S

boot: stub loader boot/source/stub_bin.S boot/source/loader_dol.S
	@$(MAKE) -C boot

test:
	@$(MAKE) -C test

clean:
	@$(MAKE) -C client clean
	@$(MAKE) -C stub clean
	@$(MAKE) -C loader clean
	@$(MAKE) -C boot clean
	@$(MAKE) -C test clean
	@rm -f boot/source/stub_bin.S boot/source/loader_dol.S

testupload: client test
	client/geckoupload test/test.elf

selfupdate: client boot
	client/geckoupload boot/geckoloader.elf

twilight: boot
	@echo i dont know what im doing
#	dd if=boot/geckoloader.elf of=/dev/sdd bs=512 seek=2048 && sync

release: boot test
	$(DEVKITPPC)/bin/powerpc-gekko-strip -g boot/geckoloader.elf
	$(DEVKITPPC)/bin/powerpc-gekko-strip -g test/test.elf
	cp boot/geckoloader.elf boot/geckoloader.dol test/test.elf .

