#!/bin/sh
# we are root
# credits edgardogho for new link
#########

# configure says checking if gcc supports -fno-rtti -fno-exceptions... no
export CFLAGS="-O2 -pipe -march=i486 -mtune=i686"
export CXXFLAGS="-O2 -pipe -march=i486 -mtune=i686"

P=libbluray
USER=`cat /etc/sysconfig/tcuser`

LIST="compiletc submitqc6 libxml2-dev freetype-dev \
fontconfig-dev    "
for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
su -c "/usr/local/bin/wget -nc  \
ftp://ftp.videolan.org/pub/videolan/libbluray/0.8.1/libbluray-0.8.1.tar.bz2 \                                
" $USER 

# we are root for rest of commands
tar jxvf $P-0.8.1.tar.bz2
cd $P-*
# configure default=/usr/local
./configure --disable-static --disable-bdjava --disable-examples
# BD-J support:                  no
# Font support (freetype2):      yes
# Metadata support (libxml2):    yes
# UDF filesystem support:        no
# Build examples:                no

make -j5                    
mkdir -p /tmp/$P
make install DESTDIR=/tmp/$P

# Strip
########
cd /tmp/$P/usr/local
strip --strip-unneeded lib/*.so*
cd /tmp

# create dev
#############
mkdir -p $P-dev/usr/local/lib
mv $P/usr/local/include $P-dev/usr/local/
mv $P/usr/local/lib/pkgconfig $P-dev/usr/local/lib/
mv $P/usr/local/lib/*.la $P-dev/usr/local/lib/
chmod 644 $P-dev/usr/local/lib/*.la

# TCZ them
##########
LIST2="$P $P-dev "
for Z in $LIST2
do
	mksquashfs $Z $Z.tcz
	md5sum $Z.tcz > $Z.tcz.md5.txt
	cd $Z
	find usr -not -type d > /tmp/$Z.tcz.list
	cd /tmp
done

# create depend files
echo "libbluray.tcz
libxml2-dev.tcz
freetype-dev.tcz
fontconfig-dev.tcz " > $P-dev.tcz.dep

echo 'libxml2.tcz' > $P.tcz.dep

# create info files let submitqc5 add size

echo 'Title:          libbluray.tcz
Description:    blu-ray playback
Version:        0.8.1
Author:         Doom9 Team
Original-site:  http://www.videolan.org/developers/libbluray.html
Copying-policy: GPLv2
Size: 		
Extension_by:   gordon64
Tags:           blu-ray 
Comments:       Allows playback of blu-ray discs mainly for vlc, mplayer

                Compiled for x86 6x.               
Change-log:     2012/01/08 first version v 0.2.1 Juanito
Current:        2015/09/04 v 0.8.1 gordon64
' > $P.tcz.info

echo 'Title:          libbluray-dev.tcz
Description:    blu-ray devs
Version:        0.8.1
Author:         Doom9 Team
Original-site:  http://www.videolan.org/developers/libbluray.html
Copying-policy: GPLv2
Size: 		
Extension_by:   gordon64
Tags:           blu-ray 
Comments:       Development files

                Compiled for x86 6x.               
Change-log:     2012/01/08 first version v 0.2.1 Juanito
Current:        2015/09/04 v 0.8.1 gordon64
' > $P-dev.tcz.info


submitqc6