#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

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

UPSTREAM_VERSION=$(shell dpkg-parsechangelog | sed -e '/^Version/!d' -e 's/^Version: //g' -e 's/-.*//g')
UPSTREAM_REVISION=$(shell echo $(UPSTREAM_VERSION) | sed -e 's/.*svn/-r/')
UPSTREAM_SVN=svn://openbios.org/openbios/trunk/openbios-devel
UPSTREAM_CHECKOUT=openbios-ppc-$(UPSTREAM_VERSION)

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

get-orig-source:
	svn export $(UPSTREAM_REVISION) $(UPSTREAM_SVN) $(UPSTREAM_CHECKOUT)
	rm -fr openbios-ppc-$(UPSTREAM_VERSION)/utils/iso
	tar -zcf ../openbios-ppc_$(UPSTREAM_VERSION).orig.tar.gz $(UPSTREAM_CHECKOUT)
	rm -rf $(UPSTREAM_CHECKOUT)

build: build-arch build-indep

build-arch:
# We have nothing to do by default.

build-indep: build-indep-stamp
build-indep-stamp:
	dh_testdir

	config/scripts/switch-arch builtin-ppc
	cd obj-ppc && $(MAKE) all
	
	touch build-indep-stamp

clean:
	dh_testdir
	dh_testroot
	rm -rf obj-*
	rm -f config.xml rules.xml
	rm -f *-stamp
	dh_clean

install: build-indep
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	mkdir -p $(CURDIR)/debian/openbios-ppc/usr/share/openbios
	install -m644 obj-ppc/openbios-qemu.elf $(CURDIR)/debian/openbios-ppc/usr/share/openbios/openbios-ppc


# Build architecture-independent files here.
binary-indep: build-indep install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installchangelogs Documentation/ChangeLog.arch
	dh_lintian
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb -- -Zxz

# Build architecture-dependent files here.
binary-arch: build-indep install
# We have nothing to do by default.

binary: binary-indep binary-arch
.PHONY: build build-arch build-indep clean binary-indep binary-arch binary install
