#!/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=libdvdread
USER=`cat /etc/sysconfig/tcuser`

LIST="compiletc submitqc6  "
for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
su -c "/usr/local/bin/wget -nc  \
http://download.videolan.org/videolan/libdvdread/5.0.3/libdvdread-5.0.3.tar.bz2 \                                
" $USER 

# we are root for rest of commands
tar jxvf $P-5.0.3.tar.bz2
cd $P-*
# configure default=/usr/local
./configure --disable-static  
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

# leave authors but delete rest from main
###########################################
rm -rf $P/usr/local/share/doc/$P/*
cp -f $P-*/AUTHORS $P/usr/local/share/doc/$P/

# 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 "libdvdread.tcz" > $P-dev.tcz.dep

# create info files let submitqc5 add size

echo 'Title:          libdvdread.tcz
Description:    provides ability to read some DVDs
Version:        5.0.3
Author:         see AUTHORS too many to list here.
Original-site:  http://download.videolan.org/videolan/libdvdread
Copying-policy: GPLv2
Size: 		
Extension_by:   gordon64
Tags:           libdvdread 
Comments:       A library that provides ability to read some DVDs.
                
                Compiled for x86 6.x
Change-log:     2010/01/18 Original v 4.1.3 Arslan S.  
Current:        2015/09/04 change upstream src v5.0.3 gordon64
' > $P.tcz.info

echo 'Title:          libdvdread-dev.tcz
Description:    libdvdread devs
Version:        5.0.3
Author:         see AUTHORS in main TCZ
Original-site:  http://download.videolan.org/videolan/libdvdread
Copying-policy: GPLv2
Size: 		
Extension_by:   gordon64
Tags:           libdvdread 
Comments:       development files

                Compiled for x86 6.x
Change-log:     2010/01/18 Original v 4.1.3 Arslan S.  
Current:        2015/09/04 change upstream src v5.0.3 gordon64
' > $P-dev.tcz.info

submitqc6