DEFINES += -DF_CPU=16000000
CFLAGS += -save-temps
CFLAGS += -std=gnu99 -Wall # implements C99, for <util/atomic.h>
# this removes dead code and does global linker optimization
#CFLAGS += -ffunction-sections -Wl,--gc-sections -Wl,--relax 


include Makefile.inc

# symbolic targets:
all:	master slave

master:
	cd masterchip; $(MAKE) $(MFLAGS)

master-clean: clean-master
clean-master:
	cd masterchip; $(MAKE) $(MFLAGS) clean

master-flash: flash-master
flash-master:
	cd masterchip; $(MAKE) $(MFLAGS) flash

master-fuses: fuses-master
fuses-master:
	cd masterchip; $(MAKE) $(MFLAGS) fuses


slave:
	cd slavechip; $(MAKE) $(MFLAGS)

slave-clean: clean-slave
clean-slave:
	cd slavechip; $(MAKE) $(MFLAGS) clean

slave-flash: flash-slave
flash-slave:
	cd slavechip; $(MAKE) $(MFLAGS) flash

slave-fuses: fuses-slave
fuses-slave:
	cd slavechip; $(MAKE) $(MFLAGS) fuses

clean:
	cd masterchip; $(MAKE) $(MFLAGS) clean
	cd slavechip; $(MAKE) $(MFLAGS) clean

flash:
	echo "Plug to master, please. Press ENTER to flash"
	bash -c read
	$(MAKE) flash-master
	echo "Plug to slave, please. Press ENTER to flash"
	bash -c read
	$(MAKE) flash-slave
