#!/usr/bin/make -f
# -*- makefile -*-

include /usr/share/dpkg/architecture.mk

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
	dh $@

override_dh_auto_clean:
	dh_auto_clean
	rm -f bin/fel-pio.* bin/*.sunxi bin/*.scr

override_dh_auto_build:
	$(MAKE) -C thunks CROSS_COMPILE=arm-none-eabi-
	$(MAKE) CFLAGS="$(CFLAGS) $(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" tools
	mkimage -A arm -T script -d bin/ramboot.uboot-sh bin/ramboot.scr

override_dh_auto_install: PKG := debian/sunxi-tools
override_dh_auto_install:
	$(MAKE) install-tools DESTDIR=$(CURDIR)/$(PKG) PREFIX=/usr

	install -m0644 bin/ramboot.scr $(PKG)/usr/share/sunxi-tools/ramboot.scr
