#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk

DEB_TAR_SRCDIR:=libao-0.8.8

include /usr/share/cdbs/1/rules/tarball.mk
include /usr/share/cdbs/1/class/autotools.mk

IS_FREMANTLE=$(shell if grep Fremantle /etc/maemo_version &> /dev/null; then echo y; else echo n; fi)

ifeq ($(IS_FREMANTLE),y)
DEB_CONFIGURE_NORMAL_ARGS:=--prefix=/usr --disable-nas --disable-arts --disable-alsa --disable-alsa09
DEB_OPT_FLAG_armel:=-O2 -fomit-frame-pointer -pipe -mcpu=cortex-a8
else
DEB_CONFIGURE_NORMAL_ARGS:=--prefix=/usr --disable-nas --disable-arts
DEB_OPT_FLAG_armel:=-O2 -fomit-frame-pointer -pipe
endif
DEB_OPT_FLAG_i386:=-O2 -fomit-frame-pointer -pipe -march=i686
DEB_OPT_FLAG:=$(DEB_OPT_FLAG_$(DEB_HOST_ARCH))

DEB_DESTDIR=$(CURDIR)/debian/tmp

install/libao0::
ifeq ($(IS_FREMANTLE),y)
	install -d -m 755 debian/tmp/opt/lib
	install -d -m 755 debian/tmp/opt/lib/ao/plugins-2

	mv debian/tmp/usr/lib/ao/plugins-2/*.so debian/tmp/opt/lib/ao/plugins-2/
	mv debian/tmp/usr/lib/libao* debian/tmp/opt/lib/

	ln -sf /opt/lib/ao/plugins-2/libpulse.so debian/tmp/usr/lib/ao/plugins-2/libpulse.so

	ln -sf /opt/lib/libao.so debian/tmp/usr/lib/libao.so
	ln -sf /opt/lib/libao.so.2 debian/tmp/usr/lib/libao.so.2
	ln -sf /opt/lib/libao.so.2.1.3 debian/tmp/usr/lib/libao.so.2.1.3
endif