#!/usr/bin/make -f

DEB_BUILD_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_CPU)

%:
	dh $@ --parallel

override_dh_auto_clean:
	dh_clean
	$(MAKE) distclean
	$(MAKE) -C $(CURDIR)/debian/spapr-rtas clean

override_dh_auto_build-indep:
ifneq ($(DEB_BUILD_ARCH_CPU),powerpc)
	@echo "This package must be built on a PowerPC machine"
	@false
endif
	dh_auto_build -- qemu CROSS=""
	$(MAKE) -C $(CURDIR)/debian/spapr-rtas

override_dh_auto_install-indep:
	mkdir -p $(CURDIR)/debian/qemu-slof/usr/share/slof
	install -m 644 $(CURDIR)/boot_rom.bin $(CURDIR)/debian/qemu-slof/usr/share/slof/slof.bin
	install -m 644 $(CURDIR)/debian/spapr-rtas/spapr-rtas.bin $(CURDIR)/debian/qemu-slof/usr/share/slof/spapr-rtas.bin
