#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)

PACKAGES     := $(shell cat packages)
CONVERT      := $(addprefix convert-,$(PACKAGES))
IA32PACKAGES := $(shell echo $(PACKAGES) | xargs -n 1 /usr/lib/ia32-libs-tools/mangle --arch $(DEB_HOST_ARCH) --rename)
FILES        := $(addprefix file-,$(IA32PACKAGES))

fetch:
	/usr/lib/ia32-libs-tools/fetch $(PACKAGES)

update:
	rm -rf *
	/usr/lib/ia32-libs-tools/create $(PACKAGES)

convert: $(CONVERT)

convert-%:
	/usr/lib/ia32-libs-tools/convert $(DEB_HOST_ARCH) $*_*.deb

files: $(FILES)

file-%:
	echo "$*_$(shell grep Version debian/$*/DEBIAN/control | cut -d" " -f2- | cut -d: -f2-)_$(DEB_HOST_ARCH).deb libs extra" >>debian/files

clean:
	dh_testdir
	dh_testroot
	dh_clean 

build:

# Build architecture-independent files here.
binary-indep:
# We have nothing to do.

# Build architecture-dependent files here.
binary-arch: convert
	dh_compress -s
	dh_md5sums -s
	dh_builddeb -s
	$(MAKE) -f debian/rules files

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