#!/bin/sh

################################################################################
#      This file is part of OpenELEC - http://www.openelec.tv
#      Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
#
#  This Program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2, or (at your option)
#  any later version.
#
#  This Program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with OpenELEC.tv; see the file COPYING.  If not, write to
#  the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
#  http://www.gnu.org/copyleft/gpl.html
################################################################################

. config/options $1

# pulseaudio fails to build with LTO support
  strip_lto

if [ "$AVAHI_DAEMON" = yes ]; then
  PULSEAUDIO_AVAHI="--enable-avahi"
else
  PULSEAUDIO_AVAHI="--disable-avahi"
fi

cd $PKG_BUILD

./configure --host=$TARGET_NAME \
            --build=$HOST_NAME \
            --prefix=/usr \
            --sysconfdir=/etc \
            --localstatedir=/var \
            --disable-static \
            --enable-shared \
            --disable-silent-rules \
            --disable-nls \
            --enable-largefile \
            --disable-rpath \
            --disable-x11 \
            --enable-samplerate \
            --disable-oss-output \
            --disable-oss-wrapper \
            --disable-coreaudio-output \
            --enable-alsa \
            --disable-esound \
            --disable-solaris \
            --disable-waveout \
            --disable-glib2 \
            --disable-gtk2 \
            --disable-gconf \
            $PULSEAUDIO_AVAHI \
            --disable-jack \
            --disable-asyncns \
            --disable-tcpwrap \
            --disable-lirc \
            --enable-dbus \
            --disable-hal \
            --disable-bluez \
            --enable-udev \
            --disable-hal-compat \
            --enable-ipv6 \
            --enable-openssl \
            --disable-orc \
            --disable-manpages \
            --disable-per-user-esound-socket \
            --disable-legacy-runtime-dir \
            --disable-legacy-database-entry-format \
            --with-system-user=root \
            --with-system-group=root \
            --with-access-group=root \
            --with-module-dir="/usr/lib/pulse" \

make

mkdir -p $SYSROOT_PREFIX/usr/lib
  cp -P src/.libs/libpulse.so* $SYSROOT_PREFIX/usr/lib
  cp -P src/.libs/libpulse-simple.so* $SYSROOT_PREFIX/usr/lib
  cp -P src/.libs/libpulsecommon-*.so* $SYSROOT_PREFIX/usr/lib
  cp -P src/.libs/libpulsecore-*.so $SYSROOT_PREFIX/usr/lib

mkdir -p $SYSROOT_PREFIX/usr/lib/pkgconfig
  cp libpulse.pc $SYSROOT_PREFIX/usr/lib/pkgconfig
  cp libpulse-simple.pc $SYSROOT_PREFIX/usr/lib/pkgconfig

make DESTDIR="$SYSROOT_PREFIX" -C src install-pulseincludeHEADERS

