#*******************************************************************
#* Makefile for MSII
#*
#* COPYRIGHT: Philip L Johnson 2004
#* This header must appear on all derivatives of this file.
#*
#*******************************************************************
# Extended for MS2/Extra by Ken Culver and James Murray  2006
# $Id: Makefile,v 1.45 2011-11-12 17:26:06 jsmcortina Exp $

all:	megasquirt   # default is to build for ms2 platform

both: clean_not_common megasquirt clean_not_common_us microsquirt bootstrap

megasquirt:
	$(MAKE) --makefile Makefile.ms2
microsquirt:
	$(MAKE) --makefile Makefile.us

#aliases
us: microsquirt
ms2: megasquirt

release: clean both
	rm -rf release
	mkdir release
	cp megasquirt-ii.ms2extra.ini ms2_extra.s19 ms2_extra_us.s19 ms2dl.exe utils/CHOICE.COM utils/download-MS2-firmware.bat README.txt release
	cp bootstrap_src/bootstrap.s19 LICENSE.txt release
	# Make sure you updated sigs.c

bootstrap:
	$(MAKE) -C bootstrap_src

.PHONY: clean
clean:
	$(RM) -rf release megasquirt-ii.ini.ms2extra megasquirt-ii.ini.us2extra *~
	$(MAKE) --makefile Makefile.ms2 clean
	$(MAKE) --makefile Makefile.us clean
	$(MAKE) -C bootstrap_src clean

.PHONY: clean_not_common     # delete the object files that contain MS2 vs. MICROSQUIRT dependencies
clean_not_common:
	$(RM) -f ms2_extra_ign.o ms2_extra_ign_in.o ms2_extra_init.o ms2_extra_misc.o isr_ign.o isr_inj.o isr_rtc.o ms2_extra_main.o ms2_extra_idle.o ms2_extra_inj.o sigs.o

.PHONY: clean_not_common_us     # delete the object files that contain MS2 vs. MICROSQUIRT dependencies
clean_not_common_us:
	$(RM) -f ms2_extra_ign.o ms2_extra_ign_in.o ms2_extra_init.o ms2_extra_misc.o isr_ign.o isr_inj.o isr_rtc.o ms2_extra_main.o ms2_extra_idle.o ms2_extra_inj.o sigs.o
