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

DEB_TAR_SRCDIR:=libao-1.0.0

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/libao1::
ifeq ($(IS_FREMANTLE),y)
	install -d -m 755 debian/tmp/opt/lib
	install -d -m 755 debian/tmp/opt/lib/ao/plugins-4

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

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

	ln -sf /opt/lib/libao.so debian/tmp/usr/lib/libao.so
	ln -sf /opt/lib/libao.so.4 debian/tmp/usr/lib/libao.so.4
	ln -sf /opt/lib/libao.so.4.0.0 debian/tmp/usr/lib/libao.so.4.0.0
endif
