#!/usr/bin/make -f

%:
	dh $@

PACKAGE = firm-phoenix-ware

DESTDIR = debian/$(PACKAGE)

override_dh_auto_build:
	$(MAKE) all_firmware

override_dh_auto_clean:
	$(MAKE) clean_firmware
	rm -f firmware/eyes firmware/mca firmware/*.hex

override_dh_auto_install:
	for d in expeyes kuttypy microhope; do \
	  mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)/$$d; \
	done
	cp -a firmware/* $(DESTDIR)/usr/share/$(PACKAGE)/expeyes
	cp -a kuttyPy/firmware/* $(DESTDIR)/usr/share/$(PACKAGE)/kuttypy
	cp -a microhope/firmware/* $(DESTDIR)/usr/share/$(PACKAGE)/microhope

override_dh_builddeb:
	# remove executable flags (ELF files are for AVR)
	# except for shell scripts
	for f in $$(find $(DESTDIR)/usr/share/$(PACKAGE) -type f); do \
	   if file $$f | grep -q "shell script"; then chmod +x $$f; \
	   else chmod -x $$f; fi; \
	done
	dh_builddeb
